mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
32 lines
No EOL
931 B
Ruby
32 lines
No EOL
931 B
Ruby
require 'fog/core/collection'
|
|
require 'fog/vcloudng/models/compute/catalog_item'
|
|
|
|
module Fog
|
|
module Compute
|
|
class Vcloudng
|
|
|
|
class CatalogItems < Collection
|
|
model Fog::Compute::Vcloudng::CatalogItem
|
|
|
|
attribute :catalog
|
|
|
|
private
|
|
|
|
def item_list
|
|
data = service.get_catalog(catalog.id).body
|
|
items = data[:CatalogItems][:CatalogItem].select { |link| link[:type] == "application/vnd.vmware.vcloud.catalogItem+xml" }
|
|
items.each{|item| service.add_id_from_href!(item) }
|
|
items
|
|
end
|
|
|
|
def get_by_id(item_id)
|
|
item = service.get_catalog_item(item_id).body
|
|
item[:vapp_template_id] = item[:Entity][:href].split('/').last
|
|
%w(:Link :Entity).each {|key_to_delete| item.delete(key_to_delete) }
|
|
service.add_id_from_href!(item)
|
|
item
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end |