From 55d6cb833c1cd659937a65f0d0eeaf436a3258e9 Mon Sep 17 00:00:00 2001 From: alexkak Date: Mon, 16 Mar 2026 16:10:29 +0200 Subject: [PATCH 1/9] Refine log levels in ACL service --- .../capif_acl/core/accesscontrolpolicyapi.py | 6 ++--- .../capif_acl/core/consumer_messager.py | 4 ++-- .../capif_acl/core/internal_service_ops.py | 22 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/accesscontrolpolicyapi.py b/services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/accesscontrolpolicyapi.py index 5c00ac43..9173a5f9 100644 --- a/services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/accesscontrolpolicyapi.py +++ b/services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/accesscontrolpolicyapi.py @@ -27,11 +27,11 @@ class accessControlPolicyApi(Resource): if supported_features is not None: current_app.logger.debug(f"SupportedFeatures present on query with value {supported_features}, but currently not used") - current_app.logger.info(f"Looking for ACLs of service: {service_api_id}, aef_id: {aef_id}, invoker: {api_invoker_id} and supportedFeatures: {supported_features}") + current_app.logger.debug(f"Looking for ACLs of service: {service_api_id}, aef_id: {aef_id}, invoker: {api_invoker_id} and supportedFeatures: {supported_features}") policies_cursor = mycol.find(query,projection) policies = list(policies_cursor) if not policies: - current_app.logger.info(f"No ACLs found for the requested service: {service_api_id}, aef_id: {aef_id}, invoker: {api_invoker_id} and supportedFeatures: {supported_features}") + current_app.logger.warning(f"No ACLs found for the requested service: {service_api_id}, aef_id: {aef_id}, invoker: {api_invoker_id} and supportedFeatures: {supported_features}") #Not found error return not_found_error(f"No ACLs found for the requested service: {service_api_id}, aef_id: {aef_id}, invoker: {api_invoker_id} and supportedFeatures: {supported_features}", "Wrong id") @@ -42,7 +42,7 @@ class accessControlPolicyApi(Resource): api_invoker_policies = policies[0]['api_invoker_policies'] current_app.logger.debug(f"api_invoker_policies: {api_invoker_policies}") if not api_invoker_policies: - current_app.logger.info(f"ACLs list is present but empty, then no ACLs found for the requested service: {service_api_id}, aef_id: {aef_id}, invoker: {api_invoker_id} and supportedFeatures: {supported_features}") + current_app.logger.warning(f"ACLs list is present but empty, then no ACLs found for the requested service: {service_api_id}, aef_id: {aef_id}, invoker: {api_invoker_id} and supportedFeatures: {supported_features}") #Not found error return not_found_error(f"No ACLs found for the requested service: {service_api_id}, aef_id: {aef_id}, invoker: {api_invoker_id} and supportedFeatures: {supported_features}", "Wrong id") acl = AccessControlPolicyList(api_invoker_policies) diff --git a/services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/consumer_messager.py b/services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/consumer_messager.py index 141b1604..f23340bf 100644 --- a/services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/consumer_messager.py +++ b/services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/consumer_messager.py @@ -22,7 +22,7 @@ class Subscriber(): def listen(self): for raw_message in self.p.listen(): if raw_message["type"] == "message" and raw_message["channel"].decode('utf-8') == "acls-messages": - current_app.logger.info("acls-messages recived") + current_app.logger.debug("acls-messages recived") message, *ids = raw_message["data"].decode('utf-8').split(":") if message == "create-acl" and len(ids) == 3: self.acls_ops.create_acl(ids[0], ids[1], ids[2]) @@ -32,7 +32,7 @@ class Subscriber(): self.acls_ops.remove_invoker_acl(ids[0]) if raw_message["type"] == "message" and raw_message["channel"].decode('utf-8') == "internal-messages": - current_app.logger.info("New internal event received") + current_app.logger.debug("New internal event received") internal_redis_event = json.loads( raw_message["data"].decode('utf-8')) if internal_redis_event.get('event') == "INVOKER-REMOVED": diff --git a/services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/internal_service_ops.py b/services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/internal_service_ops.py index 700805b0..790f7a95 100644 --- a/services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/internal_service_ops.py +++ b/services/TS29222_CAPIF_Access_Control_Policy_API/capif_acl/core/internal_service_ops.py @@ -13,7 +13,7 @@ class InternalServiceOps(Resource): def create_acl(self, invoker_id, service_id, aef_id): - current_app.logger.info(f"Creating ACL for invoker: {invoker_id}") + current_app.logger.debug(f"Creating ACL for invoker: {invoker_id}") if "acls" not in self.db.db.list_collection_names(): self.db.db.create_collection("acls") @@ -39,7 +39,7 @@ class InternalServiceOps(Resource): {"service_id": service_id, "aef_id": aef_id}, {"_id": 0}) if res: - current_app.logger.info( + current_app.logger.debug( f"Adding invoker ACL for invoker {invoker_id}") range_list = [TimeRangeList( datetime.utcnow(), datetime.utcnow()+timedelta(days=time_range_days))] @@ -53,9 +53,9 @@ class InternalServiceOps(Resource): inserted_invoker_acl = mycol.find_one({"service_id": service_id, "aef_id": aef_id, "api_invoker_policies.api_invoker_id": invoker_id}, {"_id": 0}) - current_app.logger.info(inserted_invoker_acl) + current_app.logger.debug(inserted_invoker_acl) inserted_invoker_acl_camel = dict_to_camel_case(inserted_invoker_acl) - current_app.logger.info(inserted_invoker_acl_camel) + current_app.logger.debug(inserted_invoker_acl_camel) created_invoker_policy = next((policy for policy in inserted_invoker_acl_camel['apiInvokerPolicies'] if policy['apiInvokerId'] == invoker_id), None) @@ -67,7 +67,7 @@ class InternalServiceOps(Resource): acc_ctrl_pol_list=accCtrlPolListExt).send_event() else: - current_app.logger.info( + current_app.logger.debug( f"Creating service ACLs for service: {service_id}") range_list = [TimeRangeList( datetime.utcnow(), datetime.utcnow()+timedelta(days=time_range_days))] @@ -82,9 +82,9 @@ class InternalServiceOps(Resource): result = mycol.insert_one(service_acls) inserted_service_acls = mycol.find_one({"_id": result.inserted_id}, {"_id": 0}) - current_app.logger.info(inserted_service_acls) + current_app.logger.debug(inserted_service_acls) inserted_service_acls_camel = dict_to_camel_case(inserted_service_acls) - current_app.logger.info(inserted_service_acls_camel) + current_app.logger.debug(inserted_service_acls_camel) created_invoker_policy = next((policy for policy in inserted_service_acls_camel['apiInvokerPolicies'] if policy['apiInvokerId'] == invoker_id), None) @@ -100,7 +100,7 @@ class InternalServiceOps(Resource): def remove_acl(self, invoker_id, service_id, aef_id): - current_app.logger.info(f"Removing ACL for invoker: {invoker_id}") + current_app.logger.debug(f"Removing ACL for invoker: {invoker_id}") mycol = self.db.get_col_by_name(self.db.acls) @@ -113,7 +113,7 @@ class InternalServiceOps(Resource): "api_invoker_id": invoker_id}}} ) else: - current_app.logger.info( + current_app.logger.warning( f"Not found: {service_id} for api : {service_id}") RedisEvent("ACCESS_CONTROL_POLICY_UNAVAILABLE").send_event() @@ -123,7 +123,7 @@ class InternalServiceOps(Resource): def remove_invoker_acl(self, invoker_id): - current_app.logger.info(f"Removing ACLs for invoker: {invoker_id}") + current_app.logger.debug(f"Removing ACLs for invoker: {invoker_id}") mycol = self.db.get_col_by_name(self.db.acls) mycol.update_many({"api_invoker_policies.api_invoker_id": invoker_id}, @@ -135,7 +135,7 @@ class InternalServiceOps(Resource): def remove_provider_acls(self, id): - current_app.logger.info(f"Removing ACLs for provider/service: {id}") + current_app.logger.debug(f"Removing ACLs for provider/service: {id}") mycol = self.db.get_col_by_name(self.db.acls) mycol.delete_many({"$or": [{"service_id": id}, {"aef_id": id}]}) -- GitLab From 4d019777700523e02e14c85e7ff7fe9257e83bba Mon Sep 17 00:00:00 2001 From: alexkak Date: Thu, 19 Mar 2026 14:37:59 +0200 Subject: [PATCH 2/9] refine log levels in API_Invoker_Management_API --- ...individual_on_boarded_api_invoker_document_controller.py | 6 +++--- .../on_boarded_api_invokers_collection_controller.py | 2 +- .../core/apiinvokerenrolmentdetails.py | 6 +++--- .../api_invoker_management/core/consumer_messager.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/controllers/individual_on_boarded_api_invoker_document_controller.py b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/controllers/individual_on_boarded_api_invoker_document_controller.py index aaff12d0..a43dcde2 100644 --- a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/controllers/individual_on_boarded_api_invoker_document_controller.py +++ b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/controllers/individual_on_boarded_api_invoker_document_controller.py @@ -56,7 +56,7 @@ def delete_ind_onboarded_api_invoker(onboarding_id): # noqa: E501 :rtype: Union[None, Tuple[None, int], Tuple[None, int, Dict[str, str]] """ - current_app.logger.info("Removing invoker") + current_app.logger.debug("Removing invoker") res = invoker_operations.remove_apiinvokerenrolmentdetail(onboarding_id) return res @@ -74,7 +74,7 @@ def modify_ind_api_invoke_enrolment(onboarding_id, body): # noqa: E501 :rtype: Union[APIInvokerEnrolmentDetails, Tuple[APIInvokerEnrolmentDetails, int], Tuple[APIInvokerEnrolmentDetails, int, Dict[str, str]] """ - current_app.logger.info("Updating invoker") + current_app.logger.debug("Updating invoker") if request.is_json: body = APIInvokerEnrolmentDetailsPatch.from_dict(request.get_json()) # noqa: E501 @@ -95,7 +95,7 @@ def update_ind_onboarded_api_invoker(onboarding_id, body): # noqa: E501 :rtype: Union[APIInvokerEnrolmentDetails, Tuple[APIInvokerEnrolmentDetails, int], Tuple[APIInvokerEnrolmentDetails, int, Dict[str, str]] """ - current_app.logger.info("Updating invoker") + current_app.logger.debug("Updating invoker") if request.is_json: body = APIInvokerEnrolmentDetails.from_dict(request.get_json()) # noqa: E501 diff --git a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/controllers/on_boarded_api_invokers_collection_controller.py b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/controllers/on_boarded_api_invokers_collection_controller.py index 240dc26e..4d630943 100644 --- a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/controllers/on_boarded_api_invokers_collection_controller.py +++ b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/controllers/on_boarded_api_invokers_collection_controller.py @@ -24,7 +24,7 @@ def create_onboarded_api_invoker(body): # noqa: E501 identity = get_jwt_identity() username, uuid = identity.split() - current_app.logger.info("Creating Invoker") + current_app.logger.debug("Creating Invoker") if request.is_json: body = APIInvokerEnrolmentDetails.from_dict(request.get_json()) # noqa: E501 diff --git a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py index 70e35b85..0c8cbe84 100644 --- a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py +++ b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py @@ -51,7 +51,7 @@ class InvokerManagementOperations(Resource): old_values = mycol.find_one(my_query) if old_values is None: - current_app.logger.error("Not found api invoker id") + current_app.logger.warning("Not found api invoker id") return not_found_error(detail="Please provide an existing Network App ID", cause="Not exist Network App ID") return old_values @@ -93,12 +93,12 @@ class InvokerManagementOperations(Resource): apiinvokerenrolmentdetail.onboarding_information.api_invoker_public_key}) if res is not None: - current_app.logger.error( + current_app.logger.warning( "Generating forbbiden error, invoker registered") return forbidden_error(detail="Invoker already registered", cause="Identical invoker public key") if rfc3987.match(apiinvokerenrolmentdetail.notification_destination, rule="URI") is None: - current_app.logger.error("Bad url format") + current_app.logger.warning("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 not apiinvokerenrolmentdetail.supported_features: diff --git a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/consumer_messager.py b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/consumer_messager.py index f6243656..ca504ff2 100644 --- a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/consumer_messager.py +++ b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/consumer_messager.py @@ -18,7 +18,7 @@ class Subscriber(): def listen(self): for raw_message in self.p.listen(): if raw_message["type"] == "message" and raw_message["channel"].decode('utf-8') == "internal-messages": - current_app.logger.info("New internal event received") + current_app.logger.debug("New internal event received") internal_redis_event = json.loads( raw_message["data"].decode('utf-8')) if internal_redis_event.get('event') == "SECURITY-CONTEXT-CREATED": -- GitLab From 030e997eef1fa066c77ec99b14520aeb7c8c24bc Mon Sep 17 00:00:00 2001 From: alexkak Date: Thu, 19 Mar 2026 15:02:55 +0200 Subject: [PATCH 3/9] refine log levels in API_Provider_Management_API --- .../controllers/default_controller.py | 6 +++--- ...dual_api_provider_enrolment_details_controller.py | 2 +- .../core/provider_enrolment_details_api.py | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/controllers/default_controller.py b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/controllers/default_controller.py index cbe36042..244c6b40 100644 --- a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/controllers/default_controller.py +++ b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/controllers/default_controller.py @@ -60,7 +60,7 @@ def registrations_post(body): # noqa: E501 identity = get_jwt_identity() username, uuid = identity.split() - current_app.logger.info("Registering Provider Domain") + current_app.logger.debug("Registering Provider Domain") if request.is_json: body = APIProviderEnrolmentDetails.from_dict(request.get_json()) # noqa: E501 @@ -80,7 +80,7 @@ def registrations_registration_id_delete(registration_id): # noqa: E501 :rtype: Union[None, Tuple[None, int], Tuple[None, int, Dict[str, str]] """ - current_app.logger.info("Removing Provider Domain") + current_app.logger.debug("Removing Provider Domain") res = provider_management_ops.delete_api_provider_enrolment_details(registration_id) return res @@ -98,7 +98,7 @@ def registrations_registration_id_put(registration_id, body): # noqa: E501 :rtype: Union[APIProviderEnrolmentDetails, Tuple[APIProviderEnrolmentDetails, int], Tuple[APIProviderEnrolmentDetails, int, Dict[str, str]] """ - current_app.logger.info("Updating Provider Domain") + current_app.logger.debug("Updating Provider Domain") if request.is_json: body = APIProviderEnrolmentDetails.from_dict(request.get_json()) # noqa: E501 diff --git a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/controllers/individual_api_provider_enrolment_details_controller.py b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/controllers/individual_api_provider_enrolment_details_controller.py index 9305c73b..0b265bfe 100644 --- a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/controllers/individual_api_provider_enrolment_details_controller.py +++ b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/controllers/individual_api_provider_enrolment_details_controller.py @@ -55,7 +55,7 @@ def modify_ind_api_provider_enrolment(registration_id, body): # noqa: E501 :rtype: Union[APIProviderEnrolmentDetails, Tuple[APIProviderEnrolmentDetails, int], Tuple[APIProviderEnrolmentDetails, int, Dict[str, str]] """ - current_app.logger.info("Patch Provider Domain") + current_app.logger.debug("Patch Provider Domain") if request.is_json: body = APIProviderEnrolmentDetailsPatch.from_dict(request.get_json()) # noqa: E501 diff --git a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/provider_enrolment_details_api.py b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/provider_enrolment_details_api.py index f6db1b7b..01466834 100644 --- a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/provider_enrolment_details_api.py +++ b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/provider_enrolment_details_api.py @@ -37,7 +37,7 @@ class ProviderManagementOperations(Resource): provider_enrolment_details = mycol.find_one(search_filter) if provider_enrolment_details is None: - current_app.logger.error("Not found api provider domain") + current_app.logger.warning("Not found api provider domain") return not_found_error(detail="Not Exist Provider Enrolment Details", cause="Not found registrations to send this api provider details") return provider_enrolment_details @@ -55,7 +55,7 @@ class ProviderManagementOperations(Resource): my_provider_enrolment_details = mycol.find_one(search_filter) if my_provider_enrolment_details is not None: - current_app.logger.error( + current_app.logger.warning( "Found provider registered with same id") return forbidden_error(detail="Provider already registered", cause="Identical provider reg sec") @@ -92,7 +92,7 @@ class ProviderManagementOperations(Resource): mycol.insert_one(provider_dict) - current_app.logger.debug("Provider inserted in database") + current_app.logger.info("Provider inserted in database") res = make_response(object=serialize_clean_camel_case( api_provider_enrolment_details), status=201) @@ -128,7 +128,7 @@ class ProviderManagementOperations(Resource): mycol.delete_one({'api_prov_dom_id': api_prov_dom_id}) out = "The provider matching apiProvDomainId " + \ api_prov_dom_id + " was offboarded." - current_app.logger.debug("Removed provider domain from database") + current_app.logger.info("Removed provider domain from database") self.auth_manager.remove_auth_provider(func_ids) @@ -199,7 +199,7 @@ class ProviderManagementOperations(Resource): '_id': 0}, return_document=ReturnDocument.AFTER, upsert=False) result = clean_empty(result) - current_app.logger.debug("Provider domain updated in database") + current_app.logger.info("Provider domain updated in database") provider_updated = APIProviderEnrolmentDetails().from_dict(dict_to_camel_case(result)) return make_response(object=serialize_clean_camel_case(provider_updated), status=200) @@ -228,7 +228,7 @@ class ProviderManagementOperations(Resource): result = clean_empty(result) - current_app.logger.debug("Provider domain updated in database") + current_app.logger.info("Provider domain updated in database") provider_updated = APIProviderEnrolmentDetails().from_dict(dict_to_camel_case(result)) return make_response(object=serialize_clean_camel_case(provider_updated), status=200) -- GitLab From e941caf5e2c0e8d00087705245c4993e4c98536e Mon Sep 17 00:00:00 2001 From: alexkak Date: Thu, 19 Mar 2026 15:27:32 +0200 Subject: [PATCH 4/9] refine log levels in Auditing_API --- .../logs/controllers/default_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/TS29222_CAPIF_Auditing_API/logs/controllers/default_controller.py b/services/TS29222_CAPIF_Auditing_API/logs/controllers/default_controller.py index e5ac1ef7..595d3681 100644 --- a/services/TS29222_CAPIF_Auditing_API/logs/controllers/default_controller.py +++ b/services/TS29222_CAPIF_Auditing_API/logs/controllers/default_controller.py @@ -91,7 +91,7 @@ def api_invocation_logs_get(aef_id=None, api_invoker_id=None, time_range_start=N :rtype: Union[InvocationLogsRetrieveRes, Tuple[InvocationLogsRetrieveRes, int], Tuple[InvocationLogsRetrieveRes, int, Dict[str, str]] """ - current_app.logger.info("Audit logs") + current_app.logger.debug("Audit logs") if aef_id is None or api_invoker_id is None: return bad_request_error(detail="aef_id and api_invoker_id parameters are mandatory", -- GitLab From e76b8e37c6d183c7c1841c69d352ec795ddbb329 Mon Sep 17 00:00:00 2001 From: alexkak Date: Thu, 19 Mar 2026 15:45:27 +0200 Subject: [PATCH 5/9] refine log levels in Discover_Service_API --- .../service_apis/controllers/default_controller.py | 2 +- .../service_apis/core/discoveredapis.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/TS29222_CAPIF_Discover_Service_API/service_apis/controllers/default_controller.py b/services/TS29222_CAPIF_Discover_Service_API/service_apis/controllers/default_controller.py index 457716d5..e9836132 100644 --- a/services/TS29222_CAPIF_Discover_Service_API/service_apis/controllers/default_controller.py +++ b/services/TS29222_CAPIF_Discover_Service_API/service_apis/controllers/default_controller.py @@ -101,7 +101,7 @@ def all_service_apis_get(api_invoker_id, api_name=None, api_version=None, comm_t :rtype: Union[DiscoveredAPIs, Tuple[DiscoveredAPIs, int], Tuple[DiscoveredAPIs, int, Dict[str, str]] """ - current_app.logger.info("Discovering service apis") + current_app.logger.debug("Discovering service apis") query_params = {"api_name": api_name, "api_version": api_version, "comm_type": comm_type, "protocol": protocol, "aef_id": aef_id, "data_format": data_format, diff --git a/services/TS29222_CAPIF_Discover_Service_API/service_apis/core/discoveredapis.py b/services/TS29222_CAPIF_Discover_Service_API/service_apis/core/discoveredapis.py index 6f9b0651..02a8b733 100644 --- a/services/TS29222_CAPIF_Discover_Service_API/service_apis/core/discoveredapis.py +++ b/services/TS29222_CAPIF_Discover_Service_API/service_apis/core/discoveredapis.py @@ -53,7 +53,7 @@ class DiscoverApisOperations(Resource): try: invoker = invokers.find_one({"api_invoker_id": api_invoker_id}) if invoker is None: - current_app.logger.error("Api invoker not found in database") + current_app.logger.warning("Api invoker not found in database") return not_found_error(detail="API Invoker does not exist", cause="API Invoker id not found") my_params = [] -- GitLab From e9332b8125aedec4ab0301e700cdabae6c023245 Mon Sep 17 00:00:00 2001 From: alexkak Date: Fri, 20 Mar 2026 14:40:29 +0200 Subject: [PATCH 6/9] refine log levels in Events_API --- ...nts_subscriptions_collection_controller.py | 2 +- ...events_subscription_document_controller.py | 2 +- .../capif_events/core/auth_manager.py | 2 +- .../capif_events/core/consumer_messager.py | 8 ++--- .../capif_events/core/events_apis.py | 30 +++++++++---------- .../capif_events/core/internal_event_ops.py | 10 +++---- .../capif_events/core/notifications.py | 4 +-- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/controllers/capifs_events_subscriptions_collection_controller.py b/services/TS29222_CAPIF_Events_API/capif_events/controllers/capifs_events_subscriptions_collection_controller.py index d4fc1c3a..2dd567a8 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/controllers/capifs_events_subscriptions_collection_controller.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/controllers/capifs_events_subscriptions_collection_controller.py @@ -60,7 +60,7 @@ def create_event_subsc(subscriber_id, body): # noqa: E501 :rtype: Union[EventSubscription, Tuple[EventSubscription, int], Tuple[EventSubscription, int, Dict[str, str]] """ - current_app.logger.info("Creating event subscription") + current_app.logger.debug("Creating event subscription") if request.is_json: body = EventSubscription.from_dict(request.get_json()) # noqa: E501 diff --git a/services/TS29222_CAPIF_Events_API/capif_events/controllers/individual_capifs_events_subscription_document_controller.py b/services/TS29222_CAPIF_Events_API/capif_events/controllers/individual_capifs_events_subscription_document_controller.py index 3339992a..5c02fd49 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/controllers/individual_capifs_events_subscription_document_controller.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/controllers/individual_capifs_events_subscription_document_controller.py @@ -62,7 +62,7 @@ def delete_ind_event_subsc(subscriber_id, subscription_id): # noqa: E501 :rtype: Union[None, Tuple[None, int], Tuple[None, int, Dict[str, str]] """ - current_app.logger.info("Removing event subscription") + current_app.logger.debug("Removing event subscription") res = events_ops.delete_event(subscriber_id, subscription_id) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/auth_manager.py b/services/TS29222_CAPIF_Events_API/capif_events/core/auth_manager.py index 013889b0..f284ce88 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/auth_manager.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/auth_manager.py @@ -42,7 +42,7 @@ class AuthManager(Resource): cert_col.find_one_and_update({"id":subscriber_id}, {"$set":auth_context}) except Exception as e: - current_app.logger.info(f"Something wrong in remove auth resources: {e}") + current_app.logger.error(f"Something wrong in remove auth resources: {e}") def remove_auth_all_event(self, subscriber_id): diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/consumer_messager.py b/services/TS29222_CAPIF_Events_API/capif_events/core/consumer_messager.py index 902ea465..5f19fea7 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/consumer_messager.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/consumer_messager.py @@ -19,14 +19,14 @@ class Subscriber(): def listen(self): for raw_message in self.p.listen(): - current_app.logger.info(raw_message) + current_app.logger.debug(raw_message) if raw_message["type"] == "message" and raw_message["channel"].decode('utf-8') == "events": - current_app.logger.info("Event received") + current_app.logger.debug("Event received") redis_event = json.loads(raw_message["data"].decode('utf-8')) - current_app.logger.info(json.dumps(redis_event, indent=4)) + current_app.logger.debug(json.dumps(redis_event, indent=4)) self.notification.send_notifications(redis_event) elif raw_message["type"] == "message" and raw_message["channel"].decode('utf-8') == "internal-messages": - current_app.logger.info("New internal event received") + current_app.logger.debug("New internal event received") internal_redis_event = json.loads( raw_message["data"].decode('utf-8')) if internal_redis_event.get('event') == "INVOKER-REMOVED": 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 ae4674e7..7749607a 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 @@ -51,7 +51,7 @@ class EventSubscriptionsOperations(Resource): provider = mycol_provider.find_one(provider_query) if invoker is None and provider is None: - current_app.logger.error("Not found invoker or provider with this subscriber id") + current_app.logger.warning("Not found invoker or provider with this subscriber id") return not_found_error(detail="Invoker or APF or AEF or AMF Not found", cause="Subscriber Not Found") return None @@ -76,7 +76,7 @@ class EventSubscriptionsOperations(Resource): invalid_filters = set(filter.keys()) - set(valid_filters.get(event, [])) if invalid_filters: - current_app.logger.debug(f"The eventFilter {invalid_filters} for event {event} are not applicable.") + current_app.logger.warning(f"The eventFilter {invalid_filters} for event {event} are not applicable.") return bad_request_error(detail="Bad Param", cause = f"Invalid eventFilter for event {event}", invalid_params=[{"param": "eventFilter", "reason": f"The eventFilter {invalid_filters} for event {event} are not applicable."}]) return None @@ -87,7 +87,7 @@ class EventSubscriptionsOperations(Resource): if event_subscription.event_req.mon_dur > datetime.now(timezone.utc): expired_at = event_subscription.event_req.mon_dur else: - current_app.logger.error("monDur is in the past") + current_app.logger.warning("monDur is in the past") return bad_request_error( detail="Bad Param", cause="monDur is in the past", @@ -95,7 +95,7 @@ class EventSubscriptionsOperations(Resource): ) if event_subscription.event_req.notif_method == "PERIODIC" and event_subscription.event_req.rep_period is None: - current_app.logger.error("Periodic notification method selected but repPeriod not provided") + current_app.logger.warning("Periodic notification method selected but repPeriod not provided") return bad_request_error( detail="Bad Param", cause="Periodic notification method selected but repPeriod not provided", @@ -123,7 +123,7 @@ class EventSubscriptionsOperations(Resource): current_app.logger.debug("Creating event") if rfc3987.match(event_subscription.notification_destination, rule="URI") is None: - current_app.logger.error("Bad url format") + current_app.logger.warning("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: @@ -158,14 +158,14 @@ class EventSubscriptionsOperations(Resource): return result else: if event_subscription.event_filters: - current_app.logger.error("Event filters provided but EnhancedEventReport is not enabled") + current_app.logger.warning("Event filters provided but EnhancedEventReport is not enabled") return bad_request_error( detail="Bad Param", cause="Event filters provided but EnhancedEventReport is not enabled", invalid_params=[{"param": "eventFilters", "reason": "EnhancedEventReport is not enabled"}] ) if event_subscription.event_req: - current_app.logger.error("Event requirement provided but EnhancedEventReport is not enabled") + current_app.logger.warning("Event requirement provided but EnhancedEventReport is not enabled") return bad_request_error( detail="Bad Param", cause="Event requirement provided but EnhancedEventReport is not enabled", @@ -186,7 +186,7 @@ class EventSubscriptionsOperations(Resource): evnt.update(event_subscription.to_dict()) mycol.insert_one(evnt) - current_app.logger.debug("Event Subscription inserted in database") + current_app.logger.info("Event Subscription inserted in database") self.auth_manager.add_auth_event(subscription_id, subscriber_id) @@ -219,12 +219,12 @@ class EventSubscriptionsOperations(Resource): eventdescription = mycol.find_one(my_query) if eventdescription is None: - current_app.logger.error("Event subscription not found") + current_app.logger.warning("Event subscription not found") return not_found_error(detail="Event subscription not exist", cause="Event API subscription id not found") mycol.delete_one(my_query) notifications_col.delete_many({"subscription_id": subscription_id}) - current_app.logger.debug("Event subscription removed from database") + current_app.logger.info("Event subscription removed from database") self.auth_manager.remove_auth_event(subscription_id, subscriber_id) @@ -272,14 +272,14 @@ class EventSubscriptionsOperations(Resource): return result else: if event_subscription.event_filters: - current_app.logger.error("Event filters provided but EnhancedEventReport is not enabled") + current_app.logger.warning("Event filters provided but EnhancedEventReport is not enabled") return bad_request_error( detail="Bad Param", cause="Event filters provided but EnhancedEventReport is not enabled", invalid_params=[{"param": "eventFilters", "reason": "EnhancedEventReport is not enabled"}] ) if event_subscription.event_req: - current_app.logger.error("Event requirement provided but EnhancedEventReport is not enabled") + current_app.logger.warning("Event requirement provided but EnhancedEventReport is not enabled") return bad_request_error( detail="Bad Param", cause="Event requirement provided but EnhancedEventReport is not enabled", @@ -302,7 +302,7 @@ class EventSubscriptionsOperations(Resource): notifications_col.delete_many({"subscription_id": subscription_id}) mycol.replace_one(my_query, body) - current_app.logger.debug("Event subscription updated from database") + current_app.logger.info("Event subscription updated from database") res = make_response(object=serialize_clean_camel_case(event_subscription), status=200) @@ -332,7 +332,7 @@ class EventSubscriptionsOperations(Resource): eventdescription = mycol.find_one(my_query) if eventdescription is None: - current_app.logger.error("Event subscription not found") + current_app.logger.warning("Event subscription not found") return not_found_error(detail="Event subscription not exist", cause="Event API subscription id not found") current_app.logger.debug(event_subscription) @@ -368,7 +368,7 @@ class EventSubscriptionsOperations(Resource): notifications_col.delete_many({"subscription_id": subscription_id}) document = mycol.update_one(my_query, {"$set":body}) document = mycol.find_one(my_query) - current_app.logger.debug("Event subscription patched from database") + current_app.logger.info("Event subscription patched from database") res = make_response(object=EventSubscription.from_dict(dict_to_camel_case(document)), status=200) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/internal_event_ops.py b/services/TS29222_CAPIF_Events_API/capif_events/core/internal_event_ops.py index 73ea353f..17b8d4dd 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/internal_event_ops.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/internal_event_ops.py @@ -31,14 +31,14 @@ class InternalEventOperations(Resource): current_app.logger.info(f"Removed subscription: {subscription_id}") def get_event_subscriptions(self, event): - current_app.logger.info("get subscription from db") + current_app.logger.debug("get subscription from db") try: mycol = self.db.get_col_by_name(self.db.event_collection) query={'events':{'$in':[event]}} subscriptions = mycol.find(query) if subscriptions is None: - current_app.logger.error("Not found event subscriptions") + current_app.logger.warning("Not found event subscriptions") else: json_docs=[] @@ -52,7 +52,7 @@ class InternalEventOperations(Resource): return False def add_notification(self, notification): - current_app.logger.info("Adding Notification to notifications list") + current_app.logger.debug("Adding Notification to notifications list") try: mycol = self.db.get_col_by_name(self.db.notifications_col) mycol.insert_one(notification) @@ -62,12 +62,12 @@ class InternalEventOperations(Resource): return False def update_report_nbr(self, subscription_id): - current_app.logger.info("Incrementing report number") + current_app.logger.debug("Incrementing report number") try: mycol = self.db.get_col_by_name(self.db.event_collection) my_query = {'subscription_id': subscription_id} result = mycol.update_one(my_query, {'$inc': {'report_nbr': 1}}) - current_app.logger.info(result) + current_app.logger.debug(result) current_app.logger.info("Report number incremented") except Exception as e: current_app.logger.error("An exception occurred ::" + str(e)) 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 ab1aafbd..27dd8a3b 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py @@ -40,9 +40,9 @@ class Notifications(): raise("Event value is not present on received event from REDIS") - current_app.logger.info("Received event " + event + ", sending notifications") + current_app.logger.debug("Received event " + event + ", sending notifications") subscriptions = self.events_ops.get_event_subscriptions(event) - current_app.logger.info(subscriptions) + current_app.logger.debug(subscriptions) for sub in subscriptions: url = sub["notification_destination"] -- GitLab From def23c988443ce93762bccce8b016065bc77110d Mon Sep 17 00:00:00 2001 From: alexkak Date: Fri, 20 Mar 2026 14:57:10 +0200 Subject: [PATCH 7/9] refine log levels in Logging_API_Invocation_API --- .../controllers/default_controller.py | 2 +- .../api_invocation_logs/core/invocationlogs.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/controllers/default_controller.py b/services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/controllers/default_controller.py index ce62116b..d1e9dc6b 100644 --- a/services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/controllers/default_controller.py +++ b/services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/controllers/default_controller.py @@ -60,7 +60,7 @@ def aef_id_logs_post(aef_id, body): # noqa: E501 :rtype: Union[InvocationLog, Tuple[InvocationLog, int], Tuple[InvocationLog, int, Dict[str, str]] """ - current_app.logger.info("API Invocation Logs") + current_app.logger.debug("API Invocation Logs") if request.is_json: body = InvocationLog.from_dict(request.get_json()) # noqa: E501 diff --git a/services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/invocationlogs.py b/services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/invocationlogs.py index df2e3121..6f00e996 100644 --- a/services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/invocationlogs.py +++ b/services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/invocationlogs.py @@ -36,7 +36,7 @@ class LoggingInvocationOperations(Resource): 'api_prov_func_role': 'AEF', 'api_prov_func_id': request_aef_id}}}) if aef_res is None: - current_app.logger.error("Exposer not exist") + current_app.logger.warning("Exposer not exist") return not_found_error(detail="Exposer not exist", cause="Exposer id not found") if request_aef_id != body_aef_id: @@ -51,7 +51,7 @@ class LoggingInvocationOperations(Resource): invoker_res = inv_col.find_one({'api_invoker_id': invoker_id}) if invoker_res is None: - current_app.logger.error("Invoker not exist") + current_app.logger.warning("Invoker not exist") return not_found_error(detail="Invoker not exist", cause="Invoker id not found") return None @@ -67,7 +67,7 @@ class LoggingInvocationOperations(Resource): detail = "Service API not exist" cause = "Service API with id {} and name {} not found".format( api_id, api_name) - current_app.logger.error(detail) + current_app.logger.warning(detail) return not_found_error(detail=detail, cause=cause) return None @@ -111,7 +111,7 @@ class LoggingInvocationOperations(Resource): else: event = "SERVICE_API_INVOCATION_FAILURE" - current_app.logger.info(event) + current_app.logger.debug(event) invocation_log_base['logs'] = [log.to_dict()] invocationLogs = [invocation_log_base] RedisEvent(event, invocation_logs= @@ -143,7 +143,7 @@ class LoggingInvocationOperations(Resource): res = make_response(object=serialize_clean_camel_case( invocationlog), status=201) - current_app.logger.debug("Invocation Logs response ready") + current_app.logger.info("Invocation Logs response ready") apis_added = { log.api_id: log.api_name for log in invocationlog.logs} -- GitLab From ac4cb87b95be91c75146627e0aff5dfd5171cc1a Mon Sep 17 00:00:00 2001 From: alexkak Date: Mon, 23 Mar 2026 12:32:02 +0200 Subject: [PATCH 8/9] refine log levels in Publish_Service_API --- .../controllers/default_controller.py | 10 +++--- ...individual_apf_published_api_controller.py | 2 +- .../published_apis/core/auth_manager.py | 2 +- .../published_apis/core/consumer_messager.py | 4 +-- .../core/internal_service_ops.py | 2 +- .../core/serviceapidescriptions.py | 36 +++++++++---------- .../published_apis/core/validate_user.py | 6 ++-- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/services/TS29222_CAPIF_Publish_Service_API/published_apis/controllers/default_controller.py b/services/TS29222_CAPIF_Publish_Service_API/published_apis/controllers/default_controller.py index 7908b28e..7524015c 100644 --- a/services/TS29222_CAPIF_Publish_Service_API/published_apis/controllers/default_controller.py +++ b/services/TS29222_CAPIF_Publish_Service_API/published_apis/controllers/default_controller.py @@ -71,7 +71,7 @@ def apf_id_service_apis_get(apf_id): # noqa: E501 :rtype: Union[List[ServiceAPIDescription], Tuple[List[ServiceAPIDescription], int], Tuple[List[ServiceAPIDescription], int, Dict[str, str]] """ - current_app.logger.info("Obtainig all service published") + current_app.logger.debug("Obtainig all service published") res = service_operations.get_serviceapis(apf_id) return res @@ -89,7 +89,7 @@ def apf_id_service_apis_post(apf_id, body): # noqa: E501 :rtype: Union[ServiceAPIDescription, Tuple[ServiceAPIDescription, int], Tuple[ServiceAPIDescription, int, Dict[str, str]] """ - current_app.logger.info("Publishing service") + current_app.logger.debug("Publishing service") if 'supportedFeatures' not in body: return bad_request_error( @@ -134,7 +134,7 @@ def apf_id_service_apis_service_api_id_delete(service_api_id, apf_id): # noqa: :rtype: Union[None, Tuple[None, int], Tuple[None, int, Dict[str, str]] """ - current_app.logger.info("Removing service published") + current_app.logger.debug("Removing service published") res = service_operations.delete_serviceapidescription( service_api_id, apf_id) @@ -153,7 +153,7 @@ def apf_id_service_apis_service_api_id_get(service_api_id, apf_id): # noqa: E50 :rtype: Union[ServiceAPIDescription, Tuple[ServiceAPIDescription, int], Tuple[ServiceAPIDescription, int, Dict[str, str]] """ - current_app.logger.info("Obtaining service api with id: " + service_api_id) + current_app.logger.debug("Obtaining service api with id: " + service_api_id) res = service_operations.get_one_serviceapi(service_api_id, apf_id) return res @@ -173,7 +173,7 @@ def apf_id_service_apis_service_api_id_put(service_api_id, apf_id, body): # noq :rtype: Union[ServiceAPIDescription, Tuple[ServiceAPIDescription, int], Tuple[ServiceAPIDescription, int, Dict[str, str]] """ - current_app.logger.info( + current_app.logger.debug( "Updating service api id with id: " + service_api_id) if 'supportedFeatures' not in body: diff --git a/services/TS29222_CAPIF_Publish_Service_API/published_apis/controllers/individual_apf_published_api_controller.py b/services/TS29222_CAPIF_Publish_Service_API/published_apis/controllers/individual_apf_published_api_controller.py index 291ca99c..b39664fb 100644 --- a/services/TS29222_CAPIF_Publish_Service_API/published_apis/controllers/individual_apf_published_api_controller.py +++ b/services/TS29222_CAPIF_Publish_Service_API/published_apis/controllers/individual_apf_published_api_controller.py @@ -69,7 +69,7 @@ def modify_ind_apf_pub_api(service_api_id, apf_id, body): # noqa: E501 :rtype: Union[ServiceAPIDescription, Tuple[ServiceAPIDescription, int], Tuple[ServiceAPIDescription, int, Dict[str, str]] """ - current_app.logger.info( + current_app.logger.debug( "Patching service api id with id: " + service_api_id) if request.is_json: body = ServiceAPIDescriptionPatch.from_dict(request.get_json()) # noqa: E501 diff --git a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/auth_manager.py b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/auth_manager.py index d20daffd..0e0d7f12 100644 --- a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/auth_manager.py +++ b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/auth_manager.py @@ -17,7 +17,7 @@ class AuthManager(Resource): else: auth_context["resources"]["services"] = [service_id] - current_app.logger.info(auth_context) + current_app.logger.debug(auth_context) cert_col.find_one_and_update({"id":apf_id}, {"$set":auth_context}) diff --git a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/consumer_messager.py b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/consumer_messager.py index 3814c71b..abcdadbc 100644 --- a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/consumer_messager.py +++ b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/consumer_messager.py @@ -16,10 +16,10 @@ class Subscriber(): self.p.subscribe("internal-messages") def listen(self): - current_app.logger.info("Listening publish messages") + current_app.logger.debug("Listening publish messages") for raw_message in self.p.listen(): if raw_message["type"] == "message" and raw_message["channel"].decode('utf-8') == "internal-messages": - current_app.logger.info("New internal event received") + current_app.logger.debug("New internal event received") internal_redis_event = json.loads( raw_message["data"].decode('utf-8')) if internal_redis_event.get('event') == "PROVIDER-REMOVED": diff --git a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/internal_service_ops.py b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/internal_service_ops.py index fa7bc67d..4f25d25d 100644 --- a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/internal_service_ops.py +++ b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/internal_service_ops.py @@ -13,7 +13,7 @@ class InternalServiceOps(Resource): def delete_intern_service(self, apf_ids): - current_app.logger.info("Provider removed, removing services published by APF") + current_app.logger.debug("Provider removed, removing services published by APF") mycol = self.db.get_col_by_name(self.db.service_api_descriptions) for apf_id in apf_ids: my_query = {'apf_id': apf_id} 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 c2ff0506..0226457e 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 @@ -52,7 +52,7 @@ class PublishServiceOperations(Resource): {"api_prov_funcs.api_prov_func_id": apf_id}) if provider is None: - current_app.logger.error("Publisher not exist") + current_app.logger.warning("Publisher not exist") return unauthorized_error( detail="Publisher not existing", cause="Publisher id not found") @@ -60,7 +60,7 @@ class PublishServiceOperations(Resource): list_apf_ids = [func["api_prov_func_id"] for func in provider["api_prov_funcs"] if func["api_prov_func_role"] == "APF"] if apf_id not in list_apf_ids: - current_app.logger.debug("This id not belongs to APF") + current_app.logger.warning("This id not belongs to APF") return unauthorized_error( detail="You are not a publisher", cause="This API is only available for publishers") @@ -95,7 +95,7 @@ class PublishServiceOperations(Resource): "api_status": 1}) current_app.logger.debug(service) if service is None: - current_app.logger.error("Not found services for this apf id") + current_app.logger.warning("Not found services for this apf id") return not_found_error(detail="Not exist published services for this apf_id", cause="Not exist service with this apf_id") json_docs = [] @@ -125,7 +125,7 @@ class PublishServiceOperations(Resource): service = mycol.find_one( {"api_name": serviceapidescription.api_name}) if service is not None: - current_app.logger.error( + current_app.logger.warning( "Service already registered with same api name") return forbidden_error(detail="Already registered service with same api name", cause="Found service with same api name") @@ -196,7 +196,7 @@ class PublishServiceOperations(Resource): "ccf_id": 1, "api_status": 1}) if service_api is None: - current_app.logger.error(service_api_not_found_message) + current_app.logger.warning(service_api_not_found_message) return not_found_error( detail=service_api_not_found_message, cause="No Service with specific credentials exists") @@ -237,7 +237,7 @@ class PublishServiceOperations(Resource): "api_status": 1}) if serviceapidescription_dict is None: - current_app.logger.error(service_api_not_found_message) + current_app.logger.warning(service_api_not_found_message) return not_found_error( detail="Service API not existing", cause="Service API id not found") @@ -246,7 +246,7 @@ class PublishServiceOperations(Resource): self.auth_manager.remove_auth_service(service_api_id, apf_id) - current_app.logger.debug("Removed service from database") + current_app.logger.info("Removed service from database") out = "The service matching api_id " + service_api_id + " was deleted." res = make_response(out, status=204) serviceapidescription = clean_empty( @@ -257,14 +257,14 @@ class PublishServiceOperations(Resource): clean_n_camel_case( serviceapidescription_dict)) if event_to_send != "SERVICE_API_UNAVAILABLE": - current_app.logger.info("Send SERVICE_API_UNAVAILABLE event") + current_app.logger.debug("Send SERVICE_API_UNAVAILABLE event") RedisEvent( "SERVICE_API_UNAVAILABLE", service_api_descriptions=[serviceapidescription], api_ids=[str(service_api_id)] ).send_event() else: - current_app.logger.info("Not send SERVICE_API_UNAVAILABLE because this Service API was unavailable previously") + current_app.logger.debug("Not send SERVICE_API_UNAVAILABLE because this Service API was unavailable previously") return res @@ -300,7 +300,7 @@ class PublishServiceOperations(Resource): "onboarding_date": 1, "api_status": 1}) if serviceapidescription_old is None: - current_app.logger.error(service_api_not_found_message) + current_app.logger.warning(service_api_not_found_message) return not_found_error(detail="Service API not existing", cause="Service API id not found") service_api_description = service_api_description.to_dict() @@ -338,7 +338,7 @@ class PublishServiceOperations(Resource): return_document=ReturnDocument.AFTER, upsert=False) result = clean_empty(result) - current_app.logger.debug("Updated service api") + current_app.logger.info("Updated service api") service_api_description_updated = dict_to_camel_case(result) @@ -393,7 +393,7 @@ class PublishServiceOperations(Resource): "ccf_id": 1, "api_status": 1}) if serviceapidescription_old is None: - current_app.logger.error(service_api_not_found_message) + current_app.logger.warning(service_api_not_found_message) return not_found_error(detail="Service API not existing", cause="Service API id not found") patch_service_api_description = patch_service_api_description.to_dict() @@ -431,7 +431,7 @@ class PublishServiceOperations(Resource): result = clean_empty(result) - current_app.logger.debug("Patched service api") + current_app.logger.info("Patched service api") service_api_description_updated = dict_to_camel_case(result) @@ -491,18 +491,18 @@ class PublishServiceOperations(Resource): def service_api_availability_event(self, service_api_description): service_api_status = "" if return_negotiated_supp_feat_dict(service_api_description.get("supportedFeatures"))["ApiStatusMonitoring"]: - current_app.logger.info( + current_app.logger.debug( "ApiStatusMonitoring active") if service_api_description.get("apiStatus") is None or len(service_api_description.get("apiStatus").get("aefIds")) > 0: - current_app.logger.info( + current_app.logger.debug( "Service available, at least one AEF is available") service_api_status = "SERVICE_API_AVAILABLE" else: - current_app.logger.info( + current_app.logger.debug( "Service unavailable, all AEFs are unavailable") service_api_status = "SERVICE_API_UNAVAILABLE" else: - current_app.logger.info("ApiStatusMonitoring") - current_app.logger.info("Service available") + current_app.logger.debug("ApiStatusMonitoring") + current_app.logger.debug("Service available") service_api_status = "SERVICE_API_AVAILABLE" return service_api_status diff --git a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/validate_user.py b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/validate_user.py index 1782fe04..87c2766d 100644 --- a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/validate_user.py +++ b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/validate_user.py @@ -30,14 +30,14 @@ class ControlAccess(Resource): if service_id not in cert_entry["resources"].get("services"): is_user_owner = False if is_user_owner == False: - current_app.logger.info("STEP3") + current_app.logger.debug("STEP3") prob = ProblemDetails( title="Unauthorized", detail="User not authorized", cause="You are not the owner of this resource") - current_app.logger.info("STEP4") + current_app.logger.debug("STEP4") prob = serialize_clean_camel_case(prob) - current_app.logger.info("STEP5") + current_app.logger.debug("STEP5") return Response( json.dumps(prob, cls=CustomJSONEncoder), status=401, -- GitLab From d810c2f21cb03388c87cac96363c685548b51900 Mon Sep 17 00:00:00 2001 From: alexkak Date: Mon, 23 Mar 2026 13:03:20 +0200 Subject: [PATCH 9/9] refine log levels in Security_API --- .../controllers/default_controller.py | 14 ++--- .../capif_security/core/consumer_messager.py | 2 +- .../capif_security/core/servicesecurity.py | 58 +++++++++---------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/services/TS29222_CAPIF_Security_API/capif_security/controllers/default_controller.py b/services/TS29222_CAPIF_Security_API/capif_security/controllers/default_controller.py index 7a65eb7d..deb95a87 100644 --- a/services/TS29222_CAPIF_Security_API/capif_security/controllers/default_controller.py +++ b/services/TS29222_CAPIF_Security_API/capif_security/controllers/default_controller.py @@ -39,7 +39,7 @@ def cert_validation(): cn = cert.subject.get_attributes_for_oid( x509.OID_COMMON_NAME)[0].value.strip() - current_app.logger.info(f"CN: {cn}") + current_app.logger.debug(f"CN: {cn}") if cn != "superadmin" and "AEF" not in cn: cert_signature = cert.signature.hex() @@ -83,7 +83,7 @@ def securities_security_id_token_post(security_id, body): # noqa: E501 :rtype: Union[AccessTokenRsp, Tuple[AccessTokenRsp, int], Tuple[AccessTokenRsp, int, Dict[str, str]] """ - current_app.logger.info("Creating security token") + current_app.logger.debug("Creating security token") if request.is_json: res_owner_id = ResOwnerId.from_dict(request.get_json()) # noqa: E501 @@ -113,7 +113,7 @@ def trusted_invokers_api_invoker_id_delete(api_invoker_id): # noqa: E501 :rtype: Union[None, Tuple[None, int], Tuple[None, int, Dict[str, str]] """ - current_app.logger.info("Removing security context") + current_app.logger.debug("Removing security context") return service_security_ops.delete_servicesecurity(api_invoker_id) @@ -133,7 +133,7 @@ def trusted_invokers_api_invoker_id_delete_post(api_invoker_id, body): # noqa: if request.is_json: body = SecurityNotification.from_dict(request.get_json()) # noqa: E501 - current_app.logger.info("Revoking permissions") + current_app.logger.debug("Revoking permissions") res = service_security_ops.revoke_api_authorization(api_invoker_id, body) return res @@ -153,7 +153,7 @@ def trusted_invokers_api_invoker_id_get(api_invoker_id, authentication_info=None :rtype: Union[ServiceSecurity, Tuple[ServiceSecurity, int], Tuple[ServiceSecurity, int, Dict[str, str]] """ - current_app.logger.info("Obtaining security context") + current_app.logger.debug("Obtaining security context") res = service_security_ops.get_servicesecurity( api_invoker_id, authentication_info, authorization_info) @@ -172,7 +172,7 @@ def trusted_invokers_api_invoker_id_put(api_invoker_id, body): # noqa: E501 :rtype: Union[ServiceSecurity, Tuple[ServiceSecurity, int], Tuple[ServiceSecurity, int, Dict[str, str]] """ - current_app.logger.info("Creating security context") + current_app.logger.debug("Creating security context") if request.is_json: body = ServiceSecurity.from_dict(request.get_json()) # noqa: E501 @@ -203,7 +203,7 @@ def trusted_invokers_api_invoker_id_update_post(api_invoker_id, body): # noqa: :rtype: Union[ServiceSecurity, Tuple[ServiceSecurity, int], Tuple[ServiceSecurity, int, Dict[str, str]] """ - current_app.logger.info("Updating security context") + current_app.logger.debug("Updating security context") if request.is_json: body = ServiceSecurity.from_dict(request.get_json()) # noqa: E501 diff --git a/services/TS29222_CAPIF_Security_API/capif_security/core/consumer_messager.py b/services/TS29222_CAPIF_Security_API/capif_security/core/consumer_messager.py index a526bfbb..d1c03f8c 100644 --- a/services/TS29222_CAPIF_Security_API/capif_security/core/consumer_messager.py +++ b/services/TS29222_CAPIF_Security_API/capif_security/core/consumer_messager.py @@ -16,7 +16,7 @@ class Subscriber(): self.p.subscribe("internal-messages", "acls-messages") def listen(self): - current_app.logger.info("Listening security context messages") + current_app.logger.debug("Listening security context messages") for raw_message in self.p.listen(): if raw_message["type"] == "message" and raw_message["channel"].decode('utf-8') == "internal-messages": internal_redis_event = json.loads( diff --git a/services/TS29222_CAPIF_Security_API/capif_security/core/servicesecurity.py b/services/TS29222_CAPIF_Security_API/capif_security/core/servicesecurity.py index 70d665e3..39135678 100644 --- a/services/TS29222_CAPIF_Security_API/capif_security/core/servicesecurity.py +++ b/services/TS29222_CAPIF_Security_API/capif_security/core/servicesecurity.py @@ -49,7 +49,7 @@ class SecurityOperations(Resource): "Checking api invoker with id: " + api_invoker_id) invoker = invokers_col.find_one({"api_invoker_id": api_invoker_id}) if invoker is None: - current_app.logger.error("Invoker not found") + current_app.logger.warning("Invoker not found") return not_found_error(detail="Invoker not found", cause="API Invoker not exists or invalid ID") return None @@ -61,7 +61,7 @@ class SecurityOperations(Resource): current_app.logger.debug("Checking scope") header = scope[0:4] if header != "3gpp": - current_app.logger.error("Bad format scope") + current_app.logger.warning("Bad format scope") token_error = AccessTokenErr(error="invalid_scope", error_description="The first characters must be '3gpp'") return make_response(object=clean_empty(token_error.to_dict()), status=400) @@ -76,7 +76,7 @@ class SecurityOperations(Resource): for group in groups: aef_id, api_names = group.split(":") if aef_id not in aef_security_context: - current_app.logger.error("Bad format Scope, not valid aef id ") + current_app.logger.warning("Bad format Scope, not valid aef id ") token_error = AccessTokenErr(error="invalid_scope", error_description="One of aef_id not belongs of your security context") return make_response(object=clean_empty(token_error.to_dict()), status=400) @@ -85,7 +85,7 @@ class SecurityOperations(Resource): service = capif_service_col.find_one( {"$and": [{"api_name": api_name}, {self.filter_aef_id: aef_id}]}) if service is None: - current_app.logger.error("Bad format Scope, not valid api name") + current_app.logger.warning("Bad format Scope, not valid api name") token_error = AccessTokenErr( error="invalid_scope", error_description="One of the api names does not exist or is not associated with the aef id provided") @@ -163,7 +163,7 @@ class SecurityOperations(Resource): "_id": 0, "api_invoker_id": 0}) if services_security_object is None: - current_app.logger.error("Not found security context") + current_app.logger.warning("Not found security context") return not_found_error(detail=security_context_not_found_detail, cause=api_invoker_no_context_cause) for security_info_obj in services_security_object['security_info']: @@ -223,7 +223,7 @@ class SecurityOperations(Resource): del security_info_obj['authorization_info'] else: - current_app.logger.error("Bad format security method") + current_app.logger.warning("Bad format security method") return bad_request_error(detail="Bad format security method", cause="Bad format security method", invalid_params=[{"param": "securityMethod", "reason": "Bad format security method"}]) @@ -256,7 +256,7 @@ class SecurityOperations(Resource): return result if rfc3987.match(service_security.notification_destination, rule="URI") is None: - current_app.logger.error("Bad url format") + current_app.logger.warning("Bad url format") return bad_request_error(detail="Bad Param", cause="Detected Bad format of param", invalid_params=[{"param": "notificationDestination", "reason": "Not valid URL format"}]) services_security_object = mycol.find_one( @@ -264,7 +264,7 @@ class SecurityOperations(Resource): if services_security_object is not None: - current_app.logger.error( + current_app.logger.warning( "Already security context defined with same api invoker id") return forbidden_error(detail="Security method already defined", cause="Identical AEF Profile IDs") @@ -292,7 +292,7 @@ class SecurityOperations(Resource): current_app.logger.debug("Aef profile: " + str(aef_profiles)) if aef_profiles is None: - current_app.logger.error( + current_app.logger.warning( "Not found service with this interface description: " + json.dumps(clean_empty(service_instance.interface_details.to_dict()))) return not_found_error(detail=f"Service with interfaceDescription {json.dumps(clean_empty(service_instance.interface_details.to_dict()))} not found", cause="Not found Service") @@ -335,7 +335,7 @@ class SecurityOperations(Resource): # After processing all interfaces, use the combined set valid_security_methods.update(interface_methods) else: - current_app.logger.debug("No interfaces found in AEF profile.") + current_app.logger.warning("No interfaces found in AEF profile.") return not_found_error(detail=f"Service with interfaceDescription {json.dumps(clean_empty(service_instance.interface_details.to_dict()))} not found", cause="Not found Service") psk_interface = service_instance.interface_details.to_dict() @@ -354,7 +354,7 @@ class SecurityOperations(Resource): current_app.logger.debug("Aef profile: " + str(services_security_object)) if services_security_object is None: - current_app.logger.error( + current_app.logger.warning( "Not found service with this aef id: " + service_instance.aef_id) return not_found_error(detail="Service with this aefId not found", cause="Not found Service") @@ -406,7 +406,7 @@ class SecurityOperations(Resource): valid_security_methods) & set(pref_security_methods) if len(list(valid_security_method)) == 0: - current_app.logger.error( + current_app.logger.warning( "Not found comptaible security method with pref security method") return bad_request_error(detail="Not found compatible security method with pref security method", cause="Error pref security method", invalid_params=[{"param": "prefSecurityMethods", "reason": "pref security method not compatible with security method available"}]) @@ -429,7 +429,7 @@ class SecurityOperations(Resource): tls_protocol = request.headers.get('X-TLS-Protocol', 'N/A') session_id = request.headers.get('X-TLS-Session-ID', 'N/A') mkey = request.headers.get('X-TLS-MKey', 'N/A') - current_app.logger.info(f"TLS Protocol: {tls_protocol}, Session id: {session_id}, Master Key: {mkey}") + current_app.logger.debug(f"TLS Protocol: {tls_protocol}, Session id: {session_id}, Master Key: {mkey}") if psk_interface: current_app.logger.debug("Deriving PSK") @@ -438,13 +438,13 @@ class SecurityOperations(Resource): service_instance.authorization_info = str(psk) else: - current_app.logger.error("No interface information available to derive PSK") + current_app.logger.warning("No interface information available to derive PSK") # Send service instance to ACL current_app.logger.debug("Sending message to create ACL") publish_ops.publish_message("acls-messages", "create-acl:"+str( api_invoker_id)+":"+str(service_instance.api_id)+":"+str(service_instance.aef_id)) - current_app.logger.debug( + current_app.logger.info( "Inserted security context in database") # We use update with $setOnInsert and $push with $each to add the security info array if the document is created @@ -485,7 +485,7 @@ class SecurityOperations(Resource): services_security_count = mycol.count_documents(my_query) if services_security_count == 0: - current_app.logger.error(security_context_not_found_detail) + current_app.logger.warning(security_context_not_found_detail) return not_found_error(detail=security_context_not_found_detail, cause=api_invoker_no_context_cause) mycol.delete_many(my_query) @@ -493,7 +493,7 @@ class SecurityOperations(Resource): publish_ops.publish_message( "acls-messages", "remove-acl:"+api_invoker_id) - current_app.logger.debug( + current_app.logger.info( "Removed security context from database") out = "The security info of Network App with Network App ID " + \ api_invoker_id + " were deleted.", 204 @@ -536,7 +536,7 @@ class SecurityOperations(Resource): service_security = mycol.find_one({"api_invoker_id": security_id}) if service_security is None: - current_app.logger.error("Not found security context with id: " + security_id) + current_app.logger.warning("Not found security context with id: " + security_id) return not_found_error(detail= security_context_not_found_detail, cause=api_invoker_no_context_cause) result = self.__check_scope( @@ -555,7 +555,7 @@ class SecurityOperations(Resource): access_token_resp = AccessTokenRsp(access_token=access_token, token_type="Bearer", expires_in=int( expire_time.total_seconds()), scope=access_token_req["scope"]) - current_app.logger.debug("Created access token") + current_app.logger.info("Created access token") res = make_response(object=clean_empty(access_token_resp.to_dict()), status=200) return res @@ -579,7 +579,7 @@ class SecurityOperations(Resource): old_object = mycol.find_one({"api_invoker_id": api_invoker_id}) if old_object is None: - current_app.logger.error( + current_app.logger.warning( "Service api not found with id: " + api_invoker_id) return not_found_error(detail="Service API not existing", cause="Not exist securiy information for this invoker") @@ -605,7 +605,7 @@ class SecurityOperations(Resource): current_app.logger.debug("Aef profile: " + str(aef_profile)) if aef_profiles is None: - current_app.logger.error( + current_app.logger.warning( "Not found service with this interface description: " + json.dumps(clean_empty(service_instance.interface_details.to_dict()))) return not_found_error(detail=f"Service with interfaceDescription {json.dumps(clean_empty(service_instance.interface_details.to_dict()))} not found", cause="Not found Service") @@ -632,7 +632,7 @@ class SecurityOperations(Resource): # After processing all interfaces, use the combined set valid_security_methods.update(interface_methods) else: - current_app.logger.debug("No interfaces found in AEF profile.") + current_app.logger.warning("No interfaces found in AEF profile.") return not_found_error(detail=f"Service with interfaceDescription {json.dumps(clean_empty(service_instance.interface_details.to_dict()))} not found", cause="Not found Service") psk_interface = service_instance.interface_details.to_dict() @@ -653,7 +653,7 @@ class SecurityOperations(Resource): current_app.logger.debug("Aef profile: " + str(services_security_object)) if services_security_object is None: - current_app.logger.error( + current_app.logger.warning( "Not found service with this aef id: " + service_instance.aef_id) return not_found_error(detail="Service with this aefId not found", cause="Not found Service") @@ -705,7 +705,7 @@ class SecurityOperations(Resource): valid_security_methods) & set(pref_security_methods) if len(list(valid_security_method)) == 0: - current_app.logger.error( + current_app.logger.warning( "Not found comptaible security method with pref security method") return bad_request_error(detail="Not found compatible security method with pref security method", cause="Error pref security method", invalid_params=[{"param": "prefSecurityMethods", "reason": "pref security method not compatible with security method available"}]) @@ -717,7 +717,7 @@ class SecurityOperations(Resource): tls_protocol = request.headers.get('X-TLS-Protocol', 'N/A') session_id = request.headers.get('X-TLS-Session-ID', 'N/A') mkey = request.headers.get('X-TLS-MKey', 'N/A') - current_app.logger.info(f"TLS Protocol: {tls_protocol}, Session id: {session_id}, Master Key: {mkey}") + current_app.logger.debug(f"TLS Protocol: {tls_protocol}, Session id: {session_id}, Master Key: {mkey}") if psk_interface: current_app.logger.debug("Deriving PSK") @@ -726,14 +726,14 @@ class SecurityOperations(Resource): service_instance.authorization_info = str(psk) else: - current_app.logger.error("No interface information available to derive PSK") + current_app.logger.warning("No interface information available to derive PSK") service_security = service_security.to_dict() service_security = clean_empty(service_security) result = mycol.find_one_and_update(old_object, {"$set": service_security}, projection={ '_id': 0, "api_invoker_id": 0}, return_document=ReturnDocument.AFTER, upsert=False) - current_app.logger.debug( + current_app.logger.info( "Inserted security context in database") # result = clean_empty(result) @@ -743,7 +743,7 @@ class SecurityOperations(Resource): publish_ops.publish_message("acls-messages", "create-acl:"+str( api_invoker_id)+":"+str(update_acl['api_id'])+":"+str(update_acl['aef_id'])) - current_app.logger.debug("Updated security context") + current_app.logger.info("Updated security context") res= make_response(object=dict_to_camel_case(clean_empty(result)), status=200) res.headers['Location'] = f"https://{os.getenv("CAPIF_HOSTNAME")}/capif-security/v1/trustedInvokers/{str(api_invoker_id)}" @@ -769,7 +769,7 @@ class SecurityOperations(Resource): services_security_context = mycol.find_one(my_query) if services_security_context is None: - current_app.logger.error(security_context_not_found_detail) + current_app.logger.warning(security_context_not_found_detail) return not_found_error(detail=security_context_not_found_detail, cause=api_invoker_no_context_cause) updated_security_context = services_security_context.copy() -- GitLab