qtc-sdk 0.2.0 → 0.3.0
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/Changelog.md +14 -6
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +44 -44
- data/Rakefile +1 -1
- data/bin/qtc-cli +13 -13
- data/lib/qtc/cli/commands.rb +15 -15
- data/lib/qtc/cli/common.rb +146 -91
- 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 -125
- data/lib/qtc/cli/mar/base.rb +60 -60
- data/lib/qtc/cli/mar/commands.rb +221 -199
- data/lib/qtc/cli/mar/debug.rb +87 -86
- data/lib/qtc/cli/mar/domains.rb +35 -38
- data/lib/qtc/cli/mar/env.rb +38 -40
- data/lib/qtc/cli/mar/repository.rb +24 -26
- data/lib/qtc/cli/mar/ssl_certificates.rb +40 -42
- data/lib/qtc/cli/mar/stack.rb +29 -0
- data/lib/qtc/cli/mdb/base.rb +47 -43
- data/lib/qtc/cli/mdb/commands.rb +43 -31
- data/lib/qtc/cli/mdb/instances.rb +79 -60
- data/lib/qtc/cli/platform/clouds.rb +33 -15
- data/lib/qtc/cli/platform/commands.rb +132 -65
- data/lib/qtc/cli/platform/datacenters.rb +23 -21
- data/lib/qtc/cli/platform/ssh_keys.rb +41 -41
- data/lib/qtc/cli/platform/user.rb +25 -25
- data/lib/qtc/cli/platform/vpn.rb +93 -0
- 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 -11
- data/lib/qtc/version.rb +3 -3
- data/lib/qtc-sdk.rb +1 -1
- data/qtc-sdk.gemspec +28 -28
- data/spec/unit/qtc/client_spec.rb +147 -147
- metadata +20 -19
- data/lib/qtc/mws/client.rb +0 -89
data/lib/qtc/eds/collection.rb
CHANGED
@@ -1,125 +1,125 @@
|
|
1
|
-
module Qtc
|
2
|
-
module Eds
|
3
|
-
class Collection
|
4
|
-
|
5
|
-
##
|
6
|
-
# Initialize EDS collection
|
7
|
-
#
|
8
|
-
# @param [Qtc::Client] client
|
9
|
-
# @param [String] path
|
10
|
-
def initialize(client, path)
|
11
|
-
@client = client
|
12
|
-
@path = path
|
13
|
-
end
|
14
|
-
|
15
|
-
##
|
16
|
-
# Insert a new object
|
17
|
-
#
|
18
|
-
# @param [Hash] object
|
19
|
-
# @return [Hash]
|
20
|
-
def insert(object)
|
21
|
-
client.post(path, object)
|
22
|
-
end
|
23
|
-
|
24
|
-
##
|
25
|
-
# Update object
|
26
|
-
#
|
27
|
-
# @param [String] id
|
28
|
-
# @param [Hash] object
|
29
|
-
# @return [Hash]
|
30
|
-
def update(id, object)
|
31
|
-
client.put("#{path}/#{id}", object)
|
32
|
-
end
|
33
|
-
|
34
|
-
##
|
35
|
-
# Atomic operation
|
36
|
-
#
|
37
|
-
# @param [String] id
|
38
|
-
# @param [Hash] operation
|
39
|
-
# @return [Hash]
|
40
|
-
def atomic_operation(id, operation)
|
41
|
-
client.put("#{path}/#{id}/atomic", operation)
|
42
|
-
end
|
43
|
-
|
44
|
-
##
|
45
|
-
# Remove object
|
46
|
-
#
|
47
|
-
# @param [String]
|
48
|
-
# @return [Hash]
|
49
|
-
def remove(id)
|
50
|
-
client.delete("#{path}/#{id}")
|
51
|
-
end
|
52
|
-
|
53
|
-
##
|
54
|
-
# Find object by id
|
55
|
-
#
|
56
|
-
# @param [String] id
|
57
|
-
# @return [Hash]
|
58
|
-
def find_one(id)
|
59
|
-
client.get("#{path}/#{id}")
|
60
|
-
end
|
61
|
-
|
62
|
-
##
|
63
|
-
# Find objects
|
64
|
-
#
|
65
|
-
# @param [Hash] params
|
66
|
-
# @return [Array<Hash>]
|
67
|
-
def find(params = {})
|
68
|
-
if params[:q] && params[:q].is_a?(Hash)
|
69
|
-
params[:q] = params[:q].to_json
|
70
|
-
end
|
71
|
-
if params[:sort] && !params[:sort].is_a?(String)
|
72
|
-
params[:sort] = params[:sort].to_json
|
73
|
-
end
|
74
|
-
response = client.get("#{path}", params)
|
75
|
-
response['results']
|
76
|
-
end
|
77
|
-
|
78
|
-
##
|
79
|
-
# Set object permissions
|
80
|
-
#
|
81
|
-
# @param [String]
|
82
|
-
def set_permissions(id, permissions)
|
83
|
-
client.post("#{path}/#{id}/access", permissions)
|
84
|
-
end
|
85
|
-
|
86
|
-
##
|
87
|
-
# Add permissions
|
88
|
-
#
|
89
|
-
# @param [String] id
|
90
|
-
# @param [Hash] permissions
|
91
|
-
# @return [Hash]
|
92
|
-
def add_permissions(id, permissions)
|
93
|
-
client.put("#{path}/#{id}/access", permissions)
|
94
|
-
end
|
95
|
-
|
96
|
-
##
|
97
|
-
# Remove permissions
|
98
|
-
#
|
99
|
-
# @param [String] id
|
100
|
-
# @param [Hash] permissions
|
101
|
-
# @return [Hash]
|
102
|
-
def remove_permissions(id, permissions)
|
103
|
-
client.delete("#{path}/#{id}/access", permissions)
|
104
|
-
end
|
105
|
-
|
106
|
-
protected
|
107
|
-
|
108
|
-
##
|
109
|
-
# Get client
|
110
|
-
#
|
111
|
-
# @return [Qtc::Client]
|
112
|
-
def client
|
113
|
-
@client
|
114
|
-
end
|
115
|
-
|
116
|
-
##
|
117
|
-
# Get path
|
118
|
-
#
|
119
|
-
# @return [String]
|
120
|
-
def path
|
121
|
-
@path
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
1
|
+
module Qtc
|
2
|
+
module Eds
|
3
|
+
class Collection
|
4
|
+
|
5
|
+
##
|
6
|
+
# Initialize EDS collection
|
7
|
+
#
|
8
|
+
# @param [Qtc::Client] client
|
9
|
+
# @param [String] path
|
10
|
+
def initialize(client, path)
|
11
|
+
@client = client
|
12
|
+
@path = path
|
13
|
+
end
|
14
|
+
|
15
|
+
##
|
16
|
+
# Insert a new object
|
17
|
+
#
|
18
|
+
# @param [Hash] object
|
19
|
+
# @return [Hash]
|
20
|
+
def insert(object)
|
21
|
+
client.post(path, object)
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Update object
|
26
|
+
#
|
27
|
+
# @param [String] id
|
28
|
+
# @param [Hash] object
|
29
|
+
# @return [Hash]
|
30
|
+
def update(id, object)
|
31
|
+
client.put("#{path}/#{id}", object)
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Atomic operation
|
36
|
+
#
|
37
|
+
# @param [String] id
|
38
|
+
# @param [Hash] operation
|
39
|
+
# @return [Hash]
|
40
|
+
def atomic_operation(id, operation)
|
41
|
+
client.put("#{path}/#{id}/atomic", operation)
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Remove object
|
46
|
+
#
|
47
|
+
# @param [String]
|
48
|
+
# @return [Hash]
|
49
|
+
def remove(id)
|
50
|
+
client.delete("#{path}/#{id}")
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Find object by id
|
55
|
+
#
|
56
|
+
# @param [String] id
|
57
|
+
# @return [Hash]
|
58
|
+
def find_one(id)
|
59
|
+
client.get("#{path}/#{id}")
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Find objects
|
64
|
+
#
|
65
|
+
# @param [Hash] params
|
66
|
+
# @return [Array<Hash>]
|
67
|
+
def find(params = {})
|
68
|
+
if params[:q] && params[:q].is_a?(Hash)
|
69
|
+
params[:q] = params[:q].to_json
|
70
|
+
end
|
71
|
+
if params[:sort] && !params[:sort].is_a?(String)
|
72
|
+
params[:sort] = params[:sort].to_json
|
73
|
+
end
|
74
|
+
response = client.get("#{path}", params)
|
75
|
+
response['results']
|
76
|
+
end
|
77
|
+
|
78
|
+
##
|
79
|
+
# Set object permissions
|
80
|
+
#
|
81
|
+
# @param [String]
|
82
|
+
def set_permissions(id, permissions)
|
83
|
+
client.post("#{path}/#{id}/access", permissions)
|
84
|
+
end
|
85
|
+
|
86
|
+
##
|
87
|
+
# Add permissions
|
88
|
+
#
|
89
|
+
# @param [String] id
|
90
|
+
# @param [Hash] permissions
|
91
|
+
# @return [Hash]
|
92
|
+
def add_permissions(id, permissions)
|
93
|
+
client.put("#{path}/#{id}/access", permissions)
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# Remove permissions
|
98
|
+
#
|
99
|
+
# @param [String] id
|
100
|
+
# @param [Hash] permissions
|
101
|
+
# @return [Hash]
|
102
|
+
def remove_permissions(id, permissions)
|
103
|
+
client.delete("#{path}/#{id}/access", permissions)
|
104
|
+
end
|
105
|
+
|
106
|
+
protected
|
107
|
+
|
108
|
+
##
|
109
|
+
# Get client
|
110
|
+
#
|
111
|
+
# @return [Qtc::Client]
|
112
|
+
def client
|
113
|
+
@client
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# Get path
|
118
|
+
#
|
119
|
+
# @return [String]
|
120
|
+
def path
|
121
|
+
@path
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
125
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module Qtc
|
2
|
-
module Eds
|
3
|
-
class UserCollection < Collection
|
4
|
-
|
5
|
-
##
|
6
|
-
# Initialize EDS user collection
|
7
|
-
#
|
8
|
-
# @param [Qtc::Client] client
|
9
|
-
def initialize(client)
|
10
|
-
super(client, '/users')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
module Qtc
|
2
|
+
module Eds
|
3
|
+
class UserCollection < Collection
|
4
|
+
|
5
|
+
##
|
6
|
+
# Initialize EDS user collection
|
7
|
+
#
|
8
|
+
# @param [Qtc::Client] client
|
9
|
+
def initialize(client)
|
10
|
+
super(client, '/users')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
14
|
end
|
@@ -1,42 +1,42 @@
|
|
1
|
-
module Qtc
|
2
|
-
module Eds
|
3
|
-
class UsergroupCollection < Collection
|
4
|
-
|
5
|
-
##
|
6
|
-
# Initialize EDS usergroup collection
|
7
|
-
#
|
8
|
-
# @param [Qtc::Client] client
|
9
|
-
def initialize(client)
|
10
|
-
super(client, '/usergroups')
|
11
|
-
end
|
12
|
-
|
13
|
-
##
|
14
|
-
# Add member to usergroup
|
15
|
-
#
|
16
|
-
# @param [String] id
|
17
|
-
# @param [Hash] user
|
18
|
-
def add_member(id, user)
|
19
|
-
client.post("#{path}/#{id}/members", user)
|
20
|
-
end
|
21
|
-
|
22
|
-
##
|
23
|
-
# Remove member from usergroup
|
24
|
-
#
|
25
|
-
# @param [String] id
|
26
|
-
# @param [Hash] user
|
27
|
-
def remove_member(id, user)
|
28
|
-
client.delete("#{path}/#{id}/members", user)
|
29
|
-
end
|
30
|
-
|
31
|
-
##
|
32
|
-
# Get usergroup members
|
33
|
-
#
|
34
|
-
# @param [String] id
|
35
|
-
# @return [Array<Hash>]
|
36
|
-
def members(id)
|
37
|
-
response = client.get("#{path}/#{id}/members")
|
38
|
-
response['results']
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
1
|
+
module Qtc
|
2
|
+
module Eds
|
3
|
+
class UsergroupCollection < Collection
|
4
|
+
|
5
|
+
##
|
6
|
+
# Initialize EDS usergroup collection
|
7
|
+
#
|
8
|
+
# @param [Qtc::Client] client
|
9
|
+
def initialize(client)
|
10
|
+
super(client, '/usergroups')
|
11
|
+
end
|
12
|
+
|
13
|
+
##
|
14
|
+
# Add member to usergroup
|
15
|
+
#
|
16
|
+
# @param [String] id
|
17
|
+
# @param [Hash] user
|
18
|
+
def add_member(id, user)
|
19
|
+
client.post("#{path}/#{id}/members", user)
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# Remove member from usergroup
|
24
|
+
#
|
25
|
+
# @param [String] id
|
26
|
+
# @param [Hash] user
|
27
|
+
def remove_member(id, user)
|
28
|
+
client.delete("#{path}/#{id}/members", user)
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Get usergroup members
|
33
|
+
#
|
34
|
+
# @param [String] id
|
35
|
+
# @return [Array<Hash>]
|
36
|
+
def members(id)
|
37
|
+
response = client.get("#{path}/#{id}/members")
|
38
|
+
response['results']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
42
|
end
|
data/lib/qtc/errors.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
module Qtc
|
2
|
-
module Errors
|
3
|
-
class StandardError < ::StandardError
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
1
|
+
module Qtc
|
2
|
+
module Errors
|
3
|
+
class StandardError < ::StandardError
|
4
|
+
|
5
|
+
attr_reader :status
|
6
|
+
|
7
|
+
def initialize(status, message)
|
8
|
+
@status = status
|
9
|
+
super(message)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/qtc/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Qtc
|
2
|
-
VERSION = '0.
|
3
|
-
end
|
1
|
+
module Qtc
|
2
|
+
VERSION = '0.3.0'
|
3
|
+
end
|
data/lib/qtc-sdk.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require 'qtc/client'
|
1
|
+
require 'qtc/client'
|
2
2
|
require 'qtc/eds/client'
|
data/qtc-sdk.gemspec
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'qtc/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'qtc-sdk'
|
8
|
-
spec.version = Qtc::VERSION
|
9
|
-
spec.authors = ['Jari Kolehmainen']
|
10
|
-
spec.email = ['jari.kolehmainen@digia.com']
|
11
|
-
spec.summary = %q{Qt Cloud Services SDK for Ruby}
|
12
|
-
spec.description = %q{Qt Cloud Services SDK for Ruby}
|
13
|
-
spec.homepage = 'https://github.com/jakolehm/qtc-sdk-ruby'
|
14
|
-
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = '>= 1.9.3'
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0")
|
18
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
-
spec.require_paths = ['lib']
|
21
|
-
|
22
|
-
spec.add_development_dependency 'bundler', '~> 1.5'
|
23
|
-
spec.add_development_dependency 'rake'
|
24
|
-
spec.add_development_dependency 'rspec', '~> 2.14.0'
|
25
|
-
spec.add_runtime_dependency 'httpclient', '~> 2.3'
|
26
|
-
spec.add_runtime_dependency 'commander'
|
27
|
-
spec.add_runtime_dependency 'inifile'
|
28
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'qtc/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'qtc-sdk'
|
8
|
+
spec.version = Qtc::VERSION
|
9
|
+
spec.authors = ['Jari Kolehmainen']
|
10
|
+
spec.email = ['jari.kolehmainen@digia.com']
|
11
|
+
spec.summary = %q{Qt Cloud Services SDK for Ruby}
|
12
|
+
spec.description = %q{Qt Cloud Services SDK for Ruby}
|
13
|
+
spec.homepage = 'https://github.com/jakolehm/qtc-sdk-ruby'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 1.9.3'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 2.14.0'
|
25
|
+
spec.add_runtime_dependency 'httpclient', '~> 2.3'
|
26
|
+
spec.add_runtime_dependency 'commander'
|
27
|
+
spec.add_runtime_dependency 'inifile'
|
28
|
+
end
|