cumulogic_client 0.0.3 → 0.0.4

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Yzk1ZWUwOTc1NWVlOGJhMjJiMzMzZTFlNmIwYTlhOWNkN2EyZTJiNg==
4
+ OGM0OTUzZWIzZTdjMzA4Y2Q5ODQ0NjNmZGJmM2RkYzEyMzI3ZGY4OA==
5
5
  data.tar.gz: !binary |-
6
- NGViYTVmYmVjNDhmN2QzYWVjNjBmZTE5N2ZiMTA5NzBlZDNiN2ViNw==
6
+ MmRiNzI3ZWE4NWY4MGYyMTRlMTEwYzZiZTZjNTIzOTE2NTNhYWE5MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjczODQxYmU5YzVkMTk4NzM0YmMxYmFlNjZjYjdiYjlkMmRmMWE2MjM0YTlh
10
- MjMyZTEzZWE0ZTRiMTZjYTQ0N2NiMDM2NGM2NzE5YTZkZDRiNmQ1Y2UyMjhh
11
- OGUyMjNkM2QwYjc0NGVkYzQwOWVhMDFiNTBlYmU1NmFjNmVlNjI=
9
+ MDdiNTY3MTI5NGZlNWU5N2FiMGU2NGU2M2MyNDczMjZhODUwNmY4YjllYmY3
10
+ Zjk4MmVlYzczNDQ5ODVjZWM2NzRkZDUwMWI2ZjRhMjE1NDE3MTU2YjdmY2Y3
11
+ NTllODJjNTU2Mzc4MjU1YjI3ZWUxZjFhZDViM2M0YTY5Yzk4OTQ=
12
12
  data.tar.gz: !binary |-
13
- ZGI0YTI5ZWZlMGIxMDFlNjU1YjFiZTAxOWYxNmZmYWIyYWYzYjczMjcwZWVi
14
- MzgzNjdiZGE4ZGIzNWNkNDAwNGFmYmU5OTg3MDYyOWNkNDlkZDI2YTVhYzJh
15
- M2E5NjE5NTc2OWZhMDc1YzE1ZjFmNjE2YmNmNDNmODAyOTk4YjU=
13
+ MjljMjIwZTE2MDJhYjVmOGQ4MzY1YjU5NjY3ZDVjYTUxNTFmYjE4MGY1Njg5
14
+ Yzk5YTRkMzUxMTM3ZWVmOTIyYzhkYWFkOTBlOTdhNjVhZTMyZjM4OTRiZGEz
15
+ MTc0MmQzYjg2ZTI4NGYxMzViYjBhYzY4ODQwYmY2Nzk0NjkxYjE=
@@ -15,3 +15,6 @@
15
15
 
16
16
  Dir[File.join(File.dirname(__FILE__), 'cumulogic_client/*.rb')].sort.each { |rb| require rb }
17
17
 
18
+ module CumulogicClient
19
+
20
+ end
@@ -1,4 +1,3 @@
1
- # Copyright 2014 CumuLogic, Inc
2
1
  #
3
2
  # Licensed under the Apache License, Version 2.0 (the "License");
4
3
  # you may not use this file except in compliance with the License.
@@ -14,84 +13,88 @@
14
13
 
15
14
  require 'timeout'
16
15
 
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
16
+ module CumulogicClient
26
17
 
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 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)
18
+ class CumulogicClient::BaseClient
19
+ def initialize(api_url, username, password, use_ssl=nil, debug=false)
20
+ @api_url = api_url
21
+ @username = username
22
+ @password = password
23
+ @use_ssl = use_ssl
24
+ @debug = debug
25
+ @validationparams = nil
26
+ end
47
27
 
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}"
28
+ def call(command, params=nil)
29
+ login() if not @validationparams
30
+ callparams = Hash.new()
31
+ callparams[:inputParams] = Array.new(1)
32
+ callparams[:inputParams][0] = params if params
33
+ callparams[:validationParams] = @validationparams
34
+ request(command, callparams)
54
35
  end
55
36
 
56
- puts response.body if @debug
37
+ def request(command, params=nil)
38
+ url = "#{@api_url}#{command}"
39
+ puts url if @debug
40
+ puts params.to_json if @debug
41
+ uri = URI.parse(url)
42
+ http = Net::HTTP.new(uri.host, uri.port)
43
+ http.use_ssl = @use_ssl
44
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
45
+ request = Net::HTTP::Post.new(uri.request_uri)
46
+ request.body = URI::encode(params.to_json) if params
47
+ response = http.request(request)
57
48
 
58
- responsedata = JSON.parse(response.body)
49
+ if !response.is_a?(Net::HTTPOK)
50
+ if ["431","530","404"].include?(response.code)
51
+ raise ArgumentError, response.message
52
+ end
53
+ raise RuntimeError, "Username and password not accepted" if ["401","403"].include?(response.code)
54
+ raise RuntimeError, "Unknown error: code=#{response.code} message=#{response.message}"
55
+ end
59
56
 
60
- raise RuntimeError, "Errors: #{responsedata["errors"]}" if not responsedata["success"]
61
- return responsedata["response"]
57
+ puts response.body if @debug
62
58
 
63
- end
59
+ responsedata = JSON.parse(response.body)
64
60
 
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
- }
61
+ raise RuntimeError, "Errors: #{responsedata["errors"]}" if not responsedata["success"]
62
+ return responsedata["response"]
80
63
 
