qtc-sdk 0.3.1 → 0.4.0

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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +18 -18
  3. data/Changelog.md +23 -18
  4. data/Gemfile +4 -4
  5. data/LICENSE.txt +22 -22
  6. data/README.md +44 -44
  7. data/Rakefile +1 -1
  8. data/bin/qtc-cli +13 -13
  9. data/lib/qtc-sdk.rb +1 -1
  10. data/lib/qtc/cli/commands.rb +15 -15
  11. data/lib/qtc/cli/common.rb +146 -146
  12. data/lib/qtc/cli/eds/base.rb +27 -27
  13. data/lib/qtc/cli/eds/commands.rb +20 -20
  14. data/lib/qtc/cli/eds/instances.rb +30 -30
  15. data/lib/qtc/cli/mar/apps.rb +116 -116
  16. data/lib/qtc/cli/mar/base.rb +60 -60
  17. data/lib/qtc/cli/mar/commands.rb +266 -221
  18. data/lib/qtc/cli/mar/debug.rb +88 -88
  19. data/lib/qtc/cli/mar/domains.rb +35 -35
  20. data/lib/qtc/cli/mar/env.rb +38 -38
  21. data/lib/qtc/cli/mar/repository.rb +24 -24
  22. data/lib/qtc/cli/mar/slugs.rb +80 -0
  23. data/lib/qtc/cli/mar/ssl_certificates.rb +40 -40
  24. data/lib/qtc/cli/mar/stack.rb +29 -29
  25. data/lib/qtc/cli/mdb/base.rb +47 -47
  26. data/lib/qtc/cli/mdb/commands.rb +43 -43
  27. data/lib/qtc/cli/mdb/instances.rb +79 -79
  28. data/lib/qtc/cli/platform/clouds.rb +33 -33
  29. data/lib/qtc/cli/platform/commands.rb +132 -132
  30. data/lib/qtc/cli/platform/datacenters.rb +23 -23
  31. data/lib/qtc/cli/platform/ssh_keys.rb +41 -41
  32. data/lib/qtc/cli/platform/user.rb +25 -25
  33. data/lib/qtc/cli/platform/vpn.rb +93 -93
  34. data/lib/qtc/client.rb +170 -170
  35. data/lib/qtc/eds/client.rb +116 -116
  36. data/lib/qtc/eds/collection.rb +124 -124
  37. data/lib/qtc/eds/user_collection.rb +13 -13
  38. data/lib/qtc/eds/usergroup_collection.rb +41 -41
  39. data/lib/qtc/errors.rb +13 -13
  40. data/lib/qtc/version.rb +3 -3
  41. data/qtc-sdk.gemspec +28 -28
  42. data/spec/unit/qtc/client_spec.rb +147 -147
  43. metadata +4 -3
