Class: Armrest::Api::Auth::Metadata
- Defined in:
- lib/armrest/api/auth/metadata.rb
Constant Summary collapse
- @@available =
nil
Constants inherited from Base
Base::HTTP_READ_METHODS, Base::HTTP_WRITE_METHODS, Base::MAX_RETRIES
Instance Method Summary collapse
- #api_version ⇒ Object
- #available? ⇒ Boolean
- #creds ⇒ Object
-
#endpoint ⇒ Object
interface method.
-
#headers ⇒ Object
interface method.
-
#initialize(options = {}) ⇒ Metadata
constructor
A new instance of Metadata.
- #query_params ⇒ Object
Methods inherited from Base
#append_api_version, #build_request, #http, #request, #send_request, #set_headers!, #standarize_path, #url, #with_open_timeout
Methods included from Settings
#client_id, #client_secret, #group, #location, #resource, #subscription_id, #tenant_id
Methods included from HandleResponse
Methods included from Logging
#default_logger, #logger, #logger=
Constructor Details
#initialize(options = {}) ⇒ Metadata
Returns a new instance of Metadata.
4 5 6 |
# File 'lib/armrest/api/auth/metadata.rb', line 4 def initialize(={}) @options = end |
Instance Method Details
#api_version ⇒ Object
47 48 49 |
# File 'lib/armrest/api/auth/metadata.rb', line 47 def api_version "2021-10-01" end |
#available? ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/armrest/api/auth/metadata.rb', line 15 def available? return false if ENV['ARMREST_DISABLE_MSI'] return @@available unless @@available.nil? url = "metadata/instance" resp = nil with_open_timeout(1.5) do resp = get(url) end @@available = resp.code == "200" rescue Net::OpenTimeout => e logger.debug "#{e.class}: #{e.}" false end |
#creds ⇒ Object
8 9 10 11 12 |
# File 'lib/armrest/api/auth/metadata.rb', line 8 def creds url = "metadata/identity/oauth2/token?" + Rack::Utils.build_query(query_params) resp = get(url) load_json(resp) end |
#endpoint ⇒ Object
interface method
38 39 40 |
# File 'lib/armrest/api/auth/metadata.rb', line 38 def endpoint "http://169.254.169.254" end |
#headers ⇒ Object
interface method
43 44 45 |
# File 'lib/armrest/api/auth/metadata.rb', line 43 def headers { Metadata: true } end |
#query_params ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/armrest/api/auth/metadata.rb', line 29 def query_params params = { resource: resource } params[:client_id] = client_id if client_id params[:object_id] = object_id if @options[:object_id] params[:msi_res_id] = msi_res_id if @options[:msi_res_id] params end |