diff --git a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py index f32b7b2c1e652e08bdc98734bc9003d04e170c63..9d73d37bda6e5dd0f77db5bc4937da819b1b8870 100644 --- a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py +++ b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py @@ -116,8 +116,14 @@ class PublishServiceOperations(Resource): if res.status_code == 201: current_app.logger.info("Service published") - RedisEvent("SERVICE_API_AVAILABLE", "apiIds", - [str(api_id)]).send_event() + if serviceapidescription.api_status is None or len(serviceapidescription.api_status.aef_ids) > 0: + current_app.logger.info("Service available") + RedisEvent("SERVICE_API_AVAILABLE", "apiIds", + [str(api_id)]).send_event() + else: + current_app.logger.info("Service unavailable") + RedisEvent("SERVICE_API_UNAVAILABLE", "apiIds", + [str(api_id)]).send_event() return res except Exception as e: @@ -226,13 +232,25 @@ class PublishServiceOperations(Resource): result = clean_empty(result) current_app.logger.debug("Updated service api") + service_api_description_updated = dict_to_camel_case(result) response = make_response( object=service_api_description_updated, status=200) + if response.status_code == 200: RedisEvent("SERVICE_API_UPDATE", "serviceAPIDescriptions", [ service_api_description_updated]).send_event() + if "apiStatus" not in service_api_description_updated or len(service_api_description_updated["apiStatus"]["aefIds"]) > 0: + current_app.logger.info("Service available") + RedisEvent("SERVICE_API_AVAILABLE", "apiIds", + [str(service_api_id)]).send_event() + else: + current_app.logger.info("Service unavailable") + RedisEvent("SERVICE_API_UNAVAILABLE", "apiIds", + [str(service_api_id)]).send_event() + + return response except Exception as e: