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 +4 -4
- data/lib/redfish_client/connector.rb +15 -9
- data/lib/redfish_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bb83aba67c60478769756f451642c1cee20e2a8
|
4
|
+
data.tar.gz: dd14b581e356f10253e9b0b9cd941d2162dd2540
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2019-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|