redfish_client 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 845f7a73083c73f8fe2ce79f8968332dd605aa87
4
- data.tar.gz: 5e1e8056e6618c11428e0907050ef874242b78d3
3
+ metadata.gz: 2bb83aba67c60478769756f451642c1cee20e2a8
4
+ data.tar.gz: dd14b581e356f10253e9b0b9cd941d2162dd2540
5
5
  SHA512:
6
- metadata.gz: f2957a2b7baf789ef346b22e74e7cddb0894704eb30ae225ac4cd17cf95adf4e7f93d619859d2b3fb41c240bf2f34f1ffe09e2c3bc33110f11129d2664e19ca4
7
- data.tar.gz: b3d582a79ce5a8bfe435d5d08d63977414c426a00b68cd1ac02555297c0000480a2dc6bdb1c6027e17585858304633f031d46e31a52f04f9f4d4ab2b346cc7b9
6
+ metadata.gz: 67444264c37cf0f05e00262c5b2f9270511809fac96ede321166de38cfe30ec174d879db42b5b2f32f553f0a6b26eff87a2cdbebbaf59ab895fc64fef0294b11
7
+ data.tar.gz: f24893766d33f32415205011f8b2f555b55f88cb6c6726202ca5849d0074b813006396a5ec6e58d11429db45aa2c8469f92f860b5fd2ae64facba50755fcc545
@@ -82,13 +82,11 @@ module RedfishClient
82
82
  # @param data [Hash] data to be sent over the socket
83
83
  # @return [Response] response object
84
84
  def request(method, path, data = nil)
85
- params = prepare_request_params(method, path, data)
86
- r = @connection.request(params)
87
- if r.status == 401
88
- login
89
- r = @connection.request(params)
85
+ return @cache[path] if method == :get && @cache[path]
86
+
87
+ do_request(method, path, data).tap do |r|
88
+ @cache[path] = r if method == :get && r.status == 200
90
89
  end
91
- Response.new(r.status, downcase_headers(r.data[:headers]), r.data[:body])
92
90
  end
93
91
 
94
92
  # Issue GET request to service.
@@ -100,9 +98,7 @@ module RedfishClient
100
98
  # @param path [String] path to the resource, relative to the base url
101
99
  # @return [Response] response object
102
100
  def get(path)
103
- return @cache[path] if @cache[path]
104
-
105
- request(:get, path).tap { |r| @cache[path] = r if r.status == 200 }
101
+ request(:get, path)
106
102
  end
107
103
 
108
104
  # Issue POST requests to the service.
@@ -188,6 +184,16 @@ module RedfishClient
188
184
 
189
185
  private
190
186
 
187
+ def do_request(method, path, data)
188
+ params = prepare_request_params(method, path, data)
189
+ r = @connection.request(params)
190
+ if r.status == 401
191
+ login
192
+ r = @connection.request(params)
193
+ end
194
+ Response.new(r.status, downcase_headers(r.data[:headers]), r.data[:body])
195
+ end
196
+
191
197
  def downcase_headers(headers)
192
198
  headers.each_with_object({}) { |(k, v), obj| obj[k.downcase] = v }
193
199
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RedfishClient
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redfish_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tadej Borovšak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-03 00:00:00.000000000 Z
11
+ date: 2019-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon