Class: CloudDB::Flavor
- Inherits:
-
Object
- Object
- CloudDB::Flavor
- Defined in:
- lib/clouddb/flavor.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ram ⇒ Object
readonly
Returns the value of attribute ram.
-
#vcpus ⇒ Object
readonly
Returns the value of attribute vcpus.
Instance Method Summary collapse
-
#initialize(connection, id) ⇒ Flavor
constructor
Creates a new CloudDB::Flavor object representing a database flavor.
-
#populate ⇒ Object
(also: #refresh)
Updates the information about the current Flavor object by making an API call.
Constructor Details
#initialize(connection, id) ⇒ Flavor
Creates a new CloudDB::Flavor object representing a database flavor.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/clouddb/flavor.rb', line 10 def initialize(connection,id) @connection = connection @id = id @dbmgmthost = connection.dbmgmthost @dbmgmtpath = connection.dbmgmtpath @dbmgmtport = connection.dbmgmtport @dbmgmtscheme = connection.dbmgmtscheme populate return self end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/clouddb/flavor.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/clouddb/flavor.rb', line 5 def name @name end |
#ram ⇒ Object (readonly)
Returns the value of attribute ram.
6 7 8 |
# File 'lib/clouddb/flavor.rb', line 6 def ram @ram end |
#vcpus ⇒ Object (readonly)
Returns the value of attribute vcpus.
7 8 9 |
# File 'lib/clouddb/flavor.rb', line 7 def vcpus @vcpus end |
Instance Method Details
#populate ⇒ Object Also known as: refresh
Updates the information about the current Flavor object by making an API call.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/clouddb/flavor.rb', line 22 def populate response = @connection.dbreq("GET",@dbmgmthost,"#{@dbmgmtpath}/flavors/#{CloudDB.escape(@id.to_s)}",@dbmgmtport,@dbmgmtscheme) CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/) data = JSON.parse(response.body)['flavor'] @id = data["id"] @name = data["name"] @ram = data["ram"] @vcpus = data["vcpus"] @links = data["links"] true end |