Class: Vra::CatalogBase

Inherits:
Object
  • Object
show all
Defined in:
lib/vra/catalog_base.rb

Overview

Base class with common methods

Direct Known Subclasses

CatalogItem, CatalogSource, CatalogType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, opts) ⇒ CatalogBase

Either one of id or data hash is required, must not supply both

Parameters:

  • client (Vra::Client)
    • a vra client object

  • opts (Hash)
    • Contains the either id of the catalog or the data hash



27
28
29
30
31
# File 'lib/vra/catalog_base.rb', line 27

def initialize(client, opts)
  @client = client
  @id     = opts[:id]
  @data   = opts[:data]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



22
23
24
# File 'lib/vra/catalog_base.rb', line 22

def id
  @id
end

Instance Method Details

#entitle!(opts = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/vra/catalog_base.rb', line 33

def entitle!(opts = {})
  response = client.http_post(
    "/catalog/api/admin/entitlements?project_id=#{project_id}",
    FFI_Yajl::Encoder.encode(entitle_params(opts[:type])),
    opts[:skip_auth] || false
  )

  FFI_Yajl::Parser.parse(response.body)
end