class Fog::Compute::DigitalOcean::Mock

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

noinspection RubyStringKeysInHashInspection

Public Class Methods

data() click to toggle source
# File lib/fog/digitalocean/compute.rb, line 67
def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] = {
      :servers  => [],
      :ssh_keys => []
    }
  end
end
new(options={}) click to toggle source
# File lib/fog/digitalocean/compute.rb, line 76
def initialize(options={})
  @digitalocean_token = options[:digitalocean_token]
end

Public Instance Methods

attach_volume(volume_id, droplet_id, region) click to toggle source
# File lib/fog/digitalocean/requests/compute/attach_volume.rb, line 39
def attach_volume(volume_id, droplet_id, region)
                                response         = Excon::Response.new
                                response.status  = 201
                                response.body    = {
                                        "action" => {
                                                "id" => 72531856,
                                                "status" => "completed",
                                                "type" => "attach_volume",
                                                "started_at" => "2015-11-12T17:51:03Z",
                                                "completed_at" => "2015-11-12T17:51:14Z",
                                                "resource_id" => "null",
                                                "resource_type" => "volume",
                                                "region" => {
                                                        "name" => "New York 1",
                                                        "slug" => "nyc1",
                                                        "sizes" => [
                                                                "1gb",
                                                                "2gb",
                                                                "4gb",
                                                                "8gb",
                                                                "32gb",
                                                                "64gb",
                                                                "512mb",
                                                                "48gb",
                                                                "16gb"
                                                        ],
                                                        "features" => [
                                                                "private_networking",
                                                                "backups",
                                                                "ipv6",
                                                                "metadata"
                                                        ],
                                                        "available" => true
                                                },
                                                "region_slug" => "nyc1"
                                        }
                                }

  response
end
attach_volume_by_name(volume_name, droplet_id, region) click to toggle source
# File lib/fog/digitalocean/requests/compute/attach_volume.rb, line 79
def attach_volume_by_name(volume_name, droplet_id, region)
                                response         = Excon::Response.new
                                response.status  = 201
                                response.body    = {
                                        "action" => {
                                                "id" => 72531856,
                                                "status" => "completed",
                                                "type" => "attach_volume",
                                                "started_at" => "2015-11-12T17:51:03Z",
                                                "completed_at" => "2015-11-12T17:51:14Z",
                                                "resource_id" => "null",
                                                "resource_type" => "volume",
                                                "region" => {
                                                        "name" => "New York 1",
                                                        "slug" => "nyc1",
                                                        "sizes" => [
                                                                "1gb",
                                                                "2gb",
                                                                "4gb",
                                                                "8gb",
                                                                "32gb",
                                                                "64gb",
                                                                "512mb",
                                                                "48gb",
                                                                "16gb"
                                                        ],
                                                        "features" => [
                                                                "private_networking",
                                                                "backups",
                                                                "ipv6",
                                                                "metadata"
                                                        ],
                                                        "available" => true
                                                },
                                                "region_slug" => "nyc1"
                                        }
                                }

  response
end
change_kernel(id, kernel) click to toggle source
# File lib/fog/digitalocean/requests/compute/change_kernel.rb, line 23
def change_kernel(id, kernel)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "change_kernel",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
convert_to_snapshot(id, name) click to toggle source
# File lib/fog/digitalocean/requests/compute/convert_to_snapshot.rb, line 23
def convert_to_snapshot(id, name)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id' => 46592838,
      'status' => 'completed',
      'type' => 'convert_to_snapshot',
      'started_at' => '2015-03-24T19:02:47Z',
      'completed_at' => '2015-03-24T19:02:47Z',
      'resource_id' => 11060029,
      'resource_type' => 'image',
      'region' => nil,
      'region_slug' => nil
    }
  }
  response
end
create_server(name, size, image, region, options = {}) click to toggle source
# File lib/fog/digitalocean/requests/compute/create_server.rb, line 46
def create_server(name,
                  size,
                  image,
                  region,
                  options = {})

  response        = Excon::Response.new
  response.status = 202

  response.body = {
    'droplet' => {
      'id'           => 3164494,
      'name'         => name,
      'memory'       => 512,
      'vcpus'        => 1,
      'disk'         => 20,
      'locked'       => true,
      'status'       => 'new',
      'kernel'       => {
        'id'      => 2233,
        'name'    => 'Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic',
        'version' => '3.13.0-37-generic'
      },
      'created_at'   => '2014-11-14T16:36:31Z',
      'features'     => %w(virtio),
      'backup_ids'   => [],
      'snapshot_ids' => [],
      'image'        => {},
      'size'         => {},
      'size_slug'    => '512mb',
      'networks'     => {},
      'region'       => {}
    },
    'links'   => {
      'actions' => [
        {
          'id'   => 36805096,
          'rel'  => "create",
          'href' => "https://api.digitalocean.com/v2/actions/36805096"
        }
      ]
    }
  }

  response
end
create_ssh_key(name, public_key) click to toggle source
# File lib/fog/digitalocean/requests/compute/create_ssh_key.rb, line 29
def create_ssh_key(name, public_key)
  response        = Excon::Response.new
  response.status = 201

  data[:ssh_keys] << {
    "id" => Fog::Mock.random_numbers(6).to_i,
    "fingerprint" => (["00"] * 16).join(':'),
    "public_key" => public_key,
    "name" => name
  }

  response.body ={
    'ssh_key' => data[:ssh_keys].last
  }

  response
end
create_volume(options) click to toggle source
# File lib/fog/digitalocean/requests/compute/create_volume.rb, line 30
def create_volume(options)
  response        = Excon::Response.new
  response.status = 201

  response.body ={
    'volume' => {
      "id" => Fog::Mock.random_numbers(6).to_i,
      "fingerprint" => (["00"] * 16).join(':'),
      "region" => options[:region], 
      "size_gigabytes" => 10,
      "description" => options[:description],
      "name" => options[:name]
    }
  }

  response
end
data() click to toggle source
# File lib/fog/digitalocean/compute.rb, line 80
def data
  self.class.data[@digitalocean_token]
end
delete_server(server_id) click to toggle source
# File lib/fog/digitalocean/requests/compute/destroy_server.rb, line 24
def delete_server(server_id)
  destroy_server(server_id)
