Skip to main content

CLI for interacting with NHSD APIM's proxygen service

Project description

proxygen-cli

Installation

Installation is straightforward using pip:

pip install proxygen-cli

After installation, the proxygen executable is available. Typing proxygen displays a list of available commands.

Configuration

Settings

To specify the API you are developing for, use:

proxygen settings set api <API-NAME>

Your user must have the appropriate permissions for managing instances, secrets, and specifications related to the specified API. If permissions are insufficient, commands will fail. Reach out to the platforms-api-producer-support channel for assistance with permissions.

Credentials

There are two ways to authenticate via the Proxygen CLI. Either via user login credentials such as a username and password or as a machine user using your private key and client_id.

Setting up for user access

If you are setting up user access for the first time you will first need to request a user account. Contact the platforms-api-producer-support channel asking for a proxygen user account to be set up providing:

  • Your nhs.net email address
  • The proxygen-managed api/s your account will need access to

To setup the Proxygen CLI credentials for the first time with user access enter the following command:

proxygen credentials set

The CLI will ask you for your username, and password. These credentials will be securely stored on your local machine in the directory ~/.proxygen/credentials.yaml. The client_id and secret used for user access will be automatically added to this file after running the command.

Your user must have permissions to manipulate instances/secrets/specs for the API you set here. If you do not have sufficient permissions commands will fail. If you believe your permissions are incorrect, contact the API platform team via the platforms-api-producer-support channel.

Setting up for machine-user access

After having set up your API using the instructions at Getting set up with proxy generator, you should have the following:

  • A private key from a key pair for machine user access
  • The key id for that specific key pair
  • The client_id for your api machine user access (usually -client)

Using this information enter the following command:

proxygen credentials set private_key_path <PATH_TO_PRIVATE_KEY> key_id <KEY_ID_FOR_PRIVATE_KEY> client_id <MACHINE_USER_CLIENT_ID>

The CLI will ask you for your username, and password. For machine authentication, the username and password must be left blank. The credentials will be securely stored in the directory ~/.proxygen/credentials.yaml.

NOTE: If you are switching between using user access and machine-user access bare in mind:

  • proxygen-cli will favour user access if username and password credentials are set
  • User access uses proxygen-cli-user-client as a client_id. If you switch between access modes remember to switch the client_id
  • The value for client_secret should remain untouched as it is not used for machine-user access
  • If you lose the client_secret for then proxygen-cli-user-client then reach out to the platforms-api-producer-support channel for it

Commands

Commands are documented inside the CLI itself. Type proxygen to see a full list of available commands.

For a full user guide for proxygen-cli see this confluence page.

Deploying an API instance

To deploy an instance of an API you will need an OAS specification file. The OAS specification file can be deployed to an environment using the following command:

proxygen instance deploy <env> <base-path> path/to/specification.yaml

To manage your instances type proxygen instance --help for a list of available commands.

Publishing an API sepcification

To publish your API specification, first deploy it on the UAT version of Bloomreach, then on production. Publishing to UAT allows you to preview the API documentation's appearance and catch any errors in the code before going live.

Use the following command to publish an API specification:

# Production
proxygen spec publish <path_to_spec>
 
# UAT
proxygen spec publish <path_to_spec> --uat

To manage your instances type proxygen spec --help for a list of available commands.

Deploying a secret

The API key, considered sensitive information, is securely stored within the API platform as a 'secret'. Before configuring any instances reliant on this key, it's necessary to deploy it.

Use the following command to deploy a secret:

proxygen secret put <env> <apikey> --apikey --secret-file path/to/secret.txt

To manage your instances type proxygen secret --help for a list of available commands.

Interacting with your docker repository

To enable the push and pull of images from the API Management ECR repository, you will need to acquire authentication details.

Use the following command to obtain a docker token:

$(proxygen docker get-login)

Retrieving a token to use with the pytest-nhsd-apim python testing package

When testing using the pytest-nhsd-apim python testing package, an apigee management api token is needed. This endpoint provides this token for use in automated tests.

Use the following command to obtain the pytest-nhsd-apim token:

$(proxygen pytest_nhsd_apim get_token)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

proxygen_cli-2.1.15.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

proxygen_cli-2.1.15-py3-none-any.whl (39.0 kB view details)

Uploaded Python 3

File details

Details for the file proxygen_cli-2.1.15.tar.gz.

File metadata

  • Download URL: proxygen_cli-2.1.15.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.8.18 Linux/6.5.0-1025-azure

File hashes

Hashes for proxygen_cli-2.1.15.tar.gz
Algorithm Hash digest
SHA256 35666d6cb5e727771a0fbaba5b68e75fdda6bf02216b2f6b6219ef5f66449488
MD5 d1b7ebb39faec8c22f6346d3613a6dd8
BLAKE2b-256 e15dd17d715f37a8519213824ce8f4d75235db103bd19d454946e4347032641c

See more details on using hashes here.

Provenance

File details

Details for the file proxygen_cli-2.1.15-py3-none-any.whl.

File metadata

  • Download URL: proxygen_cli-2.1.15-py3-none-any.whl
  • Upload date:
  • Size: 39.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.8.18 Linux/6.5.0-1025-azure

File hashes

Hashes for proxygen_cli-2.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 d63e7c84214a8b484a3389590bf9c86f0569367ed820e9b6b30beedc475b6115
MD5 b6f62fffc621bf50e10c30ddd39d1a05
BLAKE2b-256 5c19cd5abeaf24249f6f5869c3d94b43639816ad0024a42e00cadf3a31279ec5

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page