Class: CFO::Account
- Inherits:
-
Object
- Object
- CFO::Account
- Defined in:
- lib/cfo/resources/account.rb
Overview
Represents an account for a specific service with a cloud provider.
Instance Attribute Summary collapse
-
#billing_codes ⇒ Object
An Array of String pairs representing all the BillingCodes associated with all this Acccount’s BillingRecords.
-
#name ⇒ Object
A human-readable ID for the account - best to make this URL-safe.
-
#provider ⇒ Object
The (Fog) name of the cloud computing service provider.
-
#service ⇒ Object
The (Fog) name of the cloud computing service.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Account
constructor
Creates a object representing a REST Resource for an account.
-
#report_uri ⇒ String
A URI path to this object’s cost report.
-
#to_hash(verbose = true) ⇒ Hash
A RESTful Hash representation of this object.
-
#to_json ⇒ String
A RESTful JSON representation of this object.
-
#uri ⇒ String
A URI path to this object’s JSON representation.
Constructor Details
#initialize(attributes = {}) ⇒ Account
Creates a object representing a REST Resource for an account.
19 20 21 |
# File 'lib/cfo/resources/account.rb', line 19 def initialize(attributes = {}) attributes.each {|k,v| self.send("#{k}=",v) if self.respond_to?("#{k}=")} end |
Instance Attribute Details
#billing_codes ⇒ Object
An Array of String pairs representing all the BillingCodes associated with all this Acccount’s BillingRecords.
15 16 17 |
# File 'lib/cfo/resources/account.rb', line 15 def billing_codes @billing_codes end |
#name ⇒ Object
A human-readable ID for the account - best to make this URL-safe.
5 6 7 |
# File 'lib/cfo/resources/account.rb', line 5 def name @name end |
#provider ⇒ Object
The (Fog) name of the cloud computing service provider.
8 9 10 |
# File 'lib/cfo/resources/account.rb', line 8 def provider @provider end |
#service ⇒ Object
The (Fog) name of the cloud computing service.
11 12 13 |
# File 'lib/cfo/resources/account.rb', line 11 def service @service end |
Instance Method Details
#report_uri ⇒ String
Returns a URI path to this object’s cost report.
45 46 47 |
# File 'lib/cfo/resources/account.rb', line 45 def report_uri "#{CFO.root}/report/for_account/#{URI.escape(@name)}" end |
#to_hash(verbose = true) ⇒ Hash
Returns a RESTful Hash representation of this object.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cfo/resources/account.rb', line 25 def to_hash(verbose = true) extra_info = { 'resources' => CloudResource.hash_list(:account => @name), 'billing_codes' => @billing_codes, } { 'id' => @name, 'service' => @service, 'provider' => @provider, 'url' => uri, 'report_url' => report_uri, }.merge(verbose ? extra_info : {}) end |
#to_json ⇒ String
Returns a RESTful JSON representation of this object.
50 |
# File 'lib/cfo/resources/account.rb', line 50 def to_json ; to_hash.to_json end |