Loading services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/invocationlogs.py +9 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,9 @@ from ..util import dict_to_camel_case, clean_empty from .resources import Resource from .responses import bad_request_error, internal_server_error, forbidden_error, not_found_error, unauthorized_error, make_response from ..models.invocation_log import InvocationLog from .publisher import Publisher publisher_ops = Publisher() class LoggingInvocationOperations(Resource): Loading Loading @@ -85,6 +88,12 @@ class LoggingInvocationOperations(Resource): if result is not None: return result if log.result: if int(log.result) >= 200 and int(log.result) < 300: publisher_ops.publish_message("events", "SERVICE_API_INVOCATION_SUCCESS") else: publisher_ops.publish_message("events", "SERVICE_API_INVOCATION_FAILURE") current_app.logger.debug("Check existing logs") my_query = {'aef_id': aef_id, 'api_invoker_id': invocationlog.api_invoker_id} existing_invocationlog = mycol.find_one(my_query) Loading services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/publisher.py 0 → 100644 +11 −0 Original line number Diff line number Diff line import redis import sys from flask import current_app class Publisher(): def __init__(self): self. r = redis.Redis(host='redis', port=6379, db=0) def publish_message(self, channel, message): self.r.publish(channel, message) services/TS29222_CAPIF_Logging_API_Invocation_API/requirements.txt +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ Flask == 2.0.3 pymongo == 4.0.1 elasticsearch == 8.4.3 flask_jwt_extended == 4.4.4 redis == 4.5.4 opentelemetry-instrumentation == 0.38b0 opentelemetry-instrumentation-flask == 0.38b0 opentelemetry-instrumentation-redis == 0.38b0 Loading tests/libraries/api_logging_service/bodyRequests.py +3 −3 Original line number Diff line number Diff line def create_log_entry(aefId=None, apiInvokerId=None, apiId=None, apiName=None): def create_log_entry(aefId, apiInvokerId, apiId, apiName, result='200'): data = { "aefId": aefId, "apiInvokerId": apiInvokerId, Loading @@ -11,7 +11,7 @@ def create_log_entry(aefId=None, apiInvokerId=None, apiId=None, apiName=None): "uri": "http://resource/endpoint", "protocol": "HTTP_1_1", "operation": "GET", "result": "string", "result": result, "invocationTime": "2023-03-30T10:30:21.408Z", "invocationLatency": 0, "inputParameters": "string", Loading Loading @@ -78,7 +78,7 @@ def create_log_entry(aefId=None, apiInvokerId=None, apiId=None, apiName=None): } return data def create_log_entry_bad_service(aefId=None, apiInvokerId=None): def create_log_entry_bad_service(aefId, apiInvokerId): data = { "aefId": aefId, "apiInvokerId": apiInvokerId, Loading Loading
services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/invocationlogs.py +9 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,9 @@ from ..util import dict_to_camel_case, clean_empty from .resources import Resource from .responses import bad_request_error, internal_server_error, forbidden_error, not_found_error, unauthorized_error, make_response from ..models.invocation_log import InvocationLog from .publisher import Publisher publisher_ops = Publisher() class LoggingInvocationOperations(Resource): Loading Loading @@ -85,6 +88,12 @@ class LoggingInvocationOperations(Resource): if result is not None: return result if log.result: if int(log.result) >= 200 and int(log.result) < 300: publisher_ops.publish_message("events", "SERVICE_API_INVOCATION_SUCCESS") else: publisher_ops.publish_message("events", "SERVICE_API_INVOCATION_FAILURE") current_app.logger.debug("Check existing logs") my_query = {'aef_id': aef_id, 'api_invoker_id': invocationlog.api_invoker_id} existing_invocationlog = mycol.find_one(my_query) Loading
services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/publisher.py 0 → 100644 +11 −0 Original line number Diff line number Diff line import redis import sys from flask import current_app class Publisher(): def __init__(self): self. r = redis.Redis(host='redis', port=6379, db=0) def publish_message(self, channel, message): self.r.publish(channel, message)
services/TS29222_CAPIF_Logging_API_Invocation_API/requirements.txt +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ Flask == 2.0.3 pymongo == 4.0.1 elasticsearch == 8.4.3 flask_jwt_extended == 4.4.4 redis == 4.5.4 opentelemetry-instrumentation == 0.38b0 opentelemetry-instrumentation-flask == 0.38b0 opentelemetry-instrumentation-redis == 0.38b0 Loading
tests/libraries/api_logging_service/bodyRequests.py +3 −3 Original line number Diff line number Diff line def create_log_entry(aefId=None, apiInvokerId=None, apiId=None, apiName=None): def create_log_entry(aefId, apiInvokerId, apiId, apiName, result='200'): data = { "aefId": aefId, "apiInvokerId": apiInvokerId, Loading @@ -11,7 +11,7 @@ def create_log_entry(aefId=None, apiInvokerId=None, apiId=None, apiName=None): "uri": "http://resource/endpoint", "protocol": "HTTP_1_1", "operation": "GET", "result": "string", "result": result, "invocationTime": "2023-03-30T10:30:21.408Z", "invocationLatency": 0, "inputParameters": "string", Loading Loading @@ -78,7 +78,7 @@ def create_log_entry(aefId=None, apiInvokerId=None, apiId=None, apiName=None): } return data def create_log_entry_bad_service(aefId=None, apiInvokerId=None): def create_log_entry_bad_service(aefId, apiInvokerId): data = { "aefId": aefId, "apiInvokerId": apiInvokerId, Loading