Class: ManageIQ::API::Client
- Inherits:
-
Object
- Object
- ManageIQ::API::Client
- Extended by:
- Forwardable
- Defined in:
- lib/manageiq/api/client/api.rb,
lib/manageiq/api/client/error.rb,
lib/manageiq/api/client/action.rb,
lib/manageiq/api/client/client.rb,
lib/manageiq/api/client/version.rb,
lib/manageiq/api/client/identity.rb,
lib/manageiq/api/client/resource.rb,
lib/manageiq/api/client/collection.rb,
lib/manageiq/api/client/connection.rb,
lib/manageiq/api/client/exceptions.rb,
lib/manageiq/api/client/api_version.rb,
lib/manageiq/api/client/null_logger.rb,
lib/manageiq/api/client/server_info.rb,
lib/manageiq/api/client/product_info.rb,
lib/manageiq/api/client/action_result.rb,
lib/manageiq/api/client/authentication.rb,
lib/manageiq/api/client/collection_options.rb
Defined Under Namespace
Classes: API, Action, ActionResult, ApiVersion, Authentication, Collection, CollectionOptions, Connection, Error, Exception, Identity, NullLogger, ProductInfo, Resource, ResourceNotFound, ServerInfo
Constant Summary collapse
- DEFAULT_URL =
URI.parse("http://localhost:3000")
- VERSION =
"0.5.0".freeze
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#authentication ⇒ Object
readonly
Returns the value of attribute authentication.
-
#authorization ⇒ Object
readonly
Returns the value of attribute authorization.
-
#client_options ⇒ Object
readonly
Returns the value of attribute client_options.
-
#collections ⇒ Object
readonly
Returns the value of attribute collections.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#identity ⇒ Object
readonly
Returns the value of attribute identity.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#product_info ⇒ Object
readonly
Returns the value of attribute product_info.
-
#server_info ⇒ Object
readonly
Returns the value of attribute server_info.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#user_settings ⇒ Object
readonly
Returns the value of attribute user_settings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(client_options = {}) ⇒ Client
constructor
A new instance of Client.
- #load_definitions ⇒ Object
- #reconnect ⇒ Object
- #update_authentication(auth_options = {}) ⇒ Object
Constructor Details
#initialize(client_options = {}) ⇒ Client
Returns a new instance of Client.
29 30 31 32 33 34 35 |
# File 'lib/manageiq/api/client/client.rb', line 29 def initialize( = {}) @client_options = .dup @logger = [:logger] || self.class.logger @url = extract_url() @authentication = ManageIQ::API::Client::Authentication.new() reconnect end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
11 12 13 |
# File 'lib/manageiq/api/client/client.rb', line 11 def api @api end |
#authentication ⇒ Object (readonly)
Returns the value of attribute authentication.
8 9 10 |
# File 'lib/manageiq/api/client/client.rb', line 8 def authentication @authentication end |
#authorization ⇒ Object (readonly)
Returns the value of attribute authorization.
14 15 16 |
# File 'lib/manageiq/api/client/client.rb', line 14 def @authorization end |
#client_options ⇒ Object (readonly)
Returns the value of attribute client_options.
5 6 7 |
# File 'lib/manageiq/api/client/client.rb', line 5 def @client_options end |
#collections ⇒ Object (readonly)
Returns the value of attribute collections.
17 18 19 |
# File 'lib/manageiq/api/client/client.rb', line 17 def collections @collections end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
9 10 11 |
# File 'lib/manageiq/api/client/client.rb', line 9 def connection @connection end |
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
13 14 15 |
# File 'lib/manageiq/api/client/client.rb', line 13 def identity @identity end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/manageiq/api/client/client.rb', line 6 def logger @logger end |
#product_info ⇒ Object (readonly)
Returns the value of attribute product_info.
16 17 18 |
# File 'lib/manageiq/api/client/client.rb', line 16 def product_info @product_info end |
#server_info ⇒ Object (readonly)
Returns the value of attribute server_info.
15 16 17 |
# File 'lib/manageiq/api/client/client.rb', line 15 def server_info @server_info end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/manageiq/api/client/client.rb', line 7 def url @url end |
#user_settings ⇒ Object (readonly)
Returns the value of attribute user_settings.
12 13 14 |
# File 'lib/manageiq/api/client/client.rb', line 12 def user_settings @user_settings end |
Class Method Details
.logger ⇒ Object
21 22 23 |
# File 'lib/manageiq/api/client/client.rb', line 21 def self.logger @logger ||= NullLogger.new end |
.logger=(logger) ⇒ Object
25 26 27 |
# File 'lib/manageiq/api/client/client.rb', line 25 def self.logger=(logger) @logger = logger end |
Instance Method Details
#load_definitions ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/manageiq/api/client/client.rb', line 37 def load_definitions entrypoint = connection.get("", :attributes => "authorization") @api = ManageIQ::API::Client::API.new(entrypoint) @user_settings = Hash(entrypoint["settings"]).dup @identity = ManageIQ::API::Client::Identity.new(Hash(entrypoint["identity"])) @authorization = Hash(entrypoint["authorization"]).dup @server_info = ServerInfo.new(Hash(entrypoint["server_info"])) @product_info = ProductInfo.new(Hash(entrypoint["product_info"])) @collections = load_collections(entrypoint["collections"]) end |
#reconnect ⇒ Object
61 62 63 64 |
# File 'lib/manageiq/api/client/client.rb', line 61 def reconnect @connection = ManageIQ::API::Client::Connection.new(self, .slice(:ssl, :open_timeout, :timeout)) load_definitions end |
#update_authentication(auth_options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/manageiq/api/client/client.rb', line 48 def update_authentication( = {}) return @authentication unless ManageIQ::API::Client::Authentication.() saved_auth = @authentication @authentication = ManageIQ::API::Client::Authentication.new() begin reconnect rescue @authentication = saved_auth raise end @authentication end |