qtc-sdk 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +18 -18
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/Changelog.md +28 -23
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +42 -44
- data/Rakefile +1 -1
- data/bin/qtc-cli +13 -13
- data/lib/qtc-sdk.rb +1 -1
- data/lib/qtc/cli/commands.rb +15 -15
- data/lib/qtc/cli/common.rb +146 -146
- data/lib/qtc/cli/eds/base.rb +27 -27
- data/lib/qtc/cli/eds/commands.rb +20 -20
- data/lib/qtc/cli/eds/instances.rb +30 -30
- data/lib/qtc/cli/mar/apps.rb +116 -116
- data/lib/qtc/cli/mar/base.rb +60 -60
- data/lib/qtc/cli/mar/commands.rb +268 -266
- data/lib/qtc/cli/mar/debug.rb +94 -88
- data/lib/qtc/cli/mar/domains.rb +35 -35
- data/lib/qtc/cli/mar/env.rb +38 -38
- data/lib/qtc/cli/mar/repository.rb +24 -24
- data/lib/qtc/cli/mar/slugs.rb +80 -80
- data/lib/qtc/cli/mar/ssl_certificates.rb +40 -40
- data/lib/qtc/cli/mar/stack.rb +29 -29
- data/lib/qtc/cli/mdb/base.rb +47 -47
- data/lib/qtc/cli/mdb/commands.rb +43 -43
- data/lib/qtc/cli/mdb/instances.rb +79 -79
- data/lib/qtc/cli/platform/clouds.rb +33 -33
- data/lib/qtc/cli/platform/commands.rb +133 -132
- data/lib/qtc/cli/platform/datacenters.rb +23 -23
- data/lib/qtc/cli/platform/ssh_keys.rb +41 -41
- data/lib/qtc/cli/platform/user.rb +29 -25
- data/lib/qtc/cli/platform/vpn.rb +93 -93
- data/lib/qtc/client.rb +170 -170
- data/lib/qtc/eds/client.rb +116 -116
- data/lib/qtc/eds/collection.rb +124 -124
- data/lib/qtc/eds/user_collection.rb +13 -13
- data/lib/qtc/eds/usergroup_collection.rb +41 -41
- data/lib/qtc/errors.rb +13 -13
- data/lib/qtc/version.rb +3 -3
- data/qtc-sdk.gemspec +28 -28
- data/spec/spec_helper.rb +17 -0
- data/spec/unit/qtc/client_spec.rb +147 -147
- metadata +5 -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,133 @@
|
|
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.
|
95
|
-
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
c.
|
102
|
-
c.
|
103
|
-
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
c.
|
110
|
-
c.
|
111
|
-
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
c.
|
118
|
-
c.
|
119
|
-
c.option '--
|
120
|
-
c.
|
121
|
-
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
c.
|
128
|
-
c.
|
129
|
-
c.
|
130
|
-
|
131
|
-
|
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.option '--token STRING', String, 'Personal access token'
|
95
|
+
c.action do |args, options|
|
96
|
+
Qtc::Cli::Platform::User.new.login(options)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
command 'logout' do |c|
|
101
|
+
c.syntax = 'qtc-cli logout'
|
102
|
+
c.description = 'Logout from Qt Cloud Services'
|
103
|
+
c.action do |args, options|
|
104
|
+
Qtc::Cli::Platform::User.new.logout
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
command 'ssh-keys' do |c|
|
109
|
+
c.syntax = 'qtc-cli ssh-keys'
|
110
|
+
c.description = 'List ssh keys'
|
111
|
+
c.action do |args, options|
|
112
|
+
Qtc::Cli::Platform::SshKeys.new.list
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
command 'ssh-keys:add' do |c|
|
117
|
+
c.syntax = 'qtc-cli ssh-keys:add'
|
118
|
+
c.description = 'Add ssh key'
|
119
|
+
c.option '--name NAME', String, 'SSH key name'
|
120
|
+
c.option '--key KEY', String, 'Path to SSH public key file'
|
121
|
+
c.action do |args, options|
|
122
|
+
Qtc::Cli::Platform::SshKeys.new.create(options)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
command 'ssh-keys:remove' do |c|
|
127
|
+
c.syntax = 'qtc-cli ssh-keys:remove'
|
128
|
+
c.description = 'Add ssh key'
|
129
|
+
c.option '--name NAME', String, 'SSH key name'
|
130
|
+
c.action do |args, options|
|
131
|
+
Qtc::Cli::Platform::SshKeys.new.destroy(options)
|
132
|
+
end
|
133
|
+
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
|