Commit 96df74c3 authored by Stavros-Anastasios Charismiadis's avatar Stavros-Anastasios Charismiadis
Browse files

include discover parameters under one if statement, implement feature...

include discover parameters under one if statement, implement feature negotiation in API Provider Enrollment Details
parent 51078a90
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ from ..core.provider_enrolment_details_api import ProviderManagementOperations
from api_provider_management.models.api_provider_enrolment_details import APIProviderEnrolmentDetails  # noqa: E501
from api_provider_management.models.problem_details import ProblemDetails  # noqa: E501
from api_provider_management import util
from api_provider_management.core.responses import bad_request_error

from ..core.validate_user import ControlAccess

@@ -60,7 +61,14 @@ def registrations_post(body): # noqa: E501

    current_app.logger.info("Registering Provider Domain")

    supp_feat_dict = APIProviderEnrolmentDetails.return_supp_feat_dict(body['suppFeat'])
    current_app.logger.info(supp_feat_dict)
    if request.is_json:
        # if supp_feat_dict['RNAA'] and 'apiProvName' not in body.keys():
        #     current_app.logger.error("RNAA feature not properly configured. apiProvName not exist")
        #     return bad_request_error(detail="Bad Request", cause="Required attribute not detected", invalid_params=[
        #         {"param": "apiProvName", "reason": "Not detected"}])

        body = APIProviderEnrolmentDetails.from_dict(request.get_json())  # noqa: E501

    res = provider_management_ops.register_api_provider_enrolment_details(body, username, uuid)
+19 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ from api_provider_management import util

from api_provider_management.models.api_provider_function_details import APIProviderFunctionDetails  # noqa: E501
import re  # noqa: E501
from flask import current_app

class APIProviderEnrolmentDetails(Model):
    """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -62,6 +63,24 @@ class APIProviderEnrolmentDetails(Model):
        self._fail_reason = fail_reason
        self._api_prov_name = api_prov_name

    @classmethod
    def return_supp_feat_dict(cls, supp_feat):
        supp_feat_in_hex = int(supp_feat, 16)
        capif_supp_feat = int("f"*len(supp_feat), 16)
        # current_app.logger.info(capif_supp_feat)
        # current_app.logger.info(supp_feat_in_hex)

        supp_feat_in_hex = supp_feat_in_hex & capif_supp_feat
        supp_feat_in_bin = bin(supp_feat_in_hex << (len(supp_feat)*4 - len(bin(supp_feat_in_hex)[2:])))[2:]

        # current_app.logger.info(supp_feat_in_hex)
        # current_app.logger.info(supp_feat_in_bin)

        return {
            "RNAA": True if supp_feat_in_bin[0] == "1" else False,
            "PatchUpdate": True if supp_feat_in_bin[1] == "1" else False,
        }

    @classmethod
    def from_dict(cls, dikt) -> 'APIProviderEnrolmentDetails':
        """Returns the dict as a model
+1 −5
Original line number Diff line number Diff line
@@ -57,16 +57,12 @@ def all_service_apis_get(api_invoker_id, api_name=None, api_version=None, comm_t
    """
    if request.is_json:
        comm_type = CommunicationType.from_dict(request.get_json()())  # noqa: E501
    if request.is_json:
        protocol = Protocol.from_dict(request.get_json()())  # noqa: E501
    if request.is_json:
        data_format = DataFormat.from_dict(request.get_json()())  # noqa: E501
    if request.is_json:
        preferred_aef_loc = AefLocation.from_dict(request.get_json()())  # noqa: E501
    if request.is_json:
        ue_ip_addr = IpAddrInfo.from_dict(request.get_json()())  # noqa: E501
    if request.is_json:
        service_kpis = ServiceKpis.from_dict(request.get_json()())  # noqa: E501

    current_app.logger.info("Discovering service apis")
    query_params = {"api_name":api_name, "api_version":api_version, "comm_type":comm_type, 
    "protocol":protocol, "aef_id":aef_id, "data_format":data_format, 
+9 −1
Original line number Diff line number Diff line
@@ -95,8 +95,16 @@ class ServiceAPIDescription(Model):

    @classmethod
    def return_supp_feat_dict(cls, supp_feat):
        # supp_feat_in_hex = int(supp_feat, 16)
        # supp_feat_in_bin = bin(supp_feat_in_hex)[2:].zfill(len(supp_feat)*4)

        supp_feat_in_hex = int(supp_feat, 16)
        supp_feat_in_bin = bin(supp_feat_in_hex)[2:]
        capif_supp_feat = int("f" * len(supp_feat), 16) # d18
        # current_app.logger.info(capif_supp_feat)
        # current_app.logger.info(supp_feat_in_hex)

        supp_feat_in_hex = supp_feat_in_hex & capif_supp_feat
        supp_feat_in_bin = bin(supp_feat_in_hex << (len(supp_feat) * 4 - len(bin(supp_feat_in_hex)[2:])))[2:]

        return {
            "VendorExt": True if supp_feat_in_bin[0] == "1" else False,