Class: Boxd::Compute
- Inherits:
-
Object
- Object
- Boxd::Compute
- Defined in:
- lib/boxd/compute.rb
Overview
Compute is the entry point. It holds the credentials + CLI backend and exposes service accessors (currently just #boxes).
compute = Boxd::Compute.new(api_key: ENV["BOXD_API_KEY"])
compute.boxes.list
compute.whoami
If api_key: is omitted, the boxd CLI’s stored login credentials are used (i.e. whatever ‘boxd login` set up locally).
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
Instance Method Summary collapse
- #boxes ⇒ Object
-
#initialize(api_key: nil, bin: nil, environment: nil) ⇒ Compute
constructor
A new instance of Compute.
- #whoami ⇒ Object
Constructor Details
#initialize(api_key: nil, bin: nil, environment: nil) ⇒ Compute
Returns a new instance of Compute.
16 17 18 19 20 |
# File 'lib/boxd/compute.rb', line 16 def initialize(api_key: nil, bin: nil, environment: nil) api_key ||= Boxd.config.api_key environment ||= Boxd.config.environment @backend = CLIBackend.new(api_key: api_key, bin: bin, environment: environment) end |
Instance Attribute Details
#backend ⇒ Object (readonly)
Returns the value of attribute backend.
14 15 16 |
# File 'lib/boxd/compute.rb', line 14 def backend @backend end |
Instance Method Details
#boxes ⇒ Object
22 23 24 |
# File 'lib/boxd/compute.rb', line 22 def boxes @boxes ||= BoxService.new(@backend) end |
#whoami ⇒ Object
26 27 28 |
# File 'lib/boxd/compute.rb', line 26 def whoami @backend.call_json("whoami") end |