Sha256: 065f56abb09198217a7c29a59876b133d640e6315cefd649e92dcb846a2f4930

Contents?: true

Size: 831 Bytes

Versions: 5

Compression:

Stored size: 831 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)
      @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

5 entries across 5 versions & 1 rubygems

Version Path
mistral_client-1.3.0 lib/mistral_client/task.rb
mistral_client-1.2.1 lib/mistral_client/task.rb
mistral_client-1.2.0 lib/mistral_client/task.rb
mistral_client-1.1.0 lib/mistral_client/task.rb
mistral_client-1.0.0 lib/mistral_client/task.rb