qtc-sdk 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qtc/cli/commands.rb +1 -25
- data/lib/qtc/cli/mar/commands.rb +21 -0
- data/lib/qtc/cli/mar/repository.rb +26 -0
- data/lib/qtc/cli/mar/ssl_certificates.rb +4 -4
- data/lib/qtc/cli/platform/clouds.rb +32 -0
- data/lib/qtc/cli/platform/commands.rb +57 -0
- data/lib/qtc/cli/platform/ssh_keys.rb +41 -0
- data/lib/qtc/cli/platform/user.rb +25 -0
- data/lib/qtc/version.rb +1 -1
- metadata +7 -3
- data/lib/qtc/cli/clouds.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4fa5b0dcf5a632850cb3a7d9db9cb5e4be9b094
|
4
|
+
data.tar.gz: 3d7ef952957e86962c1a156e37ed483f38115b8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6597366aa9a0aa4109131955639194a0e99eafbb2a355bdebe3a924666d8920731a9a65b0f061c13e3b35f7bf3352b688ff7c624deb3d9381c59eddd9c25cec
|
7
|
+
data.tar.gz: e90fab57614d8dba935174cbe6326429900c46b1056f38085fae048ccdc7f40edbdf444fc750f905373526f9dd1f9bc442accb39540914d508d28b65713fad17
|
data/lib/qtc/cli/commands.rb
CHANGED
@@ -7,30 +7,6 @@ program :description, 'Command line interface for Qt Cloud Services'
|
|
7
7
|
default_command :help
|
8
8
|
never_trace!
|
9
9
|
|
10
|
-
require_relative '
|
11
|
-
command 'clouds' do |c|
|
12
|
-
c.syntax = 'qtc-cli clouds'
|
13
|
-
c.description = 'List all clouds'
|
14
|
-
c.action do |args, options|
|
15
|
-
Qtc::Cli::Clouds.new.list
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
command 'login' do |c|
|
20
|
-
c.syntax = 'qtc-cli login'
|
21
|
-
c.description = 'Login to Qt Cloud Services'
|
22
|
-
c.action do |args, options|
|
23
|
-
Qtc::Cli::Clouds.new.login
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
command 'logout' do |c|
|
28
|
-
c.syntax = 'qtc-cli logout'
|
29
|
-
c.description = 'Logout from Qt Cloud Services'
|
30
|
-
c.action do |args, options|
|
31
|
-
Qtc::Cli::Clouds.new.logout
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
10
|
+
require_relative 'platform/commands'
|
35
11
|
require_relative 'eds/commands'
|
36
12
|
require_relative 'mar/commands'
|
data/lib/qtc/cli/mar/commands.rb
CHANGED
@@ -2,6 +2,7 @@ require_relative 'apps'
|
|
2
2
|
require_relative 'domains'
|
3
3
|
require_relative 'ssl_certificates'
|
4
4
|
require_relative 'env'
|
5
|
+
require_relative 'repository'
|
5
6
|
|
6
7
|
command 'mar list' do |c|
|
7
8
|
c.syntax = 'qtc-cli mar list'
|
@@ -145,3 +146,23 @@ command 'mar ssl:remove' do |c|
|
|
145
146
|
Qtc::Cli::Mar::SslCertificates.new.destroy(options)
|
146
147
|
end
|
147
148
|
end
|
149
|
+
|
150
|
+
command 'mar repo:purge_cache' do |c|
|
151
|
+
c.syntax = 'qtc-cli mar repo:purge_cache'
|
152
|
+
c.description = 'Delete remote repository build cache contents'
|
153
|
+
c.option '--app APP', String, 'App instance id'
|
154
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
155
|
+
c.action do |args, options|
|
156
|
+
Qtc::Cli::Mar::Repository.new.purge_cache(options)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
command 'mar repo:reset' do |c|
|
161
|
+
c.syntax = 'qtc-cli mar repo:reset'
|
162
|
+
c.description = 'Reset remote git repository'
|
163
|
+
c.option '--app APP', String, 'App instance id'
|
164
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
165
|
+
c.action do |args, options|
|
166
|
+
Qtc::Cli::Mar::Repository.new.reset(options)
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module Qtc
|
4
|
+
module Cli
|
5
|
+
class Mar::Repository < Mar::Base
|
6
|
+
|
7
|
+
def purge_cache(options)
|
8
|
+
instance_id = resolve_instance_id(options)
|
9
|
+
instance_data = instance_info(instance_id)
|
10
|
+
if instance_data
|
11
|
+
token = instance_data['authorizations'][0]['access_token']
|
12
|
+
client.delete("/apps/#{instance_id}/build_cache", nil, {}, {'Authorization' => "Bearer #{token}"})
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def reset(options)
|
17
|
+
instance_id = resolve_instance_id(options)
|
18
|
+
instance_data = instance_info(instance_id)
|
19
|
+
if instance_data
|
20
|
+
token = instance_data['authorizations'][0]['access_token']
|
21
|
+
client.delete("/apps/#{instance_id}/repository", nil, {}, {'Authorization' => "Bearer #{token}"})
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -7,8 +7,8 @@ module Qtc
|
|
7
7
|
|
8
8
|
|
9
9
|
def create(options)
|
10
|
-
raise ArgumentError.new("--key=#{
|
11
|
-
raise ArgumentError.new("--cert=#{
|
10
|
+
raise ArgumentError.new("--key=#{options.key} is not a file") unless File.exists?(File.expand_path(options.key))
|
11
|
+
raise ArgumentError.new("--cert=#{options.cert} is not a file") unless File.exists?(File.expand_path(options.cert))
|
12
12
|
|
13
13
|
instance_id = resolve_instance_id(options)
|
14
14
|
instance_data = instance_info(instance_id)
|
@@ -16,8 +16,8 @@ module Qtc
|
|
16
16
|
token = instance_data['authorizations'][0]['access_token']
|
17
17
|
data = {
|
18
18
|
name: instance_id,
|
19
|
-
privateKey: File.read(
|
20
|
-
certificateBody: File.read(
|
19
|
+
privateKey: File.read(File.expand_path(options.key)),
|
20
|
+
certificateBody: File.read(File.expand_path(options.cert))
|
21
21
|
}
|
22
22
|
client.post("/apps/#{instance_id}/ssl_certificate", data, {}, {'Authorization' => "Bearer #{token}"})
|
23
23
|
end
|
@@ -0,0 +1,32 @@
|
|
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
|
+
accounts['results'].each do |account|
|
11
|
+
print color("~ #{account['name']} (#{account['id']})", :bold)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def login
|
16
|
+
pass = password("Personal Access Token (copy from https://console.qtcloudservices.com/#/user/profile):")
|
17
|
+
inifile['platform']['token'] = pass
|
18
|
+
|
19
|
+
response = platform_client(pass).get('/user/accounts', {}) rescue nil
|
20
|
+
if response
|
21
|
+
inifile.save(filename: ini_filename)
|
22
|
+
else
|
23
|
+
print color('Invalid Personal Access Token', :red)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def logout
|
28
|
+
inifile['platform'].delete('token')
|
29
|
+
inifile.save(filename: ini_filename)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative 'clouds'
|
2
|
+
require_relative 'user'
|
3
|
+
require_relative 'ssh_keys'
|
4
|
+
|
5
|
+
module Qtc::Cli::Platform
|
6
|
+
end
|
7
|
+
|
8
|
+
command 'clouds' do |c|
|
9
|
+
c.syntax = 'qtc-cli clouds'
|
10
|
+
c.description = 'List all clouds'
|
11
|
+
c.action do |args, options|
|
12
|
+
Qtc::Cli::Platform::Clouds.new.list
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
command 'login' do |c|
|
17
|
+
c.syntax = 'qtc-cli login'
|
18
|
+
c.description = 'Login to Qt Cloud Services'
|
19
|
+
c.action do |args, options|
|
20
|
+
Qtc::Cli::Platform::User.new.login
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
command 'logout' do |c|
|
25
|
+
c.syntax = 'qtc-cli logout'
|
26
|
+
c.description = 'Logout from Qt Cloud Services'
|
27
|
+
c.action do |args, options|
|
28
|
+
Qtc::Cli::Platform::User.new.logout
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
command 'ssh-keys' do |c|
|
33
|
+
c.syntax = 'qtc-cli ssh-keys'
|
34
|
+
c.description = 'List ssh keys'
|
35
|
+
c.action do |args, options|
|
36
|
+
Qtc::Cli::Platform::SshKeys.new.list
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
command 'ssh-keys:add' do |c|
|
41
|
+
c.syntax = 'qtc-cli ssh-keys:add'
|
42
|
+
c.description = 'Add ssh key'
|
43
|
+
c.option '--name NAME', String, 'SSH key name'
|
44
|
+
c.option '--key KEY', String, 'Path to SSH public key file'
|
45
|
+
c.action do |args, options|
|
46
|
+
Qtc::Cli::Platform::SshKeys.new.create(options)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
command 'ssh-keys:remove' do |c|
|
51
|
+
c.syntax = 'qtc-cli ssh-keys:remove'
|
52
|
+
c.description = 'Add ssh key'
|
53
|
+
c.option '--name NAME', String, 'SSH key name'
|
54
|
+
c.action do |args, options|
|
55
|
+
Qtc::Cli::Platform::SshKeys.new.destroy(options)
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +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
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'qtc/client'
|
2
|
+
require_relative '../common'
|
3
|
+
|
4
|
+
module Qtc::Cli:Platform
|
5
|
+
class User
|
6
|
+
include Qtc::Cli::Common
|
7
|
+
|
8
|
+
def login
|
9
|
+
pass = password("Personal Access Token (copy from https://console.qtcloudservices.com/#/user/profile):")
|
10
|
+
inifile['platform']['token'] = pass
|
11
|
+
|
12
|
+
response = platform_client(pass).get('/user/accounts', {}) rescue nil
|
13
|
+
if response
|
14
|
+
inifile.save(filename: ini_filename)
|
15
|
+
else
|
16
|
+
print color('Invalid Personal Access Token', :red)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def logout
|
21
|
+
inifile['platform'].delete('token')
|
22
|
+
inifile.save(filename: ini_filename)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/qtc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qtc-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Kolehmainen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -151,7 +151,6 @@ files:
|
|
151
151
|
- Rakefile
|
152
152
|
- bin/qtc-cli
|
153
153
|
- lib/qtc-sdk.rb
|
154
|
-
- lib/qtc/cli/clouds.rb
|
155
154
|
- lib/qtc/cli/commands.rb
|
156
155
|
- lib/qtc/cli/common.rb
|
157
156
|
- lib/qtc/cli/eds/base.rb
|
@@ -162,7 +161,12 @@ files:
|
|
162
161
|
- lib/qtc/cli/mar/commands.rb
|
163
162
|
- lib/qtc/cli/mar/domains.rb
|
164
163
|
- lib/qtc/cli/mar/env.rb
|
164
|
+
- lib/qtc/cli/mar/repository.rb
|
165
165
|
- lib/qtc/cli/mar/ssl_certificates.rb
|
166
|
+
- lib/qtc/cli/platform/clouds.rb
|
167
|
+
- lib/qtc/cli/platform/commands.rb
|
168
|
+
- lib/qtc/cli/platform/ssh_keys.rb
|
169
|
+
- lib/qtc/cli/platform/user.rb
|
166
170
|
- lib/qtc/client.rb
|
167
171
|
- lib/qtc/eds/client.rb
|
168
172
|
- lib/qtc/eds/collection.rb
|
data/lib/qtc/cli/clouds.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'qtc/client'
|
2
|
-
require_relative 'common'
|
3
|
-
|
4
|
-
module Qtc
|
5
|
-
module Cli
|
6
|
-
class Clouds
|
7
|
-
include Common
|
8
|
-
|
9
|
-
def list
|
10
|
-
accounts = platform_client.get('/user/accounts')
|
11
|
-
accounts['results'].each do |account|
|
12
|
-
print color("~ #{account['name']} (#{account['id']})", :bold)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def login
|
17
|
-
pass = password("Personal Access Token (copy from https://console.qtcloudservices.com/#/user/profile):")
|
18
|
-
inifile['platform']['token'] = pass
|
19
|
-
|
20
|
-
response = platform_client(pass).get('/user/accounts', {}) rescue nil
|
21
|
-
if response
|
22
|
-
inifile.save(filename: ini_filename)
|
23
|
-
else
|
24
|
-
print color('Invalid Personal Access Token', :red)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def logout
|
29
|
-
inifile['platform'].delete('token')
|
30
|
-
inifile.save(filename: ini_filename)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|