Sha256: 8fc1ccb568614e0689d4f04cbf01a98481e6c8873868a295ddf19aa55e19b9e4

Contents?: true

Size: 1.85 KB

Versions: 67

Compression:

Stored size: 1.85 KB

Contents

module Fog
  module Compute
    class VcloudDirector
      class Real
        # Merge the metadata provided in the request with existing metadata.
        #
        # @param [String] id Object identifier of the vApp or VM.
        # @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-UpdateVAppMetadata.html
        # @since vCloud API version 1.5
        def post_update_vapp_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    => "vApp/#{id}/metadata/"
          )
        end
      end
    end
  end
end

Version data entries

67 entries across 67 versions & 5 rubygems

Version Path
fog-1.36.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-1.35.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-2.0.0.pre.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-1.34.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-1.33.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-1.32.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-1.31.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-1.30.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-1.29.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-1.28.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-1.27.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-1.26.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-1.25.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
nsidc-fog-1.24.1 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
fog-1.24.0 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
ns-fog-1.22.11 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
ns-fog-1.22.10 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb
ns-fog-1.22.9 lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb