Loading services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py +40 −6 Original line number Diff line number Diff line Loading @@ -202,7 +202,6 @@ class PublishServiceOperations(Resource): config_col = self.db.get_col_by_name(self.db.capif_configuration) config = config_col.find_one({}, {"_id": 0}) ccf_id = config['ccf_id'] serviceapidescription_dict['ccf_id'] = ccf_id serviceapidescription_dict['shareable_info'] = {"is_shareable": False} url = 'https://{}/published-apis/v1/{}/service-apis'.format(dom, ccf_id) Loading @@ -218,10 +217,40 @@ class PublishServiceOperations(Resource): response = requests.request("POST", url, headers=headers, data=json.dumps(clean_n_camel_case(serviceapidescription_dict), cls=encoder.CustomJSONEncoder), cert=('certs/server.crt', 'certs/server.key'), verify='certs/ca.crt') if not (response.status_code == 201 or response.status_code == 200): if (response.status_code == 201 or response.status_code == 200): if rec.get("pub_api_path") is None: current_app.logger.debug("pub_api_path not in keys") rec.update({"pub_api_path": {"ccf_ids": [interconnected_ccf.get("ccf_id")]}}) else: current_app.logger.debug("pub_api_path in keys") ccf_list = rec.get("pub_api_path").get("ccf_ids") current_app.logger.debug("fetch") ccf_list.append(interconnected_ccf.get("ccf_id")) current_app.logger.debug("append") rec.update({"pub_api_path": {"ccf_ids": ccf_list}}) current_app.logger.debug("update") else: rec['shareable_info']['capif_prov_doms'].remove(dom) if "CCF" in apf_id: rec['pub_api_path']['ccf_ids'].remove(apf_id) current_app.logger.debug("Check pub_api_path") if "CCF" in apf_id: current_app.logger.debug("After CCF in apf_id") current_app.logger.debug("rec keys: {}".format(rec.keys())) if rec.get("pub_api_path") is None: current_app.logger.debug("pub_api_path not in keys") rec.update({"pub_api_path": {"ccf_ids": [apf_id]}}) else: current_app.logger.debug("pub_api_path in keys") ccf_list = rec.get("pub_api_path").get("ccf_ids") current_app.logger.debug("fetch") ccf_list.append(apf_id) current_app.logger.debug("append") rec.update({"pub_api_path": {"ccf_ids": ccf_list}}) current_app.logger.debug("update") current_app.logger.debug("inserting record") mycol.insert_one(rec) if "APF" in apf_id: Loading @@ -229,15 +258,20 @@ class PublishServiceOperations(Resource): current_app.logger.debug("Service inserted in database") published_service = { key: value for key, value in rec.items() if key not in ("_id", "apf_id", "onboarding_date") } res = make_response(object=clean_n_camel_case( serviceapidescription_dict), status=201) published_service), status=201) res.headers['Location'] = f"https://{os.getenv('CAPIF_HOSTNAME')}/published-apis/v1/{str(apf_id)}/service-apis/{str(api_id)}" if res.status_code == 201: current_app.logger.info("Service published") event_to_send = self.service_api_availability_event( clean_n_camel_case( serviceapidescription_dict)) published_service)) RedisEvent(event_to_send, service_api_descriptions=[clean_n_camel_case( serviceapidescription.to_dict())], Loading services/docker-compose-capif.yml +1 −0 Original line number Diff line number Diff line Loading @@ -273,6 +273,7 @@ services: - fluent-bit:host-gateway - otel-collector:host-gateway - ${CAPIF_VAULT}:host-gateway - ${CAPIF_INTERCONNECTION_HOSTNAME:-capifcore-b}:host-gateway environment: - CAPIF_HOSTNAME=${CAPIF_HOSTNAME} - CONTAINER_NAME=${PUBLISHED_APIS_CONTAINER_NAME} Loading services/helper/helper_service/services/interconnection/core/capifdomaindetails.py +22 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,25 @@ class CapifDomainOperations(Resource): return Response(response.text, status=response.status_code, mimetype=remote_mimetype) def remove_ccf_from_pub_api_path(self, services_col, ccf_id): """Drop a CCF from the publication path of every service API that references it.""" current_app.logger.debug("Removing ccf_id {} from pub_api_path.ccf_ids".format(ccf_id)) result = services_col.update_many( {"pub_api_path.ccf_ids": ccf_id}, {"$pull": {"pub_api_path.ccf_ids": ccf_id}} ) current_app.logger.debug("Service APIs updated: {}".format(result.modified_count)) # ccf_ids must contain at least one entry, so null out pub_api_path once it is emptied cleaned = services_col.update_many( {"pub_api_path.ccf_ids": {"$size": 0}}, {"$set": {"pub_api_path": None}} ) current_app.logger.debug("Service APIs with empty pub_api_path nulled: {}".format(cleaned.modified_count)) return result.modified_count def sync_capifdomain(self, capifdomaindetails): """Sync interconnection state with a peer CCF.""" pass Loading Loading @@ -131,6 +150,9 @@ class CapifDomainOperations(Resource): cert=('certs/server.crt', 'certs/server.key'), verify='certs/ca.crt') if response.status_code in (204, 404): services_col = self.db.get_col_by_name(self.db.services_col) services_col.delete_many({"apf_id": ccf_id}) self.remove_ccf_from_pub_api_path(services_col, ccf_id) interconnected_col.delete_one({"ccf_id": ccf_id}) return make_response("CAPIF domain with ccf_id {} deleted".format(ccf_id), 204) else: Loading services/helper/helper_service/services/interconnection/core/ccfinstancedetails.py +22 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,25 @@ class CcfInstanceOperations(Resource): res = make_response(object=serialize_clean(ccfinstancedetails_new), status=status) return res def remove_ccf_from_pub_api_path(self, services_col, ccf_id): """Drop a CCF from the publication path of every service API that references it.""" current_app.logger.debug("Removing ccf_id {} from pub_api_path.ccf_ids".format(ccf_id)) result = services_col.update_many( {"pub_api_path.ccf_ids": ccf_id}, {"$pull": {"pub_api_path.ccf_ids": ccf_id}} ) current_app.logger.debug("Service APIs updated: {}".format(result.modified_count)) # ccf_ids must contain at least one entry, so null out pub_api_path once it is emptied cleaned = services_col.update_many( {"pub_api_path.ccf_ids": {"$size": 0}}, {"$set": {"pub_api_path": None}} ) current_app.logger.debug("Service APIs with empty pub_api_path nulled: {}".format(cleaned.modified_count)) return result.modified_count def delete_ccfinstance(self, ccf_id): """Remove an established interconnection with a peer CCF.""" current_app.logger.debug("Interconnection: Remove instance") Loading @@ -83,6 +102,9 @@ class CcfInstanceOperations(Resource): interconnected_col = self.db.get_col_by_name(self.db.interconnected) interconnected_ccf = interconnected_col.find_one({"ccf_id": ccf_id}) if interconnected_ccf: services_col = self.db.get_col_by_name(self.db.services_col) services_col.delete_many({"apf_id": ccf_id}) self.remove_ccf_from_pub_api_path(services_col, ccf_id) interconnected_col.delete_one({"ccf_id": ccf_id}) res = make_response(object = "CCF instance with ccf_id {} deleted".format(ccf_id), status=204) else: Loading Loading
services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py +40 −6 Original line number Diff line number Diff line Loading @@ -202,7 +202,6 @@ class PublishServiceOperations(Resource): config_col = self.db.get_col_by_name(self.db.capif_configuration) config = config_col.find_one({}, {"_id": 0}) ccf_id = config['ccf_id'] serviceapidescription_dict['ccf_id'] = ccf_id serviceapidescription_dict['shareable_info'] = {"is_shareable": False} url = 'https://{}/published-apis/v1/{}/service-apis'.format(dom, ccf_id) Loading @@ -218,10 +217,40 @@ class PublishServiceOperations(Resource): response = requests.request("POST", url, headers=headers, data=json.dumps(clean_n_camel_case(serviceapidescription_dict), cls=encoder.CustomJSONEncoder), cert=('certs/server.crt', 'certs/server.key'), verify='certs/ca.crt') if not (response.status_code == 201 or response.status_code == 200): if (response.status_code == 201 or response.status_code == 200): if rec.get("pub_api_path") is None: current_app.logger.debug("pub_api_path not in keys") rec.update({"pub_api_path": {"ccf_ids": [interconnected_ccf.get("ccf_id")]}}) else: current_app.logger.debug("pub_api_path in keys") ccf_list = rec.get("pub_api_path").get("ccf_ids") current_app.logger.debug("fetch") ccf_list.append(interconnected_ccf.get("ccf_id")) current_app.logger.debug("append") rec.update({"pub_api_path": {"ccf_ids": ccf_list}}) current_app.logger.debug("update") else: rec['shareable_info']['capif_prov_doms'].remove(dom) if "CCF" in apf_id: rec['pub_api_path']['ccf_ids'].remove(apf_id) current_app.logger.debug("Check pub_api_path") if "CCF" in apf_id: current_app.logger.debug("After CCF in apf_id") current_app.logger.debug("rec keys: {}".format(rec.keys())) if rec.get("pub_api_path") is None: current_app.logger.debug("pub_api_path not in keys") rec.update({"pub_api_path": {"ccf_ids": [apf_id]}}) else: current_app.logger.debug("pub_api_path in keys") ccf_list = rec.get("pub_api_path").get("ccf_ids") current_app.logger.debug("fetch") ccf_list.append(apf_id) current_app.logger.debug("append") rec.update({"pub_api_path": {"ccf_ids": ccf_list}}) current_app.logger.debug("update") current_app.logger.debug("inserting record") mycol.insert_one(rec) if "APF" in apf_id: Loading @@ -229,15 +258,20 @@ class PublishServiceOperations(Resource): current_app.logger.debug("Service inserted in database") published_service = { key: value for key, value in rec.items() if key not in ("_id", "apf_id", "onboarding_date") } res = make_response(object=clean_n_camel_case( serviceapidescription_dict), status=201) published_service), status=201) res.headers['Location'] = f"https://{os.getenv('CAPIF_HOSTNAME')}/published-apis/v1/{str(apf_id)}/service-apis/{str(api_id)}" if res.status_code == 201: current_app.logger.info("Service published") event_to_send = self.service_api_availability_event( clean_n_camel_case( serviceapidescription_dict)) published_service)) RedisEvent(event_to_send, service_api_descriptions=[clean_n_camel_case( serviceapidescription.to_dict())], Loading
services/docker-compose-capif.yml +1 −0 Original line number Diff line number Diff line Loading @@ -273,6 +273,7 @@ services: - fluent-bit:host-gateway - otel-collector:host-gateway - ${CAPIF_VAULT}:host-gateway - ${CAPIF_INTERCONNECTION_HOSTNAME:-capifcore-b}:host-gateway environment: - CAPIF_HOSTNAME=${CAPIF_HOSTNAME} - CONTAINER_NAME=${PUBLISHED_APIS_CONTAINER_NAME} Loading
services/helper/helper_service/services/interconnection/core/capifdomaindetails.py +22 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,25 @@ class CapifDomainOperations(Resource): return Response(response.text, status=response.status_code, mimetype=remote_mimetype) def remove_ccf_from_pub_api_path(self, services_col, ccf_id): """Drop a CCF from the publication path of every service API that references it.""" current_app.logger.debug("Removing ccf_id {} from pub_api_path.ccf_ids".format(ccf_id)) result = services_col.update_many( {"pub_api_path.ccf_ids": ccf_id}, {"$pull": {"pub_api_path.ccf_ids": ccf_id}} ) current_app.logger.debug("Service APIs updated: {}".format(result.modified_count)) # ccf_ids must contain at least one entry, so null out pub_api_path once it is emptied cleaned = services_col.update_many( {"pub_api_path.ccf_ids": {"$size": 0}}, {"$set": {"pub_api_path": None}} ) current_app.logger.debug("Service APIs with empty pub_api_path nulled: {}".format(cleaned.modified_count)) return result.modified_count def sync_capifdomain(self, capifdomaindetails): """Sync interconnection state with a peer CCF.""" pass Loading Loading @@ -131,6 +150,9 @@ class CapifDomainOperations(Resource): cert=('certs/server.crt', 'certs/server.key'), verify='certs/ca.crt') if response.status_code in (204, 404): services_col = self.db.get_col_by_name(self.db.services_col) services_col.delete_many({"apf_id": ccf_id}) self.remove_ccf_from_pub_api_path(services_col, ccf_id) interconnected_col.delete_one({"ccf_id": ccf_id}) return make_response("CAPIF domain with ccf_id {} deleted".format(ccf_id), 204) else: Loading
services/helper/helper_service/services/interconnection/core/ccfinstancedetails.py +22 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,25 @@ class CcfInstanceOperations(Resource): res = make_response(object=serialize_clean(ccfinstancedetails_new), status=status) return res def remove_ccf_from_pub_api_path(self, services_col, ccf_id): """Drop a CCF from the publication path of every service API that references it.""" current_app.logger.debug("Removing ccf_id {} from pub_api_path.ccf_ids".format(ccf_id)) result = services_col.update_many( {"pub_api_path.ccf_ids": ccf_id}, {"$pull": {"pub_api_path.ccf_ids": ccf_id}} ) current_app.logger.debug("Service APIs updated: {}".format(result.modified_count)) # ccf_ids must contain at least one entry, so null out pub_api_path once it is emptied cleaned = services_col.update_many( {"pub_api_path.ccf_ids": {"$size": 0}}, {"$set": {"pub_api_path": None}} ) current_app.logger.debug("Service APIs with empty pub_api_path nulled: {}".format(cleaned.modified_count)) return result.modified_count def delete_ccfinstance(self, ccf_id): """Remove an established interconnection with a peer CCF.""" current_app.logger.debug("Interconnection: Remove instance") Loading @@ -83,6 +102,9 @@ class CcfInstanceOperations(Resource): interconnected_col = self.db.get_col_by_name(self.db.interconnected) interconnected_ccf = interconnected_col.find_one({"ccf_id": ccf_id}) if interconnected_ccf: services_col = self.db.get_col_by_name(self.db.services_col) services_col.delete_many({"apf_id": ccf_id}) self.remove_ccf_from_pub_api_path(services_col, ccf_id) interconnected_col.delete_one({"ccf_id": ccf_id}) res = make_response(object = "CCF instance with ccf_id {} deleted".format(ccf_id), status=204) else: Loading