Loading services/helper/helper_service/app.py +2 −3 Changes for services/helper/helper_service/app.py: 2 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -3,9 +3,8 @@ import logging import os import requests from config import Config from controllers.helper_controller import helper_routes from pathlib import Path from db.db import MongoDatabse from db.db import get_mongo import connexion import sys from flask import Flask Loading @@ -28,7 +27,7 @@ app = connexion.App(__name__, specification_dir=str(SERVICES_DIR)) config = Config().get_config() # Connect MongoDB and get TTL for superadmin certificate db = MongoDatabse() db = get_mongo() capif_config = db.get_col_by_name("capif_configuration").find_one({}) ttl_superadmin_cert = capif_config["settings"]["certificates_expiry"].get("ttl_superadmin_cert", "43000h") Loading services/helper/helper_service/controllers/helper_controller.py −199 File deleted. Show changes services/helper/helper_service/db/db.py +27 −1 Changes for services/helper/helper_service/db/db.py: 27 added lines, 1 removed line. Original line number Diff line number Diff line import time import secrets from threading import Lock from bson.codec_options import CodecOptions from config import Config Loading @@ -9,7 +10,26 @@ from pymongo.errors import AutoReconnect class MongoDatabse(): def __init__(self): _instance = None _lock = Lock() def __new__(cls): if cls._instance is None: with cls._lock: if cls._instance is None: # double-checked cls._instance = super().__new__(cls) cls._instance._init_once() return cls._instance def close(self): if getattr(self, "_client", None): self._client.close() self._client = None def get_col_by_name(self, name): return self.db[name].with_options(codec_options=CodecOptions(tz_aware=True)) def _init_once(self): self.config = Config().get_config() self.db = self.__connect() self.invoker_col = self.config['mongo']['invoker_col'] Loading Loading @@ -78,3 +98,9 @@ class MongoDatabse(): print("Capif_configuration already contains data with a unique ccf_id. No default values inserted.") _singleton = None def get_mongo(): global _singleton if _singleton is None: _singleton = MongoDatabse() return _singleton No newline at end of file services/helper/helper_service/openapi_helper_api.yaml +14 Changes for services/helper/helper_service/openapi_helper_api.yaml: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -33,6 +33,20 @@ paths: $ref: '#/components/responses/InternalError' default: $ref: '#/components/responses/GenericError' /getCcfId: get: summary: Get CCF ID description: Retrieves the CCF ID of the CAPIF Core Function. operationId: helper_controller.get_ccf_id responses: '200': description: CCF ID retrieved successfully. '400': $ref: '#/components/responses/BadRequest' '500': $ref: '#/components/responses/InternalError' default: $ref: '#/components/responses/GenericError' /getInvokers: get: summary: Retrieve API invokers Loading services/helper/helper_service/openapi_helper_configuration.yaml +95 −39 Changes for services/helper/helper_service/openapi_helper_configuration.yaml: 95 added lines, 39 removed lines. Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ paths: get: summary: Read full configuration description: Returns the entire CAPIF configuration document. operationId: dynamic_config_controller.get_configuration operationId: configuration_controller.get_configuration responses: '200': description: Current configuration Loading Loading @@ -100,20 +100,20 @@ paths: $ref: '#/components/responses/InternalError' default: $ref: '#/components/responses/GenericError' /removeConfigParam: delete: summary: Remove config parameter description: Deletes a leaf parameter by dotted path. operationId: dynamic_config_controller.remove_config_param /addNewConfigSetting: patch: summary: Add new configuration category description: Adds a brand new top-level category. operationId: dynamic_config_controller.add_new_configuration requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ConfigParamRemoveRequest' $ref: '#/components/schemas/ConfigCategoryCreateRequest' responses: '200': description: Parameter removed description: Category added content: application/json: schema: Loading @@ -124,20 +124,21 @@ paths: $ref: '#/components/responses/InternalError' default: $ref: '#/components/responses/GenericError' /configuration/category: post: summary: Add new configuration category description: Adds a brand new top-level category. operationId: dynamic_config_controller.add_new_configuration requestBody: /removeConfigParam: delete: summary: Remove config parameter description: Deletes a leaf parameter by dotted path. operationId: dynamic_config_controller.remove_config_param parameters: - name: param_path in: query required: true content: application/json: schema: $ref: '#/components/schemas/ConfigCategoryCreateRequest' type: string description: Parameter path to remove responses: '200': description: Category added description: Parameter removed content: application/json: schema: Loading @@ -148,16 +149,18 @@ paths: $ref: '#/components/responses/InternalError' default: $ref: '#/components/responses/GenericError' /removeConfigCategory: delete: summary: Remove configuration category description: Deletes an entire top-level category by name. operationId: dynamic_config_controller.remove_config_category requestBody: parameters: - name: config_path in: query required: true content: application/json: schema: $ref: '#/components/schemas/ConfigCategoryRemoveRequest' type: string description: Configuration path to remove responses: '200': description: Category removed Loading Loading @@ -196,7 +199,19 @@ components: type: object additionalProperties: true description: CAPIF runtime configuration document. properties: config_name: type: string example: default description: Configuration name version: type: string example: 1.0 description: configuration version settings: type: object items: $ref: '#/components/schemas/Settings' ConfigParamUpdateRequest: type: object required: Loading @@ -208,14 +223,6 @@ components: description: Dotted path to the configuration value to update. new_value: description: New value for the configuration parameter. ConfigParamRemoveRequest: type: object required: - param_path properties: param_path: type: string description: Dotted path to the configuration value to delete. ConfigCategoryCreateRequest: type: object required: Loading @@ -229,14 +236,6 @@ components: type: object additionalProperties: true description: Key/value pairs that compose the new category. ConfigCategoryRemoveRequest: type: object required: - category_name properties: category_name: type: string description: Name of the category to remove. GenericError: type: object properties: Loading @@ -247,3 +246,60 @@ components: required: - code - message Settings: type: object description: Configuration Settings properties: certificates_expiry: type: object description: Expiry configuration for certificates properties: ttl_superadmin_cert: type: string example: 4300h description: ttl for superadmin certificates ttl_invoker_cert: type: string example: 4300h description: ttl for invoker certificates ttl_provider_cert: type: string example: 4300h description: ttl for provider certificates security_method_priority: type: object description: priority to follow in granting the security method properties: oauth: type: integer example: 1 pki: type: integer example: 2 psk: type: integer example: 3 acl_policy_settings: type: object description: default access policies properties: allowed_total_invocations: type: string example: 5 description: total number of requests the invoker can make allowed_invocations_per_second: type: string example: 5 description: total number of requests the invoker can make per second allowed_invocations_time_range_days: type: integer example: 365 description: time range when an invoker can make requests No newline at end of file Loading
services/helper/helper_service/app.py +2 −3 Changes for services/helper/helper_service/app.py: 2 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -3,9 +3,8 @@ import logging import os import requests from config import Config from controllers.helper_controller import helper_routes from pathlib import Path from db.db import MongoDatabse from db.db import get_mongo import connexion import sys from flask import Flask Loading @@ -28,7 +27,7 @@ app = connexion.App(__name__, specification_dir=str(SERVICES_DIR)) config = Config().get_config() # Connect MongoDB and get TTL for superadmin certificate db = MongoDatabse() db = get_mongo() capif_config = db.get_col_by_name("capif_configuration").find_one({}) ttl_superadmin_cert = capif_config["settings"]["certificates_expiry"].get("ttl_superadmin_cert", "43000h") Loading
services/helper/helper_service/db/db.py +27 −1 Changes for services/helper/helper_service/db/db.py: 27 added lines, 1 removed line. Original line number Diff line number Diff line import time import secrets from threading import Lock from bson.codec_options import CodecOptions from config import Config Loading @@ -9,7 +10,26 @@ from pymongo.errors import AutoReconnect class MongoDatabse(): def __init__(self): _instance = None _lock = Lock() def __new__(cls): if cls._instance is None: with cls._lock: if cls._instance is None: # double-checked cls._instance = super().__new__(cls) cls._instance._init_once() return cls._instance def close(self): if getattr(self, "_client", None): self._client.close() self._client = None def get_col_by_name(self, name): return self.db[name].with_options(codec_options=CodecOptions(tz_aware=True)) def _init_once(self): self.config = Config().get_config() self.db = self.__connect() self.invoker_col = self.config['mongo']['invoker_col'] Loading Loading @@ -78,3 +98,9 @@ class MongoDatabse(): print("Capif_configuration already contains data with a unique ccf_id. No default values inserted.") _singleton = None def get_mongo(): global _singleton if _singleton is None: _singleton = MongoDatabse() return _singleton No newline at end of file
services/helper/helper_service/openapi_helper_api.yaml +14 Changes for services/helper/helper_service/openapi_helper_api.yaml: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -33,6 +33,20 @@ paths: $ref: '#/components/responses/InternalError' default: $ref: '#/components/responses/GenericError' /getCcfId: get: summary: Get CCF ID description: Retrieves the CCF ID of the CAPIF Core Function. operationId: helper_controller.get_ccf_id responses: '200': description: CCF ID retrieved successfully. '400': $ref: '#/components/responses/BadRequest' '500': $ref: '#/components/responses/InternalError' default: $ref: '#/components/responses/GenericError' /getInvokers: get: summary: Retrieve API invokers Loading
services/helper/helper_service/openapi_helper_configuration.yaml +95 −39 Changes for services/helper/helper_service/openapi_helper_configuration.yaml: 95 added lines, 39 removed lines. Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ paths: get: summary: Read full configuration description: Returns the entire CAPIF configuration document. operationId: dynamic_config_controller.get_configuration operationId: configuration_controller.get_configuration responses: '200': description: Current configuration Loading Loading @@ -100,20 +100,20 @@ paths: $ref: '#/components/responses/InternalError' default: $ref: '#/components/responses/GenericError' /removeConfigParam: delete: summary: Remove config parameter description: Deletes a leaf parameter by dotted path. operationId: dynamic_config_controller.remove_config_param /addNewConfigSetting: patch: summary: Add new configuration category description: Adds a brand new top-level category. operationId: dynamic_config_controller.add_new_configuration requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ConfigParamRemoveRequest' $ref: '#/components/schemas/ConfigCategoryCreateRequest' responses: '200': description: Parameter removed description: Category added content: application/json: schema: Loading @@ -124,20 +124,21 @@ paths: $ref: '#/components/responses/InternalError' default: $ref: '#/components/responses/GenericError' /configuration/category: post: summary: Add new configuration category description: Adds a brand new top-level category. operationId: dynamic_config_controller.add_new_configuration requestBody: /removeConfigParam: delete: summary: Remove config parameter description: Deletes a leaf parameter by dotted path. operationId: dynamic_config_controller.remove_config_param parameters: - name: param_path in: query required: true content: application/json: schema: $ref: '#/components/schemas/ConfigCategoryCreateRequest' type: string description: Parameter path to remove responses: '200': description: Category added description: Parameter removed content: application/json: schema: Loading @@ -148,16 +149,18 @@ paths: $ref: '#/components/responses/InternalError' default: $ref: '#/components/responses/GenericError' /removeConfigCategory: delete: summary: Remove configuration category description: Deletes an entire top-level category by name. operationId: dynamic_config_controller.remove_config_category requestBody: parameters: - name: config_path in: query required: true content: application/json: schema: $ref: '#/components/schemas/ConfigCategoryRemoveRequest' type: string description: Configuration path to remove responses: '200': description: Category removed Loading Loading @@ -196,7 +199,19 @@ components: type: object additionalProperties: true description: CAPIF runtime configuration document. properties: config_name: type: string example: default description: Configuration name version: type: string example: 1.0 description: configuration version settings: type: object items: $ref: '#/components/schemas/Settings' ConfigParamUpdateRequest: type: object required: Loading @@ -208,14 +223,6 @@ components: description: Dotted path to the configuration value to update. new_value: description: New value for the configuration parameter. ConfigParamRemoveRequest: type: object required: - param_path properties: param_path: type: string description: Dotted path to the configuration value to delete. ConfigCategoryCreateRequest: type: object required: Loading @@ -229,14 +236,6 @@ components: type: object additionalProperties: true description: Key/value pairs that compose the new category. ConfigCategoryRemoveRequest: type: object required: - category_name properties: category_name: type: string description: Name of the category to remove. GenericError: type: object properties: Loading @@ -247,3 +246,60 @@ components: required: - code - message Settings: type: object description: Configuration Settings properties: certificates_expiry: type: object description: Expiry configuration for certificates properties: ttl_superadmin_cert: type: string example: 4300h description: ttl for superadmin certificates ttl_invoker_cert: type: string example: 4300h description: ttl for invoker certificates ttl_provider_cert: type: string example: 4300h description: ttl for provider certificates security_method_priority: type: object description: priority to follow in granting the security method properties: oauth: type: integer example: 1 pki: type: integer example: 2 psk: type: integer example: 3 acl_policy_settings: type: object description: default access policies properties: allowed_total_invocations: type: string example: 5 description: total number of requests the invoker can make allowed_invocations_per_second: type: string example: 5 description: total number of requests the invoker can make per second allowed_invocations_time_range_days: type: integer example: 365 description: time range when an invoker can make requests No newline at end of file