Sha256: cea58c7a189aa408510ecccd6114274eda9517d8fb98e0cd890ba203171b7a9a

Contents?: true

Size: 1.48 KB

Versions: 9

Compression:

Stored size: 1.48 KB

Contents

module Fog
  class Vcloud
    module Terremark
      class Ecloud

        class Real
          basic_request :get_catalog
        end

        class Mock
          def get_catalog(catalog_uri)
            catalog_uri = ensure_unparsed(catalog_uri)
            xml = nil

            if vdc = vdc_from_uri(catalog_uri)
              builder = Builder::XmlMarkup.new

              xml = builder.Catalog(xmlns.merge(
                                                :type => "application/vnd.vmware.vcloud.catalog+xml",
                                                :href => catalog_uri,
                                                :name => vdc[:catalog][:name]
                                    )) do |xml|
                xml.CatalogItems do |xml|
                  vdc[:catalog][:items].each do |catalog_item|
                    xml.CatalogItem(
                                    :type => "application/vnd.vmware.vcloud.catalogItem+xml",
                                    :href => "#{self.class.base_url}/catalogItem/#{catalog_item[:id]}-#{vdc[:id]}",
                                    :name => catalog_item[:name]
                                    )
                  end
                end
              end
            end

            if xml
              mock_it 200,
                xml, { 'Content-Type' => 'application/vnd.vmware.vcloud.catalog+xml' }
            else
              mock_error 200, "401 Unauthorized"
            end
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fog-0.3.16 lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb
fog-0.3.15 lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb
fog-0.3.14 lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb
fog-0.3.13 lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb
fog-0.3.12 lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb
fog-0.3.11 lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb
fog-0.3.10 lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb
fog-0.3.9 lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb
fog-0.3.8 lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb