qtc-sdk 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +18 -18
  3. data/Changelog.md +18 -14
  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 +221 -221
  18. data/lib/qtc/cli/mar/debug.rb +88 -87
  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/ssl_certificates.rb +40 -40
  23. data/lib/qtc/cli/mar/stack.rb +29 -29
  24. data/lib/qtc/cli/mdb/base.rb +47 -47
  25. data/lib/qtc/cli/mdb/commands.rb +43 -43
  26. data/lib/qtc/cli/mdb/instances.rb +79 -79
  27. data/lib/qtc/cli/platform/clouds.rb +33 -33
  28. data/lib/qtc/cli/platform/commands.rb +132 -132
  29. data/lib/qtc/cli/platform/datacenters.rb +23 -23
  30. data/lib/qtc/cli/platform/ssh_keys.rb +41 -41
  31. data/lib/qtc/cli/platform/user.rb +25 -25
  32. data/lib/qtc/cli/platform/vpn.rb +93 -93
  33. data/lib/qtc/client.rb +170 -170
  34. data/lib/qtc/eds/client.rb +116 -116
  35. data/lib/qtc/eds/collection.rb +124 -124
  36. data/lib/qtc/eds/user_collection.rb +13 -13
  37. data/lib/qtc/eds/usergroup_collection.rb +41 -41
  38. data/lib/qtc/errors.rb +13 -13
  39. data/lib/qtc/version.rb +3 -3
  40. data/qtc-sdk.gemspec +28 -28
  41. data/spec/unit/qtc/client_spec.rb +147 -147
  42. metadata +18 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9bfa0619d71840645a97bcdcd7e127f0e3a99c7
4
- data.tar.gz: ca672d82bb261648df83eac626cff20497a326cc
3
+ metadata.gz: 15793147bafda678e3733aac8b35a00ff042e391
4
+ data.tar.gz: 13737c15dc602ea79d73f22fa940bf12ec0ceb27
5
5
  SHA512:
6
- metadata.gz: d8ae8f845101afa83f6fbade7093bd9687d08a3889fa9b7ac65ff502f541ca8aceb695cb9d4c09b1c0866ffbeca669b6fdc8aa3c8998412ff3e4da655aaa145f
7
- data.tar.gz: b64b18daa1fda05d426481f9be1daedb8591016038986859f6bb1f4c304eea084e855ee31e83da6fa4586b0fd0fce103b0c94e77f6554c2ce03cf636a68f64e6
6
+ metadata.gz: 570dc15ffaa7146248b11b4e559c2c2dfa5930cdbe4869b1a75a8c08aa098a57a4eff0cb4798c5422519236eda12e532489147f7d4b7baabad367279ae5f5ab3
7
+ data.tar.gz: 665fef6d999f64898a7936142aa37ec1fea822fa004d7a7f342c3ab2bb2c6fe48865bd1a6ae67a60114b9c02fb31e2597523bca2a96bf7472d2d0eed12ed1715
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,14 +1,18 @@
1
- 0.3.0
2
- -----------
3
-
4
- - Add support for cloud vpn
5
- - Add support for stack change
6
- - Refactor cli to use cloud tokens
7
- - Remove MWS support
8
-
9
- 0.2.0
10
- -----------
11
-
12
- - Add support for executing ad-hoc commands inside MAR applications: qtc-cli mar exec
13
- - Add support for local debugging of MAR applications (using docker): qtc-cli mar local:run
14
- - Add initial MDB commands: qtc-cli mdb list/logs
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
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