Class: Armrest::Api::Main
Constant Summary collapse
- @@creds_cache =
cache key is the resource/audience. IE:
"https://management.azure.com" => {..., "https://vault.azure.com" => ...,
}
{}
Constants inherited from Base
Base::HTTP_READ_METHODS, Base::HTTP_WRITE_METHODS, Base::MAX_RETRIES
Instance Method Summary collapse
Methods inherited from Base
#append_api_version, #build_request, #http, #initialize, #request, #send_request, #set_headers!, #standarize_path, #url, #with_open_timeout
Methods included from Settings
#client_id, #client_secret, #endpoint, #group, #location, #resource, #subscription_id, #tenant_id
Methods included from HandleResponse
Methods included from Logging
#default_logger, #logger, #logger=
Constructor Details
This class inherits a constructor from Armrest::Api::Base
Instance Method Details
#authorization ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/armrest/api/main.rb', line 16 def creds = @@creds_cache[resource] if creds && Time.now < Time.at(creds['expires_on'].to_i) return bearer_token(creds) end provider = Armrest::Auth.new(@options).provider if provider creds = provider.creds @@creds_cache[resource] = creds bearer_token(creds) end end |
#bearer_token(creds) ⇒ Object
30 31 32 |
# File 'lib/armrest/api/main.rb', line 30 def bearer_token(creds) "#{creds['token_type']} #{creds['access_token']}" end |
#headers ⇒ Object
3 4 5 6 7 8 |
# File 'lib/armrest/api/main.rb', line 3 def headers { "Authorization" => , "Content-Type" => "application/json", } end |