diff --git a/README.md b/README.md index cda2d468c6ba86c06e184596940ac26e6701511a..dc9b11163b75a52363b85b6cc4681deedcf55514 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Network Apps can be developed by third-party service providers, network operator Next image illustrates how CAPIF works and where the SDK provides means to integrate with it: - + For that purpose Network Apps play 2 different roles when interacting with CAPIF: - **Invoker**: a Network App acting as an Invoker is responsible for consuming APIs exposed by other services. This role represents an external application or service that calls the 3GPP northbound APIs to utilize the network’s functionalities. @@ -97,6 +97,10 @@ OpenCAPIF SDK brings a set of functions to integrate with the 5G Core's function | /{apfId}/service-apis (GET) | [get_all_services()](./doc/sdk_full_documentation.md#get-all-services) | Retrieves a list of all available service APIs for a specific `apfId` | | /aef-security/v1/check-authentication (POST) | [check_authentication()](./doc/sdk_full_documentation.md#check_authentication) | This custom operation allows the API invoker to confirm the `supported_features` from the API exposing function(AEF) | | /api-invocation-logs/v1/{aefId}/logs (POST) | [create_logs( aefId, api_invoker_id)](./doc/sdk_full_documentation.md#create_logs) | This operation allows to the Provider to notice to the CCF about the query of an invoker for an especific `aefId` +| /capif-events/v1/{subscriberId}/subscriptions (POST) | [create_subscription(name, id)](./doc/sdk_full_documentation.md#create_subscription) | This operation allows to the Invoker/AEF/APF/AMF to ask to the CCF about notifications related to certain functionalities. +| /capif-events/v1/{subscriberId}/subscriptions/{subscriptionId} (DELETE) | [delete_subscription(name, id)](./doc/sdk_full_documentation.md#delete_subscription) | This operation allows to the Invoker/AEF/APF/AMF to withdraw the petition to receive notifications related to certain functionalities. +| /capif-events/v1/{subscriberId}/subscriptions/{subscriptionId} (PUT) | [update_subscription(name, id)](./doc/sdk_full_documentation.md#update_subscription) | This operation allows to the Invoker/AEF/APF/AMF to modify to the petition to receive notifications related to certain functionalities. **ONLY AVAILABLE IN OPENCAPIF RELEASE 2** +| /capif-events/v1/{subscriberId}/subscriptions/{subscriptionId} (PATCH) | [patch_subscription(name, id)](./doc/sdk_full_documentation.md#patch_subscription) | This operation allows to the Invoker/AEF/APF/AMF to modify to the petition to receive notifications related to certain functionalities. **ONLY AVAILABLE IN OPENCAPIF RELEASE 2** NOTE: Above mentioned CAPIF APIs are defined in these 3GPP references: - [CAPIF Invoker API specification](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_API_Invoker_Management_API.yaml) @@ -106,7 +110,7 @@ NOTE: Above mentioned CAPIF APIs are defined in these 3GPP references: - [CAPIF Security API specification](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Security_API.yaml) - [AEF Security API specification](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_AEF_Security_API.yaml) - [CAPIF Logging API management](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Logging_API_Invocation_API.yaml) - +- [CAPIF Events API management](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Events_API.yaml) NOTE: In the [3GPP Technical Specification (TS) 29.222 V18.5.0 Common API Framework for 3GPP Northbound APIs](https://www.etsi.org/deliver/etsi_ts/129200_129299/129222/18.05.00_60/ts_129222v180500p.pdf) the `service` concept is understood as equal as the `API` concept. @@ -132,7 +136,7 @@ Here is a visual look on the variables of the CAPIF sdk referenced in: - [Important information for Invoker Consumer](#important-information-for-invoker-consumer) - [Important information for Provider Consumer](#important-information-for-provider-consumers) - + # Network App developer path @@ -144,7 +148,7 @@ Here is a good explanation about how a usual flow of a Network App should work: A Network App development running as a Provider would typically follow this process step by step, making use of the SDK: - + 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. @@ -228,7 +232,7 @@ The `provider_capif_ids` variable stores the `provider_capif_ids.json` content i A Network App development running as an Invoker would typically follow this process step by step, making use of the SDK: - + Now, it is described in some simple steps how an Invoker can be developed in just some code lines. Find below the code snippet. It describes the usual flow an Invoker would follow to consume APIs from CAPIF. @@ -317,7 +321,6 @@ There are some features which **are not currently available at latest OpenCAPIF - [CAPIF Access control policy management](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Access_Control_Policy_API.yaml) - [CAPIF Auditing API management](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Auditing_API.yaml) - - [CAPIF Events API management](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Events_API.yaml) - [CAPIF Routing info API management](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Routing_Info_API.yaml) - [CAPIF Security API management](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Security_API.yaml) - /trustedInvokers/{apiInvokerId}/delete (POST) diff --git a/config/capif_sdk_config.json b/config/capif_sdk_config.json index b728c1a8b360330def7a4e3598057da90a63eec7..4fc7f767c9a4149816d43377d56363328d9c148b 100644 --- a/config/capif_sdk_config.json +++ b/config/capif_sdk_config.json @@ -9,10 +9,10 @@ "invoker": { "invoker_folder": "", "capif_callback_url": "", - "supported_features":"", - "check_authentication_data":{ - "ip":"", - "port":"" + "supported_features": "", + "check_authentication_data": { + "ip": "", + "port": "" }, "cert_generation": { "csr_common_name": "", @@ -38,43 +38,20 @@ "ue-ip-addr": "", "service-kpis": "" }, - "events":{ - "events": ["SERVICE_API_AVAILABLE"], + "events": { + "description": [""], "eventFilters": [ { - "apiIds": [ - "string" - ], - "apiInvokerIds": [ - "string" - ], - "aefIds": [ - "string" - ] + "apiIds": [""], + "apiInvokerIds": [""], + "aefIds": [""] } - ], - "eventReq":"string", - "requestTestNotification": true, - "websockNotifConfig": { - "websocketUri":"", - "requestWebsocketUri": true - } + ] } - }, "provider": { "provider_folder": "", "supported_features": "", - "apfs": "", - "aefs": "", - "publish_req": { - "service_api_id": "", - "publisher_apf_id": "", - "publisher_aefs_ids": [ - "", - "" - ] - }, "cert_generation": { "csr_common_name": "", "csr_organizational_unit": "", @@ -84,8 +61,30 @@ "csr_country_name": "", "csr_email_address": "" }, + "apfs": "", + "aefs": "", + "publish_req": { + "service_api_id": "", + "publisher_apf_id": "", + "publisher_aefs_ids": ["", ""] + }, "api_description_path": "", - "log":{ + "events": { + "description": [""], + "eventFilters": [ + { + "apiIds": [""], + "apiInvokerIds": [""], + "aefIds": [""] + } + ], + "notificationDestination": "", + "websockNotifConfig": { + "websocketUri": "", + "requestWebsocketUri": false + } + }, + "log": { "apiName": "", "apiVersion": "", "resourceName": "", @@ -94,5 +93,5 @@ "operation": "", "result": "" } - } + } } diff --git a/doc/images/capif_provider_details_example.png b/doc/images/capif_provider_details_example.png deleted file mode 100644 index a22b797c2bd2328a0b0e63bdedad98e6b46e94ff..0000000000000000000000000000000000000000 Binary files a/doc/images/capif_provider_details_example.png and /dev/null differ diff --git a/doc/images/flows_capif_illustration.jpg b/doc/images/flows-capif_illustration.jpg similarity index 100% rename from doc/images/flows_capif_illustration.jpg rename to doc/images/flows-capif_illustration.jpg diff --git a/doc/images/flows_data_schema.png b/doc/images/flows-data_schema.png similarity index 100% rename from doc/images/flows_data_schema.png rename to doc/images/flows-data_schema.png diff --git a/doc/images/flows-event_subscription.jpg b/doc/images/flows-event_subscription.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e2315231bc3d0385c78146ba118d26e4d38426fd Binary files /dev/null and b/doc/images/flows-event_subscription.jpg differ diff --git a/doc/images/flows-invoker_check_authentication.jpg b/doc/images/flows-invoker_check_authentication.jpg new file mode 100644 index 0000000000000000000000000000000000000000..589a305a3c7a3909b32b1be60cc105000d0dc3d5 Binary files /dev/null and b/doc/images/flows-invoker_check_authentication.jpg differ diff --git a/doc/images/flows-invoker_discover.jpg b/doc/images/flows-invoker_discover.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e51f04600fe2bd25686fb627c5084873b8c81fed Binary files /dev/null and b/doc/images/flows-invoker_discover.jpg differ diff --git a/doc/images/flows-invoker_get_tokens.jpg b/doc/images/flows-invoker_get_tokens.jpg new file mode 100644 index 0000000000000000000000000000000000000000..103966840ac019aed2cda9a4535a6b225e9bba37 Binary files /dev/null and b/doc/images/flows-invoker_get_tokens.jpg differ diff --git a/doc/images/flows-invoker_onboard.jpg b/doc/images/flows-invoker_onboard.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a80a5ebdda7b539ddbbfedb5718feb064324bc74 Binary files /dev/null and b/doc/images/flows-invoker_onboard.jpg differ diff --git a/doc/images/flows-invoker_path.jpg b/doc/images/flows-invoker_path.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6879f18f3ee43da6d9537d326e7885a2560e15c9 Binary files /dev/null and b/doc/images/flows-invoker_path.jpg differ diff --git a/doc/images/flows-invoker_update_offboard.jpg b/doc/images/flows-invoker_update_offboard.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b1aef970f23cb65f82f24940dcaa16d2aa8533a2 Binary files /dev/null and b/doc/images/flows-invoker_update_offboard.jpg differ diff --git a/doc/images/flows-provider_logs.jpg b/doc/images/flows-provider_logs.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f200d091af66958a0c5c6924cf4e28c64227c310 Binary files /dev/null and b/doc/images/flows-provider_logs.jpg differ diff --git a/doc/images/flows-provider_onboard.jpg b/doc/images/flows-provider_onboard.jpg new file mode 100644 index 0000000000000000000000000000000000000000..85c4662ba81fbbcaadbe5a66080a906a5d24819c Binary files /dev/null and b/doc/images/flows-provider_onboard.jpg differ diff --git a/doc/images/flows-provider_path.jpg b/doc/images/flows-provider_path.jpg new file mode 100644 index 0000000000000000000000000000000000000000..253b828ff2954e1bcee57e54c3e45571132554de Binary files /dev/null and b/doc/images/flows-provider_path.jpg differ diff --git a/doc/images/flows-provider_publish_functions.jpg b/doc/images/flows-provider_publish_functions.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8104ee61855cd0a911cf47bff4af2c7b7e321b3a Binary files /dev/null and b/doc/images/flows-provider_publish_functions.jpg differ diff --git a/doc/images/flows-provider_update_offboard.jpg b/doc/images/flows-provider_update_offboard.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4c8c4a3f9b16d5795e17f4cb29aaf0c367c18de3 Binary files /dev/null and b/doc/images/flows-provider_update_offboard.jpg differ diff --git a/doc/images/flows_sdk_with_register.jpg b/doc/images/flows-sdk_with_register.jpg similarity index 100% rename from doc/images/flows_sdk_with_register.jpg rename to doc/images/flows-sdk_with_register.jpg diff --git a/doc/images/flows-updated_opencapif .jpg b/doc/images/flows-updated_opencapif .jpg new file mode 100644 index 0000000000000000000000000000000000000000..6e2ac44952889f949e79a62fca210d798ecfa57e Binary files /dev/null and b/doc/images/flows-updated_opencapif .jpg differ diff --git a/doc/images/flows_invoker_check_authentication.jpg b/doc/images/flows_invoker_check_authentication.jpg deleted file mode 100644 index 29a348a902dd47f492e6bb2a29102b107cb2a003..0000000000000000000000000000000000000000 Binary files a/doc/images/flows_invoker_check_authentication.jpg and /dev/null differ diff --git a/doc/images/flows_invoker_discover.jpg b/doc/images/flows_invoker_discover.jpg deleted file mode 100644 index 8d74e9b3c716136fde6d5ab7ee9a0af4302ff148..0000000000000000000000000000000000000000 Binary files a/doc/images/flows_invoker_discover.jpg and /dev/null differ diff --git a/doc/images/flows_invoker_get_tokens.jpg b/doc/images/flows_invoker_get_tokens.jpg deleted file mode 100644 index 744496ced00b34ab994e7f04c0021d1075119ecb..0000000000000000000000000000000000000000 Binary files a/doc/images/flows_invoker_get_tokens.jpg and /dev/null differ diff --git a/doc/images/flows_invoker_onboard.jpg b/doc/images/flows_invoker_onboard.jpg deleted file mode 100644 index ba7f69e258d420cd0cdb61b351f2ced7c554c3fb..0000000000000000000000000000000000000000 Binary files a/doc/images/flows_invoker_onboard.jpg and /dev/null differ diff --git a/doc/images/flows_invoker_path.jpg b/doc/images/flows_invoker_path.jpg deleted file mode 100644 index 2cba9d6a1f7db7967501e5aec2845d223c979d55..0000000000000000000000000000000000000000 Binary files a/doc/images/flows_invoker_path.jpg and /dev/null differ diff --git a/doc/images/flows_invoker_update_offboard.jpg b/doc/images/flows_invoker_update_offboard.jpg deleted file mode 100644 index 7944c6bd51a18fb028fd7b074a2058a09cfc9860..0000000000000000000000000000000000000000 Binary files a/doc/images/flows_invoker_update_offboard.jpg and /dev/null differ diff --git a/doc/images/flows_provider_onboard.jpg b/doc/images/flows_provider_onboard.jpg deleted file mode 100644 index b352ea3de7944f4ca573b6c091fa26993fa33739..0000000000000000000000000000000000000000 Binary files a/doc/images/flows_provider_onboard.jpg and /dev/null differ diff --git a/doc/images/flows_provider_path.jpg b/doc/images/flows_provider_path.jpg deleted file mode 100644 index f80c48277993e7b9073c2d8c0892054bdd921e38..0000000000000000000000000000000000000000 Binary files a/doc/images/flows_provider_path.jpg and /dev/null differ diff --git a/doc/images/flows_provider_publish_functions.jpg b/doc/images/flows_provider_publish_functions.jpg deleted file mode 100644 index 38dec6ee58618f3e540c340f4e1eefd3a492e116..0000000000000000000000000000000000000000 Binary files a/doc/images/flows_provider_publish_functions.jpg and /dev/null differ diff --git a/doc/images/flows_provider_update_offboard.jpg b/doc/images/flows_provider_update_offboard.jpg deleted file mode 100644 index 09ad5c7e1633eda2df037d15eb0b3979213355eb..0000000000000000000000000000000000000000 Binary files a/doc/images/flows_provider_update_offboard.jpg and /dev/null differ diff --git a/doc/images/flows_updated_opencapif.jpg b/doc/images/flows_updated_opencapif.jpg deleted file mode 100644 index eb7c724cabe315da35c08f5025f2f4a1bf5daedd..0000000000000000000000000000000000000000 Binary files a/doc/images/flows_updated_opencapif.jpg and /dev/null differ diff --git a/doc/images/publish_req_example.png b/doc/images/publish_req_example.png deleted file mode 100644 index ace48252f76e40edebbfe82717a010009d87851a..0000000000000000000000000000000000000000 Binary files a/doc/images/publish_req_example.png and /dev/null differ diff --git a/doc/sdk_configuration.md b/doc/sdk_configuration.md index f5ee0cc0656ad5f396572d1a525affb33377fc40..738d5948a2644b07e941e021c61a1d437b831be2 100644 --- a/doc/sdk_configuration.md +++ b/doc/sdk_configuration.md @@ -32,7 +32,7 @@ When configuring the SDK as a **Network App Invoker**, the following fields must - `invoker_folder` - `capif_callback_url` - `supported_features` -- `cert_generation` (fields such as `csr_common_name`, `csr_country_name`, etc.) +- `cert_generation` (fields such as `csr_common_name`, `csr_country_name`, etc.) For csr_country_name it is important to fulfill the field with [THIS format](https://www.ssl.com/country-codes/) **Optional:** - `discover_filter`: useful to enable the discovery of specific APIs. Some fields under [`discover_filter`](#configuration-of-discover_filter) structure required to be configured when using discovery filters. Check devoted section below, diff --git a/doc/sdk_full_documentation.md b/doc/sdk_full_documentation.md index 32d9f43021fa51a29162ef78f31c7667b7a0a34e..d309f3d440e7383a67edc2ae4e78172bc21de444 100644 --- a/doc/sdk_full_documentation.md +++ b/doc/sdk_full_documentation.md @@ -15,7 +15,7 @@ Before using the SDK, the following steps should be completed: ## Available SDK Usage Modes - + The repository provides two modes for utilizing the OpenCAPIF SDK: @@ -77,7 +77,7 @@ OpenCAPIF SDK references: 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`. - + ### Service Publishing @@ -148,7 +148,7 @@ Retrieve information about all previously published services in `service_receive **Required SDK input**: - publisher_apf_id - + ### Update and Offboard Provider @@ -161,7 +161,7 @@ OpenCAPIF SDK references: The provider must be onboarded before using these features. - + ### Create logs @@ -177,6 +177,80 @@ For leveraging this feature the Provider must have onboarded and published an AP - api_invoker_id (Within the function) - log (Within [SDK configuration](./sdk_configuration.md) or object) + + +### Create subscription + +OpenCAPIF SDK references: +- **Function**: `create_subscription(name, id)` + +The provider ask to the CCF about notifications related to services such as SERVICE_API_AVAILABLE or API_INVOKER_UPDATED. + +This services are specificated in [CAPIF Events API management](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Events_API.yaml) explained in [SDK configuration](./sdk_configuration.md#events_configuration) + +For leveraging this feature the Provider must have onboarded previously. + +**Required SDK input**: + +- aefId//apfId//amfId (Within the function) +- name: An arbitrary name we want to set in order to store it. +- events (Within [SDK configuration](./sdk_configuration.md#events_configuration) or object) + +### Delete subscription + +OpenCAPIF SDK references: +- **Function**: `delete_subscription(name, id)` + +The provider ask to the CCF to withdraw the subscription to the notifications asked previously + +For leveraging this feature the Provider must have onboarded and created a subscription previously. + +**Required SDK input**: + +- aefId//apfId//amfId (Within the function) +- name: The name of your subscription. + +### Update subscription + +OpenCAPIF SDK references: +- **Function**: `update_subscription(name, id)` + +The provider ask to the CCF about updating the subscription for receiving different services such as SERVICE_API_AVAILABLE or API_INVOKER_UPDATED, changing the URL for receiving the notifications... + +This services are specificated in [CAPIF Events API management](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Events_API.yaml) explained in [SDK configuration](./sdk_configuration.md#events_configuration) + +For leveraging this feature the Provider must have onboarded and created a subscription previously. + + + +**ONLY AVAILABLE IN CAPIF RELEASE 2** + +**Required SDK input**: + +- aefId//apfId//amfId (Within the function) +- name: The name of your subscription. +- events (Within [SDK configuration](./sdk_configuration.md#events_configuration) or object) + +### Patch subscription + +OpenCAPIF SDK references: +- **Function**: `update_subscription(name, id)` + +The provider ask to the CCF about updating the subscription for receiving different services such as SERVICE_API_AVAILABLE or API_INVOKER_UPDATED. + +This services are specificated in [CAPIF Events API management](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Events_API.yaml) explained in [SDK configuration](./sdk_configuration.md#events_configuration) + +For leveraging this feature the Provider must have onboarded and created a subscription previously. + +**ONLY AVAILABLE IN CAPIF RELEASE 2** + +**Required SDK input**: + +- aefId//apfId//amfId (Within the function) +- name: The name of your subscription. +- events (Within [SDK configuration](./sdk_configuration.md#events_configuration) or object) + + ## Invoker Network App The OpenCAPIF SDK enables efficient implementation of invoker functionality for Network App. This section details the SDK features related to CAPIF invokers. @@ -202,7 +276,7 @@ OpenCAPIF SDK references: The SDK streamlines the invoker onboarding process, storing the `api_invoker_id` in the `capif_api_security_context_details.json`. - + ### Service Discovery @@ -216,7 +290,7 @@ The [discover_filter](./sdk_configuration.md) can be used to retrieve access to Use the [discover_filter](./sdk_configuration.md) to retrieve access to target APIs. Ensure you are [onboarded as an invoker](#invoker-onboarding) before using this feature. - + ### Obtain JWT Tokens @@ -226,7 +300,7 @@ OpenCAPIF SDK references: The SDK facilitates JWT token creation for secure access to target APIs. This process stores JWT access token in `capif_api_security_context_details.json`. - + ### Check authentication @@ -240,7 +314,7 @@ It is mandatory to have obtained the [JWT token](#obtain-jwt-tokens) previously. **Required SDK inputs**: - check_authentication_data - + ### Update and Offboard Invoker @@ -250,7 +324,7 @@ OpenCAPIF SDK references: Onboarding is required before utilizing these functions. - + ## Other Features @@ -281,4 +355,4 @@ OpenCAPIF SDK reference: Simplifies the logout process for admin users and removes a CAPIF user. - + diff --git a/opencapif_sdk/capif_event_feature.py b/opencapif_sdk/capif_event_feature.py index f9df6213a12cab495c437ce6456100969ec29f31..32d0bf35938c3570f701774b646438da7b73c5a6 100644 --- a/opencapif_sdk/capif_event_feature.py +++ b/opencapif_sdk/capif_event_feature.py @@ -98,10 +98,11 @@ class capif_invoker_event_feature(capif_invoker_connector): if not isinstance(name, str): name = str(name) + if str(subscriberId) not in subscription: + # If the subscriberId is not in the subscription, create an empty dictionary for it + subscription[str(subscriberId)] = {} # Update the subscription structure - subscription[str(subscriberId)] = { - f"{name}": identifier - } + subscription[str(subscriberId)][name] = identifier # Save the updated dictionary back to the file self._create_or_update_file("capif_subscriptions_id", "json", subscription, "w") @@ -283,10 +284,11 @@ class capif_provider_event_feature(capif_provider_connector): if not isinstance(name, str): name = str(name) + if str(subscriberId) not in subscription: + # If the subscriberId is not in the subscription, create an empty dictionary for it + subscription[str(subscriberId)] = {} # Update the subscription structure - subscription[str(subscriberId)] = { - f"{name}": identifier - } + subscription[str(subscriberId)][name] = identifier # Save the updated dictionary back to the file self._create_or_update_file("capif_subscriptions_id", "json", subscription, "w") diff --git a/scripts/invoker_capif_event_subcription.py b/scripts/invoker_capif_event_subcription.py index 4f98dc8a72eea6f6d7a29311cf4eef26b65b1e3c..a8a95d45dbfcf8eae9c69329cd40438893bcf03f 100644 --- a/scripts/invoker_capif_event_subcription.py +++ b/scripts/invoker_capif_event_subcription.py @@ -1,19 +1,26 @@ import utilities -from opencapif_sdk import capif_invoker_event_feature +from opencapif_sdk import capif_invoker_connector, capif_invoker_event_feature def showcase_capif_connector(): """ This method showcases how one can use the CAPIFConnector class. """ + # invoker = capif_invoker_connector(config_file=utilities.get_config_file()) + + # invoker.onboard_invoker() events = capif_invoker_event_feature(config_file=utilities.get_config_file()) events.create_subscription(name="Servicio_2") + + events.create_subscription(name="Servicio_3") - events.update_subcription(name="Servicio_2") + # events.update_subcription(name="Servicio_2") events.delete_subscription(name="Servicio_2") + + events.delete_subscription(name="Servicio_3") print("COMPLETED") diff --git a/scripts/provider_capif_event_feature.py b/scripts/provider_capif_event_feature.py index cce0f46ec2a300fd7d7b9a9c4127ee7bac1ecc39..5665369e7a67abf270bfeb97554bf8a4c5324376 100644 --- a/scripts/provider_capif_event_feature.py +++ b/scripts/provider_capif_event_feature.py @@ -8,15 +8,21 @@ def showcase_capif_connector(): """ provider = capif_provider_connector(config_file=utilities.get_config_file()) - id = provider.provider_capif_ids["AEF-1"] + # provider.onboard_provider() + + id = provider.provider_capif_ids['AEF-1'] events = capif_provider_event_feature(config_file=utilities.get_config_file()) events.create_subscription(name="Servicio_2", id=id) + + events.create_subscription(name="Servicio_3", id=id) - events.update_subcription(name="Servicio_2", id=id) + # events.update_subcription(name="Servicio_2", id=id) events.delete_subscription(name="Servicio_2", id=id) + + events.delete_subscription(name="Servicio_3", id=id) print("COMPLETED") diff --git a/test/capif_sdk_config_sample_test.json b/test/capif_sdk_config_sample_test.json index 037226b9cf72a48a837459c32574a5910d744bcb..598a11cbca8733e85285321bd6087ba544e92b7c 100644 --- a/test/capif_sdk_config_sample_test.json +++ b/test/capif_sdk_config_sample_test.json @@ -10,7 +10,7 @@ "invoker_folder": "/Users/IDB0128/Documents/OpenCapif/test_invoker_certificate_folder", "capif_callback_url": "http://localhost:5000", "supported_features": "fffffff", - "check_authorization": { + "check_authentication_data": { "ip": "", "port": "" }, diff --git a/test/test.py b/test/test.py index 9ca0b1fa78d24825e7ef4f449a10fe7c68ca63f4..a4ec863c28f783e964817bce1eb7af71c138e9d7 100644 --- a/test/test.py +++ b/test/test.py @@ -2,7 +2,7 @@ import json # flake8: noqa -from opencapif_sdk import capif_invoker_connector, capif_provider_connector, service_discoverer,capif_logging_feature +from opencapif_sdk import capif_invoker_connector, capif_provider_connector, service_discoverer, capif_logging_feature, capif_invoker_event_feature, capif_provider_event_feature capif_sdk_config_path = "./capif_sdk_config_sample_test.json" @@ -92,6 +92,16 @@ if __name__ == "__main__": # Update configuration file capif_provider_connector.publish_req['publisher_apf_id'] = APF1 capif_provider_connector.publish_req['publisher_aefs_ids'] = [AEF1, AEF2] + + event_provider = capif_provider_event_feature(config_file=capif_sdk_config_path) + + event_provider.create_subscription(name="Ejemplo1",id=AEF2) + + event_provider.create_subscription(name="Ejemplo2",id=APF1) + + event_provider.delete_subscription(name="Ejemplo1",id=AEF2) + + event_provider.delete_subscription(name="Ejemplo2",id=APF1) capif_provider_connector.publish_services() @@ -120,7 +130,7 @@ if __name__ == "__main__": discoverer = service_discoverer(config_file=capif_sdk_config_path) - discoverer.discover_filter["api-name"]= "safe-6g-resilience-function" + discoverer.discover_filter["api-name"]= "Testtrece" discoverer.discover() @@ -136,6 +146,16 @@ if __name__ == "__main__": logger.create_logs(aefId=AEF1,api_invoker_id=invoker_id) + event_invoker = capif_invoker_event_feature(config_file=capif_sdk_config_path) + + event_invoker.create_subscription(name="Ejemplo3") + + event_invoker.create_subscription(name="Ejemplo4") + + event_invoker.delete_subscription(name="Ejemplo3") + + event_invoker.delete_subscription(name="Ejemplo4") + capif_invoker_connector.update_invoker() print("INVOKER UPDATE SERVICE COMPLETED")