@@ -1,33 +1,33 @@
1
- require 'qtc/client'
2
- require_relative '../common'
3
-
4
- module Qtc::Cli::Platform
5
- class Clouds
6
- include Qtc::Cli::Common
7
-
8
- def list
9
- accounts = platform_client.get('/user/accounts')
10
- template = '%-40.40s %-40.40s'
11
- puts template % ['ID', 'NAME']
12
- accounts['results'].each do |account|
13
- name = account['name']
14
- name = "* #{name}" if account['id'] == inifile['platform']['current_cloud']
15
- puts template % [account['id'], name]
16
- end
17
- end
18
-
19
- def use(id)
20
- account = platform_client.get("/accounts/#{id}")
21
- puts "Using cloud: #{account['name']} (#{id})"
22
- inifile['platform']['current_cloud'] = id
23
- inifile['platform']['current_dc'] = account['datacenter']['id']
24
- inifile.save(filename: ini_filename)
25
- end
26
-
27
- def create(name, opts)
28
- datacenter = opts.datacenter || 'eu-1'
29
- data = {name: name, datacenter: datacenter, vpc: opts.vpc}
30
- platform_client.post('/accounts', data)
31
- end
32
- end
33
- end
1
+ require 'qtc/client'
2
+ require_relative '../common'
3
+
4
+ module Qtc::Cli::Platform
5
+ class Clouds
6
+ include Qtc::Cli::Common
7
+
8
+ def list
9
+ accounts = platform_client.get('/user/accounts')
10
+ template = '%-40.40s %-40.40s'
11
+ puts template % ['ID', 'NAME']
12
+ accounts['results'].each do |account|
13
+ name = account['name']
14
+ name = "* #{name}" if account['id'] == inifile['platform']['current_cloud']
15
+ puts template % [account['id'], name]
16
+ end
17
+ end
18
+
19
+ def use(id)
20
+ account = platform_client.get("/accounts/#{id}")
21
+ puts "Using cloud: #{account['name']} (#{id})"
22
+ inifile['platform']['current_cloud'] = id
23
+ inifile['platform']['current_dc'] = account['datacenter']['id']
24
+ inifile.save(filename: ini_filename)
25
+ end
26
+
27
+ def create(name, opts)
28
+ datacenter = opts.datacenter || 'eu-1'
29
+ data = {name: name, datacenter: datacenter, vpc: opts.vpc}
30
+ platform_client.post('/accounts', data)
31
+ end
32
+ end
33
+ end
@@ -1,132 +1,132 @@
1
- module Qtc::Cli::Platform; end;
2
-
3
- require_relative 'datacenters'
4
- require_relative 'clouds'
5
- require_relative 'vpn'
6
- require_relative 'user'
7
- require_relative 'ssh_keys'
8
-
9
- command 'datacenters' do |c|
10
- c.syntax = 'qtc-cli datacenters'
11
- c.description = 'List all datacenters'
12
- c.action do |args, options|
13
- Qtc::Cli::Platform::Datacenters.new.list
14
- end
15
- end
16
-
17
- command 'clouds:list' do |c|
18
- c.syntax = 'qtc-cli clouds:list'
19
- c.description = 'List all clouds'
20
- c.action do |args, options|
21
- Qtc::Cli::Platform::Clouds.new.list
22
- end
23
- end
24
-
25
- command 'clouds:use' do |c|
26
- c.syntax = 'qtc-cli clouds:use <id>'
27
- c.description = 'Set default cloud to use'
28
- c.action do |args, options|
29
- Qtc::Cli::Platform::Clouds.new.use(args[0])
30
- end
31
- end
32
-
33
- command 'vpn:create' do |c|
34
- c.syntax = 'qtc-cli vpn:create'
35
- c.description = 'Create vpn connection'
36
- c.action do |args, options|
37
- Qtc::Cli::Platform::Vpn.new.create
38
- end
39
- end
40
-
41
- command 'vpn:show' do |c|
42
- c.syntax = 'qtc-cli vpn:show'
43
- c.description = 'Show vpn connection'
44
- c.action do |args, options|
45
- Qtc::Cli::Platform::Vpn.new.show
46
- end
47
- end
48
-
49
- command 'vpn:start' do |c|
50
- c.syntax = 'qtc-cli vpn:start'
51
- c.description = 'Start vpn server'
52
- c.action do |args, options|
53
- Qtc::Cli::Platform::Vpn.new.start
54
- end
55
- end
56
-
57
- command 'vpn:stop' do |c|
58
- c.syntax = 'qtc-cli vpn:stop'
59
- c.description = 'Stop vpn server'
60
- c.action do |args, options|
61
- Qtc::Cli::Platform::Vpn.new.stop
62
- end
63
- end
64
-
65
- command 'vpn:remove' do |c|
66
- c.syntax = 'qtc-cli vpn:remove'
67
- c.description = 'Remove vpn connection'
68
- c.action do |args, options|
69
- Qtc::Cli::Platform::Vpn.new.destroy
70
- end
71
- end
72
-
73
- command 'vpn:config' do |c|
74
- c.syntax = 'qtc-cli vpn:config'
75
- c.description = 'Show vpn configuration'
76
- c.action do |args, options|
77
- Qtc::Cli::Platform::Vpn.new.config
78
- end
79
- end
80
-
81
- command 'clouds:create' do |c|
82
- c.syntax = 'qtc-cli clouds:create name'
83
- c.description = 'Create a new cloud'
84
- c.option '--datacenter STRING', String, 'Specify datacenter for this cloud (default: eu-1)'
85
- c.option '--vpc', 'Enable virtual private cloud'
86
- c.action do |args, options|
87
- Qtc::Cli::Platform::Clouds.new.create(args.join(' '), options)
88
- end
89
- end
90
-
91
- command 'login' do |c|
92
- c.syntax = 'qtc-cli login'
93
- c.description = 'Login to Qt Cloud Services'
94
- c.action do |args, options|
95
- Qtc::Cli::Platform::User.new.login
96
- end
97
- end
98
-
99
- command 'logout' do |c|
100
- c.syntax = 'qtc-cli logout'
101
- c.description = 'Logout from Qt Cloud Services'
102
- c.action do |args, options|
103
- Qtc::Cli::Platform::User.new.logout
104
- end
105
- end
106
-
107
- command 'ssh-keys' do |c|
108
- c.syntax = 'qtc-cli ssh-keys'
109
- c.description = 'List ssh keys'
110
- c.action do |args, options|
111
- Qtc::Cli::Platform::SshKeys.new.list
112
- end
113
- end
114
-
115
- command 'ssh-keys:add' do |c|
116
- c.syntax = 'qtc-cli ssh-keys:add'
117
- c.description = 'Add ssh key'
118
- c.option '--name NAME', String, 'SSH key name'
119
- c.option '--key KEY', String, 'Path to SSH public key file'
120
- c.action do |args, options|
121
- Qtc::Cli::Platform::SshKeys.new.create(options)
122
- end
123
- end
124
-
125
- command 'ssh-keys:remove' do |c|
126
- c.syntax = 'qtc-cli ssh-keys:remove'
127
- c.description = 'Add ssh key'
128
- c.option '--name NAME', String, 'SSH key name'
129
- c.action do |args, options|
130
- Qtc::Cli::Platform::SshKeys.new.destroy(options)
131
- end
132
- end
1
+ module Qtc::Cli::Platform; end;
2
+
3
+ require_relative 'datacenters'
4
+ require_relative 'clouds'
5
+ require_relative 'vpn'
6
+ require_relative 'user'
7
+ require_relative 'ssh_keys'
8
+
9
+ command 'datacenters' do |c|
10
+ c.syntax = 'qtc-cli datacenters'
11
+ c.description = 'List all datacenters'
12
+ c.action do |args, options|
13
+ Qtc::Cli::Platform::Datacenters.new.list
14
+ end
15
+ end
16
+
17
+ command 'clouds:list' do |c|
18
+ c.syntax = 'qtc-cli clouds:list'
19
+ c.description = 'List all clouds'
20
+ c.action do |args, options|
21
+ Qtc::Cli::Platform::Clouds.new.list
22
+ end
23
+ end
24
+
25
+ command 'clouds:use' do |c|
26
+ c.syntax = 'qtc-cli clouds:use <id>'
27
+ c.description = 'Set default cloud to use'
28
+ c.action do |args, options|
29
+ Qtc::Cli::Platform::Clouds.new.use(args[0])
30
+ end
31
+ end
32
+
33
+ command 'vpn:create' do |c|
34
+ c.syntax = 'qtc-cli vpn:create'
35
+ c.description = 'Create vpn connection'
36
+ c.action do |args, options|
37
+ Qtc::Cli::Platform::Vpn.new.create
38
+ end
39
+ end
40
+
41
+ command 'vpn:show' do |c|
42
+ c.syntax = 'qtc-cli vpn:show'
43
+ c.description = 'Show vpn connection'
44
+ c.action do |args, options|
45
+ Qtc::Cli::Platform::Vpn.new.show
46
+ end
47
+ end
48
+
49
+ command 'vpn:start' do |c|
50
+ c.syntax = 'qtc-cli vpn:start'
51
+ c.description = 'Start vpn server'
52
+ c.action do |args, options|
53
+ Qtc::Cli::Platform::Vpn.new.start
54
+ end
55
+ end
56
+
57
+ command 'vpn:stop' do |c|
58
+ c.syntax = 'qtc-cli vpn:stop'
59
+ c.description = 'Stop vpn server'
60
+ c.action do |args, options|
61
+ Qtc::Cli::Platform::Vpn.new.stop
62
+ end
63
+ end
64
+
65
+ command 'vpn:remove' do |c|
66
+ c.syntax = 'qtc-cli vpn:remove'
67
+ c.description = 'Remove vpn connection'
68
+ c.action do |args, options|
69
+ Qtc::Cli::Platform::Vpn.new.destroy
70
+ end
71
+ end
72
+
73
+ command 'vpn:config' do |c|
74
+ c.syntax = 'qtc-cli vpn:config'
75
+ c.description = 'Show vpn configuration'
76
+ c.action do |args, options|
77
+ Qtc::Cli::Platform::Vpn.new.config
78
+ end
79
+ end
80
+
81
+ command 'clouds:create' do |c|
82
+ c.syntax = 'qtc-cli clouds:create name'
83
+ c.description = 'Create a new cloud'
84
+ c.option '--datacenter STRING', String, 'Specify datacenter for this cloud (default: eu-1)'
85
+ c.option '--vpc', 'Enable virtual private cloud'
86
+ c.action do |args, options|
87
+ Qtc::Cli::Platform::Clouds.new.create(args.join(' '), options)
88
+ end
89
+ end
90
+
91
+ command 'login' do |c|
92
+ c.syntax = 'qtc-cli login'
93
+ c.description = 'Login to Qt Cloud Services'
94
+ c.action do |args, options|
95
+ Qtc::Cli::Platform::User.new.login
96
+ end
97
+ end
98
+
99
+ command 'logout' do |c|
100
+ c.syntax = 'qtc-cli logout'
101
+ c.description = 'Logout from Qt Cloud Services'
102
+ c.action do |args, options|
103
+ Qtc::Cli::Platform::User.new.logout
104
+ end
105
+ end
106
+
107
+ command 'ssh-keys' do |c|
108
+ c.syntax = 'qtc-cli ssh-keys'
109
+ c.description = 'List ssh keys'
110
+ c.action do |args, options|
111
+ Qtc::Cli::Platform::SshKeys.new.list
112
+ end
113
+ end
114
+
115
+ command 'ssh-keys:add' do |c|
116
+ c.syntax = 'qtc-cli ssh-keys:add'
117
+ c.description = 'Add ssh key'
118
+ c.option '--name NAME', String, 'SSH key name'
119
+ c.option '--key KEY', String, 'Path to SSH public key file'
120
+ c.action do |args, options|
121
+ Qtc::Cli::Platform::SshKeys.new.create(options)
122
+ end
123
+ end
124
+
125
+ command 'ssh-keys:remove' do |c|
126
+ c.syntax = 'qtc-cli ssh-keys:remove'
127
+ c.description = 'Add ssh key'
128
+ c.option '--name NAME', String, 'SSH key name'
129
+ c.action do |args, options|
130
+ Qtc::Cli::Platform::SshKeys.new.destroy(options)
131
+ end
132
+ end
@@ -1,23 +1,23 @@
1
- require 'qtc/client'
2
- require_relative '../common'
3
-
4
- module Qtc::Cli::Platform
5
- class Datacenters
6
- include Qtc::Cli::Common
7
-
8
- def list
9
- datacenters = platform_client.get('/datacenters')
10
- inifile['datacenters'] = {}
11
-
12
- template = '%-20.20s %-40.40s'
13
- puts template % ['NAME', 'DESCRIPTION']
14
- datacenters['results'].each do |datacenter|
15
- datacenter['services'].each do |service|
16
- inifile['datacenters']["#{service['id']}-#{datacenter['id']}"] = service['url']
17
- end
18
- puts template % [datacenter['id'], datacenter['description']]
19
- end
20
- inifile.save(filename: ini_filename)
21
- end
22
- end
23
- end
1
+ require 'qtc/client'
2
+ require_relative '../common'
3
+
4
+ module Qtc::Cli::Platform
5
+ class Datacenters
6
+ include Qtc::Cli::Common
7
+
8
+ def list
9
+ datacenters = platform_client.get('/datacenters')
10
+ inifile['datacenters'] = {}
11
+
12
+ template = '%-20.20s %-40.40s'
13
+ puts template % ['NAME', 'DESCRIPTION']
14
+ datacenters['results'].each do |datacenter|
15
+ datacenter['services'].each do |service|
16
+ inifile['datacenters']["#{service['id']}-#{datacenter['id']}"] = service['url']
17
+ end
18
+ puts template % [datacenter['id'], datacenter['description']]
19
+ end
20
+ inifile.save(filename: ini_filename)
21
+ end
22
+ end
23
+ end
@@ -1,41 +1,41 @@
1
- require 'qtc/client'
2
- require_relative '../common'
3
-
4
- module Qtc::Cli::Platform
5
- class SshKeys
6
- include Qtc::Cli::Common
7
-
8
- def list
9
- response = platform_client.get('/user/ssh_keys')
10
- response['results'].each do |ssh_key|
11
- say "~ #{ssh_key['name']}"
12
- end
13
- end
14
-
15
- def create(options)
16
- raise ArgumentError.new('--name is required') if options.name.nil?
17
- raise ArgumentError.new('--key is required') if options.key.nil?
18
- unless File.exists?(options.key)
19
- raise ArgumentError.new("#{options.key} does not exist")
20
- end
21
-
22
- data = {
23
- name: options.name,
24
- key: File.read(options.key)
25
- }
26
-
27
- platform_client.post('/user/ssh_keys', data)
28
- end
29
-
30
- def destroy(options)
31
- raise ArgumentError.new('--name is required') if options.name.nil?
32
- response = platform_client.get('/user/ssh_keys')
33
- matches = response['results'].select{|r| r['name'] == options.name}
34
- if matches.size == 0
35
- raise ArgumentError.new("SSH key with name #{options.name} does not exist")
36
- else
37
- platform_client.delete("/user/ssh_keys/#{matches[0]['id']}")
38
- end
39
- end
40
- end
41
- end
1
+ require 'qtc/client'
2
+ require_relative '../common'
3
+
4
+ module Qtc::Cli::Platform
5
+ class SshKeys
6
+ include Qtc::Cli::Common
7
+
8
+ def list
9
+ response = platform_client.get('/user/ssh_keys')
10
+ response['results'].each do |ssh_key|
11
+ say "~ #{ssh_key['name']}"
12
+ end
13
+ end
14
+
15
+ def create(options)
16
+ raise ArgumentError.new('--name is required') if options.name.nil?
17
+ raise ArgumentError.new('--key is required') if options.key.nil?
18
+ unless File.exists?(options.key)
19
+ raise ArgumentError.new("#{options.key} does not exist")
20
+ end
21
+
22
+ data = {
23
+ name: options.name,
24
+ key: File.read(options.key)
25
+ }
26
+
27
+ platform_client.post('/user/ssh_keys', data)
28
+ end
29
+
30
+ def destroy(options)
31
+ raise ArgumentError.new('--name is required') if options.name.nil?
32
+ response = platform_client.get('/user/ssh_keys')
33
+ matches = response['results'].select{|r| r['name'] == options.name}
34
+ if matches.size == 0
35
+ raise ArgumentError.new("SSH key with name #{options.name} does not exist")
36
+ else
37
+ platform_client.delete("/user/ssh_keys/#{matches[0]['id']}")
38
+ end
39
+ end
40
+ end
41
+ end