Class: Vra::CatalogItem
- Inherits:
-
Object
- Object
- Vra::CatalogItem
- Defined in:
- lib/vra/catalog_item.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #blueprint_id ⇒ Object
- #description ⇒ Object
- #fetch_catalog_item ⇒ Object
-
#initialize(client, opts) ⇒ CatalogItem
constructor
A new instance of CatalogItem.
- #name ⇒ Object
- #organization ⇒ Object
- #status ⇒ Object
- #subtenant_id ⇒ Object
- #subtenant_name ⇒ Object
- #tenant_id ⇒ Object
- #tenant_name ⇒ Object
Constructor Details
#initialize(client, opts) ⇒ CatalogItem
Returns a new instance of CatalogItem.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vra/catalog_item.rb', line 24 def initialize(client, opts) @client = client @id = opts[:id] @catalog_item_data = opts[:data] if @id.nil? && @catalog_item_data.nil? raise ArgumentError, 'must supply an id or a catalog item data hash' end if !@id.nil? && !@catalog_item_data.nil? raise ArgumentError, 'must supply an id OR a catalog item data hash, not both' end if @catalog_item_data.nil? fetch_catalog_item else @id = @catalog_item_data['id'] end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
23 24 25 |
# File 'lib/vra/catalog_item.rb', line 23 def client @client end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
23 24 25 |
# File 'lib/vra/catalog_item.rb', line 23 def id @id end |
Instance Method Details
#blueprint_id ⇒ Object
84 85 86 |
# File 'lib/vra/catalog_item.rb', line 84 def blueprint_id @catalog_item_data['providerBinding']['bindingId'] end |
#description ⇒ Object
54 55 56 |
# File 'lib/vra/catalog_item.rb', line 54 def description @catalog_item_data['description'] end |
#fetch_catalog_item ⇒ Object
44 45 46 47 48 |
# File 'lib/vra/catalog_item.rb', line 44 def fetch_catalog_item @catalog_item_data = client.get_parsed("/catalog-service/api/consumer/catalogItems/#{id}") rescue Vra::Exception::HTTPNotFound raise Vra::Exception::NotFound, "catalog ID #{id} does not exist" end |
#name ⇒ Object
50 51 52 |
# File 'lib/vra/catalog_item.rb', line 50 def name @catalog_item_data['name'] end |
#organization ⇒ Object
62 63 64 65 66 |
# File 'lib/vra/catalog_item.rb', line 62 def organization return {} if @catalog_item_data['organization'].nil? @catalog_item_data['organization'] end |
#status ⇒ Object
58 59 60 |
# File 'lib/vra/catalog_item.rb', line 58 def status @catalog_item_data['status'] end |
#subtenant_id ⇒ Object
76 77 78 |
# File 'lib/vra/catalog_item.rb', line 76 def subtenant_id organization['subtenantRef'] end |
#subtenant_name ⇒ Object
80 81 82 |
# File 'lib/vra/catalog_item.rb', line 80 def subtenant_name organization['subtenantLabel'] end |
#tenant_id ⇒ Object
68 69 70 |
# File 'lib/vra/catalog_item.rb', line 68 def tenant_id organization['tenantRef'] end |
#tenant_name ⇒ Object
72 73 74 |
# File 'lib/vra/catalog_item.rb', line 72 def tenant_name organization['tenantLabel'] end |