Sha256: 338e6ee8d90949564d762b38bb913dfc267362e03fc251e850b67d1a8b048eaa

Contents?: true

Size: 845 Bytes

Versions: 2

Compression:

Stored size: 845 Bytes

Contents

require 'uri'

module MistralClient
  class Task < Base
    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

    include MistralClient::Mixins::MistralObject

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

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mistral_client-3.0.0 lib/mistral_client/task.rb
mistral_client-2.0.0 lib/mistral_client/task.rb