Class: MistralClient::Task

Inherits:
Base
  • Object
show all
Includes:
Mixins::MistralObject
Defined in:
lib/mistral_client/task.rb

Constant Summary collapse

UNICODE_FIELDS =
%w[
  workflow_id
  workflow_execution_id
  workflow_name
  state
  state_info
  result
  name
].freeze
JSON_FIELDS =
%w[published runtime_context].freeze
BOOL_FIELDS =
%w[reset processed].freeze
PATH =
'tasks'.freeze

Constants inherited from Base

Base::DATE_FIELDS

Instance Method Summary collapse

Methods included from Mixins::MistralObject

included, #ivars_from_response, #list, #reload

Constructor Details

#initialize(server, id: nil) ⇒ Task

Returns a new instance of Task.



22
23
24
25
26
27
28
# File 'lib/mistral_client/task.rb', line 22

def initialize(server, id: nil)
  super()
  @server = server
  @path = 'tasks'
  @id = id
  reload if id
end

Instance Method Details

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



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/mistral_client/task.rb', line 30

def patch(state: nil, reset: nil, env: nil)
  body = {}
  body[:state] = state if state
  body[:reset] = reset if reset
  body[:env] = env if env

  return if body.empty?

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