Class: Aptible::Api
- Inherits:
-
HyperResource
- Object
- HyperResource
- Aptible::Api
- Includes:
- GemConfig::Base
- Defined in:
- lib/aptible/api.rb
Defined Under Namespace
Classes: Account, Adapter, App, Attachment, Configuration, Container, Disk, Image, Operation, Permission, Proxy, Release, Resource, Service, Vhost
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
- #adapter ⇒ Object
- #bearer_token ⇒ Object
- #find_by_url(url) ⇒ Object
-
#initialize(options = {}) ⇒ Api
constructor
A new instance of Api.
Constructor Details
#initialize(options = {}) ⇒ Api
Returns a new instance of Api.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/aptible/api.rb', line 31 def initialize( = {}) if .is_a?(Hash) self.token = [:token] [:root] ||= config.root_url [:namespace] ||= 'Aptible::Api' [:headers] ||= { 'Content-Type' => 'application/json' } [:headers].merge!( 'Authorization' => "Bearer #{bearer_token}" ) if [:token] end super() end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
10 11 12 |
# File 'lib/aptible/api.rb', line 10 def config @config end |
#token ⇒ Object
Returns the value of attribute token.
10 11 12 |
# File 'lib/aptible/api.rb', line 10 def token @token end |
Class Method Details
.adapter ⇒ Object
23 24 25 |
# File 'lib/aptible/api.rb', line 23 def self.adapter Aptible::Api::Adapter end |
.get_data_type_from_response(response) ⇒ Object
18 19 20 21 |
# File 'lib/aptible/api.rb', line 18 def self.get_data_type_from_response(response) return nil unless response && response.body adapter.get_data_type_from_object(adapter.deserialize(response.body)) end |
Instance Method Details
#adapter ⇒ Object
27 28 29 |
# File 'lib/aptible/api.rb', line 27 def adapter self.class.adapter end |
#bearer_token ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/aptible/api.rb', line 54 def bearer_token case token when Aptible::Auth::Token then token.access_token when Fridge::AccessToken then token.to_s when String then token end end |