API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

API Connect Quick Check script

By Ricky Moorhouse posted 27 days ago

  

This script originated as part of a much wider framework of tests that we put together when I was in the API Connect SRE team. However I’ve found this set of functions to be something useful to be able to validate quickly from time to time in different contexts to give a high level answer to ‘Is it working?’ The steps this script takes are as follows:

  • Authenticate to the API Manager Platform API and retrieve an access token
  • Take a templated API and Product and modify it to return a unique value
  • Publish this API to a nominated catalog
  • Invoke the API through the gateway (looping until a successful response is seen)
  • Query the Analytics APIs to find the event logged for this invocation (again looping until found)

Whilst the entire test frameworks a lot of assumptions around how our environments are built and deployed, this test was relatively standalone - and I just needed to make a couple of updates to it to work outside of our cloud deployments - add support to turn off certificate validation and for username/password instead of API Key based authentication.  Take a look at the script on GitHub.

If you want to try this in your own environment you can follow these steps:

Clone the repository

git clone https://github.com/ibm-apiconnect/quick-check.git

Install the python required dependencies

pip install -r requirements.txt

Identify the appropriate credentials to use for your stack - either username/password or an api-key if you are using an OIDC registry and set these as environment variables (APIC_API_KEY or APIC_REALM, APIC_USERNAME & APIC_PASSWORD) or use the command line parameters - either:


-u <apim_user> -p <apim_password> -r provider/default-idp-2 or -a <apim_api_key>

Download the credentials.json file from the toolkit download page to identify the client id and client secret for your environment - these can either be set as environment variables (CLIENT_ID / CLIENT_SECRET) or as command line parameters (--client_id / --client_secret)

Run the script according to the usage examples

python api-deploy-check.py -s <platform-api-hostname> -o <provider_org_name> -c <catalog_name> [credential parameters]

If successful, you should see output like this:

I'd be interested to hear if you find this useful or if you have other similar utilities you use already - let me know!

#APIConnect#scripting

0 comments
14 views

Permalink