Class: Barge::Client
- Inherits:
-
Object
- Object
- Barge::Client
- Defined in:
- lib/barge/client.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{}
- DIGITAL_OCEAN_URL =
'https://api.digitalocean.com/v2'
- TIMEOUTS =
10
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#request_options ⇒ Object
Returns the value of attribute request_options.
Instance Method Summary collapse
- #account ⇒ Object
- #action ⇒ Object
- #domain ⇒ Object
- #droplet ⇒ Object
- #faraday ⇒ Object
- #floating_ip ⇒ Object
- #image ⇒ Object
-
#initialize(options = DEFAULT_OPTIONS) {|_self| ... } ⇒ Client
constructor
A new instance of Client.
- #key ⇒ Object
- #region ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(options = DEFAULT_OPTIONS) {|_self| ... } ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 |
# File 'lib/barge/client.rb', line 13 def initialize( = DEFAULT_OPTIONS) self.access_token = .fetch(:access_token, nil) self. = { open_timeout: TIMEOUTS, timeout: TIMEOUTS } .merge(.fetch(:request_options, {})) yield(self) if block_given? fail ArgumentError, 'missing access_token' unless access_token end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/barge/client.rb', line 6 def access_token @access_token end |
#request_options ⇒ Object
Returns the value of attribute request_options.
7 8 9 |
# File 'lib/barge/client.rb', line 7 def @request_options end |
Instance Method Details
#account ⇒ Object
22 23 24 |
# File 'lib/barge/client.rb', line 22 def account @account ||= Resource::Account.new(faraday) end |
#action ⇒ Object
26 27 28 |
# File 'lib/barge/client.rb', line 26 def action @action ||= Resource::Action.new(faraday) end |
#domain ⇒ Object
30 31 32 |
# File 'lib/barge/client.rb', line 30 def domain @domain ||= Resource::Domain.new(faraday) end |
#droplet ⇒ Object
34 35 36 |
# File 'lib/barge/client.rb', line 34 def droplet @droplet ||= Resource::Droplet.new(faraday) end |
#faraday ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/barge/client.rb', line 58 def faraday @faraday ||= Faraday.new do |f| f.adapter :net_http f.request :json f.response :follow_redirects f.response :mashify f.response :json f..merge! end end |
#floating_ip ⇒ Object
54 55 56 |
# File 'lib/barge/client.rb', line 54 def floating_ip @floating_ip ||= Resource::FloatingIP.new(faraday) end |
#image ⇒ Object
38 39 40 |
# File 'lib/barge/client.rb', line 38 def image @image ||= Resource::Image.new(faraday) end |
#key ⇒ Object
42 43 44 |
# File 'lib/barge/client.rb', line 42 def key @key ||= Resource::Key.new(faraday) end |