Sha256: 0fcbc38c40bc1a4f4db2135900e6b8e72a7f47a4635af316ac93d9a37c816174

Contents?: true

Size: 1.29 KB

Versions: 14

Compression:

Stored size: 1.29 KB

Contents

module Fog
  module Compute
    class Google
      class Mock
        def set_metadata(_instance, _zone, _fingerprint, _metadata = {})
          Fog::Mock.not_implemented
        end
      end

      class Real
        # Set an instance metadata
        #
        # ==== Parameters
        # * instance<~String> - Instance name (identity)
        # * zone<~String> - Zone short name (without the full path)
        # * fingerprint<~String> - The fingerprint of the last metadata. Can be retrieved by reloading the compute object, and checking the metadata fingerprint field.
        #     instance.reload
        #     fingerprint = instance.metadata['fingerprint']
        # * metadata<~Hash> - A new metadata
        #
        # ==== Returns
        # * response<~Excon::Response>
        def set_metadata(instance, zone, fingerprint, metadata = {})
          api_method = @compute.instances.set_metadata
          parameters = {
            "project" => @project,
            "instance" => instance,
            "zone" => zone
          }
          body_object = {
            "fingerprint" => fingerprint,
            "items" => metadata.to_a.map { |pair| { :key => pair[0], :value => pair[1] } }
          }
          request(api_method, parameters, body_object = body_object)
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-google-0.6.0 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.5.5 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.5.4 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.5.3 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.5.2 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.5.1 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.5.0 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.4.2 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.4.1 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.4.0 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.3.2 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.3.1 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.3.0 lib/fog/compute/google/requests/set_metadata.rb
fog-google-0.2.0 lib/fog/compute/google/requests/set_metadata.rb