Class: Vra::CatalogSource

Inherits:
CatalogBase show all
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

#id

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, opts) ⇒ CatalogSource

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



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_typeObject



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_idObject



39
40
41
# File 'lib/vra/catalog_source.rb', line 39

def catalog_type_id
  data['typeId']
end

#configObject



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

Returns:

  • (Boolean)


51
52
53
# File 'lib/vra/catalog_source.rb', line 51

def global?
  data['global'] == true
end

#nameObject



35
36
37
# File 'lib/vra/catalog_source.rb', line 35

def name
  data['name']
end

#project_idObject



55
56
57
# File 'lib/vra/catalog_source.rb', line 55

def project_id
  config['sourceProjectId']
end