Loading services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py +3 −6 Original line number Diff line number Diff line Loading @@ -107,8 +107,7 @@ class InvokerManagementOperations(Resource): if res.status_code == 201: current_app.logger.info("Invoker Created") RedisEvent("API_INVOKER_ONBOARDED", ["apiInvokerIds"], [[str(api_invoker_id)]]).send_event() api_invoker_ids=[str(api_invoker_id)]).send_event() return res def update_apiinvokerenrolmentdetail(self, onboard_id, apiinvokerenrolmentdetail): Loading Loading @@ -154,8 +153,7 @@ class InvokerManagementOperations(Resource): if res.status_code == 200: current_app.logger.info("Invoker Updated") RedisEvent("API_INVOKER_UPDATED", ["apiInvokerIds"], [[onboard_id]]).send_event() api_invoker_ids=[onboard_id]).send_event() return res except Exception as e: Loading Loading @@ -183,8 +181,7 @@ class InvokerManagementOperations(Resource): if res.status_code == 204: current_app.logger.info("Invoker Removed") RedisEvent("API_INVOKER_OFFBOARDED", ["apiInvokerIds"], [[onboard_id]]).send_event() api_invoker_ids=[onboard_id]).send_event() RedisInternalEvent("INVOKER-REMOVED", "invokerId", { Loading services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/redis_event.py +25 −4 Original line number Diff line number Diff line Loading @@ -6,7 +6,14 @@ publisher_ops = Publisher() class RedisEvent(): def __init__(self, event, event_detail_key=None, information=None) -> None: def __init__(self, event, service_api_descriptions=None, api_ids=None, api_invoker_ids=None, acc_ctrl_pol_list=None, invocation_logs=None, api_topo_hide=None) -> None: self.EVENTS_ENUM = [ 'SERVICE_API_AVAILABLE', 'SERVICE_API_UNAVAILABLE', Loading @@ -27,9 +34,23 @@ class RedisEvent(): self.redis_event = { "event": event } if event_detail_key != None and information != None: self.redis_event['key'] = event_detail_key self.redis_event['information'] = information # Add event filter keys to an auxiliary object event_detail = { "serviceApiDescriptions": service_api_descriptions, "apiIds": api_ids, "apiInvokerIds": api_invoker_ids, "accCtrlPolList": acc_ctrl_pol_list, "invocationLogs": invocation_logs, "apiTopoHide": api_topo_hide } # Filter keys with not None values filtered_event_detail = {k: v for k, v in event_detail.items() if v is not None} # If there are valid values then add to redis event. if filtered_event_detail: self.redis_event["event_detail"] = filtered_event_detail def to_string(self): return json.dumps(self.redis_event, cls=JSONEncoder) Loading services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/internal_service_ops.py +1 −1 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ class InternalServiceOps(Resource): "apiInvokerPolicies": inserted_service_acls_camel['apiInvokerPolicies'] } RedisEvent("ACCESS_CONTROL_POLICY_UPDATE", ["accCtrlPolList"], [accCtrlPolListExt]).send_event() acc_ctrl_pol_list=accCtrlPolListExt).send_event() current_app.logger.info( f"Invoker ACL added for invoker: {invoker_id} for service: {service_id}") Loading services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/redis_event.py +25 −4 Original line number Diff line number Diff line Loading @@ -6,7 +6,14 @@ publisher_ops = Publisher() class RedisEvent(): def __init__(self, event, event_detail_key=None, information=None) -> None: def __init__(self, event, service_api_descriptions=None, api_ids=None, api_invoker_ids=None, acc_ctrl_pol_list=None, invocation_logs=None, api_topo_hide=None) -> None: self.EVENTS_ENUM = [ 'SERVICE_API_AVAILABLE', 'SERVICE_API_UNAVAILABLE', Loading @@ -27,9 +34,23 @@ class RedisEvent(): self.redis_event = { "event": event } if event_detail_key != None and information != None: self.redis_event['key'] = event_detail_key self.redis_event['information'] = information # Add event filter keys to an auxiliary object event_detail = { "serviceApiDescriptions": service_api_descriptions, "apiIds": api_ids, "apiInvokerIds": api_invoker_ids, "accCtrlPolList": acc_ctrl_pol_list, "invocationLogs": invocation_logs, "apiTopoHide": api_topo_hide } # Filter keys with not None values filtered_event_detail = {k: v for k, v in event_detail.items() if v is not None} # If there are valid values then add to redis event. if filtered_event_detail: self.redis_event["event_detail"] = filtered_event_detail def to_string(self): return json.dumps(self.redis_event, cls=CustomJSONEncoder) Loading services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py +23 −21 Original line number Diff line number Diff line Loading @@ -21,36 +21,38 @@ class Notifications(): def send_notifications(self, redis_event): try: if redis_event.get('event', None) == None: event = redis_event.get('event', None) if event is None: raise("Event value is not present on received event from REDIS") current_app.logger.info("Received event " + redis_event.get('event') + ", sending notifications") subscriptions = self.events_ops.get_event_subscriptions(redis_event.get('event')) current_app.logger.info("Received event " + event + ", sending notifications") subscriptions = self.events_ops.get_event_subscriptions(event) current_app.logger.info(subscriptions) for sub in subscriptions: url = sub["notification_destination"] 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: data = EventNotification(sub["subscription_id"], events=event) event_detail_redis=redis_event.get('event_detail', None) if event_detail_redis is not 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"] 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(f"event: {event_detail_redis}") if event in ["SERVICE_API_AVAILABLE", "SERVICE_API_UNAVAILABLE"]: event_detail["apiIds"]=event_detail_redis.get('apiIds', None) if EventSubscription.return_supp_feat_dict(sub["supported_features"])["ApiStatusMonitoring"]: event_detail["serviceAPIDescriptions"]=event_detail_redis.get('serviceAPIDescriptions', None) elif event in ["SERVICE_API_UPDATE"]: event_detail["serviceAPIDescriptions"]=event_detail_redis.get('serviceAPIDescriptions', None) elif event in ["API_INVOKER_ONBOARDED", "API_INVOKER_OFFBOARDED", "API_INVOKER_UPDATED"]: event_detail["apiInvokerIds"]=event_detail_redis.get('apiInvokerIds', None) elif event in ["ACCESS_CONTROL_POLICY_UPDATE"]: event_detail["accCtrlPolList"]=event_detail_redis.get('accCtrlPolList', None) elif event in ["SERVICE_API_INVOCATION_SUCCESS", "SERVICE_API_INVOCATION_FAILURE"]: event_detail["invocationLogs"]=event_detail_redis.get('invocationLogs', None) elif event in ["API_TOPOLOGY_HIDING_CREATED", "API_TOPOLOGY_HIDING_REVOKED"]: event_detail["apiTopoHide"]=event_detail_redis.get('apiTopoHide', None) current_app.logger.debug(event_detail) data.event_detail=event_detail Loading Loading
services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py +3 −6 Original line number Diff line number Diff line Loading @@ -107,8 +107,7 @@ class InvokerManagementOperations(Resource): if res.status_code == 201: current_app.logger.info("Invoker Created") RedisEvent("API_INVOKER_ONBOARDED", ["apiInvokerIds"], [[str(api_invoker_id)]]).send_event() api_invoker_ids=[str(api_invoker_id)]).send_event() return res def update_apiinvokerenrolmentdetail(self, onboard_id, apiinvokerenrolmentdetail): Loading Loading @@ -154,8 +153,7 @@ class InvokerManagementOperations(Resource): if res.status_code == 200: current_app.logger.info("Invoker Updated") RedisEvent("API_INVOKER_UPDATED", ["apiInvokerIds"], [[onboard_id]]).send_event() api_invoker_ids=[onboard_id]).send_event() return res except Exception as e: Loading Loading @@ -183,8 +181,7 @@ class InvokerManagementOperations(Resource): if res.status_code == 204: current_app.logger.info("Invoker Removed") RedisEvent("API_INVOKER_OFFBOARDED", ["apiInvokerIds"], [[onboard_id]]).send_event() api_invoker_ids=[onboard_id]).send_event() RedisInternalEvent("INVOKER-REMOVED", "invokerId", { Loading
services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/redis_event.py +25 −4 Original line number Diff line number Diff line Loading @@ -6,7 +6,14 @@ publisher_ops = Publisher() class RedisEvent(): def __init__(self, event, event_detail_key=None, information=None) -> None: def __init__(self, event, service_api_descriptions=None, api_ids=None, api_invoker_ids=None, acc_ctrl_pol_list=None, invocation_logs=None, api_topo_hide=None) -> None: self.EVENTS_ENUM = [ 'SERVICE_API_AVAILABLE', 'SERVICE_API_UNAVAILABLE', Loading @@ -27,9 +34,23 @@ class RedisEvent(): self.redis_event = { "event": event } if event_detail_key != None and information != None: self.redis_event['key'] = event_detail_key self.redis_event['information'] = information # Add event filter keys to an auxiliary object event_detail = { "serviceApiDescriptions": service_api_descriptions, "apiIds": api_ids, "apiInvokerIds": api_invoker_ids, "accCtrlPolList": acc_ctrl_pol_list, "invocationLogs": invocation_logs, "apiTopoHide": api_topo_hide } # Filter keys with not None values filtered_event_detail = {k: v for k, v in event_detail.items() if v is not None} # If there are valid values then add to redis event. if filtered_event_detail: self.redis_event["event_detail"] = filtered_event_detail def to_string(self): return json.dumps(self.redis_event, cls=JSONEncoder) Loading
services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/internal_service_ops.py +1 −1 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ class InternalServiceOps(Resource): "apiInvokerPolicies": inserted_service_acls_camel['apiInvokerPolicies'] } RedisEvent("ACCESS_CONTROL_POLICY_UPDATE", ["accCtrlPolList"], [accCtrlPolListExt]).send_event() acc_ctrl_pol_list=accCtrlPolListExt).send_event() current_app.logger.info( f"Invoker ACL added for invoker: {invoker_id} for service: {service_id}") Loading
services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/redis_event.py +25 −4 Original line number Diff line number Diff line Loading @@ -6,7 +6,14 @@ publisher_ops = Publisher() class RedisEvent(): def __init__(self, event, event_detail_key=None, information=None) -> None: def __init__(self, event, service_api_descriptions=None, api_ids=None, api_invoker_ids=None, acc_ctrl_pol_list=None, invocation_logs=None, api_topo_hide=None) -> None: self.EVENTS_ENUM = [ 'SERVICE_API_AVAILABLE', 'SERVICE_API_UNAVAILABLE', Loading @@ -27,9 +34,23 @@ class RedisEvent(): self.redis_event = { "event": event } if event_detail_key != None and information != None: self.redis_event['key'] = event_detail_key self.redis_event['information'] = information # Add event filter keys to an auxiliary object event_detail = { "serviceApiDescriptions": service_api_descriptions, "apiIds": api_ids, "apiInvokerIds": api_invoker_ids, "accCtrlPolList": acc_ctrl_pol_list, "invocationLogs": invocation_logs, "apiTopoHide": api_topo_hide } # Filter keys with not None values filtered_event_detail = {k: v for k, v in event_detail.items() if v is not None} # If there are valid values then add to redis event. if filtered_event_detail: self.redis_event["event_detail"] = filtered_event_detail def to_string(self): return json.dumps(self.redis_event, cls=CustomJSONEncoder) Loading
services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py +23 −21 Original line number Diff line number Diff line Loading @@ -21,36 +21,38 @@ class Notifications(): def send_notifications(self, redis_event): try: if redis_event.get('event', None) == None: event = redis_event.get('event', None) if event is None: raise("Event value is not present on received event from REDIS") current_app.logger.info("Received event " + redis_event.get('event') + ", sending notifications") subscriptions = self.events_ops.get_event_subscriptions(redis_event.get('event')) current_app.logger.info("Received event " + event + ", sending notifications") subscriptions = self.events_ops.get_event_subscriptions(event) current_app.logger.info(subscriptions) for sub in subscriptions: url = sub["notification_destination"] 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: data = EventNotification(sub["subscription_id"], events=event) event_detail_redis=redis_event.get('event_detail', None) if event_detail_redis is not 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"] 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(f"event: {event_detail_redis}") if event in ["SERVICE_API_AVAILABLE", "SERVICE_API_UNAVAILABLE"]: event_detail["apiIds"]=event_detail_redis.get('apiIds', None) if EventSubscription.return_supp_feat_dict(sub["supported_features"])["ApiStatusMonitoring"]: event_detail["serviceAPIDescriptions"]=event_detail_redis.get('serviceAPIDescriptions', None) elif event in ["SERVICE_API_UPDATE"]: event_detail["serviceAPIDescriptions"]=event_detail_redis.get('serviceAPIDescriptions', None) elif event in ["API_INVOKER_ONBOARDED", "API_INVOKER_OFFBOARDED", "API_INVOKER_UPDATED"]: event_detail["apiInvokerIds"]=event_detail_redis.get('apiInvokerIds', None) elif event in ["ACCESS_CONTROL_POLICY_UPDATE"]: event_detail["accCtrlPolList"]=event_detail_redis.get('accCtrlPolList', None) elif event in ["SERVICE_API_INVOCATION_SUCCESS", "SERVICE_API_INVOCATION_FAILURE"]: event_detail["invocationLogs"]=event_detail_redis.get('invocationLogs', None) elif event in ["API_TOPOLOGY_HIDING_CREATED", "API_TOPOLOGY_HIDING_REVOKED"]: event_detail["apiTopoHide"]=event_detail_redis.get('apiTopoHide', None) current_app.logger.debug(event_detail) data.event_detail=event_detail Loading