Sha256: f6eb78a57035fdd2bbc392b9da3ef23e238fcaacc29de2943d9d9386fbe99ec6

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

module Fog
  module Compute
    class DigitalOceanV2
      class Real
        def shutdown(id)
          body = { :type => "shutdown" }

          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 shutdown(id)
          response         = Excon::Response.new
          response.status  = 201
          response.body    = {
            'action' => {
              'id'            => Fog::Mock.random_numbers(1).to_i,
              'status'        => "in-progress",
              'type'          => "shutdown",
              '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

4 entries across 4 versions & 1 rubygems

Version Path
fog-1.38.0 lib/fog/digitalocean/requests/compute_v2/shutdown.rb
fog-1.37.0 lib/fog/digitalocean/requests/compute_v2/shutdown.rb
fog-1.36.0 lib/fog/digitalocean/requests/compute_v2/shutdown.rb
fog-1.35.0 lib/fog/digitalocean/requests/compute_v2/shutdown.rb