terraform-enterprise-client 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +11 -53
  3. data/lib/terraform-enterprise-client.rb +1 -39
  4. data/lib/terraform-enterprise.rb +1 -0
  5. data/lib/terraform_enterprise.rb +2 -0
  6. data/lib/terraform_enterprise/api/client.rb +62 -0
  7. data/lib/terraform_enterprise/api/request.rb +97 -0
  8. data/lib/terraform_enterprise/api/resource.rb +48 -0
  9. data/lib/terraform_enterprise/api/resource_request.rb +12 -0
  10. data/lib/terraform_enterprise/api/resource_requests/configuration_versions.rb +28 -0
  11. data/lib/{terraform-enterprise/resource_requests/oauth-tokens.rb → terraform_enterprise/api/resource_requests/oauth_tokens.rb} +5 -4
  12. data/lib/{terraform-enterprise → terraform_enterprise/api}/resource_requests/organizations.rb +8 -7
  13. data/lib/terraform_enterprise/api/resource_requests/policies.rb +46 -0
  14. data/lib/terraform_enterprise/api/resource_requests/policy_checks.rb +18 -0
  15. data/lib/terraform_enterprise/api/resource_requests/runs.rb +53 -0
  16. data/lib/{terraform-enterprise → terraform_enterprise/api}/resource_requests/teams.rb +8 -8
  17. data/lib/terraform_enterprise/api/resource_requests/variables.rb +48 -0
  18. data/lib/terraform_enterprise/api/resource_requests/workspaces.rb +52 -0
  19. data/lib/terraform_enterprise/api/response.rb +39 -0
  20. data/lib/terraform_enterprise/api/version.rb +5 -0
  21. data/lib/terraform_enterprise_client.rb +1 -0
  22. metadata +24 -88
  23. data/bin/tfe +0 -4
  24. data/lib/terraform-enterprise-command-line.rb +0 -29
  25. data/lib/terraform-enterprise/client/request.rb +0 -82
  26. data/lib/terraform-enterprise/client/resource.rb +0 -19
  27. data/lib/terraform-enterprise/client/resource_request.rb +0 -10
  28. data/lib/terraform-enterprise/client/response.rb +0 -37
  29. data/lib/terraform-enterprise/commands/command.rb +0 -46
  30. data/lib/terraform-enterprise/commands/formatter.rb +0 -93
  31. data/lib/terraform-enterprise/commands/oauth_tokens_command.rb +0 -16
  32. data/lib/terraform-enterprise/commands/organizations_command.rb +0 -30
  33. data/lib/terraform-enterprise/commands/strings.rb +0 -79
  34. data/lib/terraform-enterprise/commands/teams_command.rb +0 -33
  35. data/lib/terraform-enterprise/commands/variables_command.rb +0 -61
  36. data/lib/terraform-enterprise/commands/workspaces_command.rb +0 -87
  37. data/lib/terraform-enterprise/resource_requests/variables.rb +0 -48
  38. data/lib/terraform-enterprise/resource_requests/workspaces.rb +0 -45
  39. data/lib/terraform-enterprise/version.rb +0 -3
