Class: Vra::CatalogItem
- Inherits:
-
CatalogBase
- Object
- CatalogBase
- Vra::CatalogItem
- Defined in:
- lib/vra/catalog_item.rb
Overview
Class that represents the Catalog Item
Constant Summary collapse
- INDEX_URL =
'/catalog/api/admin/items'
Instance Attribute Summary collapse
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
Attributes inherited from CatalogBase
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
- #entitle!(opts = {}) ⇒ Object
- #fetch_catalog_item ⇒ Object
- #icon_id ⇒ Object
-
#initialize(client, opts = {}) ⇒ CatalogItem
constructor
A new instance of CatalogItem.
- #name ⇒ Object
- #source ⇒ Object
- #source_id ⇒ Object
- #source_name ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(client, opts = {}) ⇒ CatalogItem
Returns a new instance of CatalogItem.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/vra/catalog_item.rb', line 30 def initialize(client, opts = {}) super @project_id = opts[:project_id] validate! if @data.nil? fetch_catalog_item else @id = @data['id'] end end |
Instance Attribute Details
#project_id ⇒ Object (readonly)
Returns the value of attribute project_id.
28 29 30 |
# File 'lib/vra/catalog_item.rb', line 28 def project_id @project_id end |
Class Method Details
.entitle!(client, id) ⇒ Object
80 81 82 |
# File 'lib/vra/catalog_item.rb', line 80 def self.entitle!(client, id) new(client, id: id).entitle! end |
Instance Method Details
#description ⇒ Object
52 53 54 |
# File 'lib/vra/catalog_item.rb', line 52 def description data['description'] end |
#entitle!(opts = {}) ⇒ Object
76 77 78 |
# File 'lib/vra/catalog_item.rb', line 76 def entitle!(opts = {}) super(opts.merge(type: 'CatalogItemIdentifier')) end |
#fetch_catalog_item ⇒ Object
42 43 44 45 46 |
# File 'lib/vra/catalog_item.rb', line 42 def fetch_catalog_item @data = client.get_parsed("/catalog/api/admin/items/#{id}") rescue Vra::Exception::HTTPNotFound raise Vra::Exception::NotFound, "catalog ID #{id} does not exist" end |
#icon_id ⇒ Object
72 73 74 |
# File 'lib/vra/catalog_item.rb', line 72 def icon_id data['iconId'] end |
#name ⇒ Object
48 49 50 |
# File 'lib/vra/catalog_item.rb', line 48 def name data['name'] end |
#source ⇒ Object
64 65 66 |
# File 'lib/vra/catalog_item.rb', line 64 def source @source ||= Vra::CatalogSource.new(client, id: source_id) end |
#source_id ⇒ Object
56 57 58 |
# File 'lib/vra/catalog_item.rb', line 56 def source_id data['sourceId'] end |
#source_name ⇒ Object
60 61 62 |
# File 'lib/vra/catalog_item.rb', line 60 def source_name data['sourceName'] end |
#type ⇒ Object
68 69 70 |
# File 'lib/vra/catalog_item.rb', line 68 def type @type ||= Vra::CatalogType.new(client, data: data['type']) end |