From f32e1e5be652f2adbd0fb492b5d82319007cfda2 Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Thu, 28 Nov 2024 10:38:58 +0100 Subject: [PATCH 1/6] Fix enhanced events --- .../TS29222_CAPIF_Events_API/capif_events/core/events_apis.py | 4 ++-- .../capif_events/core/notifications.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py index 62604e4..09ad7f7 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py @@ -14,6 +14,7 @@ from .responses import internal_server_error, not_found_error, make_response, ba from ..db.db import MongoDatabse from ..util import serialize_clean_camel_case, clean_empty, dict_to_camel_case from .auth_manager import AuthManager +import os class EventSubscriptionsOperations(Resource): @@ -75,8 +76,7 @@ class EventSubscriptionsOperations(Resource): self.auth_manager.add_auth_event(subscription_id, subscriber_id) res = make_response(object=serialize_clean_camel_case(event_subscription), status=201) - res.headers['Location'] = "http://localhost:8080/capif-events/v1/" + \ - str(subscriber_id) + "/subscriptions/" + str(subscription_id) + res.headers['Location'] = f"http://{os.getenv("CAPIF_HOSTNAME")}/capif-events/v1/{str(subscriber_id)}/subscriptions/{str(subscription_id)}" return res diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py b/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py index c1c7db1..2c25288 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py @@ -40,7 +40,7 @@ class Notifications(): if not (key == "serviceAPIDescriptions" and redis_event.get('event', None) in ["SERVICE_API_AVAILABLE", "SERVICE_API_UNAVAILABLE"]): event_detail[key]=redis_event.get('information', None)[pos] else: - if not (redis_event.get('event', None) in ["SERVICE_API_AVAILABLE", "SERVICE_API_UNAVAILABLE"] and key == "serviceAPIDescriptions" and not EventSubscription.return_supp_feat_dict(sub["supported_features"])["ApiStatusMonitoring"]): + if not (redis_event.get('event', None) in ["SERVICE_API_AVAILABLE", "SERVICE_API_UNAVAILABLE"] and key == "serviceAPIDescriptions" and (not EventSubscription.return_supp_feat_dict(sub["supported_features"])["ApiStatusMonitoring"] or not EventSubscription.return_supp_feat_dict(sub["supported_features"])["EnhancedEventReport"])): event_detail[key]=redis_event.get('information', None)[pos] current_app.logger.debug(event_detail) -- GitLab From 79cbeb6af91af1aba3962e799a15053dc1b1707c Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Thu, 28 Nov 2024 15:49:53 +0100 Subject: [PATCH 2/6] Events Logic notifications --- .../capif_events/core/events_apis.py | 14 +++++++++ .../capif_events/core/notifications.py | 29 ++++++++++++------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py index 09ad7f7..ef7c2ce 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py @@ -54,6 +54,13 @@ class EventSubscriptionsOperations(Resource): current_app.logger.error("Bad url format") return bad_request_error(detail="Bad Param", cause = "Detected Bad formar of param", invalid_params=[{"param": "notificationDestination", "reason": "Not valid URL format"}]) + if event_subscription.supportedFeatures is None: + return bad_request_error( + detail="supportedFeatures must be present in this request", + cause="supportedFeatures missed", + invalid_params=[{"param": "supportedFeatures", "reason": "not defined"}] + ) + ## Verify that this subscriberID exist in publishers or invokers result = self.__check_subscriber_id(subscriber_id) @@ -124,6 +131,13 @@ class EventSubscriptionsOperations(Resource): mycol = self.db.get_col_by_name(self.db.event_collection) current_app.logger.debug("Updating event subscription") + + if event_subscription.supportedFeatures is None: + return bad_request_error( + detail="supportedFeatures must be present in this request", + cause="supportedFeatures missed", + invalid_params=[{"param": "supportedFeatures", "reason": "not defined"}] + ) result = self.__check_subscriber_id(subscriber_id) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py b/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py index 2c25288..27a7f3e 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py @@ -33,18 +33,25 @@ class Notifications(): current_app.logger.debug(url) data = EventNotification(sub["subscription_id"], events=redis_event.get('event')) if redis_event.get('key', None) != None and redis_event.get('information', None) != None: - event_detail={} - for pos, key in enumerate(redis_event.get('key', None)): + if EventSubscription.return_supp_feat_dict(sub["supported_features"])["EnhancedEventReport"]: + event_detail={} + if redis_event.get('event', None) in ["SERVICE_API_AVAILABLE", "SERVICE_API_UNAVAILABLE"]: + event_detail["apiIds"]=redis_event.get('information', None)["apiIds"] + if EventSubscription.return_supp_feat_dict(sub["supported_features"])["ApiStatusMonitoring"] and "serviceAPIDescriptions" in redis_event.get('key', None): + event_detail["serviceAPIDescriptions"]=redis_event.get('information', None)["serviceAPIDescription"] + elif redis_event.get('event', None) in ["SERVICE_API_UPDATE"]: + event_detail["serviceAPIDescriptions"]=redis_event.get('information', None)["serviceAPIDescription"] + elif redis_event.get('event', None) in ["API_INVOKER_ONBOARDED", "API_INVOKER_OFFBOARDED", "API_INVOKER_UPDATED"]: + event_detail["apiInvokerIds"]=redis_event.get('information', None)["apiInvokerIds"] + elif redis_event.get('event', None) in ["ACCESS_CONTROL_POLICY_UPDATE"]: + event_detail["accCtrlPolList"]=redis_event.get('information', None)["accCtrlPolList"] + elif redis_event.get('event', None) in ["SERVICE_API_INVOCATION_SUCCESS", "SERVICE_API_INVOCATION_FAILURE"]: + event_detail["invocationLogs"]=redis_event.get('information', None)["invocationLogs"] + elif redis_event.get('event', None) in ["API_TOPOLOGY_HIDING_CREATED", "API_TOPOLOGY_HIDING_REVOKED"]: + event_detail["apiTopoHide"]=redis_event.get('information', None)["apiTopoHide"] - if sub["supported_features"] is None: - if not (key == "serviceAPIDescriptions" and redis_event.get('event', None) in ["SERVICE_API_AVAILABLE", "SERVICE_API_UNAVAILABLE"]): - event_detail[key]=redis_event.get('information', None)[pos] - else: - if not (redis_event.get('event', None) in ["SERVICE_API_AVAILABLE", "SERVICE_API_UNAVAILABLE"] and key == "serviceAPIDescriptions" and (not EventSubscription.return_supp_feat_dict(sub["supported_features"])["ApiStatusMonitoring"] or not EventSubscription.return_supp_feat_dict(sub["supported_features"])["EnhancedEventReport"])): - event_detail[key]=redis_event.get('information', None)[pos] - - current_app.logger.debug(event_detail) - data.event_detail=event_detail + current_app.logger.debug(event_detail) + data.event_detail=event_detail current_app.logger.debug(json.dumps(data.to_dict(),cls=CustomJSONEncoder)) -- GitLab From a78904e8b898e98ab77b2e73dad2cdfdc555502d Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Mon, 2 Dec 2024 11:54:12 +0100 Subject: [PATCH 3/6] fix events redis --- .../capif_events/app.py | 25 +++++++++++------- .../capif_events/core/events_apis.py | 24 ++++++++--------- .../capif_events/core/notifications.py | 26 ++++++++++--------- 3 files changed, 42 insertions(+), 33 deletions(-) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/app.py b/services/TS29222_CAPIF_Events_API/capif_events/app.py index a4eb747..36aacd7 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/app.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/app.py @@ -17,6 +17,7 @@ from multiprocessing import Process from threading import Thread from flask_executor import Executor from flask_apscheduler import APScheduler +from datetime import datetime from logging.handlers import RotatingFileHandler from config import Config import os @@ -144,18 +145,24 @@ if monitoring_value == "true": config = Config() executor = Executor(app.app) subscriber = Subscriber() -# scheduler = APScheduler() -# scheduler.init_app(app.app) +scheduler = APScheduler() +scheduler.init_app(app.app) +scheduler.start() # @app.app.before_first_request # def create_listener_message(): # executor.submit(subscriber.listen) -first = True +# first = True -@app.app.before_request -def create_listener_message(): - global first - if first: - executor.submit(subscriber.listen) - first = False +@scheduler.task('date', id='listener', next_run_time=datetime.now()) +def up_listener(): + with scheduler.app.app_context(): + executor.submit(subscriber.listen()) + +# @app.app.before_request +# def create_listener_message(): +# global first +# if first: +# executor.submit(subscriber.listen) +# first = False diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py index ef7c2ce..a8c0780 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py @@ -54,12 +54,12 @@ class EventSubscriptionsOperations(Resource): current_app.logger.error("Bad url format") return bad_request_error(detail="Bad Param", cause = "Detected Bad formar of param", invalid_params=[{"param": "notificationDestination", "reason": "Not valid URL format"}]) - if event_subscription.supportedFeatures is None: - return bad_request_error( - detail="supportedFeatures must be present in this request", - cause="supportedFeatures missed", - invalid_params=[{"param": "supportedFeatures", "reason": "not defined"}] - ) + # if event_subscription.supported_features is None: + # return bad_request_error( + # detail="supportedFeatures must be present in this request", + # cause="supportedFeatures missed", + # invalid_params=[{"param": "supportedFeatures", "reason": "not defined"}] + # ) ## Verify that this subscriberID exist in publishers or invokers @@ -132,12 +132,12 @@ class EventSubscriptionsOperations(Resource): current_app.logger.debug("Updating event subscription") - if event_subscription.supportedFeatures is None: - return bad_request_error( - detail="supportedFeatures must be present in this request", - cause="supportedFeatures missed", - invalid_params=[{"param": "supportedFeatures", "reason": "not defined"}] - ) + # if event_subscription.supported_features is None: + # return bad_request_error( + # detail="supportedFeatures must be present in this request", + # cause="supportedFeatures missed", + # invalid_params=[{"param": "supportedFeatures", "reason": "not defined"}] + # ) result = self.__check_subscriber_id(subscriber_id) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py b/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py index 27a7f3e..353f85e 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py @@ -33,25 +33,27 @@ class Notifications(): current_app.logger.debug(url) data = EventNotification(sub["subscription_id"], events=redis_event.get('event')) if redis_event.get('key', None) != None and redis_event.get('information', None) != None: - if EventSubscription.return_supp_feat_dict(sub["supported_features"])["EnhancedEventReport"]: - event_detail={} + # if EventSubscription.return_supp_feat_dict(sub["supported_features"])["EnhancedEventReport"]: + event_detail={} + for pos, key in enumerate(redis_event.get('key', None)): + current_app.logger.debug(f"information: {redis_event.get('information', None)[pos]}") if redis_event.get('event', None) in ["SERVICE_API_AVAILABLE", "SERVICE_API_UNAVAILABLE"]: - event_detail["apiIds"]=redis_event.get('information', None)["apiIds"] - if EventSubscription.return_supp_feat_dict(sub["supported_features"])["ApiStatusMonitoring"] and "serviceAPIDescriptions" in redis_event.get('key', None): - event_detail["serviceAPIDescriptions"]=redis_event.get('information', None)["serviceAPIDescription"] + event_detail["apiIds"]=[redis_event.get('information', None)[pos]] + # if EventSubscription.return_supp_feat_dict(sub["supported_features"])["ApiStatusMonitoring"] and "serviceAPIDescriptions" in information: + # event_detail["serviceAPIDescriptions"]=information["serviceAPIDescription"] elif redis_event.get('event', None) in ["SERVICE_API_UPDATE"]: - event_detail["serviceAPIDescriptions"]=redis_event.get('information', None)["serviceAPIDescription"] + event_detail["serviceAPIDescriptions"]=redis_event.get('information', None)[pos] elif redis_event.get('event', None) in ["API_INVOKER_ONBOARDED", "API_INVOKER_OFFBOARDED", "API_INVOKER_UPDATED"]: - event_detail["apiInvokerIds"]=redis_event.get('information', None)["apiInvokerIds"] + event_detail["apiInvokerIds"]=redis_event.get('information', None)[pos] elif redis_event.get('event', None) in ["ACCESS_CONTROL_POLICY_UPDATE"]: - event_detail["accCtrlPolList"]=redis_event.get('information', None)["accCtrlPolList"] + event_detail["accCtrlPolList"]=redis_event.get('information', None)[pos] elif redis_event.get('event', None) in ["SERVICE_API_INVOCATION_SUCCESS", "SERVICE_API_INVOCATION_FAILURE"]: - event_detail["invocationLogs"]=redis_event.get('information', None)["invocationLogs"] + event_detail["invocationLogs"]=redis_event.get('information', None)[pos] elif redis_event.get('event', None) in ["API_TOPOLOGY_HIDING_CREATED", "API_TOPOLOGY_HIDING_REVOKED"]: - event_detail["apiTopoHide"]=redis_event.get('information', None)["apiTopoHide"] + event_detail["apiTopoHide"]=redis_event.get('information', None)[pos] - current_app.logger.debug(event_detail) - data.event_detail=event_detail + current_app.logger.debug(event_detail) + data.event_detail=event_detail current_app.logger.debug(json.dumps(data.to_dict(),cls=CustomJSONEncoder)) -- GitLab From da5cc31dc9ae3bf82fa022a491c2f79827014b64 Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Mon, 2 Dec 2024 13:26:36 +0100 Subject: [PATCH 4/6] fix supported features apiStatusMonitoring --- .../capif_events/core/events_apis.py | 12 +++--- .../capif_events/core/notifications.py | 40 +++++++++---------- .../core/serviceapidescriptions.py | 40 +++++++------------ 3 files changed, 40 insertions(+), 52 deletions(-) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py index a8c0780..33620c8 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py @@ -54,12 +54,12 @@ class EventSubscriptionsOperations(Resource): current_app.logger.error("Bad url format") return bad_request_error(detail="Bad Param", cause = "Detected Bad formar of param", invalid_params=[{"param": "notificationDestination", "reason": "Not valid URL format"}]) - # if event_subscription.supported_features is None: - # return bad_request_error( - # detail="supportedFeatures must be present in this request", - # cause="supportedFeatures missed", - # invalid_params=[{"param": "supportedFeatures", "reason": "not defined"}] - # ) + if event_subscription.supported_features is None: + return bad_request_error( + detail="supportedFeatures must be present in this request", + cause="supportedFeatures missed", + invalid_params=[{"param": "supportedFeatures", "reason": "not defined"}] + ) ## Verify that this subscriberID exist in publishers or invokers diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py b/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py index 353f85e..f537917 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py @@ -33,27 +33,27 @@ class Notifications(): current_app.logger.debug(url) data = EventNotification(sub["subscription_id"], events=redis_event.get('event')) if redis_event.get('key', None) != None and redis_event.get('information', None) != None: - # if EventSubscription.return_supp_feat_dict(sub["supported_features"])["EnhancedEventReport"]: - event_detail={} - for pos, key in enumerate(redis_event.get('key', None)): - current_app.logger.debug(f"information: {redis_event.get('information', None)[pos]}") - if redis_event.get('event', None) in ["SERVICE_API_AVAILABLE", "SERVICE_API_UNAVAILABLE"]: - event_detail["apiIds"]=[redis_event.get('information', None)[pos]] - # if EventSubscription.return_supp_feat_dict(sub["supported_features"])["ApiStatusMonitoring"] and "serviceAPIDescriptions" in information: - # event_detail["serviceAPIDescriptions"]=information["serviceAPIDescription"] - elif redis_event.get('event', None) in ["SERVICE_API_UPDATE"]: - event_detail["serviceAPIDescriptions"]=redis_event.get('information', None)[pos] - elif redis_event.get('event', None) in ["API_INVOKER_ONBOARDED", "API_INVOKER_OFFBOARDED", "API_INVOKER_UPDATED"]: - event_detail["apiInvokerIds"]=redis_event.get('information', None)[pos] - elif redis_event.get('event', None) in ["ACCESS_CONTROL_POLICY_UPDATE"]: - event_detail["accCtrlPolList"]=redis_event.get('information', None)[pos] - elif redis_event.get('event', None) in ["SERVICE_API_INVOCATION_SUCCESS", "SERVICE_API_INVOCATION_FAILURE"]: - event_detail["invocationLogs"]=redis_event.get('information', None)[pos] - elif redis_event.get('event', None) in ["API_TOPOLOGY_HIDING_CREATED", "API_TOPOLOGY_HIDING_REVOKED"]: - event_detail["apiTopoHide"]=redis_event.get('information', None)[pos] + if EventSubscription.return_supp_feat_dict(sub["supported_features"])["EnhancedEventReport"]: + event_detail={} + for pos, key in enumerate(redis_event.get('key', None)): + current_app.logger.debug(f"information: {redis_event.get('information', None)[pos]}") + if redis_event.get('event', None) in ["SERVICE_API_AVAILABLE", "SERVICE_API_UNAVAILABLE"] and key == "apiIds": + event_detail["apiIds"]=[redis_event.get('information', None)[pos]] + elif EventSubscription.return_supp_feat_dict(sub["supported_features"])["ApiStatusMonitoring"] and key == "serviceAPIDescriptions": + event_detail["serviceAPIDescriptions"]=redis_event.get('information', None)[pos] + elif redis_event.get('event', None) in ["SERVICE_API_UPDATE"]: + event_detail["serviceAPIDescriptions"]=redis_event.get('information', None)[pos] + elif redis_event.get('event', None) in ["API_INVOKER_ONBOARDED", "API_INVOKER_OFFBOARDED", "API_INVOKER_UPDATED"]: + event_detail["apiInvokerIds"]=redis_event.get('information', None)[pos] + elif redis_event.get('event', None) in ["ACCESS_CONTROL_POLICY_UPDATE"]: + event_detail["accCtrlPolList"]=redis_event.get('information', None)[pos] + elif redis_event.get('event', None) in ["SERVICE_API_INVOCATION_SUCCESS", "SERVICE_API_INVOCATION_FAILURE"]: + event_detail["invocationLogs"]=redis_event.get('information', None)[pos] + elif redis_event.get('event', None) in ["API_TOPOLOGY_HIDING_CREATED", "API_TOPOLOGY_HIDING_REVOKED"]: + event_detail["apiTopoHide"]=redis_event.get('information', None)[pos] - current_app.logger.debug(event_detail) - data.event_detail=event_detail + current_app.logger.debug(event_detail) + data.event_detail=event_detail current_app.logger.debug(json.dumps(data.to_dict(),cls=CustomJSONEncoder)) 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 c9714ca..4a05a00 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 @@ -132,39 +132,27 @@ class PublishServiceOperations(Resource): if res.status_code == 201: current_app.logger.info("Service published") if serviceapidescription.api_status is None or len(serviceapidescription.api_status.aef_ids) > 0: - if serviceapidescription.supported_features is not None: - if serviceapidescription.return_supp_feat_dict(serviceapidescription.supported_features)["ApiStatusMonitoring"]: - current_app.logger.info(f"Service available") - RedisEvent("SERVICE_API_AVAILABLE", - ["serviceAPIDescriptions", "apiIds"], - [[clean_n_camel_case(serviceapidescription.to_dict())], [str(api_id)]]).send_event() - else: - current_app.logger.info("Service available") - RedisEvent("SERVICE_API_AVAILABLE", - ["apiIds"], - [str(api_id)]).send_event() + if serviceapidescription.return_supp_feat_dict(serviceapidescription.supported_features)["ApiStatusMonitoring"]: + current_app.logger.info(f"Service available") + RedisEvent("SERVICE_API_AVAILABLE", + ["serviceAPIDescriptions", "apiIds"], + [[clean_n_camel_case(serviceapidescription.to_dict())], [str(api_id)]]).send_event() else: current_app.logger.info("Service available") RedisEvent("SERVICE_API_AVAILABLE", - ["apiIds"], - [str(api_id)]).send_event() + ["apiIds"], + [str(api_id)]).send_event() else: - if serviceapidescription.supported_features is not None: - if serviceapidescription.return_supp_feat_dict(serviceapidescription.supported_features)["ApiStatusMonitoring"]: - current_app.logger.info(f"Service unavailable") - RedisEvent("SERVICE_API_UNAVAILABLE", - ["serviceAPIDescriptions", "apiIds"], - [[clean_n_camel_case(serviceapidescription.to_dict())], [str(api_id)]]).send_event() - else: - current_app.logger.info("Service available") - RedisEvent("SERVICE_API_UNAVAILABLE", - ["apiIds"], - [str(api_id)]).send_event() + if serviceapidescription.return_supp_feat_dict(serviceapidescription.supported_features)["ApiStatusMonitoring"]: + current_app.logger.info(f"Service unavailable") + RedisEvent("SERVICE_API_UNAVAILABLE", + ["serviceAPIDescriptions", "apiIds"], + [[clean_n_camel_case(serviceapidescription.to_dict())], [str(api_id)]]).send_event() else: current_app.logger.info("Service available") RedisEvent("SERVICE_API_UNAVAILABLE", - ["apiIds"], - [str(api_id)]).send_event() + ["apiIds"], + [str(api_id)]).send_event() return res -- GitLab From df02e9fcacc8cc3f0ae84a80c5b0ce5e1dff002a Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Mon, 2 Dec 2024 13:48:18 +0100 Subject: [PATCH 5/6] remove comments --- .../TS29222_CAPIF_Events_API/capif_events/app.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/app.py b/services/TS29222_CAPIF_Events_API/capif_events/app.py index 36aacd7..d21ee57 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/app.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/app.py @@ -149,20 +149,7 @@ scheduler = APScheduler() scheduler.init_app(app.app) scheduler.start() -# @app.app.before_first_request -# def create_listener_message(): -# executor.submit(subscriber.listen) - -# first = True - @scheduler.task('date', id='listener', next_run_time=datetime.now()) def up_listener(): with scheduler.app.app_context(): executor.submit(subscriber.listen()) - -# @app.app.before_request -# def create_listener_message(): -# global first -# if first: -# executor.submit(subscriber.listen) -# first = False -- GitLab From 942fac6b7e64ebb4e12b5d554fed2538f09aa2b3 Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Mon, 2 Dec 2024 15:49:49 +0100 Subject: [PATCH 6/6] Fix supportedfeature not present error --- .../capif_events/core/events_apis.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py index 33620c8..f0226d0 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py @@ -56,8 +56,8 @@ class EventSubscriptionsOperations(Resource): if event_subscription.supported_features is None: return bad_request_error( - detail="supportedFeatures must be present in this request", - cause="supportedFeatures missed", + detail="supportedFeatures not present in request", + cause="supportedFeatures not present", invalid_params=[{"param": "supportedFeatures", "reason": "not defined"}] ) @@ -132,12 +132,12 @@ class EventSubscriptionsOperations(Resource): current_app.logger.debug("Updating event subscription") - # if event_subscription.supported_features is None: - # return bad_request_error( - # detail="supportedFeatures must be present in this request", - # cause="supportedFeatures missed", - # invalid_params=[{"param": "supportedFeatures", "reason": "not defined"}] - # ) + if event_subscription.supported_features is None: + return bad_request_error( + detail="supportedFeatures not present in request", + cause="supportedFeatures not present", + invalid_params=[{"param": "supportedFeatures", "reason": "not defined"}] + ) result = self.__check_subscriber_id(subscriber_id) -- GitLab