Sha256: 2cb6c8f9101fe41991bf3066b86919d7728b2a6b9f69503545fbaa2b8f49ad4b

Contents?: true

Size: 1.21 KB

Versions: 22

Compression:

Stored size: 1.21 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)

          request(api_method, parameters, body_object)
        end
      end
    end
  end
end

Version data entries

22 entries across 20 versions & 5 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-google-0.1.0/lib/fog/google/requests/compute/insert_snapshot.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-google-0.1.0/lib/fog/google/requests/compute/insert_snapshot.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-google-0.1.0/lib/fog/google/requests/compute/insert_snapshot.rb
fog-google-0.1.3 lib/fog/google/requests/compute/insert_snapshot.rb
fog-google-0.1.2 lib/fog/google/requests/compute/insert_snapshot.rb
fog-google-0.1.1 lib/fog/google/requests/compute/insert_snapshot.rb
fog-google-0.1.0 lib/fog/google/requests/compute/insert_snapshot.rb
fog-google-0.0.9 lib/fog/google/requests/compute/insert_snapshot.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-google-0.0.7/lib/fog/google/requests/compute/insert_snapshot.rb
fog-google-0.0.7 lib/fog/google/requests/compute/insert_snapshot.rb
fog-google-0.0.6 lib/fog/google/requests/compute/insert_snapshot.rb
fog-google-0.0.5 lib/fog/google/requests/compute/insert_snapshot.rb
fog-google-0.0.4 lib/fog/google/requests/compute/insert_snapshot.rb
fog-google-0.0.3 lib/fog/google/requests/compute/insert_snapshot.rb
fog-google-0.0.2 lib/fog/google/requests/compute/insert_snapshot.rb
fog-1.29.0 lib/fog/google/requests/compute/insert_snapshot.rb
fog-1.28.0 lib/fog/google/requests/compute/insert_snapshot.rb
fog-1.27.0 lib/fog/google/requests/compute/insert_snapshot.rb
fog-1.26.0 lib/fog/google/requests/compute/insert_snapshot.rb
fog-1.25.0 lib/fog/google/requests/compute/insert_snapshot.rb