redfish_client 0.6.0 → 0.6.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 +4 -4
- metadata +12 -28
- data/.codeclimate.yml +0 -4
- data/.github/workflows/ci.yml +0 -21
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.rubocop.yml +0 -48
- data/.simplecov +0 -3
- data/.yardopts +0 -3
- data/Gemfile +0 -6
- data/LICENSE +0 -202
- data/README.md +0 -98
- data/Rakefile +0 -6
- data/bin/console +0 -10
- data/bin/setup +0 -8
- data/lib/redfish_client/connector.rb +0 -262
- data/lib/redfish_client/event_listener.rb +0 -35
- data/lib/redfish_client/nil_hash.rb +0 -44
- data/lib/redfish_client/resource.rb +0 -290
- data/lib/redfish_client/response.rb +0 -47
- data/lib/redfish_client/root.rb +0 -77
- data/lib/redfish_client/version.rb +0 -5
- data/lib/redfish_client.rb +0 -21
- data/redfish_client.gemspec +0 -42
data/lib/redfish_client/root.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "server_sent_events"
|
4
|
-
|
5
|
-
require "redfish_client/event_listener"
|
6
|
-
require "redfish_client/resource"
|
7
|
-
|
8
|
-
module RedfishClient
|
9
|
-
# Root resource represents toplevel entry point into Redfish service data.
|
10
|
-
# Its main purpose is to provide authentication support for the API.
|
11
|
-
class Root < Resource
|
12
|
-
# Find Redfish service object by OData ID field.
|
13
|
-
#
|
14
|
-
# @param oid [String] Odata id of the resource
|
15
|
-
# @return [Resource, nil] new resource or nil if resource cannot be found
|
16
|
-
def find(oid)
|
17
|
-
find!(oid)
|
18
|
-
rescue NoResource
|
19
|
-
nil
|
20
|
-
end
|
21
|
-
|
22
|
-
# Find Redfish service object by OData ID field.
|
23
|
-
#
|
24
|
-
# @param oid [String] Odata id of the resource
|
25
|
-
# @return [Resource] new resource
|
26
|
-
# @raise [NoResource] resource cannot be fetched
|
27
|
-
def find!(oid)
|
28
|
-
Resource.new(@connector, oid: oid)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Return event listener.
|
32
|
-
#
|
33
|
-
# If the service does not support SSE, this function will return nil.
|
34
|
-
#
|
35
|
-
# @return [EventListener, nil] event listener
|
36
|
-
def event_listener
|
37
|
-
address = dig("EventService", "ServerSentEventUri")
|
38
|
-
return nil if address.nil?
|
39
|
-
|
40
|
-
EventListener.new(ServerSentEvents.create_client(address))
|
41
|
-
end
|
42
|
-
|
43
|
-
# Authenticate against the service.
|
44
|
-
#
|
45
|
-
# Calling this method will select the appropriate method of authentication
|
46
|
-
# and try to login using provided credentials.
|
47
|
-
#
|
48
|
-
# @param username [String] username
|
49
|
-
# @param password [String] password
|
50
|
-
# @raise [RedfishClient::AuthenticatedConnector::AuthError] if user
|
51
|
-
# session could not be authenticated
|
52
|
-
def login(username, password)
|
53
|
-
@connector.set_auth_info(
|
54
|
-
username, password, auth_test_path, session_path
|
55
|
-
)
|
56
|
-
@connector.login
|
57
|
-
end
|
58
|
-
|
59
|
-
# Sign out of the service.
|
60
|
-
def logout
|
61
|
-
@connector.logout
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def session_path
|
67
|
-
# We access raw values here on purpose, since calling dig on resource
|
68
|
-
# instance would try to download the sessions collection, which would
|
69
|
-
# fail since we are not yet logged in.
|
70
|
-
raw.dig("Links", "Sessions", "@odata.id")
|
71
|
-
end
|
72
|
-
|
73
|
-
def auth_test_path
|
74
|
-
raw.values.find { |v| v["@odata.id"] }["@odata.id"]
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
data/lib/redfish_client.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "redfish_client/connector"
|
4
|
-
require "redfish_client/nil_hash"
|
5
|
-
require "redfish_client/root"
|
6
|
-
require "redfish_client/version"
|
7
|
-
|
8
|
-
module RedfishClient
|
9
|
-
# Create new Redfish API client.
|
10
|
-
#
|
11
|
-
# @param url [String] base URL of Redfish API
|
12
|
-
# @param prefix [String] Redfish API prefix
|
13
|
-
# @param verify [Boolean] verify certificates for https connections
|
14
|
-
# @param use_session [Boolean] Use a session for authentication
|
15
|
-
# @param use_cache [Boolean] cache API responses
|
16
|
-
def self.new(url, prefix: "/redfish/v1", verify: true, use_cache: true, use_session: true)
|
17
|
-
cache = (use_cache ? Hash : NilHash).new
|
18
|
-
con = Connector.new(url, verify: verify, cache: cache, use_session: use_session)
|
19
|
-
Root.new(con, oid: prefix)
|
20
|
-
end
|
21
|
-
end
|
data/redfish_client.gemspec
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "redfish_client/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "redfish_client"
|
8
|
-
spec.version = RedfishClient::VERSION
|
9
|
-
spec.authors = ["Tadej Borovšak"]
|
10
|
-
spec.email = ["tadej.borovsak@xlab.si"]
|
11
|
-
|
12
|
-
spec.summary = "Simple Redfish client library"
|
13
|
-
spec.homepage = "https://github.com/xlab-steampunk/redfish-client-ruby"
|
14
|
-
spec.license = "Apache-2.0"
|
15
|
-
|
16
|
-
if spec.respond_to?(:metadata)
|
17
|
-
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
|
-
else
|
19
|
-
raise "RubyGems 2.0 or newer is required to protect against " \
|
20
|
-
"public gem pushes."
|
21
|
-
end
|
22
|
-
|
23
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
24
|
-
f.match(%r{^(test|spec|features)/})
|
25
|
-
end
|
26
|
-
spec.bindir = "exe"
|
27
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
-
spec.require_paths = ["lib"]
|
29
|
-
|
30
|
-
spec.required_ruby_version = ">= 2.1"
|
31
|
-
|
32
|
-
spec.add_runtime_dependency "excon", "~> 0.71"
|
33
|
-
spec.add_runtime_dependency "server_sent_events", "~> 0.1"
|
34
|
-
|
35
|
-
spec.add_development_dependency "rake", ">= 11.0"
|
36
|
-
spec.add_development_dependency "rspec", ">= 3.7"
|
37
|
-
spec.add_development_dependency "simplecov"
|
38
|
-
spec.add_development_dependency "webmock", "~> 3.4"
|
39
|
-
spec.add_development_dependency "yard"
|
40
|
-
spec.add_development_dependency "rubocop", "~> 0.54.0"
|
41
|
-
spec.add_development_dependency "pry"
|
42
|
-
end
|