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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15793147bafda678e3733aac8b35a00ff042e391
4
- data.tar.gz: 13737c15dc602ea79d73f22fa940bf12ec0ceb27
3
+ metadata.gz: aa7296e5b88e68be2cc7c2cb7182f84f08ab028c
4
+ data.tar.gz: 2e9f1fa63c4225572894ecb089a401235f4ba100
5
5
  SHA512:
6
- metadata.gz: 570dc15ffaa7146248b11b4e559c2c2dfa5930cdbe4869b1a75a8c08aa098a57a4eff0cb4798c5422519236eda12e532489147f7d4b7baabad367279ae5f5ab3
7
- data.tar.gz: 665fef6d999f64898a7936142aa37ec1fea822fa004d7a7f342c3ab2bb2c6fe48865bd1a6ae67a60114b9c02fb31e2597523bca2a96bf7472d2d0eed12ed1715
6
+ metadata.gz: ed984ff2fb473f1c571799eda81ad09b1a9b1c4774f17ee7701ef02080e138e4d48b42b227d7b0679a59b5f1706ce454675eb783ab04ce69ecbed346ce20b173
7
+ data.tar.gz: 9d32a47dbb36687a96e605df9a2ed3fb5e3ea8a6b1b9f7ed1b77d835ae3e37ab4550ff19ee180a7d235649af35acf779fe65ac505cddf60c326a2e33af63aab0
data/.gitignore CHANGED
@@ -1,18 +1,18 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- .idea
7
- Gemfile.lock
8
- InstalledFiles
9
- _yardoc
10
- coverage
11
- doc/
12
- lib/bundler/man
13
- pkg
14
- rdoc
15
- spec/reports
16
- test/tmp
17
- test/version_tmp
18
- tmp
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .idea
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Changelog.md CHANGED
@@ -1,18 +1,23 @@
1
- 0.3.1
2
- -----------
3
- - Fix mar local:build_slug
4
-
5
- 0.3.0
6
- -----------
7
-
8
- - Add support for cloud vpn
9
- - Add support for stack change
10
- - Refactor cli to use cloud tokens
11
- - Remove MWS support
12
-
13
- 0.2.0
14
- -----------
15
-
16
- - Add support for executing ad-hoc commands inside MAR applications: qtc-cli mar exec
17
- - Add support for local debugging of MAR applications (using docker): qtc-cli mar local:run
18
- - Add initial MDB commands: qtc-cli mdb list/logs
1
+ 0.4.0
2
+ -----------
3
+ - Add support for slug upload & deploy functionality: qtc-cli mar slug:upload ...; qtc-cli mar slug:deploy v1.2
4
+
5
+ 0.3.1
6
+ -----------
7
+ - Fix mar local:build_slug
8
+
9
+
10
+ 0.3.0
11
+ -----------
12
+
13
+ - Add support for cloud vpn
14
+ - Add support for stack change
15
+ - Refactor cli to use cloud tokens
16
+ - Remove MWS support
17
+
18
+ 0.2.0
19
+ -----------
20
+
21
+ - Add support for executing ad-hoc commands inside MAR applications: qtc-cli mar exec
22
+ - Add support for local debugging of MAR applications (using docker): qtc-cli mar local:run
23
+ - Add initial MDB commands: qtc-cli mdb list/logs
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in qtc-sdk.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in qtc-sdk.gemspec
4
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,22 +1,22 @@
1
- Copyright (c) 2014 Jari Kolehmainen
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2014 Jari Kolehmainen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,44 +1,44 @@
1
- # Qt Cloud Services SDK for Ruby
2
-
3
- This is Qt Cloud Services SDK for Ruby. What is Qt Cloud Services? See below:
4
-
5
- * The Qt Cloud Services home page is at https://www.qtc.io
6
- * The Developer Documentation page is at https://developer.qtc.io
7
-
8
- ## Getting Started
9
-
10
- You can find a getting started guide for Qt Cloud Services at:
11
-
12
- http://developer.qtc.io/qtc/getting-started?snippets=ruby
13
-
14
- If you are looking for service specific guides, please see:
15
-
16
- * [Enginio Data Storage](http://developer.qtc.io/eds/getting-started?snippets=ruby)
17
- * [Managed Application Runtime](http://developer.qtc.io/mar/getting-started?snippets=ruby)
18
-
19
-
20
- ## Installation
21
-
22
- Add this line to your application's Gemfile:
23
-
24
- gem 'qtc-sdk'
25
-
26
- And then execute:
27
-
28
- $ bundle
29
-
30
- Or install it yourself as:
31
-
32
- $ gem install qtc-sdk
33
-
34
- ## Usage
35
-
36
- TODO: Write usage instructions here
37
-
38
- ## Contributing
39
-
40
- 1. Fork it ( http://github.com/qtcloudservices/qtc-sdk-ruby/fork )
41
- 2. Create your feature branch (`git checkout -b my-new-feature`)
42
- 3. Commit your changes (`git commit -am 'Add some feature'`)
43
- 4. Push to the branch (`git push origin my-new-feature`)
44
- 5. Create new Pull Request
1
+ # Qt Cloud Services SDK for Ruby
2
+
3
+ This is Qt Cloud Services SDK for Ruby. What is Qt Cloud Services? See below:
4
+
5
+ * The Qt Cloud Services home page is at https://www.qtc.io
6
+ * The Developer Documentation page is at https://developer.qtc.io
7
+
8
+ ## Getting Started
9
+
10
+ You can find a getting started guide for Qt Cloud Services at:
11
+
12
+ http://developer.qtc.io/qtc/getting-started?snippets=ruby
13
+
14
+ If you are looking for service specific guides, please see:
15
+
16
+ * [Enginio Data Storage](http://developer.qtc.io/eds/getting-started?snippets=ruby)
17
+ * [Managed Application Runtime](http://developer.qtc.io/mar/getting-started?snippets=ruby)
18
+
19
+
20
+ ## Installation
21
+
22
+ Add this line to your application's Gemfile:
23
+
24
+ gem 'qtc-sdk'
25
+
26
+ And then execute:
27
+
28
+ $ bundle
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install qtc-sdk
33
+
34
+ ## Usage
35
+
36
+ TODO: Write usage instructions here
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it ( http://github.com/qtcloudservices/qtc-sdk-ruby/fork )
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create new Pull Request
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require "bundler/gem_tasks"
data/bin/qtc-cli CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- # resolve bin path, ignoring symlinks
5
- require 'pathname'
6
- bin_file = Pathname.new(__FILE__).realpath
7
-
8
- # add self to libpath
9
- $:.unshift File.expand_path('../../lib', bin_file)
10
-
11
- STDOUT.sync = true
12
-
13
- require 'commander/import'
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ # resolve bin path, ignoring symlinks
5
+ require 'pathname'
6
+ bin_file = Pathname.new(__FILE__).realpath
7
+
8
+ # add self to libpath
9
+ $:.unshift File.expand_path('../../lib', bin_file)
10
+
11
+ STDOUT.sync = true
12
+
13
+ require 'commander/import'
14
14
  require 'qtc/cli/commands'
data/lib/qtc-sdk.rb CHANGED
@@ -1,2 +1,2 @@
1
- require 'qtc/client'
1
+ require 'qtc/client'
2
2
  require 'qtc/eds/client'
@@ -1,15 +1,15 @@
1
- require 'qtc/version'
2
-
3
- module Qtc::Cli; end;
4
-
5
- program :name, 'qtc-cli'
6
- program :version, Qtc::VERSION
7
- program :description, 'Command line interface for Qt Cloud Services'
8
-
9
- default_command :help
10
- never_trace!
11
-
12
- require_relative 'platform/commands'
13
- require_relative 'eds/commands'
14
- require_relative 'mar/commands'
15
- require_relative 'mdb/commands'
1
+ require 'qtc/version'
2
+
3
+ module Qtc::Cli; end;
4
+
5
+ program :name, 'qtc-cli'
6
+ program :version, Qtc::VERSION
7
+ program :description, 'Command line interface for Qt Cloud Services'
8
+
9
+ default_command :help
10
+ never_trace!
11
+
12
+ require_relative 'platform/commands'
13
+ require_relative 'eds/commands'
14
+ require_relative 'mar/commands'
15
+ require_relative 'mdb/commands'
@@ -1,146 +1,146 @@
1
- require 'inifile'
2
- module Qtc
3
- module Cli
4
- module Common
5
-
6
- attr_accessor :datacenter_id
7
-
8
- ##
9
- # @param [String] instance_id
10
- def instance_info(instance_id)
11
- instance_data = platform_client.get("/instances/#{instance_id}")
12
- unless instance_data
13
- abort("Error: instance not found")
14
- end
15
-
16
- instance_data
17
- end
18
-
19
- ##
20
- # @return [String]
21
- def current_cloud_id
22
- unless @current_cloud_id
23
- unless inifile['platform']['current_cloud']
24
- raise ArgumentError.new("Please specify used cloud first: qtc-cli clouds:use <id>")
25
- end
26
- @current_cloud_id = inifile['platform']['current_cloud']
27
- self.datacenter_id = inifile['platform']['current_dc']
28
- end
29
- @current_cloud_id
30
- end
31
-
32
- ##
33
- # @return [String]
34
- def current_cloud_dc
35
- unless @current_cloud_dc
36
- unless inifile['platform']['current_cloud']
37
- raise ArgumentError.new("Please specify used cloud first: qtc-cli clouds:use <id>")
38
- end
39
- @current_cloud_dc = inifile['platform']['current_dc']
40
- end
41
- @current_cloud_dc
42
- end
43
-
44
- ##
45
- # @return [String]
46
- def current_cloud_token
47
- token = nil
48
- begin
49
- authorizations = platform_client.get("/accounts/#{current_cloud_id}/authorizations")
50
- unless authorizations['results'][0]
51
- platform_client.post("/accounts/#{current_cloud_id}/authorizations", {})
52
- raise StandardError.new "retry"
53
- end
54
- token = authorizations['results'][0]['access_token']
55
- rescue ArgumentError => e
56
- raise e
57
- rescue Qtc::Errors::StandardError => e
58
- if e.status == 404
59
- raise ArgumentError.new("Cloud not found. Please specify used cloud first: qtc-cli clouds:use <id>")
60
- end
61
- rescue => e
62
- retry
63
- end
64
-
65
- token
66
- end
67
-
68
- ##
69
- # @param [String] token
70
- # @return [Qtc::Client]
71
- def platform_client(token = nil)
72
- inifile['platform']['token'] = token unless token.nil?
73
- unless inifile['platform']['token']
74
- raise ArgumentError.new("Please login first using: qtc-cli login")
75
- end
76
-
77
- if @platform_client.nil?
78
- @platform_client = Qtc::Client.new(platform_base_url, {'Authorization' => "Bearer #{inifile['platform']['token']}"})
79
- end
80
-
81
- @platform_client
82
- end
83
-
84
- ##
85
- # @return [String]
86
- def ini_filename
87
- File.join(Dir.home, '/.qtc_client')
88
- end
89
-
90
- ##
91
- # @return [Hash]
92
- def inifile
93
- if @inifile.nil?
94
- if File.exists?(ini_filename)
95
- @inifile = IniFile.load(ini_filename)
96
- else
97
- @inifile = IniFile.new
98
- end
99
- end
100
-
101
- unless @inifile['platform']
102
- @inifile['platform'] = {}
103
- end
104
-
105
- @inifile
106
- end
107
-
108
- ##
109
- # @param [String,NilClass]
110
- # @return [String]
111
- def extract_app_in_dir(remote = nil)
112
- if File.exists?(File.expand_path('./.git/config'))
113
- remotes = []
114
- git_remotes = `git remote -v`
115
- git_remotes.lines.each do |line|
116
- if match = line.match(/#{remote}\s+git@git-mar-(.*)\:(.*) \(push\)/)
117
- remotes << match[2]
118
- end
119
- end
120
- apps = remotes.uniq
121
- if apps.size == 1
122
- return apps[0]
123
- elsif apps.size > 1
124
- raise ArgumentError.new("Multiple app git remotes\nSpecify app with --remote REMOTE or --app APP")
125
- end
126
- end
127
- end
128
-
129
- ##
130
- # @return [Qtc::Client]
131
- def client
132
- if @client.nil?
133
- @client = Qtc::Client.new(base_url)
134
- end
135
-
136
- @client
137
- end
138
-
139
- ##
140
- # @return [String]
141
- def platform_base_url
142
- ENV['QTC_PLATFORM_URL'] || 'https://api.qtc.io/v1'
143
- end
144
- end
145
- end
146
- end
1
+ require 'inifile'
2
+ module Qtc
3
+ module Cli
4
+ module Common
5
+
6
+ attr_accessor :datacenter_id
7
+
8
+ ##
9
+ # @param [String] instance_id
10
+ def instance_info(instance_id)
11
+ instance_data = platform_client.get("/instances/#{instance_id}")
12
+ unless instance_data
13
+ abort("Error: instance not found")
14
+ end
15
+
16
+ instance_data
17
+ end
18
+
19
+ ##
20
+ # @return [String]
21
+ def current_cloud_id
22
+ unless @current_cloud_id
23
+ unless inifile['platform']['current_cloud']
24
+ raise ArgumentError.new("Please specify used cloud first: qtc-cli clouds:use <id>")
25
+ end
26
+ @current_cloud_id = inifile['platform']['current_cloud']
27
+ self.datacenter_id = inifile['platform']['current_dc']
28
+ end
29
+ @current_cloud_id
30
+ end
31
+
32
+ ##
33
+ # @return [String]
34
+ def current_cloud_dc
35
+ unless @current_cloud_dc
36
+ unless inifile['platform']['current_cloud']
37
+ raise ArgumentError.new("Please specify used cloud first: qtc-cli clouds:use <id>")
38
+ end
39
+ @current_cloud_dc = inifile['platform']['current_dc']
40
+ end
41
+ @current_cloud_dc
42
+ end
43
+
44
+ ##
45
+ # @return [String]
46
+ def current_cloud_token
47
+ token = nil
48
+ begin
49
+ authorizations = platform_client.get("/accounts/#{current_cloud_id}/authorizations")
50
+ unless authorizations['results'][0]
51
+ platform_client.post("/accounts/#{current_cloud_id}/authorizations", {})
52
+ raise StandardError.new "retry"
53
+ end
54
+ token = authorizations['results'][0]['access_token']
55
+ rescue ArgumentError => e
56
+ raise e
57
+ rescue Qtc::Errors::StandardError => e
58
+ if e.status == 404
59
+ raise ArgumentError.new("Cloud not found. Please specify used cloud first: qtc-cli clouds:use <id>")
60
+ end
61
+ rescue => e
62
+ retry
63
+ end
64
+
65
+ token
66
+ end
67
+
68
+ ##
69
+ # @param [String] token
70
+ # @return [Qtc::Client]
71
+ def platform_client(token = nil)
72
+ inifile['platform']['token'] = token unless token.nil?
73
+ unless inifile['platform']['token']
74
+ raise ArgumentError.new("Please login first using: qtc-cli login")
75
+ end
76
+
77
+ if @platform_client.nil?
78
+ @platform_client = Qtc::Client.new(platform_base_url, {'Authorization' => "Bearer #{inifile['platform']['token']}"})
79
+ end
80
+
81
+ @platform_client
82
+ end
83
+
84
+ ##
85
+ # @return [String]
86
+ def ini_filename
87
+ File.join(Dir.home, '/.qtc_client')
88
+ end
89
+
90
+ ##
91
+ # @return [Hash]
92
+ def inifile
93
+ if @inifile.nil?
94
+ if File.exists?(ini_filename)
95
+ @inifile = IniFile.load(ini_filename)
96
+ else
97
+ @inifile = IniFile.new
98
+ end
99
+ end
100
+
101
+ unless @inifile['platform']
102
+ @inifile['platform'] = {}
103
+ end
104
+
105
+ @inifile
106
+ end
107
+
108
+ ##
109
+ # @param [String,NilClass]
110
+ # @return [String]
111
+ def extract_app_in_dir(remote = nil)
112
+ if File.exists?(File.expand_path('./.git/config'))
113
+ remotes = []
114
+ git_remotes = `git remote -v`
115
+ git_remotes.lines.each do |line|
116
+ if match = line.match(/#{remote}\s+git@git-mar-(.*)\:(.*) \(push\)/)
117
+ remotes << match[2]
118
+ end
119
+ end
120
+ apps = remotes.uniq
121
+ if apps.size == 1
122
+ return apps[0]
123
+ elsif apps.size > 1
124
+ raise ArgumentError.new("Multiple app git remotes\nSpecify app with --remote REMOTE or --app APP")
125
+ end
126
+ end
127
+ end
128
+
129
+ ##
130
+ # @return [Qtc::Client]
131
+ def client
132
+ if @client.nil?
133
+ @client = Qtc::Client.new(base_url)
134
+ end
135
+
136
+ @client
137
+ end
138
+
139
+ ##
140
+ # @return [String]
141
+ def platform_base_url
142
+ ENV['QTC_PLATFORM_URL'] || 'https://api.qtc.io/v1'
143
+ end
144
+ end
145
+ end
146
+ end