Sha256: 9d76a71631757bdaa6aab7bd8ee2593bcbd568e82344c6f2a480aaae4983c73c

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 KB

Contents

module Fog
  module Ecloud
    class Compute

      class Real
        basic_request :get_catalog
      end

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

          if catalog = mock_data.catalog_from_href(catalog_uri)
            builder = Builder::XmlMarkup.new

            xml = builder.Catalog(xmlns.merge(
                                              :type => "application/vnd.vmware.vcloud.catalog+xml",
                                              :href => catalog.href,
                                              :name => catalog.name
                                  )) do |xml|
              xml.CatalogItems do |xml|
                catalog.items.each do |catalog_item|
                  xml.CatalogItem(
                                  :type => "application/vnd.vmware.vcloud.catalogItem+xml",
                                  :href => catalog_item.href,
                                  :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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fog-0.8.2 lib/fog/compute/requests/ecloud/get_catalog.rb
fog-0.8.1 lib/fog/compute/requests/ecloud/get_catalog.rb
fog-0.8.0 lib/fog/compute/requests/ecloud/get_catalog.rb
fog-0.7.2 lib/fog/compute/requests/ecloud/get_catalog.rb
fog-0.7.1 lib/fog/compute/requests/ecloud/get_catalog.rb
fog-0.7.0 lib/fog/compute/requests/ecloud/get_catalog.rb
fog-0.6.0 lib/fog/compute/requests/ecloud/get_catalog.rb