end
delete_ssh_key(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/delete_ssh_key.rb, line 20
def delete_ssh_key(id)
  self.data[:ssh_keys].select! do |key|
    key["id"] != id
  end

  response        = Excon::Response.new
  response.status = 204
  response
end
destroy_server(_) click to toggle source
# File lib/fog/digitalocean/requests/compute/destroy_server.rb, line 27
def destroy_server(_)
  response        = Excon::Response.new
  response.status = 204
  response
end
destroy_volume(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/destroy_volume.rb, line 20
def destroy_volume(id)
  self.data[:volumes].select! do |key|
    key["id"] != id
  end

  response        = Excon::Response.new
  response.status = 204
  response
end
detach_volume(volume_id, droplet_id, region) click to toggle source
# File lib/fog/digitalocean/requests/compute/detach_volume.rb, line 38
def detach_volume(volume_id, droplet_id, region)
  response         = Excon::Response.new
  response.status  = 201
                                response.body    = {
                                        "action" => {
                                                "id" => 68212773,
                                                "status" => "in-progress",
                                                "type" => "detach_volume",
                                                "started_at" => "2015-10-15T17:46:15Z",
                                                "completed_at" => nil,
                                                "resource_id" => nil,
                                                "resource_type" => "backend",
                                                "region" => {
                                                        "name" => "New York 1",
                                                        "slug" => "nyc1",
                                                        "sizes" => [
                                                                "512mb",
                                                                "1gb",
                                                                "2gb",
                                                                "4gb",
                                                                "8gb",
                                                                "16gb",
                                                                "32gb",
                                                                "48gb",
                                                                "64gb"
                                                        ],
                                                        "features" => [
                                                                "private_networking",
                                                                "backups",
                                                                "ipv6",
                                                                "metadata"
                                                        ],
                                                        "available" => true
                                                },
                                                "region_slug" => "nyc1"
                                        }
                                }

                                response
                        end
detach_volume_by_name(volume_name, droplet_id, region) click to toggle source
# File lib/fog/digitalocean/requests/compute/detach_volume.rb, line 78
def detach_volume_by_name(volume_name, droplet_id, region)
  response         = Excon::Response.new
  response.status  = 201
                                response.body    = {
                                        "action" => {
                                                "id" => 68212773,
                                                "status" => "in-progress",
                                                "type" => "detach_volume",
                                                "started_at" => "2015-10-15T17:46:15Z",
                                                "completed_at" => nil,
                                                "resource_id" => nil,
                                                "resource_type" => "backend",
                                                "region" => {
                                                        "name" => "New York 1",
                                                        "slug" => "nyc1",
                                                        "sizes" => [
                                                                "512mb",
                                                                "1gb",
                                                                "2gb",
                                                                "4gb",
                                                                "8gb",
                                                                "16gb",
                                                                "32gb",
                                                                "48gb",
                                                                "64gb"
                                                        ],
                                                        "features" => [
                                                                "private_networking",
                                                                "backups",
                                                                "ipv6",
                                                                "metadata"
                                                        ],
                                                        "available" => true
                                                },
                                                "region_slug" => "nyc1"
                                        }
                                }

                                response
end
disable_backups(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/disable_backups.rb, line 23
def disable_backups(id)
  response        = Excon::Response.new
  response.status = 201
  response.body   = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "disable_backups",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
enable_ipv6(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/enable_ipv6.rb, line 23
def enable_ipv6(id)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "enable_ipv6",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
enable_private_networking(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/enable_private_networking.rb, line 23
def enable_private_networking(id)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "enable_private_networking",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
get_droplet_action(droplet_id, action) click to toggle source
# File lib/fog/digitalocean/requests/compute/get_droplet_action.rb, line 15
def get_droplet_action(droplet_id, action)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "change_kernel",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
get_image_details(id_or_slug) click to toggle source
# File lib/fog/digitalocean/requests/compute/get_image_details.rb, line 16
def get_image_details(id_or_slug)
  response        = Excon::Response.new

  if [7555620, 'nifty-new-snapshot-ubuntu'].include?(id_or_slug)
    response.status = 200

    response.body = {
      'image' =>
      {
        'id' => 7555620,
        'name' => 'Nifty New Snapshot',
        'distribution' => 'Ubuntu',
        'slug' => 'nifty-new-snapshot-ubuntu',
        'public' => false,
        'regions' => [
          'nyc2',
          'nyc2'
          ],
          'created_at' => '2014-11-04T22:23:02Z',
          'min_disk_size' => 20
        }
      }
  else
    response.status = 404
    raise(Fog::Compute::DigitalOcean::NotFound.new("Expected([200]) <=> Actual(404 Not Found)"))
  end

  response
end
get_server_details(_) click to toggle source
# File lib/fog/digitalocean/requests/compute/get_server_details.rb, line 16
def get_server_details(_)
  response        = Excon::Response.new
  response.status = 200

  response.body = {
    'droplet' => {
      'id'           => 3164494,
      'name'         => 'example.com',
      'memory'       => 512,
      'vcpus'        => 1,
      'disk'         => 20,
      'locked'       => false,
      'status'       => 'active',
      'kernel'       => {
        'id'      => 2233,
        'name'    => 'Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic',
        'version' => '3.13.0-37-generic'
      },
      'created_at'   => '2014-11-14T16:36:31Z',
      'features'     => %w(ipv6 virtio),
      'backup_ids'   => [],
      'snapshot_ids' => [7938206],
      'image'        => {
        'id'            => 6918990,
        'name'          => '14.04 x64',
        'distribution'  => 'Ubuntu',
        'slug'          => 'ubuntu-14-04-x64',
        'public'        => true,
        'regions'       => %w(nyc1 ams1 sfo1 nyc2 ams2 sgp1 lon1 nyc3 ams3 nyc3),
        'created_at'    => '2014-10-17T20:24:33Z',
        'type'          => 'snapshot',
        'min_disk_size' => 20
      },
      'size'         => {},
      'size_slug'    => '512mb',
      'networks'     => {
        'v4' => [
          {
            'ip_address' => '104.131.186.241',
            'netmask'    => '255.255.240.0',
            'gateway'    => '104.131.176.1',
            'type'       => 'public'
          }
        ],
        'v6' => [
          {
            'ip_address' => '2604:A880:0800:0010:0000:0000:031D:2001',
            'netmask'    => 64,
            'gateway'    => '2604:A880:0800:0010:0000:0000:0000:0001',
            'type'       => 'public'
          }
        ]
      },
      'region'       => {
        'name'      => 'New York 3',
        'slug'      => 'nyc3',
        'sizes'     => %w(32gb 16gb 2gb 1gb 4gb 8gb 512mb 64gb 48gb),
        'features'  => %w(virtio private_networking backups ipv6 metadata),
        'available' => true
      }
    }
  }

  response
end
get_ssh_key(_) click to toggle source
# File lib/fog/digitalocean/requests/compute/get_ssh_key.rb, line 16
def get_ssh_key(_)
  response        = Excon::Response.new
  response.status = 200

  response.body = {
    'ssh_key' => {
      'id'          => 512190,
      'fingerprint' => '3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa',
      'public_key'  => 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example',
      'name'        => 'My SSH Public Key'
    }
  }

  response
end
get_volume_details(_) click to toggle source
# File lib/fog/digitalocean/requests/compute/get_volume_details.rb, line 16
def get_volume_details(_)
  response        = Excon::Response.new
  response.status = 200

  response.body = {
    'volume' => {
      "id" =>  "v4-e098-11e5-ad9f-000f53306ae1",
      "region" => {
        "name" => "New York 1",
        "slug" => "nyc1",
        "sizes" => [
          "512mb",
          "1gb",
          "2gb",
          "4gb",
          "8gb",
          "16gb",
          "32gb",
          "48gb",
          "64gb"
        ],
        "features" => [
          "private_networking",
          "backups",
          "ipv6",
          "metadata"
        ],
        "available" => true
      },
      "droplet_ids" => [

      ],
      "name" => "example",
      "description" => "Block store for examples",
      "size_gigabytes" => 10,
      "created_at" => "2016-03-02T17:00:49Z"
    }
  }

  response
end
list_droplet_actions(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/list_droplet_actions.rb, line 15
def list_droplet_actions(id)
  response        = Excon::Response.new
  response.status = 201
  response.body   = {
    'actions' => [
      'action' => {
        'id'            => Fog::Mock.random_numbers(1).to_i,
        'status'        => "in-progress",
        'type'          => "change_kernel",
        'started_at'    => "2014-11-14T16:31:00Z",
        'completed_at'  => nil,
        'resource_id'   => id,
        'resource_type' => "droplet",
        'region'        => "nyc3",
        'region_slug'   => "nyc3"
      }
    ]
  }
  response
end
list_flavors(filters = {}) click to toggle source
# File lib/fog/digitalocean/requests/compute/list_flavors.rb, line 17
def list_flavors(filters = {})
  response        = Excon::Response.new
  response.status = 200
  response.body   = {

    'sizes' => [
      {
        'slug'          => '512mb',
        'memory'        => 512,
        'vcpus'         => 1,
        'disk'          => 20,
        'transfer'      => 1.0,
        'price_monthly' => 5.0,
        'price_hourly'  => 0.00744,
        'regions'       => %w(nyc1 sgp1 ams1 ams2 sfo1 nyc2 lon1 nyc3 ams3),
        'available'     => true
      },
      {
        'slug'          => '1gb',
        'memory'        => 1024,
        'vcpus'         => 1,
        'disk'          => 30,
        'transfer'      => 2.0,
        'price_monthly' => 10.0,
        'price_hourly'  => 0.01488,
        'regions'       => %w(nyc2 sgp1 ams1 sfo1 lon1 nyc3 ams3 ams2 nyc1),
        'available'     => true
      },
      {
        'slug'          => '2gb',
        'memory'        => 2048,
        'vcpus'         => 2,
        'disk'          => 40,
        'transfer'      => 3.0,
        'price_monthly' => 20.0,
        'price_hourly'  => 0.02976,
        'regions'       => %w(nyc2 sfo1 ams1 sgp1 ams2 lon1 nyc3 ams3 nyc1),
        'available'     => true
      },
      {
        'slug'          => '4gb',
        'memory'        => 4096,
        'vcpus'         => 2,
        'disk'          => 60,
        'transfer'      => 4.0,
        'price_monthly' => 40.0,
        'price_hourly'  => 0.05952,
        'regions'       => %w(nyc2 sfo1 ams1 sgp1 ams2 lon1 nyc3 ams3 nyc1),
        'available'     => true
      },
      {
        'slug'          => '8gb',
        'memory'        => 8192,
        'vcpus'         => 4,
        'disk'          => 80,
        'transfer'      => 5.0,
        'price_monthly' => 80.0,
        'price_hourly'  => 0.11905,
        'regions'       => %w(nyc2 sfo1 sgp1 ams1 ams2 nyc1 lon1 nyc3 ams3),
        'available'     => true
      },
      {
        'slug'          => '16gb',
        'memory'        => 16384,
        'vcpus'         => 8,
        'disk'          => 160,
        'transfer'      => 6.0,
        'price_monthly' => 160.0,
        'price_hourly'  => 0.2381,
        'regions'       => %w(sgp1 nyc1 sfo1 ams2 nyc3 lon1 nyc2 ams1 ams3),
        'available'     => true
      },
      {
        'slug'          => '32gb',
        'memory'        => 32768,
        'vcpus'         => 12,
        'disk'          => 320,
        'transfer'      => 7.0,
        'price_monthly' => 320.0,
        'price_hourly'  => 0.47619,
        'regions'       => %w(nyc2 sgp1 ams2 nyc1 sfo1 lon1 ams3 nyc3),
        'available'     => true
      },
      {
        'slug'          => '48gb',
        'memory'        => 49152,
        'vcpus'         => 16,
        'disk'          => 480,
        'transfer'      => 8.0,
        'price_monthly' => 480.0,
        'price_hourly'  => 0.71429,
        'regions'       => %w(sgp1 ams2 sfo1 nyc1 lon1 nyc2 ams3 nyc3),
        'available'     => true
      },
      {
        'slug'          => '64gb',
        'memory'        => 65536,
        'vcpus'         => 20,
        'disk'          => 640,
        'transfer'      => 9.0,
        'price_monthly' => 640.0,
        'price_hourly'  => 0.95238,
        'regions'       => %w(sgp1 nyc1 nyc2 sfo1 lon1 ams3 ams2 nyc3),
        'available'     => true
      }
    ],
    'links' => {},
    'meta'  => {'total' => 9}
  }

  response
end
list_images(filters = {}) click to toggle source
# File lib/fog/digitalocean/requests/compute/list_images.rb, line 17
def list_images(filters = {})
  next_page = (filters[:page] || 1).to_i + 1

  response        = Excon::Response.new
  response.status = 200
  response.body   = {

    'images' => [
      {
        'id'            => 7555620,
        'name'          => 'Nifty New Snapshot',
        'distribution'  => 'Ubuntu',
        'slug'          => 'nifty-new-snapshot-ubuntu',
        'public'        => false,
        'regions'       => %w(nyc2 nyc3),
        'created_at'    => '2014-11-04T22:23:02Z',
        'type'          => 'snapshot',
        'min_disk_size' => 20,
      }
    ],
    'links'  => {
      'pages' => {
        'last' => 'https://api.digitalocean.com/v2/images?page=56&per_page=1',
        'next' => "https://api.digitalocean.com/v2/images?page=#{next_page}&per_page=1"
      }
    },
    'meta'   => {
      'total' => 56
    }
  }

  response
end
list_regions(filters = {}) click to toggle source
# File lib/fog/digitalocean/requests/compute/list_regions.rb, line 17
def list_regions(filters = {})
  response        = Excon::Response.new
  response.status = 200
  response.body   = {
    'regions' => [
      {
        'name'      => 'New York 1',
        'slug'      => 'nyc1',
        'sizes'     => [],
        'features'  => %w(virtio backups),
        'available' => false
      },
      {
        'name'      => 'Amsterdam 1',
        'slug'      => 'ams1',
        'sizes'     => [],
        'features'  => %w(virtio backups),
        'available' => false
      },
      {
        'name'      => 'San Francisco 1',
        'slug'      => 'sfo1',
        'sizes'     => %w(32gb 16gb 2gb 1gb 4gb 8gb 512mb 64gb 48gb),
        'features'  => %w(virtio backups metadata),
        'available' => true
      },
      {
        'name'      => 'New York 2',
        'slug'      => 'nyc2',
        'sizes'     => %w(32gb 16gb 2gb 1gb 4gb 8gb 512mb 64gb 48gb),
        'features'  => %w(virtio private_networking backups),
        'available' => true
      },
      {
        'name'      => 'Amsterdam 2',
        'slug'      => 'ams2',
        'sizes'     => %w(32gb 16gb 2gb 1gb 4gb 8gb 512mb 64gb 48gb),
        'features'  => %w(virtio private_networking backups metadata),
        'available' => true
      },
      {
        'name'      => 'Singapore 1',
        'slug'      => 'sgp1',
        'sizes'     => %w(32gb 16gb 2gb 1gb 4gb 8gb 512mb 64gb 48gb),
        'features'  => %w(virtio private_networking backups ipv6 metadata),
        'available' => true
      },
      {
        'name'      => 'London 1',
        'slug'      => 'lon1',
        'sizes'     => %w(32gb 16gb 2gb 1gb 4gb 8gb 512mb 64gb 48gb),
        'features'  => %w(virtio private_networking backups ipv6 metadata),
        'available' => true
      },
      {
        'name'      => 'New York 3',
        'slug'      => 'nyc3',
        'sizes'     => %w(32gb 16gb 2gb 1gb 4gb 8gb 512mb 64gb 48gb),
        'features'  => %w(virtio private_networking backups ipv6 metadata),
        'available' => true
      },
      {
        'name'      => 'Amsterdam 3',
        'slug'      => 'ams3',
        'sizes'     => %w(32gb 16gb 2gb 1gb 4gb 8gb 512mb 64gb 48gb),
        'features'  => %w(virtio private_networking backups ipv6 metadata),
        'available' => true
      }
    ],
    'links'   => {},
    'meta'    => {'total' => 9}
  }

  response
end
list_servers(filters = {}) click to toggle source
# File lib/fog/digitalocean/requests/compute/list_servers.rb, line 17
def list_servers(filters = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {
      "status" => "OK",
      "droplets"  => self.data[:servers],
      "links" => {},
      "meta" => {
        "total" => data[:servers].count
      }
  }
  response
end
list_ssh_keys(filters = {}) click to toggle source
# File lib/fog/digitalocean/requests/compute/list_ssh_keys.rb, line 17
def list_ssh_keys(filters = {})
  response        = Excon::Response.new
  response.status = 200
  response.body   = {
    "ssh_keys" => data[:ssh_keys] ||
      [
        {
          "id" => 512189,
          "fingerprint" => "3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa",
          "public_key" => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
          "name" => "My SSH Public Key"
        }
      ],
    "links" => {
    },
    "meta" => {
      "total" => data[:ssh_keys].count || 1
    }
  }
  response
end
list_volume_actions(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/list_volume_actions.rb, line 15
def list_volume_actions(id)
  response        = Excon::Response.new
  response.status = 201
  response.body   = {
    "actions" => [
      {
        "id" => 72531856,
        "status" => "completed",
        "type" => "attach_volume",
        "started_at" => "2015-11-21T21:51:09Z",
        "completed_at" => "2015-11-21T21:51:09Z",
        "resource_id" => nil,
        "resource_type" => "volume",
        "region" => {
          "name" => "New York 1",
          "slug" => "nyc1",
          "sizes" => [
            "512mb",
            "1gb",
            "2gb",
            "4gb",
            "8gb",
            "16gb",
            "32gb",
            "48gb",
            "64gb"
          ],
          "features" => [
            "private_networking",
            "backups",
            "ipv6",
            "metadata"
          ],
          "available" => true
        },
        "region_slug" => "nyc1"
      }
    ],
    "links" => {
    },
    "meta" => {
      "total" => 1
    }
  }
  response
end
list_volumes(filters = {}) click to toggle source
# File lib/fog/digitalocean/requests/compute/list_volumes.rb, line 17
def list_volumes(filters = {})
  response        = Excon::Response.new
                                response.status = 200
                                response.body   = {
                                        "volumes" => [
                                                {
                                                        "id" => "506f78a4-e098-11e5-ad9f-000f53306ae1",
                                                        "region" => {
                                                                "name" => "New York 1",
                                                                "slug" =>"nyc1",
                                                                "sizes" => [
                                                                        "512mb",
                                                                        "1gb",
                                                                        "2gb",
                                                                        "4gb",
                                                                        "8gb",
                                                                        "16gb",
                                                                        "32gb",
                                                                        "48gb",
                                                                        "64gb"
                                                                ],
                                                                "features" => [
                                                                        "private_networking",
                                                                        "backups",
                                                                        "ipv6",
                                                                        "metadata"
                                                                ],
                                                                "available" => true
                                                        },
                                                        "droplet_ids" => [],
                                                        "name" =>"example",
                                                        "description" =>"Block store for examples",
                                                        "size_gigabytes" =>10,
                                                        "created_at" =>"2016-03-02T17:00:49Z"
                                                }
                                        ],
                                        "links" => {},
                                        "meta" => {
                                                "total" => 1
                                        }
                                }

  response
end
password_reset(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/password_reset.rb, line 23
def password_reset(id)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "password_reset",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
power_cycle(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/power_cycle.rb, line 23
def power_cycle(id)
  response        = Excon::Response.new
  response.status = 201
  response.body   = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "power_cycle",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
power_off(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/power_off.rb, line 23
def power_off(id)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "power_off",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
power_on(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/power_on.rb, line 23
def power_on(id)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "power_on",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
reboot_server(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/reboot_server.rb, line 23
def reboot_server(id)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "reboot",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
rebuild(id, image) click to toggle source
# File lib/fog/digitalocean/requests/compute/rebuild.rb, line 23
def rebuild(id, image)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "rebuild",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
rename(id, name) click to toggle source
# File lib/fog/digitalocean/requests/compute/rename.rb, line 23
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
reset_data() click to toggle source
# File lib/fog/digitalocean/compute.rb, line 84
def reset_data
  self.class.data.delete(@digitalocean_token)
end
resize(id, resize_disk, size) click to toggle source
# File lib/fog/digitalocean/requests/compute/resize.rb, line 27
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'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
resize_volume(volume_id, size, region) click to toggle source
# File lib/fog/digitalocean/requests/compute/resize_volume.rb, line 23
def resize_volume(volume_id, size, region)
                                response         = Excon::Response.new
                                response.status  = 201
  response.body    = {
    "action" => {
      "id" => 72531856,
      "status" => "in-progress",
      "type" => "resize",
      "started_at" => "2015-11-12T17:51:03Z",
      "completed_at" => "2015-11-12T17:51:14Z",
      "resource_id" => nil,
      "resource_type" => "volume",
      "region" => {
        "name" => "New York 1",
        "slug" => "nyc1",
        "sizes" => [
          "1gb",
          "2gb",
          "4gb",
          "8gb",
          "32gb",
          "64gb",
          "512mb",
          "48gb",
          "16gb"
        ],
        "features" => [
          "private_networking",
          "backups",
          "ipv6",
          "metadata"
        ],
        "available" => true
      },
      "region_slug" => "nyc1"
    }
  }
  response
end
restore(id, image) click to toggle source
# File lib/fog/digitalocean/requests/compute/restore.rb, line 23
def restore(id, image)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "restore",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
shutdown(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/shutdown.rb, line 23
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'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
snapshot(id, name) click to toggle source
# File lib/fog/digitalocean/requests/compute/snapshot.rb, line 23
def snapshot(id, name)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "snapshot",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end
transfer_image(id, name) click to toggle source
# File lib/fog/digitalocean/requests/compute/transfer_image.rb, line 23
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' => nil,
      'resource_id' => 7938269,
      'resource_type' => 'image',
      'region' => 'nyc3',
      'region_slug' => 'nyc3'
    }
  }
  response
end
update_ssh_key(key_id, name) click to toggle source
# File lib/fog/digitalocean/requests/compute/update_ssh_key.rb, line 28
def update_ssh_key(key_id, name)
  response        = Excon::Response.new
  response.status = 200

  response.body ={
    'ssh_key' => {
      'id'          => 512190,
      'fingerprint' => "3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa",
      'public_key'  => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
      'name'        => "My SSH Public Key"
    }
  }

  response
end
upgrade(id) click to toggle source
# File lib/fog/digitalocean/requests/compute/upgrade.rb, line 23
def upgrade(id)
  response         = Excon::Response.new
  response.status  = 201
  response.body    = {
    'action' => {
      'id'            => Fog::Mock.random_numbers(1).to_i,
      'status'        => "in-progress",
      'type'          => "upgrade",
      'started_at'    => "2014-11-14T16:31:00Z",
      'completed_at'  => nil,
      'resource_id'   => id,
      'resource_type' => "droplet",
      'region'        => "nyc3",
      'region_slug'   => "nyc3"
    }
  }
  response
end