Path: blob/main/L4assets/DSandMLOpsAssets/CLIandSDK/Notebooks/CPD-04 Services.ipynb
1928 views
Services and permissions
This notebook shows how we can get information about services using API calls.
The use of cpd-cli is also demonstrated.
The best source of information on how to use the API calls appears to be: Using the Volumes API
Make sure to set the variables in the next cell
cpd_url, username, password
Download and install cpd-cli
Also setup the environment to use the command
Make sure to add the proper API key
os.environ['CPD_API_KEY'] = "<YOUR_API_KEY>"
Support functions
Get an access token
Note that the token usually lasts for only one hour.
An access token is used to identify a user in API requests.
List service instances with cpd-cli
cpd-cli service-instance list --profile ${CPD_PROFILE_NAME} --output=text --verbose
The text output format is the default
Show the command options
Get the result in json format
It returns a IPython.utils.text.SList that has to be converted to a dictionary
Show verbose
Show what we get with --verbose
What is revealing is the one before last debug statement that returns something like:
API GET <cpd_url>/zen-data/v3/service_instances?offset=0&limit=50&fetch_all_instances=true
This provides the API call needed to get the same result
List service instances using an API call
For this we use a function available in the support function library
List the members of the OpenScale service
There does not seem to be a cpd-cli command equivalent
Create a target user
Add the target user to OpenScale
The possible roles are: Admin, Editor, and Viewer
List members again to prove the user was added
Delete a target user from a service
Cleanup: remove the target user
Author
Jacques Roy is a member of the IBM Enablement for Data and AI
Copyright © 2023. This notebook and its source code are released under the terms of the MIT License.