mms-api 0.2.0 → 0.2.1

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 522bb6499771a5d35e3775dc983f503c17213531
4
- data.tar.gz: c1a3b629f19493576070783dfa937d0611195169
3
+ metadata.gz: 99243da27e77449309ff42e832ed197d1fa4487b
4
+ data.tar.gz: bcf2dd491e8c55d6626c73ad8b0e50a76b19e6e4
5
5
  SHA512:
6
- metadata.gz: 0feb735e81520656658e134e5fccbd5a46af4e192862b4072aae6a431c4e0796e7d4bb1f688c962a661d0445da7bcc4f4e477cf9d99874aa57963215de1b30b2
7
- data.tar.gz: 7bbbf7c6f5d75db491d175aa11f9b6a5774b3a862bf1400c37fac9e75b83a7491facd32651bb1d6e7326ba34b8d891298681259a9e9cc4a942b9e8f784f2ba0b
6
+ metadata.gz: 8664f3eb89de119c3acb66ff643370b8dee51f6e449366699e5bdbd54dd7b1e9a24e4666434bb58304ae1b7d25b5d04955d553f4db88a38ddbc33e0b154025e2
7
+ data.tar.gz: 8ee7a3250ddba415772c9454a01b365f06f74cce855d01333e975fb180bb30f563063649ee8e96db7c1e45716cd390ad0f6638adf9dcb275ed074b88e5e5a266
@@ -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
- fail('Invalid datetime. Correct `YYYY-MM-RRTH:m:sZ`') if datetime.nil?
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
@@ -53,9 +53,9 @@ module MMS
53
53
  end
54
54
 
55
55
  def parse_user_home_config
56
- fail(MMS::ConfigError.new('Config file path is not set!')) if @config.config_path.nil?
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
- fail(MMS::ConfigError.new("Config file `#{config_file}` does not exist")) unless config_file.exist?
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|
@@ -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
- fail 'Invalid method' unless http_method.is_a?(Class) && http_method < Net::HTTPRequest
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
- fail MMS::AuthError.new(msg, req, response) if response.code == '401'
79
- fail MMS::ApiError.new(msg, req, response)
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
- (response_json.nil? || response_json['results'].nil?) ? response_json : response_json['results']
89
+ response_json.nil? || response_json['results'].nil? ? response_json : response_json['results']
83
90
  end
84
91
  end
85
92
  end
@@ -32,31 +32,31 @@ module MMS
32
32
 
33
33
  # @return [Array<String>]
34
34
  def table_row
35
- fail("`#{__method__}` is not implemented for `#{self.class.name}`")
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
- fail("`#{__method__}` is not implemented for `#{self.class.name}`")
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
- fail("`#{__method__}` is not implemented for `#{self.class.name}`")
45
+ raise("`#{__method__}` is not implemented for `#{self.class.name}`")
46
46
  end
47
47
 
48
48
  def _load(_id)
49
- fail("`#{__method__}` is not implemented for `#{self.class.name}`")
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
- fail("`#{__method__}` is not implemented for `#{self.class.name}`")
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
- fail("`#{__method__}` is not implemented for `#{self.class.name}`")
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
- def self.cache_key(id)
88
- "Class::#{name}:#{id}"
87
+ class << self
88
+ def cache_key(id)
89
+ "Class::#{name}:#{id}"
90
+ end
89
91
  end
90
92
  end
91
93
  end
@@ -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
- fail MMS::ResourceError.new("Cannot create job from snapshot `#{id}`", self)
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
- fail MMS::ResourceError.new("Cannot create job from snapshot `#{id}`", self)
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|
@@ -1,3 +1,3 @@
1
1
  module MMS
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'.freeze
3
3
  end
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.0
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: 2015-12-07 00:00:00.000000000 Z
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: '0'
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: '0'
112
+ version: 0.41.2
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rspec
115
115
  requirement: !ruby/object:Gem::Requirement