Sha256: c738dfc06b2a41c16168414a01db7dbd3ca38b7543b636c7e54c66f1dfcd695b

Contents?: true

Size: 891 Bytes

Versions: 71

Compression:

Stored size: 891 Bytes

Contents

class Terraspace::Terraform::Api
  class Runs < Base
    extend Memoist

    attr_reader :workspace_id
    def initialize(workspace_id)
      @workspace_id = workspace_id
    end

    def list
      data, next_page = [], :start
      while next_page == :start || next_page
        url = "workspaces/#{@workspace_id}/runs"
        if next_page
          qs = URI.encode_www_form('page[number]': next_page) if next_page
          url += "?#{qs}"
        end
        payload = http.get(url)
        return unless payload
        data += payload['data']
        next_page = payload['meta']['pagination']['next-page']
      end
      data
    end

    def discard(id)
      action("discard", id)
    end

    def cancel(id)
      action("cancel", id)
    end

    def action(action, id)
      payload = http.post("runs/#{id}/actions/#{action}")
      payload['data'] if payload
    end
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
terraspace-2.1.5 lib/terraspace/terraform/api/runs.rb
terraspace-2.1.4 lib/terraspace/terraform/api/runs.rb
terraspace-2.1.3 lib/terraspace/terraform/api/runs.rb
terraspace-2.1.2 lib/terraspace/terraform/api/runs.rb
terraspace-2.1.1 lib/terraspace/terraform/api/runs.rb
terraspace-2.1.0 lib/terraspace/terraform/api/runs.rb
terraspace-2.0.3 lib/terraspace/terraform/api/runs.rb
terraspace-2.0.2 lib/terraspace/terraform/api/runs.rb
terraspace-2.0.1 lib/terraspace/terraform/api/runs.rb
terraspace-2.0.0 lib/terraspace/terraform/api/runs.rb
terraspace-1.1.7 lib/terraspace/terraform/api/runs.rb
terraspace-1.1.6 lib/terraspace/terraform/api/runs.rb
terraspace-1.1.5 lib/terraspace/terraform/api/runs.rb
terraspace-1.1.4 lib/terraspace/terraform/api/runs.rb
terraspace-1.1.3 lib/terraspace/terraform/api/runs.rb
terraspace-1.1.2 lib/terraspace/terraform/api/runs.rb
terraspace-1.1.1 lib/terraspace/terraform/api/runs.rb
terraspace-1.1.0 lib/terraspace/terraform/api/runs.rb
terraspace-1.0.6 lib/terraspace/terraform/api/runs.rb
terraspace-1.0.5 lib/terraspace/terraform/api/runs.rb