Skip to main content

CLI and python client library for the StackStorm (st2) automation platform.

Project description

Install from Source

Git clone the StackStorm repo locally, change directory to st2client, then run “python setup.py install”.

Endpoint Configuration

By default, both the python client and the CLI will retrieve endpoint configuration from the environment. If no configuration is provided, the client will assume localhost and default ports.

  • ST2_BASE_URL - Base URL for the StackStorm API server endpoints (i.e. http://localhost). If only the base URL is provided, the client will assume default ports for the API servers are used. If any of the API server URL is provided, it will override the base URL and default port.

  • ST2_API_URL - Endpoint for the Action REST API (i.e. http://localhost:9101) for managing actions, executions, triggers, rules and reusable configuration data.

The default endpoint configuration can be explicitly specified at the StackStorm CLI and the python client. For StackStorm CLI, the endpoints are provided via optional parameters (i.e. –url for base URL, –action-url, –reactor-url, and –datastore-url). For the python client, the endpoints are provided via the Client init as kwargs (i.e. base_url, action_url, reactor_url, and datastore_url).

CLI

CLI is developed using standard python argparse and uses well known pattern for commands and subcommands. In general, trigger, rule, action, and key are commands and list, get, create, update, and delete are subcommands. The command run and execution are special cases and do not have the same set of subcommands. Please use the CLI help option for more detail description.

-h or –help option is used to display usage information.

st2 -h
st2 action -h
st2 action create -h
st2 run -h
st2 run <action-name> -h

-j or –json option will format output as JSON.

st2 rule get <rule-name> -j

-a or –attr option allows user to specify which attributes to display and in which order.

st2 rule get <rule-name> -a name description

-w or –width option lets user specify the width of table columns. If only 1 value is provided, all table columns will have the same width. By default, the width is 28.

st2 rule list -a name description -w 50
st2 rule list -a name description -w 25 50

Python Client

>>> from st2client.client import Client
>>> from st2client import models
>>> client = Client(base_url='http://localhost')
>>> rules = client.rules.get_all()
>>> key_value_pair = client.keys.create(models.KeyValuePair(name='k1', value='v1'))

The models Trigger, Rule, Action, Execution, and KeyValuePair are defined under st2client.models. Please refer to the respective README section for these models for their schema.

The resource managers for the models are instantiated under the client as triggers, rules, actions, executions, and keys. The operations get_all, get_by_name, get_by_id, create, update, and delete are generally implemented for these resource managers.

  • get_all returns a list of resource instances.

  • get_by_name and get_by_id takes name and id respectively and returns the matching resource instance.

  • create takes a resource instance as input and creates the instance, throwing unique constraint error if name already exists

  • update takes a resource instance as input and updates the instance matching by name

  • delete takes a resource instance as input and deletes the instance matching by name

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

st2client-0.5.1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

st2client-0.5.1-py2-none-any.whl (32.8 kB view details)

Uploaded Python 2

File details

Details for the file st2client-0.5.1.tar.gz.

File metadata

  • Download URL: st2client-0.5.1.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for st2client-0.5.1.tar.gz
Algorithm Hash digest
SHA256 260e377d3a0f66f59238e6b586732fe14f418d714170b63ee464cc5e16f69aa5
MD5 74ed8fec25d2ca43248576466c964729
BLAKE2b-256 0ff06ac37a6bb315abe84aaed492df1d4ea0550d8b1862d1352ebb89cf134d25

See more details on using hashes here.

File details

Details for the file st2client-0.5.1-py2-none-any.whl.

File metadata

File hashes

Hashes for st2client-0.5.1-py2-none-any.whl
Algorithm Hash digest
SHA256 45722a6ad3de84907dd7ef91dabe0604db64474aaad60f46a3a8c057d22fad47
MD5 9b23e7b99e15eac8615af2d8846f97fc
BLAKE2b-256 67ad8ec864482d7a497a951d91ff8794cffa86398127d638a77d33da1c3e0cce

See more details on using hashes here.

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