diff --git a/README.md b/README.md index 744840a43da5c3b88eafb7437ba94695bca1d2fa..9feb29dce0c537aa6418641c75d0313033757860 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,11 @@ OpenCAPIF SDK brings a set of functions to integrate with the 5G Core's function | **3GPP CAPIF API** | **OpenCAPIF SDK function** | **Description** | |-------------------------------------------------------|-------------------------------------------------------------|-------------------------------------------------------------| -| /onboardedInvokers (POST) | [onboard_invoker()](./doc/sdk_full_documentation.md#invoker-onboarding) | Registers a new invoker. | -| /onboardedInvokers/{onboardingId} (PUT) | [update_invoker()](./doc/sdk_full_documentation.md#update-and-offboard-invoker) | Updates an existing invoker for a specific `onboardingId`. | +| /onboardedInvokers (POST) | [onboard_invoker(supp_features)](./doc/sdk_full_documentation.md#invoker-onboarding) | Registers a new invoker. | +| /onboardedInvokers/{onboardingId} (PUT) | [update_invoker(supp_features)](./doc/sdk_full_documentation.md#update-and-offboard-invoker) | Updates an existing invoker for a specific `onboardingId`. | | /onboardedInvokers/{onboardingId} (DELETE) | [offboard_invoker()](./doc/sdk_full_documentation.md#update-and-offboard-invoker) | Deletes an invoker for a specific `onboardingId`. | -| registrations (POST) | [onboard_provider()](./doc/sdk_full_documentation.md#provider-onboarding) | Registers a new service provider. | -| /registrations/{registrationId} (PUT) | [update_provider()](./doc/sdk_full_documentation.md#update-and-offboard-provider) | Updates a service provider's registration for a specific `registrationId`. | +| registrations (POST) | [onboard_provider(supp_features)](./doc/sdk_full_documentation.md#provider-onboarding) | Registers a new service provider. | +| /registrations/{registrationId} (PUT) | [update_provider(supp_features)](./doc/sdk_full_documentation.md#update-and-offboard-provider) | Updates a service provider's registration for a specific `registrationId`. | | /registrations/{registrationId} (DELETE) | [offboard_provider()](./doc/sdk_full_documentation.md#update-and-offboard-provider) | Deletes a service provider's registration for a specific `registrationId`. | | /allServiceAPIs (GET) | [discover()](./doc/sdk_full_documentation.md#discover-process) | Retrieves a list of all available service APIs. | | /trustedInvokers (PUT//POST) | [get_tokens(supp_features)](./doc/sdk_full_documentation.md#discover-process) | Registers or updates trusted invokers. | diff --git a/doc/sdk_full_documentation.md b/doc/sdk_full_documentation.md index 7b5a4e003b936219ae58e5b8b181ecb8ac74e99c..899db881fe1010e6d2e066294dc598f9e5be8bc8 100644 --- a/doc/sdk_full_documentation.md +++ b/doc/sdk_full_documentation.md @@ -71,10 +71,12 @@ The provider_capif_ids variable stores the `provider_service_ids.json` content i ### Provider Onboarding OpenCAPIF SDK references: -- **Function**: `onboard_provider()` +- **Function**: `onboard_provider(supp_features)` - **Script**: `provider_capif_connector.py` The SDK simplifies the onboarding process, allowing providers to register multiple APFs and AEFs. All APFs, AEFs, and AMF certificates are created and stored in `provider_service_ids.json`. +`supp_features` parameter is optional and it stands for communicating to the CCF the supported features.It's default value its 0. +  @@ -152,12 +154,14 @@ Retrieve information about all previously published services in `service_receive ### Update and Offboard Provider OpenCAPIF SDK references: -- **Functions**: `update_provider()` and `offboard_provider()` +- **Functions**: `update_provider(supp_features)` and `offboard_provider()` - **Scripts**: `provider_capif_connector_update.py` and `provider_capif_connector_offboarding.py` -`update_provider()`: The provider updates his features such as `APFs`, `AEFs`, etc... +`update_provider(supp_features)`: The provider updates his features such as `APFs`, `AEFs`, etc... `offboard_provider()`: The provider offboards from CAPIF, this will cause the erase of the published APIs that were currently exposed. +`supp_features` parameter is optional and it stands for communicating to the CCF the supported features.It's default value its 0. + The provider must be onboarded before using these features.  @@ -278,11 +282,14 @@ The invoker_capif_details variable stores the `capif_api_security_context_detail ### Invoker onboarding OpenCAPIF SDK references: -- **Function**: `onboard_invoker()` +- **Function**: `onboard_invoker(supp_features)` - **Script**: `invoker_capif_connector.py` The SDK streamlines the invoker onboarding process, storing the `api_invoker_id` in the `capif_api_security_context_details.json`. +`supp_features` parameter is optional and it stands for communicating to the CCF the supported features.It's default value its 0. + +  ### Service Discovery @@ -327,11 +334,14 @@ It is mandatory to have obtained the [JWT token](#obtain-jwt-tokens) previously. ### Update and Offboard Invoker OpenCAPIF SDK references: -- **Functions**: `update_invoker()` and `offboard_invoker()` +- **Functions**: `update_invoker(supp_features)` and `offboard_invoker()` - **Scripts**: `invoker_capif_connector_update.py` and `invoker_capif_connector_offboarding.py` Onboarding is required before utilizing these functions. +`supp_features` parameter is optional and it stands for communicating to the CCF the supported features.It's default value its 0. + +  ## Other Features diff --git a/opencapif_sdk/capif_event_feature.py b/opencapif_sdk/capif_event_feature.py index ba286328b29075548b448f4275142c1446113787..e8fecebca7902c122dafddbb4607329789afbd43 100644 --- a/opencapif_sdk/capif_event_feature.py +++ b/opencapif_sdk/capif_event_feature.py @@ -30,7 +30,7 @@ logging.basicConfig( class capif_invoker_event_feature(capif_invoker_connector): - def create_subscription(self, name, supp_features=0): + def create_subscription(self, name, supp_features="0"): invoker_capif_details = self.invoker_capif_details @@ -150,7 +150,7 @@ class capif_invoker_event_feature(capif_invoker_connector): self.logger.error("Subscription file not found at path: %s", path) return None, {"error": "Subscription file not found"} - def update_subcription(self, name, supp_features=0): + def update_subcription(self, name, supp_features="0"): invoker_capif_details = self.invoker_capif_details subscriberId = invoker_capif_details["api_invoker_id"] @@ -209,7 +209,7 @@ class capif_invoker_event_feature(capif_invoker_connector): class capif_provider_event_feature(capif_provider_connector): - def create_subscription(self, name, id, supp_features=0): + def create_subscription(self, name, id, supp_features="0"): subscriberId = id @@ -345,7 +345,7 @@ class capif_provider_event_feature(capif_provider_connector): self.logger.error("Subscription file not found at path: %s", path) return None, {"error": "Subscription file not found"} - def update_subcription(self, name, id, supp_features=0): + def update_subcription(self, name, id, supp_features="0"): subscriberId = id @@ -420,5 +420,5 @@ class capif_provider_event_feature(capif_provider_connector): self.logger.error("Subscription file not found at path: %s", path) return None, {"error": "Subscription file not found"} - def patch_subcription(self, name, id, supp_features=0): + def patch_subcription(self, name, id, supp_features="0"): self.update_subcription(self, name, id, supp_features) diff --git a/opencapif_sdk/capif_invoker_connector.py b/opencapif_sdk/capif_invoker_connector.py index 7a3753c0f5ca4daf2c8433cbe1a105aa8fd662f6..e973a697d75628dd0f0b576b95b926d39caeb8c7 100644 --- a/opencapif_sdk/capif_invoker_connector.py +++ b/opencapif_sdk/capif_invoker_connector.py @@ -175,7 +175,7 @@ class capif_invoker_connector: url = url + "/" return url - def onboard_invoker(self) -> None: + def onboard_invoker(self, supp_features="0") -> None: self.logger.info("Registering and onboarding Invoker") try: public_key = self.__create_private_and_public_keys() @@ -184,7 +184,7 @@ class capif_invoker_connector: capif_discover_url = capif_postauth_info["ccf_discover_url"] capif_access_token = capif_postauth_info["access_token"] api_invoker_id = self.__onboard_invoker_and_create_certificate( - public_key, capif_onboarding_url, capif_access_token + public_key, capif_onboarding_url, capif_access_token, supp_features ) self.__write_to_file(api_invoker_id, capif_discover_url) self.logger.info("Invoker registered and onboarded successfully") @@ -322,7 +322,7 @@ class capif_invoker_connector: raise def __onboard_invoker_and_create_certificate( - self, public_key, capif_onboarding_url, capif_access_token + self, public_key, capif_onboarding_url, capif_access_token, supp_features ): self.logger.info( "Onboarding Invoker to CAPIF and creating signed certificate by giving our public key to CAPIF") @@ -330,7 +330,7 @@ class capif_invoker_connector: url = self.capif_https_url + capif_onboarding_url payload_dict = { "notificationDestination": self.capif_callback_url, - "supportedFeatures": f"{self.supported_features}", + "supportedFeatures": supp_features, "apiInvokerInformation": self.csr_common_name, "websockNotifConfig": { "requestWebsocketUri": True, @@ -396,7 +396,7 @@ class capif_invoker_connector: self.logger.error(f"Error during writing to file: {e}") raise - def update_invoker(self): + def update_invoker(self,supp_features="0"): self.logger.info("Updating Invoker") try: @@ -408,7 +408,7 @@ class capif_invoker_connector: public_key = file.read() self.__update_invoker_to_capif_and_create_the_signed_certificate( - public_key, capif_onboarding_url, capif_access_token + public_key, capif_onboarding_url, capif_access_token, supp_features ) self.logger.info("Invoker updated successfully") @@ -417,7 +417,7 @@ class capif_invoker_connector: raise def __update_invoker_to_capif_and_create_the_signed_certificate( - self, public_key, capif_onboarding_url, capif_access_token + self, public_key, capif_onboarding_url, capif_access_token, supp_features ): self.logger.info( "Updating Invoker to CAPIF and creating signed certificate by giving our public key to CAPIF") @@ -433,7 +433,7 @@ class capif_invoker_connector: url = self.capif_https_url + capif_onboarding_url + "/" + invokerid payload_dict = { "notificationDestination": self.capif_callback_url, - "supportedFeatures": f"{self.supported_features}", + "supportedFeatures": supp_features, "apiInvokerInformation": self.csr_common_name, "websockNotifConfig": { "requestWebsocketUri": True, diff --git a/opencapif_sdk/capif_logging_feature.py b/opencapif_sdk/capif_logging_feature.py index cbd25deeb8e4de1f73b40e087dc7bc48ce990848..ad436e62d71f50261336a5f11444d6b448475694 100644 --- a/opencapif_sdk/capif_logging_feature.py +++ b/opencapif_sdk/capif_logging_feature.py @@ -195,7 +195,7 @@ class capif_logging_feature: if not self.api_id: raise ValueError(f"No ID was found for the API '{name}'.") - def create_logs(self, aefId, jwt, supp_features=0): + def create_logs(self, aefId, jwt, supp_features="0"): api_invoker_id = self._decrypt_jwt(jwt) diff --git a/opencapif_sdk/capif_provider_connector.py b/opencapif_sdk/capif_provider_connector.py index ce5cc83acb132676c69c504faf464380c4ed0585..a493ed331e35e867add1884ace722df4eb288ea5 100644 --- a/opencapif_sdk/capif_provider_connector.py +++ b/opencapif_sdk/capif_provider_connector.py @@ -251,7 +251,7 @@ class capif_provider_connector: return public_key - def __onboard_exposer_to_capif(self, access_token, capif_onboarding_url): + def __onboard_exposer_to_capif(self, access_token, capif_onboarding_url, supp_features): self.logger.info( "Onboarding Provider to CAPIF and waiting signed certificate by giving our public keys to CAPIF") @@ -277,7 +277,7 @@ class capif_provider_connector: for role in roles ], "apiProvDomInfo": "This is provider", - "suppFeat": self.supported_features, + "suppFeat": supp_features, "failReason": "string", "regSec": access_token, } @@ -380,7 +380,7 @@ class capif_provider_connector: f"Error acquiring authorization: {e} - Response: {response.text}") raise - def onboard_provider(self) -> None: + def onboard_provider(self, supp_features="0") -> None: """ Retrieves and stores the certificate from CAPIF, acquires authorization, and registers the provider. """ @@ -397,7 +397,7 @@ class capif_provider_connector: # Onboard provider to CAPIF onboarding_response = self.__onboard_exposer_to_capif( - access_token, capif_onboarding_url + access_token, capif_onboarding_url, supp_features ) # Save onboarding details to file @@ -1137,7 +1137,7 @@ class capif_provider_connector: f"Unexpected error while loading NEF API details: {e}") raise - def update_provider(self): + def update_provider(self, supp_features="0"): self.certs_modifications() capif_postauth_info = self.__save_capif_ca_root_file_and_get_auth_token() @@ -1145,7 +1145,7 @@ class capif_provider_connector: access_token = capif_postauth_info["access_token"] ccf_publish_url = capif_postauth_info["ccf_publish_url"] onboarding_response = self.update_onboard( - capif_onboarding_url, access_token) + capif_onboarding_url, access_token, supp_features) capif_registration_id = onboarding_response["apiProvDomId"] self.__write_to_file( @@ -1171,7 +1171,7 @@ class capif_provider_connector: self.logger.info("Certificate removal process completed.") - def update_onboard(self, capif_onboarding_url, access_token): + def update_onboard(self, capif_onboarding_url, access_token, supp_features): self.logger.info( "Onboarding Provider to CAPIF and waiting signed certificate by giving our public keys to CAPIF") api_details = self._load_provider_api_details() @@ -1199,7 +1199,7 @@ class capif_provider_connector: for role in roles ], "apiProvDomInfo": "This is provider", - "suppFeat": self.supported_features, + "suppFeat": supp_features, "failReason": "string", "regSec": access_token, } diff --git a/opencapif_sdk/service_discoverer.py b/opencapif_sdk/service_discoverer.py index 18657936b2802989721283b6d096f7100eae3cb7..a000142ef903aad064396fd3558dcc36ce2da471 100644 --- a/opencapif_sdk/service_discoverer.py +++ b/opencapif_sdk/service_discoverer.py @@ -445,7 +445,7 @@ class service_discoverer: self.invoker_capif_details["access_token"] = token self.__cache_security_context() - def get_tokens(self, supp_features=0): + def get_tokens(self, supp_features="0"): self.get_security_context(supp_features) token = self.get_access_token() diff --git a/test/test1.json b/test/test1.json index c0231a163e5eceb333c1f166060d79e11b50467d..1d4d717258aac58c0f2a21aa68f6974dd0f2edb4 100644 --- a/test/test1.json +++ b/test/test1.json @@ -2,7 +2,7 @@ "apiName": "test1", "aefProfiles": [ { - "aefId": "AEFa6953ae0f359180257403c58e55a72", + "aefId": "AEF74c34d6307c5c6bd0f82a5ee5d272c", "versions": [ { "apiVersion": "v1",