Class: TerraformEnterprise::API::Runs

Inherits:
ResourceRequest show all
Defined in:
lib/terraform_enterprise/api/resource_requests/runs.rb

Overview

Variables resource request

Instance Method Summary collapse

Methods inherited from ResourceRequest

#initialize

Constructor Details

This class inherits a constructor from TerraformEnterprise::API::ResourceRequest

Instance Method Details

#action(params = {}) ⇒ Object



46
47
48
49
50
# File 'lib/terraform_enterprise/api/resource_requests/runs.rb', line 46

def action(params = {})
  id     = params.delete(:id)
  action = params.delete(:action).to_sym
  @request.post(:runs, id, :actions, action, params)
end

#create(params = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/terraform_enterprise/api/resource_requests/runs.rb', line 13

def create(params = {})
  data = {
    attributes: {
      'is-destroy' => params[:destroy] || false
    },
    relationships: {
      workspace: {
        data: {
          type: 'workspaces',
          id: params[:workspace_id]
        }
      }
    },
    type: 'runs'
  }

  if params[:configuration_version_id]
    data[:relationships]['configuration-version'] = {
      data: {
        type: 'configuration-version',
        id: params[:configuration_version_id]
      }
    }
  end

  @request.post(:runs, data: data)
end

#get(params = {}) ⇒ Object



41
42
43
44
# File 'lib/terraform_enterprise/api/resource_requests/runs.rb', line 41

def get(params = {})
  id = params.delete(:id)
  @request.get(:runs, id, params)
end

#list(params = {}) ⇒ Object



9
10
11
# File 'lib/terraform_enterprise/api/resource_requests/runs.rb', line 9

def list(params = {})
  @request.get(:workspaces, params[:id], :runs)
end