Commit b844a57a authored by Pelayo Torres's avatar Pelayo Torres
Browse files

Api status logic

parent f9e05a72
Loading
Loading
Loading
Loading
Loading
+20 −2
Original line number Original line Diff line number Diff line
@@ -116,8 +116,14 @@ class PublishServiceOperations(Resource):


            if res.status_code == 201:
            if res.status_code == 201:
                current_app.logger.info("Service published")
                current_app.logger.info("Service published")
                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",
                    RedisEvent("SERVICE_API_AVAILABLE", "apiIds",
                            [str(api_id)]).send_event()
                            [str(api_id)]).send_event()
                else:
                    current_app.logger.info("Service unavailable")
                    RedisEvent("SERVICE_API_UNAVAILABLE", "apiIds",
                            [str(api_id)]).send_event()
            return res
            return res


        except Exception as e:
        except Exception as e:
@@ -226,13 +232,25 @@ class PublishServiceOperations(Resource):
            result = clean_empty(result)
            result = clean_empty(result)


            current_app.logger.debug("Updated service api")
            current_app.logger.debug("Updated service api")

            service_api_description_updated = dict_to_camel_case(result)
            service_api_description_updated = dict_to_camel_case(result)


            response = make_response(
            response = make_response(
                object=service_api_description_updated, status=200)
                object=service_api_description_updated, status=200)
            
            if response.status_code == 200:
            if response.status_code == 200:
                RedisEvent("SERVICE_API_UPDATE", "serviceAPIDescriptions", [
                RedisEvent("SERVICE_API_UPDATE", "serviceAPIDescriptions", [
                           service_api_description_updated]).send_event()
                           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
            return response


        except Exception as e:
        except Exception as e: