mms-api 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mms/agent.rb +1 -1
- data/lib/mms/cli.rb +2 -2
- data/lib/mms/client.rb +11 -4
- data/lib/mms/resource.rb +10 -8
- data/lib/mms/resource/cluster.rb +1 -1
- data/lib/mms/resource/snapshot.rb +1 -1
- data/lib/mms/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99243da27e77449309ff42e832ed197d1fa4487b
|
4
|
+
data.tar.gz: bcf2dd491e8c55d6626c73ad8b0e50a76b19e6e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8664f3eb89de119c3acb66ff643370b8dee51f6e449366699e5bdbd54dd7b1e9a24e4666434bb58304ae1b7d25b5d04955d553f4db88a38ddbc33e0b154025e2
|
7
|
+
data.tar.gz: 8ee7a3250ddba415772c9454a01b365f06f74cce855d01333e975fb180bb30f563063649ee8e96db7c1e45716cd390ad0f6638adf9dcb275ed074b88e5e5a266
|
data/lib/mms/agent.rb
CHANGED
@@ -157,7 +157,7 @@ module MMS
|
|
157
157
|
find_group(group_id).cluster(cluster_id).snapshot(type_value).create_restorejob
|
158
158
|
else
|
159
159
|
datetime = (type_value == 'now' ? DateTime.now : DateTime.parse(type_value))
|
160
|
-
|
160
|
+
raise('Invalid datetime. Correct `YYYY-MM-RRTH:m:sZ`') if datetime.nil?
|
161
161
|
datetime_string = [[datetime.year, datetime.month, datetime.day].join('-'), 'T', [datetime.hour, datetime.minute, datetime.second].join(':'), 'Z'].join
|
162
162
|
find_group(group_id).cluster(cluster_id).create_restorejob(datetime_string)
|
163
163
|
end
|
data/lib/mms/cli.rb
CHANGED
@@ -53,9 +53,9 @@ module MMS
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def parse_user_home_config
|
56
|
-
|
56
|
+
raise(MMS::ConfigError.new('Config file path is not set!')) if @config.config_path.nil?
|
57
57
|
config_file = Pathname.new(@config.config_path)
|
58
|
-
|
58
|
+
raise(MMS::ConfigError.new("Config file `#{config_file}` does not exist")) unless config_file.exist?
|
59
59
|
|
60
60
|
config = ParseConfig.new(config_file)
|
61
61
|
config.params.map do |key, value|
|
data/lib/mms/client.rb
CHANGED
@@ -39,6 +39,13 @@ module MMS
|
|
39
39
|
_request(Net::HTTP::Patch, @url + path, @username, @apikey, data)
|
40
40
|
end
|
41
41
|
|
42
|
+
# @param [String] path
|
43
|
+
# @param [Hash] data
|
44
|
+
# @return [Hash]
|
45
|
+
def put(path, data)
|
46
|
+
_request(Net::HTTP::Put, @url + path, @username, @apikey, data)
|
47
|
+
end
|
48
|
+
|
42
49
|
private
|
43
50
|
|
44
51
|
# @param [Net::HTTPRequest] http_method
|
@@ -61,7 +68,7 @@ module MMS
|
|
61
68
|
req = http_method.new(uri.request_uri, 'Content-Type' => 'application/json')
|
62
69
|
res = http.request req
|
63
70
|
|
64
|
-
|
71
|
+
raise 'Invalid method' unless http_method.is_a?(Class) && http_method < Net::HTTPRequest
|
65
72
|
req = http_method.new(uri.request_uri, 'Content-Type' => 'application/json')
|
66
73
|
method_name = http_method.name.split('::').last.upcase
|
67
74
|
auth = digest_auth.auth_header(uri, res['WWW-Authenticate'], method_name)
|
@@ -75,11 +82,11 @@ module MMS
|
|
75
82
|
msg = "http 'get' error for url `#{url}`"
|
76
83
|
msg = response_json['detail'] unless response_json['detail'].nil?
|
77
84
|
|
78
|
-
|
79
|
-
|
85
|
+
raise MMS::AuthError.new(msg, req, response) if response.code == '401'
|
86
|
+
raise MMS::ApiError.new(msg, req, response)
|
80
87
|
end
|
81
88
|
|
82
|
-
|
89
|
+
response_json.nil? || response_json['results'].nil? ? response_json : response_json['results']
|
83
90
|
end
|
84
91
|
end
|
85
92
|
end
|
data/lib/mms/resource.rb
CHANGED
@@ -32,31 +32,31 @@ module MMS
|
|
32
32
|
|
33
33
|
# @return [Array<String>]
|
34
34
|
def table_row
|
35
|
-
|
35
|
+
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
|
36
36
|
end
|
37
37
|
|
38
38
|
# @return [Array]
|
39
39
|
def table_section
|
40
|
-
|
40
|
+
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
|
41
41
|
end
|
42
42
|
|
43
43
|
# @return [Array<String>]
|
44
44
|
def self.table_header
|
45
|
-
|
45
|
+
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
|
46
46
|
end
|
47
47
|
|
48
48
|
def _load(_id)
|
49
|
-
|
49
|
+
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
|
50
50
|
end
|
51
51
|
|
52
52
|
# @param [Hash] _data
|
53
53
|
def _from_hash(_data)
|
54
|
-
|
54
|
+
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
|
55
55
|
end
|
56
56
|
|
57
57
|
# @return [Hash]
|
58
58
|
def _to_hash
|
59
|
-
|
59
|
+
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
|
60
60
|
end
|
61
61
|
|
62
62
|
def invalidate_cache
|
@@ -84,8 +84,10 @@ module MMS
|
|
84
84
|
"Class::#{self.class.name}:#{id}"
|
85
85
|
end
|
86
86
|
|
87
|
-
|
88
|
-
|
87
|
+
class << self
|
88
|
+
def cache_key(id)
|
89
|
+
"Class::#{name}:#{id}"
|
90
|
+
end
|
89
91
|
end
|
90
92
|
end
|
91
93
|
end
|
data/lib/mms/resource/cluster.rb
CHANGED
@@ -67,7 +67,7 @@ module MMS
|
|
67
67
|
job_data_list = @client.post('/groups/' + group.id + '/clusters/' + @id + '/restoreJobs', data)
|
68
68
|
|
69
69
|
if job_data_list.nil?
|
70
|
-
|
70
|
+
raise MMS::ResourceError.new("Cannot create job from snapshot `#{id}`", self)
|
71
71
|
end
|
72
72
|
|
73
73
|
job_data_list.map do |job_data|
|
@@ -61,7 +61,7 @@ module MMS
|
|
61
61
|
job_data_list = @client.post '/groups/' + cluster.group.id + '/clusters/' + cluster.id + '/restoreJobs', data
|
62
62
|
|
63
63
|
if job_data_list.nil?
|
64
|
-
|
64
|
+
raise MMS::ResourceError.new("Cannot create job from snapshot `#{id}`", self)
|
65
65
|
end
|
66
66
|
|
67
67
|
job_data_list.map do |job_data|
|
data/lib/mms/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mms-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cargo Media
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: net-http-digest_auth
|
@@ -100,16 +100,16 @@ dependencies:
|
|
100
100
|
name: rubocop
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- - "
|
103
|
+
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
105
|
+
version: 0.41.2
|
106
106
|
type: :development
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- - "
|
110
|
+
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
112
|
+
version: 0.41.2
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: rspec
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|