Skip to content

A shim that exposes ocm-cli information for API platform tools

Notifications You must be signed in to change notification settings

tylercreller/ocm-cli-shim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OCM CLI Shim

This shim provides an API layer on top of your local ocm-cli instance that allows an application (i.e. Postman) to retrieve information from your current session; such as your authentication token and current environment URL.

Pre-requisites

  • golang 1.19 or higher
  • ocm-cli setup and logged into an environment

Running the shim

From the root folder of this repository run the following command:

go run .

Usage

Postman

https://www.postman.com/

Automatic Setup

A collection and environment are available for import from the /postman folder. These should work out of the box and allow you to start building requests with no additional configuration. The collection is setup to fire a pre-request script to the shim to populate the ocm_token and ocm_api_url environment variables. The collection has authorization set-up and will apply it to every request that inherits the auth from it's parent.

Manual setup

Create a new environment to store your OCM CLI variables in. For example, an environment named OCM CLI.

Setup the following pre-request script. This can be done at the collection, folder, or request level. This script will add/populate the ocm_token and ocm_api_url environment variables from the shim API response.

pm.sendRequest('localhost:8082', (err, response) => {
    const responseJson = response.json();
    pm.environment.set("ocm_token", responseJson.token);
    pm.environment.set("ocm_api_url", responseJson.url);
})

Lastly, configure your requests to use the environment variables. ocm_token will be used for your Bearer Token authorization and ocm_api_url will be used in your request URLs.

Additional Features

Automatic ocm-cli request conversion

When using the embedded postman collection an ocm-style request will be generated in the visualize tab. This makes things easier to share with others who may only use the ocm-cli.

postman visualize screenshot

About

A shim that exposes ocm-cli information for API platform tools

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages