Sha256: 14561038494c57744654a116ebf89c4f33d736b440fb008db9a4cde45bd116be

Contents?: true

Size: 1.63 KB

Versions: 14

Compression:

Stored size: 1.63 KB

Contents

module Fog
  module Compute
    class Google
      class Mock
        def get_disk(disk_name, zone_name)
          disk = data[:disks][disk_name]
          zone_name = zone_name.split("/")[-1] if zone_name.start_with? "http"
          get_zone(zone_name)
          zone = data[:zones][zone_name]
          if disk.nil? || disk["zone"] != zone["selfLink"]
            return build_excon_response("error" => {
                                          "errors" => [
                                            {
                                              "domain" => "global",
                                              "reason" => "notFound",
                                              "message" => "The resource 'projects/#{@project}/zones/#{zone_name}/disks/#{disk_name}' was not found"
                                            }
                                          ],
                                          "code" => 404,
                                          "message" => "The resource 'projects/#{@project}/zones/#{zone_name}/disks/#{disk_name}' was not found"
                                        })
          end

          # TODO: transition the disk through the states

          build_excon_response(disk)
        end
      end

      class Real
        def get_disk(disk_name, zone_name)
          zone_name = zone_name.split("/")[-1] if zone_name.start_with? "http"

          api_method = @compute.disks.get
          parameters = {
            "project" => @project,
            "disk" => disk_name,
            "zone" => zone_name
          }

          request(api_method, parameters)
        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/get_disk.rb
fog-google-0.5.5 lib/fog/compute/google/requests/get_disk.rb
fog-google-0.5.4 lib/fog/compute/google/requests/get_disk.rb
fog-google-0.5.3 lib/fog/compute/google/requests/get_disk.rb
fog-google-0.5.2 lib/fog/compute/google/requests/get_disk.rb
fog-google-0.5.1 lib/fog/compute/google/requests/get_disk.rb
fog-google-0.5.0 lib/fog/compute/google/requests/get_disk.rb
fog-google-0.4.2 lib/fog/compute/google/requests/get_disk.rb
fog-google-0.4.1 lib/fog/compute/google/requests/get_disk.rb
fog-google-0.4.0 lib/fog/compute/google/requests/get_disk.rb
fog-google-0.3.2 lib/fog/compute/google/requests/get_disk.rb
fog-google-0.3.1 lib/fog/compute/google/requests/get_disk.rb
fog-google-0.3.0 lib/fog/compute/google/requests/get_disk.rb
fog-google-0.2.0 lib/fog/compute/google/requests/get_disk.rb