Sha256: f0cfa0893cf58cef6fc9eebfe73f220b0821b7c66fcb8b7479eea49fa9b59b2c

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'fog/core/collection'
require 'fog/vcloud_director/models/compute/vapp'

module Fog
  module Compute
    class VcloudDirector
      class Vapps < Collection

        include Fog::VcloudDirector::Query

        model Fog::Compute::VcloudDirector::Vapp

        attribute :vdc

        def query_type
          "vApp"
        end

        def get_single_vapp(vapp_id)
          item = service.get_vapp(vapp_id).body
          return nil unless item
          new(item)
        end

        private

        def get_by_id(item_id)
          item = service.get_vapp(item_id).body
          %w(:Link).each {|key_to_delete| item.delete(key_to_delete) }
          service.add_id_from_href!(item)
          item[:Description] ||= ""
          item
        end

        def item_list
          data = service.get_vdc(vdc.id).body
          return [] if data[:ResourceEntities].empty?
          resource_entities = data[:ResourceEntities][:ResourceEntity]
          items = resource_entities.select { |link| link[:type] == "application/vnd.vmware.vcloud.vApp+xml" }
          items.each{|item| service.add_id_from_href!(item) }
          items
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-vcloud-director-0.1.5 lib/fog/vcloud_director/models/compute/vapps.rb
fog-vcloud-director-0.1.4 lib/fog/vcloud_director/models/compute/vapps.rb