Sha256: 43c9674aee9871ed1e4511e5f0a3bf3260e843993ad313217d84d65aca0769a1

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

module Fog
  module Compute
    class DigitalOcean
      class Real
        def rename(id, name)
          body = { :type => "rename", :name => name }

          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 rename(id, name)
          response         = Excon::Response.new
          response.status  = 201
          response.body    = {
            'action' => {
              'id'            => Fog::Mock.random_numbers(1).to_i,
              'status'        => "in-progress",
              'type'          => "rename",
              'started_at'    => "2014-11-14T16:31:00Z",
              'completed_at'  => nil,
              'resource_id'   => id,
              'resource_type' => "droplet",
              'region'        => "nyc3",
              'region_slug'   => "nyc3"
            }
          }
          response
        end
      end
    end
  end
end

Version data entries

5 entries across 3 versions & 2 rubygems

Version Path
fog-digitalocean-0.4.0 lib/fog/compute/digitalocean/requests/rename.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-digitalocean-0.3.0/lib/fog/digitalocean/requests/compute/rename.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-digitalocean-0.3.0/lib/fog/digitalocean/requests/compute/rename.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-digitalocean-0.3.0/lib/fog/digitalocean/requests/compute/rename.rb
fog-digitalocean-0.3.0 lib/fog/digitalocean/requests/compute/rename.rb