Class: VCloud::Org

Inherits:
BaseVCloudEntity show all
Defined in:
lib/vcloud/user/org.rb

Overview

An org contains links to VDCs, Catalogs, and Org Networks

Instance Method Summary collapse

Methods inherited from BaseVCloudEntity

attr_accessor, attr_reader, attr_writer, from_reference, inherited, #initialize, type

Methods included from RestApi

#build_generic_http_opts, #create, #delete, #http_request, #parse_response, #post, #refresh, #update

Constructor Details

This class inherits a constructor from VCloud::BaseVCloudEntity

Instance Method Details

Returns all links to Catalogs

Returns:



22
23
24
# File 'lib/vcloud/user/org.rb', line 22

def catalog_links
  @links.select {|l| l.type == VCloud::Constants::ContentType::CATALOG}
end

#get_catalog_from_name(name, session = self.session) ⇒ VCloud::Catalog

Retrieves an Catalog, assuming the user has access to it

Parameters:

  • name (String)

    Catalog name

  • session (VCloud::Client) (defaults to: self.session)

    Session to use to retrieve the Catalog

Returns:



45
46
47
48
49
# File 'lib/vcloud/user/org.rb', line 45

def get_catalog_from_name(name, session = self.session)
  catalogs = get_catalog_links_by_name
  link = catalogs[name] or return nil
  Catalog.from_reference(link, session)
end

Returns a hash of of all Catalog links keyed by the Catalog name

Returns:

  • (Hash{String => VCloud::Link})

    Links to all Catalogs in the Org, keyed by name



36
37
38
# File 'lib/vcloud/user/org.rb', line 36

def get_catalog_links_by_name
  Hash[catalog_links.collect { |l| [l.name, l] }]
end

#get_vdc_from_name(name, session = self.session) ⇒ VCloud::Vdc

Retrieves a VDC, assuming the user has access to it

Parameters:

  • name (String)

    VDC name

  • session (VCloud::Client) (defaults to: self.session)

    Session to use to retrieve the VDC

Returns:



63
64
65
66
67
# File 'lib/vcloud/user/org.rb', line 63

def get_vdc_from_name(name, session = self.session)
  links = get_vdc_links_by_name
  link = links[name] or return nil
  Vdc.from_reference(link, session)
end

Returns a hash of of all VDCs links keyed by the Catalog name

Returns:

  • (Hash{String => VCloud::Link})

    Links to all VDCs in the Org, keyed by name



54
55
56
# File 'lib/vcloud/user/org.rb', line 54

def get_vdc_links_by_name
  Hash[vdc_links.collect { |l| [l.name, l] }]
end

Returns all links to OrgNetworks

Returns:



29
30
31
# File 'lib/vcloud/user/org.rb', line 29

def org_network_links
  @links.select {|l| l.type == VCloud::Constants::ContentType::ORG_NETWORK}
end

Returns all links to VDCs

Returns:



15
16
17
# File 'lib/vcloud/user/org.rb', line 15

def vdc_links
  @links.select {|l| l.type == VCloud::Constants::ContentType::VDC}
end