Class: TerraformEnterprise::API::Workspaces

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

Overview

Workspace 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



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

def action(params = {})
  id     = params[:id]
  action = params[:action].to_sym
  @request.post(:workspaces, id, :actions, action)
end

#create(params = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/terraform_enterprise/api/resource_requests/workspaces.rb', line 17

def create(params = {})
  org = params.delete(:organization)
  data = {
    attributes: params,
    type: 'workspaces'
  }

  @request.post(:organizations, org, :workspaces, data: data)
end

#delete(params = {}) ⇒ Object



39
40
41
42
43
# File 'lib/terraform_enterprise/api/resource_requests/workspaces.rb', line 39

def delete(params = {})
  organization = params[:organization]
  workspace    = params[:workspace]
  @request.delete(:organizations, organization, :workspaces, workspace)
end

#get(params = {}) ⇒ Object



11
12
13
14
15
# File 'lib/terraform_enterprise/api/resource_requests/workspaces.rb', line 11

def get(params = {})
  organization = params[:organization]
  workspace    = params[:workspace]
  @request.get(:organizations, organization, :workspaces, workspace)
end

#list(params = {}) ⇒ Object



7
8
9
# File 'lib/terraform_enterprise/api/resource_requests/workspaces.rb', line 7

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

#update(params = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/terraform_enterprise/api/resource_requests/workspaces.rb', line 27

def update(params = {})
  org = params.delete(:organization)
  id  = params.delete(:workspace)

  data = {
    attributes: params,
    type: 'workspaces'
  }

  @request.patch(:organizations, org, :workspaces, id, data: data)
end