Sha256: 18c07ff9dea431bd269c1c3baecde7fc9ffdbc3c54b5cad1eb67be416c2f1427

Contents?: true

Size: 1.08 KB

Versions: 23

Compression:

Stored size: 1.08 KB

Contents

module ProxyAPI
  module ForemanDynflow
    class DynflowProxy
      PREFIX = 'dynflow'

      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

23 entries across 23 versions & 1 rubygems

Version Path
foreman-tasks-0.8.6 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.8.5 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.8.4 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.8.3 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.8.2 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.8.1 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.8.0 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.20 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.19 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.18 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.17 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.16 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.15 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.14 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.13 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.12 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.11 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.10 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.9 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
foreman-tasks-0.7.8 app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb