Newer
Older
# Invoker and Provider CLIs
The Invoker and Provider CLIs serve as examples for developers and integrators looking to connect their Network Applications (NetApps) to CAPIF.
They demonstrate, using Python, how to develop the necessary code for seamless communication with CAPIF, offering a practical guide to implementing the required API calls and interactions.
When using the [Provider Console](https://labs.etsi.org/rep/ocf/example-clients/provider-cli), users can create a provider entity that registers and publishes APIs to make them available within the CAPIF ecosystem.
With the provider console you can make the following requests to CAPIF:
#### provider_get_auth
It is used to request the token and the ca_root certificate in order to perform the provider onboarding.
The token has an expiration time of 10 minutes, so if it expires you will have to request a new one.
#### register_provider
It is used to perform the onboarding of a provider.
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
```
register_provider <name>
```
This request uses the [api_provider_domain.json](https://labs.etsi.org/rep/ocf/example-clients/provider-cli/-/blob/main/one_provider_gui/capif_ops/config_files/api_provider_domain.json?ref_type=heads) file as a template and creates the certificates and keys for each of the entities that make up the Provider.
#### publish_service
It is used to publish an api as a provider.
```
publish_service <service file route>
```
For this request the [demo_api_one.json](https://labs.etsi.org/rep/ocf/example-clients/provider-cli/-/blob/main/one_provider_gui/service/demo_api_one.json?ref_type=heads) file is used as a template.
#### get_services
It is used to see what services the provider has published.
```
get_service
```
Returns a list of API names.
#### remove_service
It is used to unpublish an API.
```
remove_service <api name>
```
#### remove_provider
It is used to remove the provider.
```
remove_provider
```
Once the provider is deleted, you will not be able to publish or perform other operations that require certificates.
### Additionally
In addition, an [API example](https://labs.etsi.org/rep/ocf/example-clients/provider-cli/-/blob/main/one_provider_gui/service/service_oauth.py?ref_type=heads) is provided with which you can see how the token used by invokers to use the API published by the provider is decrypted and used.
Once the API is published, the file can be executed with the next command:
```
python3 service_oauth.py
```
With this, the API will be raised to be able to make the calls.
When using the [Invoker Console](https://labs.etsi.org/rep/ocf/example-clients/invoker-cli), users can create an Invoker entity that discover APIs to consume them with the CAPIF ecosystem.
With the Invoker console you can make the following requests to CAPIF:
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#### get_auth
It is used to request the token and CA cert to be able to perform the onboarding.
```
get_auth <username> <password>
```
The token has an expiration time of 10 minutes, so if it expires you will have to request a new one.
#### register_invoker
It is usedd to perform the onboarding of an Invoker,
```
register_invoker <name>
```
This request uses the [invoker_details.json](https://labs.etsi.org/rep/ocf/example-clients/invoker-cli/-/blob/main/invoker_gui/capif_ops/config_files/invoker_details.json?ref_type=heads) file as a template and creates the certificate and keys of the Invoker.
#### discover_service
It is used to discover the APIs published in CAPIF.
```
discover_service
```
Returns a list with the names of the services published in CAPIF.
#### register_security_context
It is used to make the request to create a security context.
```
register_security_context <api name>
```
#### get_security_auth
It is used to request the token necessary for the cunsumption of an API.
```
get_security_auth <api name>
```
#### call_service
It is used to consume the API
```
call_service <api name> <method> <endpoint> <body route>
```
For the request you must specify the name of the API you want to use, the method and endpoint you want to consume, and the path of the body to use.
#### remove_security_context
It is used to delete the created security context.
```
remove_security_context
```
#### remove_invoker
It is used to delete the Invoker
```
remove_invoker
```
Once the invoker is deleted, you will not be able to discover or perform other operations that require the Invoker certificate.
## Other commands
Apart from these operations, with the Invoker and Provider console you can also perform operations as administrator if you have a CAPIF instance locally.
### Admin commands
As an administrator, you can manage which users can use CAPIF with the following commands.
#### login_admin
It is used to login as an administrator and obtain the tokenes needed to perform admin operations
```
login_admin <admin username> <admin password>
```
#### refresh_admin
It is used to refresh the tokenes of the admin user
```
refresh_admin
```
#### register_user
It is used to register a new user
```
register_user
```
uses the data in the [credentials.properties](https://labs.etsi.org/rep/ocf/example-clients/invoker-cli/-/blob/main/invoker_gui/capif_ops/config_files/credentials.properties?ref_type=heads) file as the data to record.
#### remove_user
It is used to remove the created user.
```
remove_user
```
## Tips
This section explains some tips that may be useful for developers who are using consoles.
### help command
In both consoles you can use the help command to display a list of available commands.
```
help
```
### exit command
In both consoles you can use the exit command to exit the console.
```
exit
```
### Delete the entities
It is recommended to delete all providers, Invokers and users created by the consoles if they are not going to be used anymore.
### debug mode
You can add the debug flag at the end of each command to show the complete inputs and outputs of each request and thus better understand what is being done.
[OCF Web]: https://ocf.etsi.org/ "OCF Web"
[OCF Documentation]: https://ocf.etsi.org/documentation/ "OCF Documentation"