Sha256: 19dbdffb396bdb91402b31aeac73b1058fe4452211b5dbb0304879d59001ba24

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

module Fog
  module Compute
    class DigitalOcean
      class Real
        def transfer_image(id, region)
          body = { :type => 'transfer', :region => region }

          encoded_body = Fog::JSON.encode(body)

          request(
            :expects => [201],
            :headers => {
              'Content-Type' => "application/json; charset=UTF-8",
            },
            :method  => 'POST',
            :path    => "v2/images/#{id}/actions",
            :body    => encoded_body,
          )
        end
      end

      class Mock
        def transfer_image(id, name)
          response         = Excon::Response.new
          response.status  = 201
          response.body    = {
            'action' => {
              'id' => 36805527,
              'status' => 'in-progress',
              'type' => 'transfer',
              'started_at' => '2014-11-14T16:42:45Z',
              'completed_at' => null,
              'resource_id' => 7938269,
              'resource_type' => 'image',
              'region' => 'nyc3',
              'region_slug' => 'nyc3'
            }
          }
          response
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-digitalocean-0.2.0 lib/fog/digitalocean/requests/compute/transfer_image.rb
fog-digitalocean-0.1.0 lib/fog/digitalocean/requests/compute/transfer_image.rb