class MistralClient::Execution

Constants

BOOL_FIELDS
DATE_FIELDS
JSON_FIELDS
PATH
UNICODE_FIELDS

Public Class Methods

new(server, workflow_id: nil, env: nil, task_name: nil, id: nil, input: nil) click to toggle source

rubocop:disable Metrics/ParameterLists

Calls superclass method
# File lib/mistral_client/execution.rb, line 22
def initialize(server, workflow_id: nil, env: nil, task_name: nil,
               id: nil, input: nil)
  super()
  set_attributes(server, workflow_id, env, task_name, id, input)
  if @id
    reload
  elsif @workflow_id
    create_execution
  end
end

Public Instance Methods

patch(description: nil, state: nil, env: nil) click to toggle source

rubocop:enable Metrics/ParameterLists

# File lib/mistral_client/execution.rb, line 34
def patch(description: nil, state: nil, env: nil)
  body = {}
  body[:description] = description unless description.nil?
  body[:state] = state if state
  body[:params] = { env: env } if env

  return if body.empty?

  resp = @server.put("#{PATH}/#{@id}", body.to_json, json: true)
  ivars_from_response(resp)
end

Private Instance Methods

create_execution() click to toggle source

rubocop:enable Metrics/ParameterLists

# File lib/mistral_client/execution.rb, line 59
def create_execution
  body = { workflow_id: @workflow_id }
  params = {}
  params[:env] = @env if @env
  params[:task_name] = @task_name if @task_name
  body[:params] = params unless params.empty?
  body[:input] = input unless input.nil?

  resp = @server.post(PATH, body.to_json, json: true)
  ivars_from_response(resp)
end
set_attributes(server, workflow_id, env, task_name, id, input) click to toggle source

rubocop:disable Metrics/ParameterLists

# File lib/mistral_client/execution.rb, line 49
def set_attributes(server, workflow_id, env, task_name, id, input)
  @server = server
  @env = env
  @task_name = task_name
  @id = id
  @workflow_id = workflow_id
  @input = input
end