81
- end
64
+ end
65
+
66
+ def login()
67
+ credentials = Array.new(1)
68
+ credentials[0] = {
69
+ "userName" => @username,
70
+ "password" => @password
71
+ }
72
+ login_params = Hash.new
73
+ login_params["validationParams"] = Hash.new
74
+ login_params["inputParams"] = credentials
75
+ loginresponse = request("auth/login", login_params)
76
+ @validationparams = {
77
+ "userID" => loginresponse[0]["userID"],
78
+ "userName" => loginresponse[0]["userName"],
79
+ "userLoginToken" => loginresponse[0]["userLoginToken"]
80
+ }
82
81
 
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
82
+ end
83
+
84
+ def provisioning_completed(targetobject, timeout=nil)
85
+ return Timeout::timeout(timeout) do
86
+ while true do
87
+ if not targetobject.isComplete()
88
+ puts "returned false"
89
+ sleep 10
90
+ else
91
+ puts "returned true"
92
+ return true
93
+ end
94
+ end
93
95
  end
94
96
  end
97
+
95
98
  end
96
99
 
97
100
  end
@@ -12,80 +12,82 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
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
15
+ module CumulogicClient
16
+ class Nosql
17
+ def initialize(api_url, username, password, use_ssl=nil, debug=false)
18
+ @client = CumulogicClient::BaseClient.new(api_url, username, password, use_ssl, debug)
19
+ end
19
20
 
20
- def engine_list()
21
- return @client.call('nosql/nosqlengine/list')
22
- end
21
+ def engine_list()
22
+ return @client.call('nosql/nosqlengine/list')
23
+ end
23
24
 
24
- def list()
25
- return @client.call('nosql/instance/list')
26
- end
25
+ def list()
26
+ return @client.call('nosql/instance/list')
27
+ end
27
28
 
28
- def events(instanceId)
29
- params = {
30
- 'noSqlInstanceId' => instanceId
31
- }
32
- return @client.call('nosql/instance/showEvents', params)
33
- end
29
+ def events(instanceId)
30
+ params = {
31
+ 'noSqlInstanceId' => instanceId
32
+ }
33
+ return @client.call('nosql/instance/showEvents', params)
34
+ end
34
35
 
35
- def delete(instanceId)
36
- params = {
37
- 'noSqlInstanceId' => instanceId
38
- }
39
- return @client.call('nosql/instance/deleteNoSqlInstance', params)
40
- end
36
+ def delete(instanceId)
37
+ params = {
38
+ 'noSqlInstanceId' => instanceId
39
+ }
40
+ return @client.call('nosql/instance/deleteNoSqlInstance', params)
41
+ end
41
42
 
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
43
+ def create(spec)
44
+ response = @client.call('nosql/instance/createNoSqlInstance', spec.to_hash)
45
+ @newInstanceId = response[0]['noSqlInstanceId']
46
+ @client.provisioning_completed(self, 30)
47
+ return @newInstanceId
48
+ end
48
49
 
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
50
+ def isComplete()
51
+ instances = self.list()
52
+ puts instances
53
+ target = instances.select { |id| id["noSqlInstanceId"] = @newInstanceId }
54
+ return false if (target[0]["status"] == 2)
55
+ raise RuntimeError, "Error provisioning instance: #{target[0]["errorMessage"]}" if (target[0]["status"] == 3)
56
+ return true
57
+ end
57
58
 
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
59
+ NoSQLSpec = Class.new do
60
+ attr_accessor :name
61
+ attr_accessor :description
62
+ attr_accessor :nodes
63
+ attr_accessor :collectionName
64
+ attr_accessor :characterSet
65
+ attr_accessor :port
66
+ attr_accessor :noSqlEngineId
67
+ attr_accessor :targetCloudId
68
+ attr_accessor :availabilityZoneName
69
+ attr_accessor :instanceTypeId
70
+ attr_accessor :serviceTag
71
+ attr_accessor :accessGroupId
72
+ attr_accessor :noSqlParamGroupId
73
+ attr_accessor :storageSize
74
+ attr_accessor :isbackupPreferenceSet
75
+ attr_accessor :isAutoUpdateEnabled
76
+ attr_accessor :backupRetentionPeriod
77
+ attr_accessor :backupStartTime
78
+ attr_accessor :ownerType
79
+ attr_accessor :isAvailabilityZoneMandatory
80
+ attr_accessor :isInstanceTypeMandatory
81
+ attr_accessor :availabilityZone
82
+ attr_accessor :isVolumeSizeMandatory
83
+ attr_accessor :backupRetentionPeriod
84
+ attr_accessor :backupStartTime
85
+ attr_accessor :start
85
86
 
86
- def to_hash
87
- Hash[*instance_variables.map { |v| [v.to_s().tr("@", ""), instance_variable_get(v)] }.flatten]
87
+ def to_hash
88
+ Hash[*instance_variables.map { |v| [v.to_s().tr("@", ""), instance_variable_get(v)] }.flatten]
89
+ end
88
90
  end
89
- end
90
91
 
92
+ end
91
93
  end
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module CumulogicClient
16
- VERSION = "0.0.3"
16
+ VERSION = "0.0.4"
17
17
  end
@@ -31,7 +31,4 @@ describe "base_client" do
31
31
  it "can get DB engine list" do
32
32
  @client.call("dbaas/dbengine/list")
33
33
  end
34
- it "can get instance types" do
35
- @client.listInstanceTypes("Zone#1")
36
- end
37
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cumulogic_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chip Childers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-08 00:00:00.000000000 Z
11
+ date: 2014-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler