Sha256: 4147af3848c8e2d7ebcc89fa83a389595f25ba7f0eeb7fc953f6aa1ca7ae247b

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

require 'fog/vcloud_director/models/compute/catalog_item'

module Fog
  module VcloudDirector
    class Compute
      class CatalogItems < Collection
        model Fog::VcloudDirector::Compute::CatalogItem

        attribute :catalog

        def get_single_catalog_item(catalog_item_id)
          item = service.get_catalog_item(catalog_item_id).body
          return nil unless item
          item[:vapp_template_id] = item[:Entity][:href].split('/').last
          new(item)
        end

        private

        def item_list
          data = service.get_catalog(catalog.id).body
          items = data[:CatalogItems][:CatalogItem].select do |link|
            link[:type] == 'application/vnd.vmware.vcloud.catalogItem+xml'
          end
          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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-vcloud-director-0.3.1 lib/fog/vcloud_director/models/compute/catalog_items.rb
fog-vcloud-director-0.3.0 lib/fog/vcloud_director/models/compute/catalog_items.rb