Sha256: 14cf5d6ba71f2d3e3e0ed65a6742d00d12411d8b48cede1552ba81edc9c6cae9

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

module Fog
  module Compute
    class DigitalOcean
      class Real
        def resize(id, resize_disk, size)
          body = {
            :type => "resize",
            :disk => resize_disk,
            :size => size
          }

          encoded_body = Fog::JSON.encode(body)

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

      class Mock
        def resize(id, resize_disk, size)
          response        = Excon::Response.new
          response.status = 201
          response.body   = {
            'action' => {
              'id'            => Fog::Mock.random_numbers(1).to_i,
              'status'        => "in-progress",
              'type'          => "resize",
              'started_at'    => "2014-11-14T16:31:00Z",
              'completed_at'  => null,
              'resource_id'   => id,
              'resource_type' => "droplet",
              '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/resize.rb
fog-digitalocean-0.1.0 lib/fog/digitalocean/requests/compute/resize.rb