MistralClient
MistralClient provides a Ruby interface to a limited subset of the Mistral API.
Installation
Add this line to your application's Gemfile:
gem 'mistral_client'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mistral_client
Usage
Instantiate a Client
The Mistral base URL is required:
client = MistralClient.new('https://mistral.local/v2')
If running Mistral with a self-signed certificate (e.g., during development),
you can bypass certificate verification by specifying verify: false
:
client = MistralClient.new('https://mistral.local/v2', verify: false)
You can also pass in other connection options in the same way you would with HTTParty:
client = MistralClient.new('https://mistral.local/v2', timeout: 20)
Environment Operations
Create an Environment
environment = client.environment(definition)
Delete an Environment
environment.delete!
Workflow Operations
Instantiate a Workflow
workflow = client.workflow(definition)
You can instantiate a workflow object using an existing Mistral workflow ID:
workflow = client.workflow(id: id)
or workflow name:
workflow = client.workflow(name: name)
Execute a Workflow
workflow.execute!
If your workflow uses an environment, you can specify the environment with the
env
keyword argument:
workflow.execute!(env: name)
Update a Workflow Execution
execution.patch(state: 'CANCELLED')
Update a Task
task.patch(state: 'RUNNING', reset: true)
Delete a Workflow
workflow.delete!
Validate a Workflow
client.workflow.valid?(definition)
You can also get validation error details:
client.workflow.validate(definition)
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run
rake
to run the tests. You can also run bin/console
for an interactive
prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To
release a new version, update the version number in version.rb
, and then run
bundle exec rake release
, which will create a git tag for the version, push
git commits and tags, and push the .gem
file
to rubygems.org.
To Record New VCR Cassettes
Recording new cassettes is as simple as ensuring you have a Mistral server
available at the LOCAL_MISTRAL_URL
defined in spec/spec_helper.rb
and
running rake
. To rerecord existing cassettes, simply remove the relevant
cassettes from spec/cassettes
and run rake
.
Contributing
See CONTRIBUTING.
License
MistralClient is released under the BSD 3-Clause License.