cumulogic_client 0.0.2

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YmU5MGU4NjBkMTAxMjVjMTUwYjY0OTg0NWYyNzcxNTA3NmJmNTA1OQ==
5
+ data.tar.gz: !binary |-
6
+ ZDEzNDNmM2Q2OGNmNDgzNzA0OGZlMGQ0ODNmNTc2NjQxZmZlZGIzMg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ODcwMjhhMjc4Yjg2NDZkMDU1NTVjZjFlYzE4ODJmOTkyZTNhNjU1ZTE1NDcy
10
+ NjY4ZDQ3YmYxNDQ2NzVlMDUwZjFjYTMzYjRkZTE3YjFmMjA0NGE0Y2I2YmE0
11
+ ZGUzZWVmM2Y5MzE0NmRhMTVmODdiZTA4M2Y5ODg2ZWVmOTkwZGU=
12
+ data.tar.gz: !binary |-
13
+ MzYyMWRhYzg5ZjdhMmFkZDhmYzQxMjg3NTg4ZGI2MGYzYmE1MzJlMjg2MjA4
14
+ Y2UxNTA1ZWQ3OTAyMzhhMWQ4NzkzYmQzNzRhYzNhNDQwZGVkZDMzMzEzMWZj
15
+ ODlkZTQ4NGE2MDljZGRlYmMxNzlhM2YyNWMwNTEzZGUwNDdlOTA=
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.swp
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # Copyright 2014 CumuLogic, Inc
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ source 'https://rubygems.org'
16
+
17
+ # Specify your gem's dependencies in cumulogic_client.gemspec
18
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,178 @@
1
+ Copyright (c) 2014 CumuLogic, Inc
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
data/NOTICE.txt ADDED
@@ -0,0 +1,2 @@
1
+ This product includes software developed by
2
+ CumuLogic, Inc (http://www.cumulogic.com/).
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # CumulogicClient
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cumulogic_client'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cumulogic_client
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Testing
24
+
25
+ Tests can be run using "rake test". The test suite requires a working
26
+ CumuLogic controller target, and a username and password with permission
27
+ to deploy services.
28
+
29
+ In order to provide the test suite with the required credentials, place a
30
+ YAML file at ~/.cumulogic_client.yml with the following contents:
31
+
32
+ URL: https://demo.cumulogic.com/cumulogic/REST/
33
+ USER: yourusername
34
+ PASSWORD: yourpassword
35
+ SSL: true
36
+
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it
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 ADDED
@@ -0,0 +1,20 @@
1
+ # Copyright 2014 CumuLogic, Inc
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'rspec/core/rake_task'
16
+ require "bundler/gem_tasks"
17
+
18
+ RSpec::Core::RakeTask.new(:spec)
19
+
20
+ task :default => :spec
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+
3
+ # Copyright 2014 CumuLogic, Inc
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ lib = File.expand_path('../lib', __FILE__)
18
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
19
+ require 'cumulogic_client/version'
20
+
21
+ Gem::Specification.new do |spec|
22
+ spec.name = "cumulogic_client"
23
+ spec.version = CumulogicClient::VERSION
24
+ spec.authors = ["Chip Childers"]
25
+ spec.email = ["chip.childers@gmail.com"]
26
+ spec.description = %q{Ruby API bindings for the CumuLogic platform's RESTful API.}
27
+ spec.summary = %q{API binding gem that can be used to communicate with the CumuLogic platform's RESTful API.}
28
+ spec.homepage = "https://github.com/cumulogic/cumulogic_client"
29
+ spec.license = "ASLv2"
30
+
31
+ spec.files = `git ls-files`.split($/)
32
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
33
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
34
+ spec.require_paths = ["lib"]
35
+
36
+ spec.add_development_dependency "bundler", "~> 1.3"
37
+ spec.add_development_dependency "rake"
38
+ spec.add_development_dependency "rspec", ">= 2.0.0"
39
+ end
@@ -0,0 +1,17 @@
1
+ # Copyright 2014 CumuLogic, Inc
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ %w[ base64 cgi openssl uri digest/sha1 net/https net/http json ].each { |f| require f }
15
+
16
+ Dir[File.join(File.dirname(__FILE__), 'cumulogic_client/*.rb')].sort.each { |rb| require rb }
17
+
@@ -0,0 +1,97 @@
1
+ # Copyright 2014 CumuLogic, Inc
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'timeout'
16
+
17
+ class CumulogicClient::BaseClient
18
+ def initialize(api_url, username, password, use_ssl=nil, debug=false)
19
+ @api_url = api_url
20
+ @username = username
21
+ @password = password
22
+ @use_ssl = use_ssl
23
+ @debug = debug
24
+ @validationparams = nil
25
+ end
26
+
27
+ def call(command, params=nil)
28
+ login() if not @validationparams
29
+ callparams = Hash.new()
30
+ callparams[:inputParams] = Array.new(1)
31
+ callparams[:inputParams][0] = params if params
32
+ callparams[:validationParams] = @validationparams
33
+ request(command, callparams)
34
+ end
35
+
36
+ def request(command, params=nil)
37
+ url = "#{@api_url}#{command}"
38
+ puts url if @debug
39
+ puts URI::encode(params.to_json) if @debug
40
+ uri = URI.parse(url)
41
+ http = Net::HTTP.new(uri.host, uri.port)
42
+ http.use_ssl = @use_ssl
43
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
44
+ request = Net::HTTP::Post.new(uri.request_uri)
45
+ request.body = URI::encode(params.to_json) if params
46
+ response = http.request(request)
47
+
48
+ if !response.is_a?(Net::HTTPOK)
49
+ if ["431","530","404"].include?(response.code)
50
+ raise ArgumentError, response.message
51
+ end
52
+ raise RuntimeError, "Username and password not accepted" if ["401","403"].include?(response.code)
53
+ raise RuntimeError, "Unknown error: code=#{response.code} message=#{response.message}"
54
+ end
55
+
56
+ puts response.body if @debug
57
+
58
+ responsedata = JSON.parse(response.body)
59
+
60
+ raise RuntimeError, "Errors: #{responsedata["errors"]}" if not responsedata["success"]
61
+ return responsedata["response"]
62
+
63
+ end
64
+
65
+ def login()
66
+ credentials = Array.new(1)
67
+ credentials[0] = {
68
+ "userName" => @username,
69
+ "password" => @password
70
+ }
71
+ login_params = Hash.new
72
+ login_params["validationParams"] = Hash.new
73
+ login_params["inputParams"] = credentials
74
+ loginresponse = request("auth/login", login_params)
75
+ @validationparams = {
76
+ "userID" => loginresponse[0]["userID"],
77
+ "userName" => loginresponse[0]["userName"],
78
+ "userLoginToken" => loginresponse[0]["userLoginToken"]
79
+ }
80
+
81
+ end
82
+
83
+ def provisioning_completed(targetobject, timeout=nil)
84
+ return Timeout::timeout(timeout) do
85
+ while true do
86
+ if not targetobject.isComplete()
87
+ puts "returned false"
88
+ sleep 10
89
+ else
90
+ puts "returned true"
91
+ return true
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ end
@@ -0,0 +1,91 @@
1
+ # Copyright 2014 CumuLogic, Inc
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ class CumulogicClient::Nosql
16
+ def initialize(api_url, username, password, use_ssl=nil, debug=false)
17
+ @client = CumulogicClient::BaseClient.new(api_url, username, password, use_ssl, debug)
18
+ end
19
+
20
+ def engine_list()
21
+ return @client.call('nosql/nosqlengine/list')
22
+ end
23
+
24
+ def list()
25
+ return @client.call('nosql/instance/list')
26
+ end
27
+
28
+ def events(instanceId)
29
+ params = {
30
+ 'noSqlInstanceId' => instanceId
31
+ }
32
+ return @client.call('nosql/instance/showEvents', params)
33
+ end
34
+
35
+ def delete(instanceId)
36
+ params = {
37
+ 'noSqlInstanceId' => instanceId
38
+ }
39
+ return @client.call('nosql/instance/deleteNoSqlInstance', params)
40
+ end
41
+
42
+ def create(spec)
43
+ response = @client.call('nosql/instance/createNoSqlInstance', spec.to_hash)
44
+ @newInstanceId = response[0]['noSqlInstanceId']
45
+ @client.provisioning_completed(self, 30)
46
+ return @newInstanceId
47
+ end
48
+
49
+ def isComplete()
50
+ instances = self.list()
51
+ puts instances
52
+ target = instances.select { |id| id["noSqlInstanceId"] = @newInstanceId }
53
+ return false if (target[0]["status"] == 2)
54
+ raise RuntimeError, "Error provisioning instance: #{target[0]["errorMessage"]}" if (target[0]["status"] == 3)
55
+ return true
56
+ end
57
+
58
+ NoSQLSpec = Class.new do
59
+ attr_accessor :name
60
+ attr_accessor :description
61
+ attr_accessor :nodes
62
+ attr_accessor :collectionName
63
+ attr_accessor :characterSet
64
+ attr_accessor :port
65
+ attr_accessor :noSqlEngineId
66
+ attr_accessor :targetCloudId
67
+ attr_accessor :availabilityZoneName
68
+ attr_accessor :instanceTypeId
69
+ attr_accessor :serviceTag
70
+ attr_accessor :accessGroupId
71
+ attr_accessor :noSqlParamGroupId
72
+ attr_accessor :storageSize
73
+ attr_accessor :isbackupPreferenceSet
74
+ attr_accessor :isAutoUpdateEnabled
75
+ attr_accessor :backupRetentionPeriod
76
+ attr_accessor :backupStartTime
77
+ attr_accessor :ownerType
78
+ attr_accessor :isAvailabilityZoneMandatory
79
+ attr_accessor :isInstanceTypeMandatory
80
+ attr_accessor :availabilityZone
81
+ attr_accessor :isVolumeSizeMandatory
82
+ attr_accessor :backupRetentionPeriod
83
+ attr_accessor :backupStartTime
84
+ attr_accessor :start
85
+
86
+ def to_hash
87
+ Hash[*instance_variables.map { |v| [v.to_s().tr("@", ""), instance_variable_get(v)] }.flatten]
88
+ end
89
+ end
90
+
91
+ end
@@ -0,0 +1,17 @@
1
+ # Copyright 2014 CumuLogic, Inc
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module CumulogicClient
16
+ VERSION = "0.0.2"
17
+ end
@@ -0,0 +1,37 @@
1
+ # Copyright 2014 CumuLogic, Inc
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'cumulogic_client'
16
+ require 'yaml'
17
+
18
+ describe "base_client" do
19
+ before(:all) do
20
+ cnf = YAML::load(File.open(File.expand_path('~/.cumulogic_client.yml')))
21
+ @URL = cnf['URL']
22
+ @USER = cnf['USER']
23
+ @PASSWORD = cnf['PASSWORD']
24
+ @SSL = (cnf['SSL']) || false
25
+ @DEBUG = (cnf['DEBUG']) || false
26
+ @client = CumulogicClient::BaseClient.new(@URL, @USER, @PASSWORD, @SSL, @DEBUG)
27
+ end
28
+ it "can log in" do
29
+ @client.login()
30
+ end
31
+ it "can get DB engine list" do
32
+ @client.call("dbaas/dbengine/list")
33
+ end
34
+ it "can get instance types" do
35
+ @client.listInstanceTypes("Zone#1")
36
+ end
37
+ end
@@ -0,0 +1,92 @@
1
+ # Copyright 2014 CumuLogic, Inc
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'cumulogic_client'
16
+ require 'yaml'
17
+
18
+ describe "nosql" do
19
+ before(:all) do
20
+ cnf = YAML::load(File.open(File.expand_path('~/.cumulogic_client.yml')))
21
+ @URL = cnf['URL']
22
+ @USER = cnf['USER']
23
+ @PASSWORD = cnf['PASSWORD']
24
+ @SSL = (cnf['SSL']) || false
25
+ @DEBUG = (cnf['DEBUG']) || false
26
+ @nosql = CumulogicClient::Nosql.new(@URL, @USER, @PASSWORD, @SSL, @DEBUG)
27
+ end
28
+ it "can get engine list" do
29
+ @nosql.engine_list()
30
+ end
31
+ it "can create nosql instance" do
32
+ spec = CumulogicClient::Nosql::NoSQLSpec.new()
33
+ spec.name = 'unittest'
34
+ spec.description = 'testing for client library'
35
+ spec.nodes = "1"
36
+ spec.collectionName = 'UnitTestCollection'
37
+ spec.characterSet = 'UTF-8'
38
+ spec.port = "27017"
39
+ spec.noSqlEngineId = "1"
40
+ spec.targetCloudId = "1"
41
+ spec.availabilityZoneName = "Zone#3"
42
+ spec.instanceTypeId = "4"
43
+ spec.serviceTag = 'Development'
44
+ spec.accessGroupId = "0"
45
+ spec.noSqlParamGroupId = "0"
46
+ spec.storageSize = "10"
47
+ spec.isbackupPreferenceSet = "0"
48
+ spec.isAutoUpdateEnabled = "0"
49
+ spec.ownerType = "1"
50
+ spec.isAvailabilityZoneMandatory = "true"
51
+ spec.isInstanceTypeMandatory = "true"
52
+ spec.availabilityZone = "az-3.region-a.geo-1"
53
+ spec.isVolumeSizeMandatory = "true"
54
+ spec.backupRetentionPeriod = "1"
55
+ spec.backupStartTime = ""
56
+ spec.start = "1"
57
+
58
+ @nosql.create(spec)
59
+ end
60
+ it "can delete errored intances" do
61
+ instances = @nosql.list()
62
+ instances.each { |instance| @nosql.delete(instance["noSqlInstanceId"]) if instance["status"] == 3 }
63
+ end
64
+ it "can list nosql instances" do
65
+ @nosql.list()
66
+ end
67
+ it "can clone nosql instance" do
68
+ # pass
69
+ end
70
+ it "can restart nosql instance" do
71
+ # pass
72
+ end
73
+ it "can get nosql instance events" do
74
+ #instanceId = '5'
75
+ #@nosql.events(instanceId)
76
+ end
77
+ it "can terminate nosql instance" do
78
+ # pass
79
+ end
80
+ it "can create nosql snapshot" do
81
+ # pass
82
+ end
83
+ it "can list nosql snapshots" do
84
+ # pass
85
+ end
86
+ it "can list nosql snapshot events" do
87
+ # pass
88
+ end
89
+ it "can restore from snapshot" do
90
+ # pass
91
+ end
92
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cumulogic_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Chip Childers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.0
55
+ description: Ruby API bindings for the CumuLogic platform's RESTful API.
56
+ email:
57
+ - chip.childers@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .rspec
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - NOTICE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - cumulogic_client.gemspec
70
+ - lib/cumulogic_client.rb
71
+ - lib/cumulogic_client/base_client.rb
72
+ - lib/cumulogic_client/nosql.rb
73
+ - lib/cumulogic_client/version.rb
74
+ - spec/base_client_spec.rb
75
+ - spec/nosql_spec.rb
76
+ - spec/spec_helper.rb
77
+ homepage: https://github.com/cumulogic/cumulogic_client
78
+ licenses:
79
+ - ASLv2
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.1.9
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: API binding gem that can be used to communicate with the CumuLogic platform's
101
+ RESTful API.
102
+ test_files:
103
+ - spec/base_client_spec.rb
104
+ - spec/nosql_spec.rb
105
+ - spec/spec_helper.rb