Class: VCloudSdk::Client

Inherits:
Object
  • Object
show all
Includes:
Infrastructure
Defined in:
lib/ruby_vcloud_sdk/client.rb

Constant Summary collapse

VCLOUD_VERSION_NUMBER =
"5.1"

Constants included from Infrastructure

Infrastructure::ERROR_STATUSES, Infrastructure::SUCCESS_STATUS

Instance Method Summary collapse

Constructor Details

#initialize(url, username, password, options = {}, logger = nil) ⇒ Client

Returns a new instance of Client.



18
19
20
21
22
23
24
# File 'lib/ruby_vcloud_sdk/client.rb', line 18

def initialize(url, username, password, options = {}, logger = nil)
  @url = url
  Config.configure(logger: logger || Logger.new(STDOUT))

  @session = Session.new(url, username, password, options)
  Config.logger.info("Successfully connected.")
end

Instance Method Details

#create_catalog(name, description = "") ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/ruby_vcloud_sdk/client.rb', line 26

def create_catalog(name, description = "")
  catalog = Xml::WrapperFactory.create_instance("AdminCatalog")
  catalog.name = name
  catalog.description = description
  connection.post("/api/admin/org/#{@session.org.href_id}/catalogs",
                  catalog,
                  Xml::ADMIN_MEDIA_TYPE[:CATALOG])
  find_catalog_by_name name
end

#delete_catalog_by_name(name) ⇒ Object



36
37
38
39
40
41
# File 'lib/ruby_vcloud_sdk/client.rb', line 36

def delete_catalog_by_name(name)
  catalog = find_catalog_by_name(name)
  catalog.delete_all_items
  connection.delete("/api/admin/catalog/#{catalog.id}")
  self
end

#right_recordsObject



43
44
45
46
47
48
49
# File 'lib/ruby_vcloud_sdk/client.rb', line 43

def right_records
  right_records = connection.get("/api/admin/rights/query").right_records

  right_records.map do |right_record|
    VCloudSdk::RightRecord.new(right_record)
  end
end