Sha256: f68e20638b39a96f0476207107c56b4ad4855012e1e46b3df98b8705188bf4df

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

module Fog
  module VcloudDirector
    class Compute
      class Real
        # Merge the metadata provided in the request with existing metadata.
        #
        # @param [String] id Object identifier of the vApp template.
        # @param [Hash{String=>Boolean,DateTime,Fixnum,String}] metadata
        # @return [Excon::Response]
        #   * body<~Hash>:
        #
        # @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/POST-UpdateVAppTemplateMetadata.html
        # @since vCloud API version 1.5
        def post_update_vapp_template_metadata(id, metadata={})
          body = Nokogiri::XML::Builder.new do
            attrs = {
              :xmlns => 'http://www.vmware.com/vcloud/v1.5',
              'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
            }
            Metadata(attrs) {
              metadata.each do |key, value|
                MetadataEntry {
                  Key key
                  if api_version.to_f < 5.1
                    Value value
                  else
                    type = case value
                           when TrueClass, FalseClass then 'MetadataBooleanValue';
                           when DateTime then 'MetadataDateTimeValue';
                           when Fixnum then 'MetadataNumberValue';
                           else 'MetadataStringValue'
                           end
                    TypedValue('xsi:type' => type) { Value value }
                  end
                }
              end
            }
          end.to_xml

          request(
            :body    => body,
            :expects => 202,
            :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata+xml'},
            :method  => 'POST',
            :parser  => Fog::ToHashDocument.new,
            :path    => "vAppTemplate/#{id}/metadata/"
          )
        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/requests/compute/post_update_vapp_template_metadata.rb
fog-vcloud-director-0.3.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_template_metadata.rb