README.md 2.97 KB
Newer Older
torrespel's avatar
torrespel committed
# CAPIF_Invoker_GUI
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
This is the implementation of a CAPIF Invoker 
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
* This repo is intended to be used as a test method for CAPIF services and services published on CAPIF.
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
## Prerequisites
Before executing the following code it is necessary to have raised an instance of [CAPIF](https://github.com/Telefonica/CAPIF_Future_Network_Lab.git).
To run Capif Invoker you must ensure to have docker and a docker compose version 2.10 or higher.
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
## Set Up
This repo is designed to be executed from docker, to create the images and raise the instance it is only necessary to execute the following command:
```
./run.sh
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
- Before executing the run.sh command, note that it supports one parameter, this parameter is the CAPIF hostname, by default this field is 'capifcore'. Modify it if necessary or add the hostname when executing the run.sh command
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
    ```
    ./run.sh <other_hostname>
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
    ```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
- It is important to have the following environment variables in the docker-compose file:
    ```
      - CAPIF_HOSTNAME=${CAPIF_HOSTNAME}
      - CAPIF_PORT=8080
      - REGISTER_HOSTNAME=register
      - REGISTER_PORT=8084
      - CAPIF_PORT_HTTPS=443
      - CAPIF_CALLBACK_URL=host.docker.internal
      - CAPIF_CALLBACK_PORT=8086
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
    ```
    These environment variables refer to the registration services. By default, these are the ports and names that the CAPIF script uses when launching the different services. If during the deployment of CAPIF you modify these parameters, you must modify them so that they correspond to the new ones.
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
Now it is only necessary to enter inside the container by executing this command
torrespel's avatar
torrespel committed
```
./terminal_to_py_aef.sh
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
Once inside the container you can run the provider command GUI by running
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
./python main.py
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
## Interacting with the GUI
The provider is prepared to make the necessary previous provisions automatically, but if the user is already register, you can remove the user using the command:
```
remove_user
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
and register a new user with
```
register_user
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
The different .json files that must be saved in CAPIF are also added. To make the necessary provisions you just have to execute the following commands within the GUI
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
register_invoker
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
discover_service
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
register_security_context <api_name>
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
get_security_auth <api_name>
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
### What are we doing?
- The previous commands are to register an invoker within CAPIF, discover the services that have been published and if there are any published services, create a security context to use those services.
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
*If the first command returns a 401, it means that the token to interact the first time with CAPIF has expired, run the following command
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
get_auth

```

## Call Service

```
call_service <api_name>
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
If the previous process has been executed correctly, the call_service command will call the first endpoint of the service that has been discovered.
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
If you want to call another endpoint or modify the parameters that are sent to the service, you must modify the code directly