• Beta
Bash SDK
  • 18 Nov 2020
  • 2 Minutes To Read
  • Share
  • Dark
    Light

Bash SDK

  • Share
  • Dark
    Light

Bash

Supported methods

The following SDK methods are supported by the Bash SDK:

  • Secret
  • Config
  • Track

Secret

Access the current team's secret store.

Subcommands:

Get:

USAGE:

sdk secret get <KEY>

OPTIONS:

-H, --hidden    If provided, suppresses the user notification that the secret has been retrieved

ARGS:

<KEY>    The key of the desired secret in the secret store

Set:

USAGE:

sdk secret set --key <KEY> --value <VALUE>

OPTIONS:

-k, --key <KEY>        The key to set the secret under in the secret store
-v, --value <VALUE>    The value to set in the secret store

Example:

sdk secret set --key='secret1' --value='shh'secret=$(sdk secret get secret1)
echo $secret

Output:

shh

Config

Access the current team's configuration store.

Subcommands:

Get:

USAGE:

sdk config get <KEY>

or

sdk config get --all

ARGS:

<KEY>    The key of the desired value in the configuration store

Set:

USAGE:

sdk config set --key <KEY> --value <VALUE>

OPTIONS:

-k, --key <KEY>        The key to set the value under in the configuration store
-v, --value <VALUE>    The value to set in the configuration store

Delete:

USAGE:

sdk config delete <KEY>

ARGS:

<KEY>    The key of the desired value to be deleted from the configuration store

Example:

cto-ai config set --key='myop_target_domain' --value='cto.ai'

domain=$(cto-ai config get myop_target_domain)
echo $domain

wasDeleted=$(sdk config delete myop_target_domain)
if $wasDeleted; then echo "myop_target_domain was successfully deleted"; fi

Output:

cto.ai
myop_target_domain was successfully deleted

Track

The track function allows you to send Events and retrieve custom analytic data.

USAGE:

sdk track [OPTIONS] <EVENT> [PARAM]...

OPTIONS:

-e, --error <ERROR>    An error string to report

ARGS:

<EVENT>       The event name to track
<PARAM>...    Parameters for the tracking event. Takes key:value metadata entries or tags as strings without colons

Example:

sdk track deploy image:jifejfdkdkdi3930 

Result:

Sends an analytics event to The Ops Platform with event deploy and metadata {image: jifejfdkdkdi3930}.

Using Track to Create Events for Insights

Tracking Workflow Metrics using CTO.ai can give deep insight into your team's activity. To use track to send a Workflow Metric event, place your event data in the <PARAM> field like so:

#!/bin/bash

sdk track "" \
  stage:Deployment \
  status:Succeeded \
  pipeline_id:web \
  stage_ref:956b425e5bee \
  custom_field_ABC:custom_value_XYZ

The "" argument (the first argument) is a metadata field that isn't used by the metrics dashboard, but is required by the sdk.track function, so it has been left blank in this example.

More information about Insights and Wokflow Agents can be found on the Insights Overview page.

Events

Retrieve events that were sent with sdk.track.

USAGE:

sdk events STARTTIME [ENDTIME]

Timestamps can be given in ISO format.

Example:

sdk events -s "2020-05-12T20:47:45Z" -e "2020-06-12T20:47:45Z" 

Result:

Retrieves a list of events from The Ops Platform that were stored for the active team that occurred between the two given times.

🚀 What's next?

  • To learn more about the UX options available for you, please go to Bash UX page.
  • To see which prompts we offer for this SDK, you can go to Bash Prompts page.
Was This Article Helpful?