Class: Vra::CatalogSource
- Inherits:
-
CatalogBase
- Object
- CatalogBase
- Vra::CatalogSource
- Defined in:
- lib/vra/catalog_source.rb
Overview
Class that represents the Catalog Source
Constant Summary collapse
- INDEX_URL =
'/catalog/api/admin/sources'
Instance Attribute Summary
Attributes inherited from CatalogBase
Class Method Summary collapse
-
.create(client, opts) ⇒ Object
Method to create a catalog source.
- .entitle!(client, id) ⇒ Object
Instance Method Summary collapse
- #catalog_type ⇒ Object
- #catalog_type_id ⇒ Object
- #config ⇒ Object
- #entitle!(opts = {}) ⇒ Object
- #global? ⇒ Boolean
-
#initialize(client, opts) ⇒ CatalogSource
constructor
Either one of id or data hash is required, must not supply both.
- #name ⇒ Object
- #project_id ⇒ Object
Constructor Details
#initialize(client, opts) ⇒ CatalogSource
Either one of id or data hash is required, must not supply both
29 30 31 32 33 |
# File 'lib/vra/catalog_source.rb', line 29 def initialize(client, opts) super validate! fetch_data end |
Class Method Details
.create(client, opts) ⇒ Object
Method to create a catalog source
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/vra/catalog_source.rb', line 65 def create(client, opts) validate_create!(opts) response = client.http_post( '/catalog/api/admin/sources', FFI_Yajl::Encoder.encode(create_params(opts)), opts[:skip_auth] || false ) return false unless response.success? new(client, data: FFI_Yajl::Parser.parse(response.body)) end |
.entitle!(client, id) ⇒ Object
79 80 81 |
# File 'lib/vra/catalog_source.rb', line 79 def entitle!(client, id) new(client, id: id).entitle! end |
Instance Method Details
#catalog_type ⇒ Object
43 44 45 |
# File 'lib/vra/catalog_source.rb', line 43 def catalog_type @catalog_type ||= Vra::CatalogType.new(client, id: catalog_type_id) end |
#catalog_type_id ⇒ Object
39 40 41 |
# File 'lib/vra/catalog_source.rb', line 39 def catalog_type_id data['typeId'] end |
#config ⇒ Object
47 48 49 |
# File 'lib/vra/catalog_source.rb', line 47 def config data['config'] end |
#entitle!(opts = {}) ⇒ Object
59 60 61 |
# File 'lib/vra/catalog_source.rb', line 59 def entitle!(opts = {}) super(opts.merge(type: 'CatalogSourceIdentifier')) end |
#global? ⇒ Boolean
51 52 53 |
# File 'lib/vra/catalog_source.rb', line 51 def global? data['global'] == true end |
#name ⇒ Object
35 36 37 |
# File 'lib/vra/catalog_source.rb', line 35 def name data['name'] end |
#project_id ⇒ Object
55 56 57 |
# File 'lib/vra/catalog_source.rb', line 55 def project_id config['sourceProjectId'] end |