Loading services/TS29222_CAPIF_Discover_Service_API/service_apis/controllers/default_controller.py +7 −15 Original line number Original line Diff line number Diff line Loading @@ -68,24 +68,16 @@ def all_service_apis_get(api_invoker_id, api_name=None, api_version=None, comm_t if request.is_json: if request.is_json: service_kpis = ServiceKpis.from_dict(request.get_json()()) # noqa: E501 service_kpis = ServiceKpis.from_dict(request.get_json()()) # noqa: E501 current_app.logger.info("Discovering service apis") current_app.logger.info("Discovering service apis") current_app.logger.info(request.args) query_params = {"api_name":api_name, "api_version":api_version, "comm_type":comm_type, query_params = {"api_name":api_name, "api_version":api_version, "comm_type":comm_type, "protocol":protocol, "aef_id":aef_id, "data_format":data_format, "protocol":protocol, "aef_id":aef_id, "data_format":data_format, "api_cat":api_cat, "supported_features":supported_features, "api_supported_features":api_supported_features} "api_cat":api_cat, "supported_features":supported_features, "api_supported_features":api_supported_features} # current_app.logger.info(supported_features) if supported_features is not None: if supported_features is not None: supp_feat_dict = DiscoveredAPIs.return_supp_feat_dict(supported_features) supp_feat_dict = DiscoveredAPIs.return_supp_feat_dict(supported_features) if supp_feat_dict['VendSpecQueryParams']: if supp_feat_dict['VendSpecQueryParams']: # current_app.logger.info("**************************") # current_app.logger.info(request.args) # current_app.logger.info("**************************") for q_params in request.args: for q_params in request.args: # current_app.logger.info(q_params) # current_app.logger.info(request.args[q_params]) if "vend-spec" in q_params: if "vend-spec" in q_params: query_params[q_params] = json.loads(request.args[q_params]) query_params[q_params] = json.loads(request.args[q_params]) # current_app.logger.info(query_params) response = discover_apis.get_discoveredapis(api_invoker_id, query_params) response = discover_apis.get_discoveredapis(api_invoker_id, query_params) return response return response services/TS29222_CAPIF_Discover_Service_API/service_apis/core/discoveredapis.py +19 −6 Original line number Original line Diff line number Diff line Loading @@ -4,6 +4,7 @@ from ..core.responses import internal_server_error, forbidden_error ,make_respon from ..models.discovered_apis import DiscoveredAPIs from ..models.discovered_apis import DiscoveredAPIs from ..util import serialize_clean_camel_case from ..util import serialize_clean_camel_case from ..core.resources import Resource from ..core.resources import Resource import json class DiscoverApisOperations(Resource): class DiscoverApisOperations(Resource): Loading @@ -23,22 +24,34 @@ class DiscoverApisOperations(Resource): my_params = [] my_params = [] my_query = {} my_query = {} quey_params_name = {"api_name":"api_name", "api_version":"aef_profiles.0.versions.0.api_version", "comm_type":"aef_profiles.0.versions.0.resources.0.comm_type", # QPV = Query Parameter Value "protocol":"aef_profiles.0.protocol", "aef_id":"aef_profiles.0.aef_id", "data_format":"aef_profiles.0.data_format", query_params_name = { "api_cat":"service_api_category", "supported_features":"supported_features", "api_supported_features":"api_supp_feats"} "api_name": "api_name", "api_version": '{"aef_profiles": {"$elemMatch": {"versions" : {"$elemMatch": {"api_version": "QPV"}}}}}', "comm_type": '{"aef_profiles": {"$elemMatch": {"versions" : {"$elemMatch": {"resources": {"$elemMatch": {"comm_type":"QPV"}}}}}}}', "protocol": '{"aef_profiles": {"$elemMatch": {"protocol":"QPV"}}}', "aef_id": '{"aef_profiles": {"$elemMatch": {"aef_id":"QPV"}}}', "data_format": '{"aef_profiles": {"$elemMatch": {"data_format":"QPV"}}}', "api_cat": "service_api_category", "supported_features": "supported_features", "api_supported_features": "api_supp_feats" } # current_app.logger.info(query_params) for param in query_params: for param in query_params: current_app.logger.info(query_params[param]) if query_params[param] is not None: if query_params[param] is not None: if "vend-spec" in param: if "vend-spec" in param: current_app.logger.info("vend-spec in param") current_app.logger.info("vend-spec in param") attribute_path = query_params[param]["target"].split('/') attribute_path = query_params[param]["target"].split('/') attribute = "aef_profiles.0." + attribute_path[1] + "." + attribute_path[2] attribute = "aef_profiles.0." + attribute_path[1] + "." + attribute_path[2] my_params.append({attribute: query_params[param]["value"]}) my_params.append({attribute: query_params[param]["value"]}) elif param in ["api_version", "comm_type", "protocol", "aef_id", "data_format"]: current_app.logger.info(query_params_name[param]) current_app.logger.info(query_params_name[param].replace("QPV", query_params[param])) my_params.append(json.loads(query_params_name[param].replace("QPV", query_params[param]))) else: else: my_params.append({quey_params_name[param]: query_params[param]}) my_params.append({query_params_name[param]: query_params[param]}) # current_app.logger.info(my_params) if my_params: if my_params: my_query = {"$and": my_params} my_query = {"$and": my_params} Loading services/TS29222_CAPIF_Publish_Service_API/published_apis/controllers/default_controller.py +8 −10 Original line number Original line Diff line number Diff line Loading @@ -78,25 +78,23 @@ def apf_id_service_apis_post(apf_id, body): # noqa: E501 current_app.logger.info("Publishing service") current_app.logger.info("Publishing service") supp_feat_dict = ServiceAPIDescription.return_supp_feat_dict(body['supportedFeatures']) supp_feat_dict = ServiceAPIDescription.return_supp_feat_dict(body['supportedFeatures']) # current_app.logger.info(supp_feat_dict) vendor_specific_list = [] vendor_specific = [] if request.is_json: if request.is_json: if supp_feat_dict['VendorExt']: if supp_feat_dict['VendorExt']: aef_profile_array = body['aefProfiles'] aef_profile_array = body['aefProfiles'] vendor_specific = [] for (profile,i) in zip(aef_profile_array, range(len(aef_profile_array))): for profile in aef_profile_array: for key, val in profile.items(): vendor_specific.append((profile['aefId'], key, val) for key, val in profile.items() if 'vendorSpecific' in key) if 'vendorSpecific' in key: for vend_spec in vendor_specific: vendor_specific.append((i, key, val)) vend_spec_lst = list(vend_spec) vendor_specific_list.append(vend_spec_lst) body = ServiceAPIDescription.from_dict(request.get_json()) body = ServiceAPIDescription.from_dict(request.get_json()) res = service_operations.add_serviceapidescription(apf_id, body, vendor_specific_list) res = service_operations.add_serviceapidescription(apf_id, body, vendor_specific) return res return res @cert_validation() @cert_validation() def apf_id_service_apis_service_api_id_delete(service_api_id, apf_id): # noqa: E501 def apf_id_service_apis_service_api_id_delete(service_api_id, apf_id): # noqa: E501 """apf_id_service_apis_service_api_id_delete """apf_id_service_apis_service_api_id_delete Loading services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py +5 −5 Original line number Original line Diff line number Diff line Loading @@ -104,16 +104,16 @@ class PublishServiceOperations(Resource): rec['onboarding_date'] = datetime.now() rec['onboarding_date'] = datetime.now() serviceapidescription_dict = serviceapidescription.to_dict() serviceapidescription_dict = serviceapidescription.to_dict() if vendor_specific: if vendor_specific: current_app.logger.debug("VendExt") for vend_spec in vendor_specific: for vend_spec in vendor_specific: vend_spec_lst = list(vend_spec) current_app.logger.info(vend_spec) # current_app.logger.info(vend_spec_lst) for (profile,i) in zip(serviceapidescription_dict['aef_profiles'], range(len(serviceapidescription_dict['aef_profiles']))): for profile in serviceapidescription_dict['aef_profiles']: if i == vend_spec[0]: if profile['aef_id'] == vend_spec_lst[0][0]: # ##### snake_case the vendor specific key and value to store in mongo # ##### snake_case the vendor specific key and value to store in mongo # key = ''.join(['_'+ i.lower() if i.isupper() else i for i in vend_spec_lst[0][1]]).lstrip('_').replace("-", "_") # key = ''.join(['_'+ i.lower() if i.isupper() else i for i in vend_spec_lst[0][1]]).lstrip('_').replace("-", "_") # value = dict_to_camel_case(vend_spec_lst[0][2]) # value = dict_to_camel_case(vend_spec_lst[0][2]) # profile[key] = value # profile[key] = value profile[vend_spec_lst[0][1]] = vend_spec_lst[0][2] profile[vend_spec[1]] = vend_spec[2] rec.update(serviceapidescription_dict) rec.update(serviceapidescription_dict) mycol.insert_one(rec) mycol.insert_one(rec) Loading Loading
services/TS29222_CAPIF_Discover_Service_API/service_apis/controllers/default_controller.py +7 −15 Original line number Original line Diff line number Diff line Loading @@ -68,24 +68,16 @@ def all_service_apis_get(api_invoker_id, api_name=None, api_version=None, comm_t if request.is_json: if request.is_json: service_kpis = ServiceKpis.from_dict(request.get_json()()) # noqa: E501 service_kpis = ServiceKpis.from_dict(request.get_json()()) # noqa: E501 current_app.logger.info("Discovering service apis") current_app.logger.info("Discovering service apis") current_app.logger.info(request.args) query_params = {"api_name":api_name, "api_version":api_version, "comm_type":comm_type, query_params = {"api_name":api_name, "api_version":api_version, "comm_type":comm_type, "protocol":protocol, "aef_id":aef_id, "data_format":data_format, "protocol":protocol, "aef_id":aef_id, "data_format":data_format, "api_cat":api_cat, "supported_features":supported_features, "api_supported_features":api_supported_features} "api_cat":api_cat, "supported_features":supported_features, "api_supported_features":api_supported_features} # current_app.logger.info(supported_features) if supported_features is not None: if supported_features is not None: supp_feat_dict = DiscoveredAPIs.return_supp_feat_dict(supported_features) supp_feat_dict = DiscoveredAPIs.return_supp_feat_dict(supported_features) if supp_feat_dict['VendSpecQueryParams']: if supp_feat_dict['VendSpecQueryParams']: # current_app.logger.info("**************************") # current_app.logger.info(request.args) # current_app.logger.info("**************************") for q_params in request.args: for q_params in request.args: # current_app.logger.info(q_params) # current_app.logger.info(request.args[q_params]) if "vend-spec" in q_params: if "vend-spec" in q_params: query_params[q_params] = json.loads(request.args[q_params]) query_params[q_params] = json.loads(request.args[q_params]) # current_app.logger.info(query_params) response = discover_apis.get_discoveredapis(api_invoker_id, query_params) response = discover_apis.get_discoveredapis(api_invoker_id, query_params) return response return response
services/TS29222_CAPIF_Discover_Service_API/service_apis/core/discoveredapis.py +19 −6 Original line number Original line Diff line number Diff line Loading @@ -4,6 +4,7 @@ from ..core.responses import internal_server_error, forbidden_error ,make_respon from ..models.discovered_apis import DiscoveredAPIs from ..models.discovered_apis import DiscoveredAPIs from ..util import serialize_clean_camel_case from ..util import serialize_clean_camel_case from ..core.resources import Resource from ..core.resources import Resource import json class DiscoverApisOperations(Resource): class DiscoverApisOperations(Resource): Loading @@ -23,22 +24,34 @@ class DiscoverApisOperations(Resource): my_params = [] my_params = [] my_query = {} my_query = {} quey_params_name = {"api_name":"api_name", "api_version":"aef_profiles.0.versions.0.api_version", "comm_type":"aef_profiles.0.versions.0.resources.0.comm_type", # QPV = Query Parameter Value "protocol":"aef_profiles.0.protocol", "aef_id":"aef_profiles.0.aef_id", "data_format":"aef_profiles.0.data_format", query_params_name = { "api_cat":"service_api_category", "supported_features":"supported_features", "api_supported_features":"api_supp_feats"} "api_name": "api_name", "api_version": '{"aef_profiles": {"$elemMatch": {"versions" : {"$elemMatch": {"api_version": "QPV"}}}}}', "comm_type": '{"aef_profiles": {"$elemMatch": {"versions" : {"$elemMatch": {"resources": {"$elemMatch": {"comm_type":"QPV"}}}}}}}', "protocol": '{"aef_profiles": {"$elemMatch": {"protocol":"QPV"}}}', "aef_id": '{"aef_profiles": {"$elemMatch": {"aef_id":"QPV"}}}', "data_format": '{"aef_profiles": {"$elemMatch": {"data_format":"QPV"}}}', "api_cat": "service_api_category", "supported_features": "supported_features", "api_supported_features": "api_supp_feats" } # current_app.logger.info(query_params) for param in query_params: for param in query_params: current_app.logger.info(query_params[param]) if query_params[param] is not None: if query_params[param] is not None: if "vend-spec" in param: if "vend-spec" in param: current_app.logger.info("vend-spec in param") current_app.logger.info("vend-spec in param") attribute_path = query_params[param]["target"].split('/') attribute_path = query_params[param]["target"].split('/') attribute = "aef_profiles.0." + attribute_path[1] + "." + attribute_path[2] attribute = "aef_profiles.0." + attribute_path[1] + "." + attribute_path[2] my_params.append({attribute: query_params[param]["value"]}) my_params.append({attribute: query_params[param]["value"]}) elif param in ["api_version", "comm_type", "protocol", "aef_id", "data_format"]: current_app.logger.info(query_params_name[param]) current_app.logger.info(query_params_name[param].replace("QPV", query_params[param])) my_params.append(json.loads(query_params_name[param].replace("QPV", query_params[param]))) else: else: my_params.append({quey_params_name[param]: query_params[param]}) my_params.append({query_params_name[param]: query_params[param]}) # current_app.logger.info(my_params) if my_params: if my_params: my_query = {"$and": my_params} my_query = {"$and": my_params} Loading
services/TS29222_CAPIF_Publish_Service_API/published_apis/controllers/default_controller.py +8 −10 Original line number Original line Diff line number Diff line Loading @@ -78,25 +78,23 @@ def apf_id_service_apis_post(apf_id, body): # noqa: E501 current_app.logger.info("Publishing service") current_app.logger.info("Publishing service") supp_feat_dict = ServiceAPIDescription.return_supp_feat_dict(body['supportedFeatures']) supp_feat_dict = ServiceAPIDescription.return_supp_feat_dict(body['supportedFeatures']) # current_app.logger.info(supp_feat_dict) vendor_specific_list = [] vendor_specific = [] if request.is_json: if request.is_json: if supp_feat_dict['VendorExt']: if supp_feat_dict['VendorExt']: aef_profile_array = body['aefProfiles'] aef_profile_array = body['aefProfiles'] vendor_specific = [] for (profile,i) in zip(aef_profile_array, range(len(aef_profile_array))): for profile in aef_profile_array: for key, val in profile.items(): vendor_specific.append((profile['aefId'], key, val) for key, val in profile.items() if 'vendorSpecific' in key) if 'vendorSpecific' in key: for vend_spec in vendor_specific: vendor_specific.append((i, key, val)) vend_spec_lst = list(vend_spec) vendor_specific_list.append(vend_spec_lst) body = ServiceAPIDescription.from_dict(request.get_json()) body = ServiceAPIDescription.from_dict(request.get_json()) res = service_operations.add_serviceapidescription(apf_id, body, vendor_specific_list) res = service_operations.add_serviceapidescription(apf_id, body, vendor_specific) return res return res @cert_validation() @cert_validation() def apf_id_service_apis_service_api_id_delete(service_api_id, apf_id): # noqa: E501 def apf_id_service_apis_service_api_id_delete(service_api_id, apf_id): # noqa: E501 """apf_id_service_apis_service_api_id_delete """apf_id_service_apis_service_api_id_delete Loading
services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py +5 −5 Original line number Original line Diff line number Diff line Loading @@ -104,16 +104,16 @@ class PublishServiceOperations(Resource): rec['onboarding_date'] = datetime.now() rec['onboarding_date'] = datetime.now() serviceapidescription_dict = serviceapidescription.to_dict() serviceapidescription_dict = serviceapidescription.to_dict() if vendor_specific: if vendor_specific: current_app.logger.debug("VendExt") for vend_spec in vendor_specific: for vend_spec in vendor_specific: vend_spec_lst = list(vend_spec) current_app.logger.info(vend_spec) # current_app.logger.info(vend_spec_lst) for (profile,i) in zip(serviceapidescription_dict['aef_profiles'], range(len(serviceapidescription_dict['aef_profiles']))): for profile in serviceapidescription_dict['aef_profiles']: if i == vend_spec[0]: if profile['aef_id'] == vend_spec_lst[0][0]: # ##### snake_case the vendor specific key and value to store in mongo # ##### snake_case the vendor specific key and value to store in mongo # key = ''.join(['_'+ i.lower() if i.isupper() else i for i in vend_spec_lst[0][1]]).lstrip('_').replace("-", "_") # key = ''.join(['_'+ i.lower() if i.isupper() else i for i in vend_spec_lst[0][1]]).lstrip('_').replace("-", "_") # value = dict_to_camel_case(vend_spec_lst[0][2]) # value = dict_to_camel_case(vend_spec_lst[0][2]) # profile[key] = value # profile[key] = value profile[vend_spec_lst[0][1]] = vend_spec_lst[0][2] profile[vend_spec[1]] = vend_spec[2] rec.update(serviceapidescription_dict) rec.update(serviceapidescription_dict) mycol.insert_one(rec) mycol.insert_one(rec) Loading