Class: MistralClient::Execution

Inherits:
Base
  • Object
show all
Includes:
Mixins::Definable, Mixins::Deletable, Mixins::MistralObject
Defined in:
lib/mistral_client/execution.rb

Constant Summary collapse

UNICODE_FIELDS =
%w[
  workflow_id
  workflow_name
  description
  state
  state_info
].freeze
DATE_FIELDS =
%w[created_at updated_at].freeze
JSON_FIELDS =
%w[input output params].freeze
BOOL_FIELDS =
[].freeze
PATH =
'executions'.freeze

Instance Method Summary collapse

Methods included from Mixins::Deletable

#delete!

Methods included from Mixins::Definable

#parse_definition

Methods included from Mixins::MistralObject

included, #ivars_from_response, #list, #reload

Constructor Details

#initialize(server, workflow_id: nil, env: nil, task_name: nil, id: nil, input: nil) ⇒ Execution

rubocop:disable Metrics/ParameterLists



22
23
24
25
26
27
28
29
30
31
# 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

Instance Method Details

#patch(description: nil, state: nil, env: nil) ⇒ Object

rubocop:enable Metrics/ParameterLists



34
35
36
37
38
39
40
41
42
43
44
# 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