Class: Fog::Compute::DigitalOcean::Real

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/compute/digitalocean/requests/create_server.rb,
lib/fog/compute/digitalocean.rb,
lib/fog/compute/digitalocean/requests/rename.rb,
lib/fog/compute/digitalocean/requests/resize.rb,
lib/fog/compute/digitalocean/requests/rebuild.rb,
lib/fog/compute/digitalocean/requests/restore.rb,
lib/fog/compute/digitalocean/requests/upgrade.rb,
lib/fog/compute/digitalocean/requests/power_on.rb,
lib/fog/compute/digitalocean/requests/shutdown.rb,
lib/fog/compute/digitalocean/requests/snapshot.rb,
lib/fog/compute/digitalocean/requests/power_off.rb,
lib/fog/compute/digitalocean/requests/enable_ipv6.rb,
lib/fog/compute/digitalocean/requests/get_ssh_key.rb,
lib/fog/compute/digitalocean/requests/list_images.rb,
lib/fog/compute/digitalocean/requests/power_cycle.rb,
lib/fog/compute/digitalocean/requests/list_flavors.rb,
lib/fog/compute/digitalocean/requests/list_regions.rb,
lib/fog/compute/digitalocean/requests/list_servers.rb,
lib/fog/compute/digitalocean/requests/list_volumes.rb,
lib/fog/compute/digitalocean/requests/attach_volume.rb,
lib/fog/compute/digitalocean/requests/change_kernel.rb,
lib/fog/compute/digitalocean/requests/create_volume.rb,
lib/fog/compute/digitalocean/requests/detach_volume.rb,
lib/fog/compute/digitalocean/requests/list_ssh_keys.rb,
lib/fog/compute/digitalocean/requests/reboot_server.rb,
lib/fog/compute/digitalocean/requests/resize_volume.rb,
lib/fog/compute/digitalocean/requests/create_ssh_key.rb,
lib/fog/compute/digitalocean/requests/delete_ssh_key.rb,
lib/fog/compute/digitalocean/requests/destroy_server.rb,
lib/fog/compute/digitalocean/requests/destroy_volume.rb,
lib/fog/compute/digitalocean/requests/password_reset.rb,
lib/fog/compute/digitalocean/requests/transfer_image.rb,
lib/fog/compute/digitalocean/requests/update_ssh_key.rb,
lib/fog/compute/digitalocean/requests/disable_backups.rb,
lib/fog/compute/digitalocean/requests/get_image_details.rb,
lib/fog/compute/digitalocean/requests/get_droplet_action.rb,
lib/fog/compute/digitalocean/requests/get_server_details.rb,
lib/fog/compute/digitalocean/requests/get_volume_details.rb,
lib/fog/compute/digitalocean/requests/convert_to_snapshot.rb,
lib/fog/compute/digitalocean/requests/list_volume_actions.rb,
lib/fog/compute/digitalocean/requests/list_droplet_actions.rb,
lib/fog/compute/digitalocean/requests/enable_private_networking.rb

Overview

noinspection RubyStringKeysInHashInspection

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



90
91
92
93
94
95
96
97
98
99
# File 'lib/fog/compute/digitalocean.rb', line 90

def initialize(options={})
  digitalocean_token = options[:digitalocean_token]
  persistent         = false
  options            = {
    headers: {
      'Authorization' => "Bearer #{digitalocean_token}",
    }
  }
  @connection        = Fog::Core::Connection.new 'https://api.digitalocean.com', persistent, options
end

Instance Method Details

#attach_volume(volume_id, droplet_id, region) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/attach_volume.rb', line 5

def attach_volume(volume_id, droplet_id, region)
  body = { :type => 'attach', droplet_id: droplet_id, region: region}

  encoded_body = Fog::JSON.encode(body)

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

#attach_volume_by_name(volume_name, droplet_id, region) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/digitalocean/requests/attach_volume.rb', line 21

def attach_volume_by_name(volume_name, droplet_id, region)
  body = { :type => 'attach', volume_name: volume_name, droplet_id: droplet_id, region: region}

  encoded_body = Fog::JSON.encode(body)

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

#change_kernel(id, kernel) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/change_kernel.rb', line 5

def change_kernel(id, kernel)
  body = { :type => "change_kernel", :kernel => kernel }

  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

#convert_to_snapshot(id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/convert_to_snapshot.rb', line 5

def convert_to_snapshot(id)
  body = { :type => 'convert',}

  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

#create_server(name, size, image, region, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/compute/digitalocean/requests/create_server.rb', line 7

def create_server(name,
                  size,
                  image,
                  region,
                  options = {})

  create_options = {
    :name   => name,
    :region => region,
    :size   => size,
    :image  => image,
  }

  [:backups, :ipv6, :private_networking].each do |opt|
    create_options[opt] = !!options[opt] if options[opt]
  end

  [:user_data, :ssh_keys].each do |opt|
    create_options[opt] = options[opt] if options[opt]
  end

  create_options[:volume] = options[:volume] || []

  encoded_body = Fog::JSON.encode(create_options)

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

#create_ssh_key(name, public_key) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/compute/digitalocean/requests/create_ssh_key.rb', line 7

def create_ssh_key(name, public_key)
  create_options = {
    :name       => name,
    :public_key => public_key,
  }

  encoded_body = Fog::JSON.encode(create_options)

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

#create_volume(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/compute/digitalocean/requests/create_volume.rb', line 7

def create_volume(options={})
  create_options = {
    :name        => "name",
    :region      => "nyc1",
    :size_gigabytes => 1
  }.merge(options)

  encoded_body = Fog::JSON.encode(create_options)

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

#delete_server(server_id) ⇒ Object



6
7
8
9
# File 'lib/fog/compute/digitalocean/requests/destroy_server.rb', line 6

def delete_server(server_id)
  Fog::Logger.warning("delete_server method has been deprecated, use destroy_server instead")
  destroy_server(server_id)
end

#delete_ssh_key(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/compute/digitalocean/requests/delete_ssh_key.rb', line 6

def delete_ssh_key(id)
  request(
    :expects => [204],
    :headers => {
      'Content-Type' => "application/json; charset=UTF-8",
    },
    :method  => 'DELETE',
    :path    => "/v2/account/keys/#{id}",
  )
end

#destroy_server(server_id) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/destroy_server.rb', line 10

def destroy_server(server_id)
  request(
    :expects         => [204],
    :headers         => {
      'Content-Type' => "application/json; charset=UTF-8",
    },
    :method          => 'DELETE',
    :path            => "/v2/droplets/#{server_id}",
  )
end

#destroy_volume(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/compute/digitalocean/requests/destroy_volume.rb', line 6

def destroy_volume(id)
  request(
    :expects => [204],
    :headers => {
      'Content-Type' => "application/json; charset=UTF-8",
    },
    :method  => 'DELETE',
    :path    => "/v2/volumes/#{id}",
  )
end

#detach_volume(volume_id, droplet_id, region) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/detach_volume.rb', line 5

def detach_volume(volume_id, droplet_id, region)
  body = { :type => 'detach', droplet_id: droplet_id, region: region}

  encoded_body = Fog::JSON.encode(body)

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

#detach_volume_by_name(volume_name, droplet_id, region) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/digitalocean/requests/detach_volume.rb', line 20

def detach_volume_by_name(volume_name, droplet_id, region)
  body = { :type => 'detach', volume_name: volume_name, droplet_id: droplet_id, region: region}

  encoded_body = Fog::JSON.encode(body)

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

#disable_backups(id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/disable_backups.rb', line 5

def disable_backups(id)
  body = { :type => "disable_backups" }

  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

#enable_ipv6(id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/enable_ipv6.rb', line 5

def enable_ipv6(id)
  body = { :type => "enable_ipv6" }

  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

#enable_private_networking(id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/enable_private_networking.rb', line 5

def enable_private_networking(id)
  body = { :type => "enable_private_networking" }

  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

#get_droplet_action(droplet_id, action_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/compute/digitalocean/requests/get_droplet_action.rb', line 5

def get_droplet_action(droplet_id, action_id)
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "v2/droplets/#{droplet_id}/actions/#{action_id}",
  )
end

#get_image_details(image_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/compute/digitalocean/requests/get_image_details.rb', line 5

def get_image_details(image_id)
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "/v2/images/#{image_id}"
  )
end

#get_server_details(server_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/compute/digitalocean/requests/get_server_details.rb', line 5

def get_server_details(server_id)
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "/v2/droplets/#{server_id}"
  )
end

#get_ssh_key(key_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/compute/digitalocean/requests/get_ssh_key.rb', line 5

