Sha256: eb04ede273c6bb3c80918a2f7a517b075c9a9e81f22f353a53fddb5f002ef922

Contents?: true

Size: 1.32 KB

Versions: 38

Compression:

Stored size: 1.32 KB

Contents

module Fog
  module Compute
    class Google

      class Mock

        def insert_snapshot(snap_name)
          Fog::Mock.not_implemented
        end

      end

      class Real

        def insert_snapshot(disk_name, zone_name, project=@project, opts={})

          # This is unfortunate, since we might be called from 2 contexts
          # 1. disk.snapshot <-- here validation of disk_name is not needed
          # 2. snapshot.create <-- here we must validate the disk_name
          #
          # Validation would involve 'get'ing the disk by that name. This is
          # redundant (and expensive) for case (1) which is likely the common
          # codepath. So we won't do it.

          api_method = @compute.disks.create_snapshot

          parameters = {
            'disk'    => disk_name,
            'zone'    => zone_name,
            'project' => @project,
          }

          snap_name = opts.delete('name')
          raise ArgumentError.new('Must specify snapshot name') unless snap_name
          body_object = { 'name' => snap_name }

          # Merge in any remaining options (description)
          body_object.merge(opts)

          result = self.build_result(api_method, parameters,
                                     body_object)
          response = self.build_response(result)
        end

      end

    end
  end
end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
fog-1.22.0 lib/fog/google/requests/compute/insert_snapshot.rb
fog-1.21.0 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/google/requests/compute/insert_snapshot.rb
fog-1.20.0 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/google/requests/compute/insert_snapshot.rb
fog-1.19.0 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/google/requests/compute/insert_snapshot.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/google/requests/compute/insert_snapshot.rb