OpenAPI Generator
Python Client Bindings
To generate Python client bindings using the OpenAPI generator:
git clone https://github.com/Internet2/comanage-registry.git pushd comanage-registry git checkout develop popd mkdir mnt cp comanage-registry/app/Config/Schema/restapiv1.yaml mnt/restapiv1.yaml docker run \ --rm \ -v $PWD/mnt:/mnt openapitools/openapi-generator-cli generate \ -i /mnt/restapiv1.yaml \ -g python \ -o /mnt/out/python \ --additional-properties=packageName=comanage_registry_restapiv1_client
To create a virtual environment with the client API package installed:
python -m venv myenv source myenv/bin/activate pip install --upgrade pip sudo chown -R `whoami` local/out pip install -e mnt/out/python/
The Python binding specific documentation will be rendered in markdown with the entry point in the file mnt/out/python/README.md
Below is an example Python script that exercises parts of the API.
Before executing the script you must create a new API User in the working CO.
Be sure to edit the values for SERVER, CO_ID, USERNAME, PASSWORD, and IDENTIFIER. See the comments in the code.
Other Examples
Suppose you have two COs with these COUs:
CO 4:
- L and S
- Chemistry
- Physics
- Astronomy
CO 5:
- Optics Team
- Diffraction Team
- Storage Ring Team
Listing
The REST call for a Platform API User (CO 1) might look like this:
The same call with a Privileged CO API User (CO 5) will result in a 401 Unauthorized since the Privileged CO API User does not have access to all COs:
Instead the Privileged CO API User should specify the (numeric) CO to which the user has access using the View (per CO) syntax
Adding
A Privileged CO API User (CO 5) may add a new COU for CO 5 like this: