diff --git a/README.md b/README.md index 608ae1ff7582575c4be7fb81bf1671d2e9d01e9c..f206015e17c79410b771f7f019b7231276d856f7 100644 --- a/README.md +++ b/README.md @@ -147,10 +147,14 @@ A Network App development running as a Provider would typically follow this proc Now, it is described in 4 simple steps how a Provider can be developed in just some code lines, below snippet. It describes the usual flow a Provider would follow to publish an API service. ```python - from sdk import capif_provider_connector - provider = capif_provider_connector(config_file="path/to/the/capif_sdk_config.json") + from sdk import capif_provider_connector,api_schema_translator + + provider = capif_provider_connector(config_file="path/to/capif_sdk_config.json") provider.onboard_provider() - provider.api_description_path = "./nef_upf_vendor_1.json" + + #translator = api_schema_translator("./path/to/openapi.yaml") + #translator.build("api_description_name",ip="0.0.0.0",port=9090) + provider.api_description_path = "./api_description_name.json" APF = provider.provider_capif_ids["APF-1"] @@ -179,6 +183,8 @@ Code is next explained step by step: In the `provider_folder`, more specifically in the `capif_username` folder, it will be sotres the provider API details file. This file contains all the APFs and AEFs IDs that have already onboarded with this `capif_username`. It is also important to have previously prepared the **API schema description** file of the API to be published. **This file must follow the [CAPIF_Publish_Service_API](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Publish_Service_API.yaml) 3GPP specification.** + + If the **API** is defined in an Openapi.yaml format, the sdk has a facility which creates automatically the **API schema description**.For using this functionality uncomment the translator lines. More information:[Translator functionality](./doc/sdk_full_documentation.md#openapi-translation) Choose one APF and the AEF identifiers, and fulfill the `publish_req` structure and the `api_description_path`. diff --git a/doc/sdk_configuration.md b/doc/sdk_configuration.md index f50ee8647d9da4239e4f303687916d140d114da9..d9193cb49086ddfa1b16e9c92f836afa2a23a9b5 100644 --- a/doc/sdk_configuration.md +++ b/doc/sdk_configuration.md @@ -69,6 +69,9 @@ This section is mandatory when using the [CAPIF Publish Service API](https://git The `api_description_path` must point to the Publish API to be shared, and it should follow the [ServiceAPIDescription](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Publish_Service_API.yaml) schema. +To obtain this schema, opencapif_sdk has a facility to translate Openapi structures to ServiceAPIDescription schemas. +More information:[Translator functionality](./sdk_full_documentation.md#openapi-translation) + If the `publisher_aefs_ids` do not match the `aefProfiles` in the API description, an error will be raised by the SDK. ## Descriptions of `capif_sdk_config` Fields diff --git a/doc/sdk_developers.md b/doc/sdk_developers.md index f37e6f47fa14db8ff632d59c66d9f86c13426336..1d5d977dd2431c035b33cd47cf0c099910278c90 100644 --- a/doc/sdk_developers.md +++ b/doc/sdk_developers.md @@ -5,7 +5,7 @@ Before proceeding, ensure you have fulfilled the necessary [requirements](../REA Follow the steps below to install the OpenCAPIF SDK for development purposes: -## Prerequisites +## Requisites - Developers must have the following tools installed: - **pyenv** diff --git a/doc/sdk_full_documentation.md b/doc/sdk_full_documentation.md index 7c201a71cc1b23dc5f75da10991d547664d26c50..84969d26623ad13f8a52eef6149e6197e5474844 100644 --- a/doc/sdk_full_documentation.md +++ b/doc/sdk_full_documentation.md @@ -48,6 +48,7 @@ As outlined in the [Network App developers section](../README.md), the OpenCAPIF - [Check authentication](#check-authentication) - [Update and Offboard Invoker](#update-and-offboard-invoker) - [Other Features](#other-features) + - [Openapi translation](#openapi-translation) - [CAPIF Registration and Login](#capif-registration-and-login) - [CAPIF Deregistration and Logout](#capif-registration-and-login) @@ -86,11 +87,17 @@ OpenCAPIF SDK references: The SDK streamlines API publishing with the option to select specific APFs and AEFs. A copy of the uploaded API is stored in `capif_<api_name>_<api_id>.json`, and the `provider_capif_ids.json` is updated with the API name and its ID. +It is also important to have previously prepared the **API schema description** file of the API to be published. **This file must follow the [CAPIF_Publish_Service_API](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Publish_Service_API.yaml) 3GPP specification.** + +To obtain this schema, opencapif_sdk has a facility to translate Openapi structures to ServiceAPIDescription schemas. +More information:[Translator functionality](#openapi-translation) + **Important**: The SDK will automatically add in the `custom operations`, within the API description path, the capabilities for exposing the [AEF_security](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_AEF_Security_API.yaml) methods. The developer must code this API endpoints. **Required SDK inputs**: - publisher_apf_id - publisher_aefs_ids +- api_description_path ### Service Deletion @@ -230,6 +237,18 @@ Onboarding is required before utilizing these functions. ## Other Features +### Openapi translation + +The `api_description_path` must point to the Publish API to be shared, and it should follow the [ServiceAPIDescription](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Publish_Service_API.yaml) schema. + +This schema could be obtained by applying this code. +```python + from sdk import api_schema_translator + translator = api_schema_translator("./path/to/openapi.yaml") + translator.build("api_description_name",ip="0.0.0.0",port=9090) +``` +This code will read `openapi.yaml`, ensure the structure of it and translate the content into ServiceAPIDescription schema, then will create a .json named `api_description_name`. Also it is necessary to fill the ip and port fields to create correctly the schema. + ### CAPIF Registration and Login OpenCAPIF SDK reference: diff --git a/network_app_samples/network_app_invoker_sample/capif_sdk_config_sample.json b/network_app_samples/network_app_invoker_sample/capif_sdk_config_sample.json index 806d47d5e8cea0b41bced29b31d42d3b688f6dbd..1532d3a800fe890923174dc7d5e45c4bcde24938 100644 --- a/network_app_samples/network_app_invoker_sample/capif_sdk_config_sample.json +++ b/network_app_samples/network_app_invoker_sample/capif_sdk_config_sample.json @@ -1,27 +1,27 @@ { - "capif_host": "capif-prev.mobilesandbox.cloud", - "register_host": "registercapif-prev.mobilesandbox.cloud", - "capif_https_port": "36212", - "capif_register_port": "36211", - "capif_username": "echeva_0", - "capif_password": "echevapass", - "debug_mode": "True", + "capif_host": "", + "register_host": "", + "capif_https_port": "", + "capif_register_port": "", + "capif_username": "", + "capif_password": "", + "debug_mode": "", "invoker":{ - "invoker_folder": "/Users/IDB0128/Documents/OpenCapif/test_invoker_certificate_folder", - "capif_callback_url": "http://localhost:5000", - "supported_features":"fffffff", + "invoker_folder": "", + "capif_callback_url": "", + "supported_features":"", "check_authentication_data":{ "ip":"", "port":"" }, "cert_generation":{ - "csr_common_name": "invoker", - "csr_organizational_unit": "test_app_ou", - "csr_organization": "test_app_o", - "crs_locality": "Madrid", - "csr_state_or_province_name": "Madrid", - "csr_country_name": "ES", - "csr_email_address": "test@example.com" + "csr_common_name": "", + "csr_organizational_unit": "", + "csr_organization": "", + "crs_locality": "", + "csr_state_or_province_name": "", + "csr_country_name": "", + "csr_email_address": "" }, "discover_filter": { "api-name": "", @@ -41,8 +41,8 @@ }, "provider":{ "provider_folder": "", - "apfs": 1, - "aefs": 3, + "apfs": "", + "aefs": "", "publish_req": { "service_api_id": "", "publisher_apf_id": "", diff --git a/network_app_samples/network_app_provider_sample/capif_sdk_config_sample.json b/network_app_samples/network_app_provider_sample/capif_sdk_config_sample.json index 2782ab0baf6cb85aa4e020e4d84b4cd3cba4d9e4..a024f595e40b90230df398b190d0757c1985b953 100644 --- a/network_app_samples/network_app_provider_sample/capif_sdk_config_sample.json +++ b/network_app_samples/network_app_provider_sample/capif_sdk_config_sample.json @@ -1,11 +1,11 @@ { - "capif_host": "capif-prev.mobilesandbox.cloud", - "register_host": "registercapif-prev.mobilesandbox.cloud", - "capif_https_port": "36212", - "capif_register_port": "36211", - "capif_username": "echeva_0", - "capif_password": "echevapass", - "debug_mode": "False", + "capif_host": "", + "register_host": "", + "capif_https_port": "", + "capif_register_port": "", + "capif_username": "", + "capif_password": "", + "debug_mode": "", "invoker":{ "invoker_folder": "", "capif_callback_url": "", @@ -39,15 +39,15 @@ } }, "provider":{ - "provider_folder": "/Users/IDB0128/Documents/OpenCapif/test_provider_certificate_folder", + "provider_folder": "", "cert_generation":{ - "csr_common_name": "provider", - "csr_organizational_unit": "discovery", - "csr_organization": "telefonica", - "crs_locality": "madrid", - "csr_state_or_province_name": "madrid", - "csr_country_name": "ES", - "csr_email_address": "hola@gmail.com" + "csr_common_name": "", + "csr_organizational_unit": "", + "csr_organization": "", + "crs_locality": "", + "csr_state_or_province_name": "", + "csr_country_name": "", + "csr_email_address": "" }, "apfs": "2", "aefs": "3",