@@ -1,33 +0,0 @@
1
- require 'terraform-enterprise/commands/command'
2
-
3
- module TerraformEnterprise
4
- module Commands
5
- class TeamsCommand < TerraformEnterprise::Commands::Command
6
- ATTR_STR = STRINGS[:teams][:attributes]
7
- CMD_STR = STRINGS[:teams][:commands]
8
-
9
- desc 'list', CMD_STR[:list]
10
- option :table, type: :boolean, default: true, desc: STRINGS[:options][:table]
11
- option :organization, required: true, type: :string, desc: ATTR_STR[:organization]
12
- def list
13
- render client.teams.list(organization: options[:organization]), except: [:permissions]
14
- end
15
-
16
- desc 'create <name>', CMD_STR[:create]
17
- option :organization, required: true, type: :string, desc: ATTR_STR[:organization]
18
- def create(name)
19
- render client.teams.create(name: name, organization: options[:organization])
20
- end
21
-
22
- desc 'get <id>', CMD_STR[:get]
23
- def get(id)
24
- render client.teams.get(id:id), except: [:permissions]
25
- end
26
-
27
- desc 'delete <id>', CMD_STR[:delete]
28
- def delete(id)
29
- render client.teams.delete(id: id), except: [:permissions]
30
- end
31
- end
32
- end
33
- end
@@ -1,61 +0,0 @@
1
- require 'terraform-enterprise/commands/command'
2
-
3
- module TerraformEnterprise
4
- module Commands
5
- class VariablesCommand < TerraformEnterprise::Commands::Command
6
- ATTR_STR = STRINGS[:variables][:attributes]
7
- CMD_STR = STRINGS[:variables][:commands]
8
-
9
- desc 'list', CMD_STR[:list]
10
- option :table, type: :boolean, default: true, desc: STRINGS[:options][:table]
11
- option :organization, required: true, type: :string, desc: ATTR_STR[:organization]
12
- option :workspace, type: :string, desc: ATTR_STR[:workspace]
13
- def list
14
- render client.variables.list(options)
15
- end
16
-
17
- desc 'create <key> <value>', CMD_STR[:create]
18
- option :organization, required: true, type: :string, desc: ATTR_STR[:organization]
19
- option :workspace, required: true, type: :string, desc: ATTR_STR[:workspace]
20
- option :category, default: 'terraform', type: :string, desc: ATTR_STR[:category]
21
- option :hcl, default: false, type: :boolean, desc: ATTR_STR[:hcl]
22
- option :sensitive, default: false, type: :boolean, desc: ATTR_STR[:sensitive]
23
- def create(key, value)
24
- params = {
25
- category: options[:category],
26
- hcl: options[:hcl],
27
- key: key,
28
- organization: options[:organization],
29
- sensitive: options[:sensitive],
30
- value: value,
31
- workspace: options[:workspace],
32
- }
33
- render client.variables.create(params)
34
- end
35
-
36
- desc 'update <id>', CMD_STR[:update]
37
- option :hcl, type: :boolean, desc: ATTR_STR[:hcl]
38
- option :sensitive, type: :boolean, desc: ATTR_STR[:sensitive]
39
- option :key, type: :string, desc: ATTR_STR[:key]
40
- option :value, type: :string, desc: ATTR_STR[:value]
41
- def update(id)
42
- params = {id: id}
43
- params[:hcl] = options[:hcl] if options.include?('hcl')
44
- params[:key] = options[:key] if options[:key]
45
- params[:sensitive] = options[:sensitive] if options.include?('sensitive')
46
- params[:value] = options[:value] if options[:value]
47
- render client.variables.update(params)
48
- end
49
-
50
- desc 'get <id>', CMD_STR[:get]
51
- def get(id)
52
- render client.variables.get(id:id)
53
- end
54
-
55
- desc 'delete <id>', CMD_STR[:delete]
56
- def delete(id)
57
- render client.variables.delete(id: id)
58
- end
59
- end
60
- end
61
- end
@@ -1,87 +0,0 @@
1
- require 'terraform-enterprise/commands/command'
2
-
3
- module TerraformEnterprise
4
- module Commands
5
- class WorkspacesCommand < TerraformEnterprise::Commands::Command
6
- ATTR_STR = STRINGS[:workspaces][:attributes]
7
- CMD_STR = STRINGS[:workspaces][:commands]
8
-
9
- desc 'list', CMD_STR[:list]
10
- option :organization, required: true, type: :string, desc: ATTR_STR[:organization]
11
- option :table, type: :boolean, default: true, desc: STRINGS[:options][:table]
12
- def list
13
- render client.workspaces.list(options), except:[:permissions, :actions, :environment, 'created-at']
14
- end
15
-
16
- desc 'create <name>', CMD_STR[:create]
17
- option :terraform_version, type: :string, desc: ATTR_STR[:terraform_version]
18
- option :working_directory, type: :string, desc: ATTR_STR[:working_directory]
19
- option :oauth_token, type: :string, desc: ATTR_STR[:oauth_token]
20
- option :branch, type: :string, desc: ATTR_STR[:branch]
21
- option :ingress_submodules, type: :boolean, desc: ATTR_STR[:ingress_submodules]
22
- option :repo, type: :string, desc: ATTR_STR[:repos]
23
- option :import_legacy_environment, type: :string, desc: ATTR_STR[:import_legacy]
24
- option :organization, required: true, type: :string, desc: ATTR_STR[:organization]
25
- def create(name)
26
- params = {
27
- organization: options[:organization],
28
- name: name,
29
- 'working-directory' => options[:working_directory] || '',
30
- }
31
- if options[:repo] && options[:oauth_token]
32
- repo = {}
33
- repo['branch'] = options[:branch] || ''
34
- repo['identifier'] = options[:repo]
35
- repo['oauth-token-id'] = options[:oauth_token]
36
- repo['ingress-submodules'] = options[:ingress_submodules] || false
37
- params['vcs-repo'] = repo
38
- end
39
-
40
- params['migration-environment'] = options[:import_legacy_environment] if options[:import_legacy_environment]
41
- params['terraform_version'] = options[:terraform_version] if options[:terraform_version]
42
- render client.workspaces.create(params), except:[:permissions, :actions, :environment]
43
- end
44
-
45
- desc 'get <name>', CMD_STR[:get]
46
- option :organization, required: true, type: :string, desc: ATTR_STR[:organization]
47
- def get(name)
48
- params = {
49
- organization: options[:organization],
50
- workspace: name
51
- }
52
- render client.workspaces.get(params), except:[:permissions, :actions, :environment]
53
- end
54
-
55
- desc 'delete <name>', CMD_STR[:delete]
56
- option :organization, required: true, type: :string, desc: ATTR_STR[:organization]
57
- def delete(name)
58
- params = {
59
- organization: options[:organization],
60
- workspace: name
61
- }
62
- render client.workspaces.delete(params), except:[:permissions, :actions, :environment]
63
- end
64
-
65
- desc 'update <name>', CMD_STR[:update]
66
- option :working_directory, type: :string, desc: ATTR_STR[:working_directory]
67
- option :terraform_version, type: :string, desc: ATTR_STR[:terraform_version]
68
- option :auto_apply, type: :boolean, desc: ATTR_STR[:auto_apply]
69
- option :organization, required: true, type: :string, desc: ATTR_STR[:organization]
70
- def update(name)
71
- params = options
72
- params[:workspace] = name
73
- render client.workspaces.update(params), except:[:permissions, :actions, :environment]
74
- end
75
-
76
- desc 'lock <id>', CMD_STR[:lock]
77
- def lock(id)
78
- render client.workspaces.action(action: :lock, id: id), except:[:permissions, :actions, :environment]
79
- end
80
-
81
- desc 'unlock <id>', CMD_STR[:unlock]
82
- def unlock(id)
83
- render client.workspaces.action(action: :unlock, id: id), except:[:permissions, :actions, :environment]
84
- end
85
- end
86
- end
87
- end
@@ -1,48 +0,0 @@
1
- require "terraform-enterprise/client/resource_request"
2
-
3
- module TerraformEnterprise
4
- module API
5
- class Variables < TerraformEnterprise::API::ResourceRequest
6
-
7
- def list(params={})
8
- filter = {}
9
- filter[:workspace] = {name: params[:workspace]} if params[:workspace]
10
- filter[:organization] = {name: params[:organization]} if params[:organization]
11
- @request.get(:vars, {filter:filter})
12
- end
13
-
14
- def get(params={})
15
- @request.get(:vars, params[:id])
16
- end
17
-
18
- def create(params={})
19
- org = params.delete(:organization)
20
- workspace = params.delete(:workspace)
21
- data = {
22
- attributes: params,
23
- type: 'vars',
24
- }
25
- filter = {
26
- organization: {name: org},
27
- workspace: {name: workspace}
28
- }
29
-
30
- @request.post(:vars, {data: data, filter: filter})
31
- end
32
-
33
- def update(params={})
34
- id = params.delete(:id)
35
- data = {
36
- attributes: params,
37
- type: 'vars',
38
- }
39
-
40
- @request.patch(:vars, id, data: data)
41
- end
42
-
43
- def delete(params={})
44
- @request.delete(:vars, params[:id])
45
- end
46
- end
47
- end
48
- end
@@ -1,45 +0,0 @@
1
- require "terraform-enterprise/client/resource_request"
2
-
3
- module TerraformEnterprise
4
- module API
5
- class Workspaces < TerraformEnterprise::API::ResourceRequest
6
- def list(params={})
7
- @request.get(:organizations, params[:organization], :workspaces)
8
- end
9
-
10
- def get(params={})
11
- @request.get(:organizations, params[:organization], :workspaces, params[:workspace])
12
- end
13
-
14
- def create(params={})
15
- org = params.delete(:organization)
16
- data = {
17
- attributes: params,
18
- type: 'workspaces'
19
- }
20
-
21
- @request.post(:organizations, org, :workspaces, data: data)
22
- end
23
-
24
- def update(params={})
25
- org = params.delete(:organization)
26
- id = params.delete(:workspace)
27
-
28
- data = {
29
- attributes: params,
30
- type: 'workspaces'
31
- }
32
-
33
- @request.patch(:organizations, org, :workspaces, id, data: data)
34
- end
35
-
36
- def delete(params={})
37
- @request.delete(:organizations, params[:organization], :workspaces, params[:workspace])
38
- end
39
-
40
- def action(params={})
41
- @request.post(:workspaces, params[:id], :actions, params[:action].to_sym)
42
- end
43
- end
44
- end
45
- end
@@ -1,3 +0,0 @@
1
- module TerraformEnterprise
2
- VERSION = "0.0.6"
3
- end