Sha256: 7c3cb06906feeb1e04f1c0aa4475bb9fe86c9efc3ae3647ba07a93b8a78016e3

Contents?: true

Size: 1.08 KB

Versions: 24

Compression:

Stored size: 1.08 KB

Contents

module ProxyAPI
  module ForemanDynflow
    class DynflowProxy
      PREFIX = 'dynflow'.freeze

      class Task < ProxyAPI::Resource
        def initialize(args)
          @url = "#{args[:url]}/#{PREFIX}/tasks"
          super args
          @connect_params[:headers] ||= {}
          @connect_params[:headers]['content-type'] = 'application/json'
        end
      end

      def initialize(args)
        @args = args
      end

      # Initiate the command
      def trigger_task(action_name, action_input)
        payload = MultiJson.dump(:action_name => action_name, :action_input => action_input)
        MultiJson.load(Task.new(@args).send(:post, payload))
      end

      # Cancel the command
      def cancel_task(proxy_task_id)
        MultiJson.load(Task.new(@args).send(:post, '', "#{proxy_task_id}/cancel"))
      end

      def status_of_task(proxy_task_id)
        MultiJson.load(Task.new(@args).send(:get, "#{proxy_task_id}/status"))
      end

      def tasks_count(state)
        MultiJson.load(Task.new(@args).send(:get, "count?state=#{state}"))['count'].to_i
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
foreman-tasks-0.11.3 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.13.0 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.12.2 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.11.2 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.12.1 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.12.0 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.11.1 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.10.9 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.11.0 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.10.8 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.10.7 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.10.6 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.10.4 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.9.6 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.10.3 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.10.2 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.10.1 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.9.5 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.10.0 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.9.4 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb