Class: Brightbox::Account
- Inherits:
-
Api
- Object
- Api
- Brightbox::Account
show all
- Defined in:
- lib/brightbox-cli/accounts.rb
Instance Attribute Summary
Attributes inherited from Api
#id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Api
#attributes, cache_all!, cached_get, conn, #created_on, #exists?, find, find_all_or_warn, find_by_handle, find_or_call, #fog_attributes, #fog_model, #initialize, klass_name, #method_missing, require_account?, #respond_to_missing?
Constructor Details
This class inherits a constructor from Brightbox::Api
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Brightbox::Api
Class Method Details
.all ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/brightbox-cli/accounts.rb', line 23
def self.all
if Brightbox.config.using_application?
conn.accounts.all
else
[conn.account]
end
end
|
.default_field_order ⇒ Object
43
44
45
|
# File 'lib/brightbox-cli/accounts.rb', line 43
def self.default_field_order
%i[id name cloud_ips_limit lb_limit ram_limit ram_used ram_free]
end
|
.get(id) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/brightbox-cli/accounts.rb', line 31
def self.get(id)
acc = if Brightbox.config.using_application?
conn.accounts.get(id)
else
conn.account
end
return unless acc && acc.id == id
acc
end
|
Instance Method Details
#cloud_ip_limit ⇒ Object
7
8
9
|
# File 'lib/brightbox-cli/accounts.rb', line 7
def cloud_ip_limit
attributes[:cloud_ips_limit]
end
|
#lb_limit ⇒ Object
11
12
13
|
# File 'lib/brightbox-cli/accounts.rb', line 11
def lb_limit
attributes[:load_balancers_limit]
end
|
#ram_free ⇒ Object
3
4
5
|
# File 'lib/brightbox-cli/accounts.rb', line 3
def ram_free
[ram_limit.to_i - ram_used.to_i, 0].max
end
|
#to_row ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/brightbox-cli/accounts.rb', line 15
def to_row
attributes.to_h.merge(
:ram_free => ram_free,
:cloud_ip_limit => cloud_ip_limit,
:lb_limit => lb_limit
)
end
|
#to_s ⇒ Object
47
48
49
|
# File 'lib/brightbox-cli/accounts.rb', line 47
def to_s
@id
end
|