Class: TerraformEnterprise::CommandLine::Commands::PoliciesCommand

Inherits:
TerraformEnterprise::CommandLine::Command show all
Defined in:
lib/terraform_enterprise/command_line/commands/policies.rb

Constant Summary collapse

ATTR_STR =
STRINGS[:policies][:attributes]
CMD_STR =
STRINGS[:policies][:commands]

Constants included from TerraformEnterprise::CommandLine

STRINGS, VERSION

Instance Method Summary collapse

Methods included from Util::Tar

#gzip, #tar, #tarball

Instance Method Details

#create(name) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/terraform_enterprise/command_line/commands/policies.rb', line 20

def create(name)
  params = {
    name: name,
    organization: options[:organization],
    enforce: [
      {
        path: "#{name}.sentinel",
        mode: options[:mode]
      }
    ]
  }
  render client.policies.create(params)
end

#delete(id) ⇒ Object



58
59
60
# File 'lib/terraform_enterprise/command_line/commands/policies.rb', line 58

def delete(id)
  render client.policies.delete(id: id)
end

#get(id) ⇒ Object



53
54
55
# File 'lib/terraform_enterprise/command_line/commands/policies.rb', line 53

def get(id)
  render client.policies.get(id:id)
end

#listObject



13
14
15
# File 'lib/terraform_enterprise/command_line/commands/policies.rb', line 13

def list
  render client.policies.list(organization: options[:organization])
end

#update(id) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/terraform_enterprise/command_line/commands/policies.rb', line 36

def update(id)
  name = ''
  params = {
    id: id,
    name: name,
    enforce: [
      {
        path: 'default.sentinel',
        mode: options[:mode]
      }
    ]
  }

  render client.policies.update(params)
end

#upload(path, policy_id) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/terraform_enterprise/command_line/commands/policies.rb', line 63

def upload(path, policy_id)
  full_path = File.expand_path(path)
  content = File.read(full_path)

  params = { content: content, id: policy_id }

  render client.policies.upload(params)
end