def get_ssh_key(key_id)
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "/v2/account/keys/#{key_id}"
  )
end

#get_volume_details(volume_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/compute/digitalocean/requests/get_volume_details.rb', line 5

def get_volume_details(volume_id)
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "/v2/volumes/#{volume_id}"
  )
end

#list_droplet_actions(id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/compute/digitalocean/requests/list_droplet_actions.rb', line 5

def list_droplet_actions(id)
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "v2/droplets/#{id}/actions",
  )
end

#list_flavors(filters = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/compute/digitalocean/requests/list_flavors.rb', line 5

def list_flavors(filters = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "/v2/sizes",
    :query   => filters
  )
end

#list_images(filters = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/compute/digitalocean/requests/list_images.rb', line 5

def list_images(filters = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "/v2/images",
    :query   => filters
  )
end

#list_regions(filters = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/compute/digitalocean/requests/list_regions.rb', line 5

def list_regions(filters = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "/v2/regions",
    :query   => filters
  )
end

#list_servers(filters = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/compute/digitalocean/requests/list_servers.rb', line 5

def list_servers(filters = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "/v2/droplets",
    :query   => filters
  )
end

#list_ssh_keys(filters = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/compute/digitalocean/requests/list_ssh_keys.rb', line 5

def list_ssh_keys(filters = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "v2/account/keys",
    :query   => filters
  )
end

#list_volume_actions(id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/compute/digitalocean/requests/list_volume_actions.rb', line 5

def list_volume_actions(id)
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "v2/volumes/#{id}/actions",
  )
end

#list_volumes(filters = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/compute/digitalocean/requests/list_volumes.rb', line 5

def list_volumes(filters = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "/v2/volumes",
    :query   => filters
  )
end

#password_reset(id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/password_reset.rb', line 5

def password_reset(id)
  body = { :type => "password_reset" }

  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

#power_cycle(id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/power_cycle.rb', line 5

def power_cycle(id)
  body = { :type => "power_cycle" }

  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

#power_off(id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/power_off.rb', line 5

def power_off(id)
  body = { :type => "power_off" }

  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

#power_on(id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/power_on.rb', line 5

def power_on(id)
  body = { :type => "power_on" }

  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

#reboot_server(id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/reboot_server.rb', line 5

def reboot_server(id)
  body = { :type => "reboot" }

  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

#rebuild(id, image) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/rebuild.rb', line 5

def rebuild(id, image)
  body = { :type => "rebuild", :image => image }

  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

#rename(id, name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/rename.rb', line 5

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

#request(params) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/fog/compute/digitalocean.rb', line 101

def request(params)
  params[:headers] ||= {}
  begin
    response = @connection.request(params)
  rescue Excon::Errors::HTTPStatusError => error
    raise case error
            when Excon::Errors::NotFound
              NotFound.slurp(error)
            else
              error
          end
  end
  unless response.body.empty?
    response.body = Fog::JSON.decode(response.body)
  end
  response
end

#resize(id, resize_disk, size) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/compute/digitalocean/requests/resize.rb', line 5

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

#resize_volume(volume_id, size, region) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/resize_volume.rb', line 5

def resize_volume(volume_id, size, region)
  body = { :type => 'resize', size_gigabytes: size, region: region}

  encoded_body = Fog::JSON.encode(body)

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

#restore(id, image) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/restore.rb', line 5

def restore(id, image)
  body = { :type => "restore", :image => image }

  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

#shutdown(id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/shutdown.rb', line 5

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

#snapshot(id, name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/snapshot.rb', line 5

def snapshot(id, name)
  body = { :type => "snapshot", :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

#transfer_image(id, region) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/transfer_image.rb', line 5

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

#update_ssh_key(key_id, name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/compute/digitalocean/requests/update_ssh_key.rb', line 7

def update_ssh_key(key_id, name)
  update_options = {
    :name       => name,
  }

  encoded_body = Fog::JSON.encode(update_options)

  request(
    :expects => [200],
    :headers => {
      'Content-Type' => "application/json; charset=UTF-8",
    },
    :method  => 'PUT',
    :path    => "/v2/account/keys/#{key_id}",
    :body    => encoded_body,
  )
end

#upgrade(id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/digitalocean/requests/upgrade.rb', line 5

def upgrade(id)
  body = { :type => "upgrade" }

  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