class MistralClient::Workflow
Constants
- BOOL_FIELDS
- JSON_FIELDS
- PATH
- UNICODE_FIELDS
Public Class Methods
new(server, definition = nil, id: nil, name: nil)
click to toggle source
Calls superclass method
# File lib/mistral_client/workflow.rb, line 13 def initialize(server, definition = nil, id: nil, name: nil) super() @server = server if definition @definition = parse_definition(definition) create_workflow elsif id || name @id = id || name reload end end
Public Instance Methods
execute!(env: nil, task_name: nil, input: nil)
click to toggle source
# File lib/mistral_client/workflow.rb, line 25 def execute!(env: nil, task_name: nil, input: nil) Execution.new(@server, workflow_id: @id, env: env, task_name: task_name, input: input) end
valid?(definition)
click to toggle source
# File lib/mistral_client/workflow.rb, line 33 def valid?(definition) resp = perform_validation(definition) resp['valid'] end
validate(definition)
click to toggle source
# File lib/mistral_client/workflow.rb, line 38 def validate(definition) resp = perform_validation(definition) resp['error']&.split("\n")&.first end
Private Instance Methods
create_workflow()
click to toggle source
# File lib/mistral_client/workflow.rb, line 45 def create_workflow resp = @server.post(PATH, @definition) if resp['workflows'].length > 1 raise ConfigurationError, 'Only one workflow per definition is supported' end ivars_from_response(resp['workflows'][0]) end
perform_validation(definition)
click to toggle source
# File lib/mistral_client/workflow.rb, line 54 def perform_validation(definition) @server.post("#{PATH}/validate", parse_definition(definition)) end