Class: Fog::Compute::Packet::Real

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/compute/packet/compute.rb,
lib/fog/compute/packet/requests/get_ip.rb,
lib/fog/compute/packet/requests/get_vpn.rb,
lib/fog/compute/packet/requests/get_user.rb,
lib/fog/compute/packet/requests/list_ips.rb,
lib/fog/compute/packet/requests/assign_ip.rb,
lib/fog/compute/packet/requests/get_batch.rb,
lib/fog/compute/packet/requests/get_email.rb,
lib/fog/compute/packet/requests/bond_ports.rb,
lib/fog/compute/packet/requests/enable_vpn.rb,
lib/fog/compute/packet/requests/get_device.rb,
lib/fog/compute/packet/requests/get_volume.rb,
lib/fog/compute/packet/requests/list_plans.rb,
lib/fog/compute/packet/requests/list_users.rb,
lib/fog/compute/packet/requests/reserve_ip.rb,
lib/fog/compute/packet/requests/assign_port.rb,
lib/fog/compute/packet/requests/disable_vpn.rb,
lib/fog/compute/packet/requests/get_license.rb,
lib/fog/compute/packet/requests/get_project.rb,
lib/fog/compute/packet/requests/get_ssh_key.rb,
lib/fog/compute/packet/requests/list_events.rb,
lib/fog/compute/packet/requests/unassign_ip.rb,
lib/fog/compute/packet/requests/update_user.rb,
lib/fog/compute/packet/requests/create_batch.rb,
lib/fog/compute/packet/requests/create_email.rb,
lib/fog/compute/packet/requests/delete_email.rb,
lib/fog/compute/packet/requests/get_capacity.rb,
lib/fog/compute/packet/requests/list_batches.rb,
lib/fog/compute/packet/requests/list_devices.rb,
lib/fog/compute/packet/requests/list_volumes.rb,
lib/fog/compute/packet/requests/update_email.rb,
lib/fog/compute/packet/requests/verify_email.rb,
lib/fog/compute/packet/requests/attach_volume.rb,
lib/fog/compute/packet/requests/create_device.rb,
lib/fog/compute/packet/requests/create_volume.rb,
lib/fog/compute/packet/requests/delete_device.rb,
lib/fog/compute/packet/requests/delete_volume.rb,
lib/fog/compute/packet/requests/detach_volume.rb,
lib/fog/compute/packet/requests/disbond_ports.rb,
lib/fog/compute/packet/requests/get_bandwidth.rb,
lib/fog/compute/packet/requests/list_licenses.rb,
lib/fog/compute/packet/requests/list_projects.rb,
lib/fog/compute/packet/requests/list_sessions.rb,
lib/fog/compute/packet/requests/list_ssh_keys.rb,
lib/fog/compute/packet/requests/reboot_device.rb,
lib/fog/compute/packet/requests/session_login.rb,
lib/fog/compute/packet/requests/unassign_port.rb,
lib/fog/compute/packet/requests/update_device.rb,
lib/fog/compute/packet/requests/update_volume.rb,
lib/fog/compute/packet/requests/create_license.rb,
lib/fog/compute/packet/requests/create_project.rb,
lib/fog/compute/packet/requests/create_ssh_key.rb,
lib/fog/compute/packet/requests/delete_license.rb,
lib/fog/compute/packet/requests/delete_project.rb,
lib/fog/compute/packet/requests/delete_session.rb,
lib/fog/compute/packet/requests/delete_ssh_key.rb,
lib/fog/compute/packet/requests/get_invitation.rb,
lib/fog/compute/packet/requests/get_membership.rb,
lib/fog/compute/packet/requests/list_snapshots.rb,
lib/fog/compute/packet/requests/poweron_device.rb,
lib/fog/compute/packet/requests/update_license.rb,
lib/fog/compute/packet/requests/update_project.rb,
lib/fog/compute/packet/requests/update_ssh_key.rb,
lib/fog/compute/packet/requests/create_snapshot.rb,
lib/fog/compute/packet/requests/delete_snapshot.rb,
lib/fog/compute/packet/requests/get_bgp_session.rb,
lib/fog/compute/packet/requests/list_facilities.rb,
lib/fog/compute/packet/requests/poweroff_device.rb,
lib/fog/compute/packet/requests/get_notification.rb,
lib/fog/compute/packet/requests/get_organization.rb,
lib/fog/compute/packet/requests/list_invitations.rb,
lib/fog/compute/packet/requests/list_memberships.rb,
lib/fog/compute/packet/requests/transfer_project.rb,
lib/fog/compute/packet/requests/accept_invitation.rb,
lib/fog/compute/packet/requests/delete_membership.rb,
lib/fog/compute/packet/requests/list_bgp_sessions.rb,
lib/fog/compute/packet/requests/update_membership.rb,
lib/fog/compute/packet/requests/validate_capacity.rb,
lib/fog/compute/packet/requests/create_bgp_session.rb,
lib/fog/compute/packet/requests/decline_invitation.rb,
lib/fog/compute/packet/requests/delete_bgp_session.rb,
lib/fog/compute/packet/requests/get_payment_method.rb,
lib/fog/compute/packet/requests/list_notifications.rb,
lib/fog/compute/packet/requests/list_organizations.rb,
lib/fog/compute/packet/requests/create_organization.rb,
lib/fog/compute/packet/requests/delete_organization.rb,
lib/fog/compute/packet/requests/update_notification.rb,
lib/fog/compute/packet/requests/update_organization.rb,
lib/fog/compute/packet/requests/get_transfer_request.rb,
lib/fog/compute/packet/requests/list_payment_methods.rb,
lib/fog/compute/packet/requests/create_payment_method.rb,
lib/fog/compute/packet/requests/delete_payment_method.rb,
lib/fog/compute/packet/requests/list_spotmarketprices.rb,
lib/fog/compute/packet/requests/list_virtual_networks.rb,
lib/fog/compute/packet/requests/update_payment_method.rb,
lib/fog/compute/packet/requests/create_virtual_network.rb,
lib/fog/compute/packet/requests/delete_virtual_network.rb,
lib/fog/compute/packet/requests/enable_two_factor_auth.rb,
lib/fog/compute/packet/requests/list_operating_systems.rb,
lib/fog/compute/packet/requests/list_transfer_requests.rb,
lib/fog/compute/packet/requests/accept_transfer_request.rb,
lib/fog/compute/packet/requests/disable_two_factor_auth.rb,
lib/fog/compute/packet/requests/decline_transfer_request.rb,
lib/fog/compute/packet/requests/get_hardware_reservation.rb,
lib/fog/compute/packet/requests/move_hardware_reservation.rb,
lib/fog/compute/packet/requests/list_hardware_reservations.rb,
lib/fog/compute/packet/requests/request_email_verification.rb,
lib/fog/compute/packet/requests/list_spotmarketprices_history.rb

Overview

Real

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/fog/compute/packet/compute.rb', line 242

def initialize(options = {})
  if options[:packet_token] 
    @packet_token = options[:packet_token]
  else
    @packet_token = ENV["PACKET_TOKEN"]
  end

  raise "Packet token is not present. Please pass it as an argument or set environment variable 'PACKET_TOKEN'." unless @packet_token

  @base_url = options[:packet_url] ? options[:packet_url] : "https://api.packet.net/" 
  @version = ""

  @header = {
    "X-Auth-Token" => @packet_token,
    "Content-Type" => "application/json"
  }
  @connection = Fog::Core::Connection.new(@base_url)
end

Instance Method Details

#accept_invitation(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/accept_invitation.rb', line 6

def accept_invitation(id)
  request(
    :expects => [200],
    :method => "PUT",
    :path => "/invitations/" + id
  )
end

#accept_transfer_request(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/accept_transfer_request.rb', line 6

def accept_transfer_request(id)
  request(
    :expects => [204],
    :method => "PUT",
    :path => "/transfers/" + id
  )
end

#assign_ip(device_id, options) ⇒ Object



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

def assign_ip(device_id, options)
  req = {
    "address" => options[:address]
  }

  req["manageable"] = options[:manageable] if options[:manageable]

  request(
    :expects => [201],
    :method => "POST",
    :path => "/devices/" + device_id + "/ips",
    :body => Fog::JSON.encode(req)
  )
end

#assign_port(port_id, vnid) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/assign_port.rb', line 6

def assign_port(port_id, vnid)
  request(
    :expects => [200],
    :method => "POST",
    :path => "/ports/" + port_id + "/assign?vnid=" + vnid
  )
end

#attach_volume(volume_id, device_id) ⇒ Object



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

def attach_volume(volume_id, device_id)
  req = {
    "device_id" => device_id
  }

  request(
    :expects => [201],
    :method => "POST",
    :path => "/storage/" + volume_id + "/attachments",
    :body => Fog::JSON.encode(req)
  )
end

#bond_ports(port_id, bulk_enable) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/bond_ports.rb', line 6

def bond_ports(port_id, bulk_enable)
  request(
    :expects => [200],
    :method => "POST",
    :path => "/ports/" + port_id + "/bond?bulk_enable=" + (bulk_enable ? "true" : "false")
  )
end

#create_batch(project_id, options) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/create_batch.rb', line 6

def create_batch(project_id, options)
  request(
    :expects => [201],
    :method => "POST",
    :path => "/projects/" + project_id + "/devices/batch",
    :body => Fog::JSON.encode(options)
  )
end

#create_bgp_session(device_id, address_family) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/create_bgp_session.rb', line 6

def create_bgp_session(device_id, address_family)
  request(
    :expects => [201],
    :method => "POST",
    :path => "/devices/" + device_id + "/bgp/sessions?address_family=" + address_family
  )
end

#create_device(project_id, options) ⇒ Object



6
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
# File 'lib/fog/compute/packet/requests/create_device.rb', line 6

def create_device(project_id, options)
  device = {
    "facility" => options[:facility],
    "plan" => options[:plan],
    "hostname" => options[:hostname],
    "operating_system" => options[:operating_system]
  }

  device["description"] = options[:description] if options[:description]
  device["billing_cycle"] = options[:billing_cycle] if options[:billing_cycle]
  device["always_pxe"] = options[:always_pxe] if options[:always_pxe]
  device["ipxe_script_url"] = options[:ipxe_script_url] if options[:ipxe_script_url]
  device["userdata"] = options[:userdata] if options[:userdata]
  device["locked"] = options[:locked] if options[:locked]
  device["hardware_reservation_id"] = options[:hardware_reservation_id] if options[:hardware_reservation_id]
  device["spot_instance"] = options[:spot_instance] if options[:spot_instance]
  device["spot_price_max"] = options[:spot_price_max] if options[:spot_price_max]
  device["termination_time"] = options[:termination_time] if options[:termination_time]
  device["tags"] = options[:tags] if options[:tags]
  device["project_ssh_keys"] = options[:project_ssh_keys] if options[:project_ssh_keys]
  device["user_ssh_keys"] = options[:user_ssh_keys] if options[:user_ssh_keys]
  device["features"] = options[:features] if options[:features]

  request(
    :expects => [201],
    :method => "POST",
    :path => "/projects/" + project_id + "/devices",
    :body => Fog::JSON.encode(device)
  )
end

#create_email(options) ⇒ Object



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

def create_email(options)
  email = {
    "address" => options[:address],
    "default" => options[:default]
  }

  request(
    :expects => [201],
    :method => "POST",
    :path => "/emails",
    :body => Fog::JSON.encode(email)
  )
end

#create_license(project_id, options) ⇒ Object



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

def create_license(project_id, options)
  license = {
    "description" => options[:description],
    "size" => options[:size]
  }

  license["license_product_id"] = options[:license_product_id] if options[:license_product_id]

  request(
    :expects => [201],
    :method => "POST",
    :path => "/projects/" + project_id + "/licenses",
    :body => Fog::JSON.encode(license)
  )
end

#create_organization(options) ⇒ Object



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

def create_organization(options)
  org = {
    "name" => options[:name],
    "description" => options[:description]
  }

  org["website"] = options[:website] if options[:website]
  org["twitter"] = options[:twitter] if options[:twitter]
  org["logo"] = options[:logo] if options[:logo]
  org["address"] = options[:address] if options[:address]
  org["customdata"] = options[:customdata] if options[:customdata]

  request(
    :expects => [201],
    :method => "POST",
    :path => "/organizations",
    :body => Fog::JSON.encode(org)
  )
end

#create_payment_method(org_id, options) ⇒ Object



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

def create_payment_method(org_id, options)
  payment_method = {
    "name" => options[:name]
  }
  payment_method["default"] = options[:default] if options[:default]
  payment_method["nonce"] = options[:nonce] if options[:nonce]

  request(
    :expects => [201],
    :method => "POST",
    :path => "/organizations/" + org_id + "/payment_methods",
    :body => Fog::JSON.encode(payment_method)
  )
end

#create_project(options) ⇒ Object



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

def create_project(options)
  project = {
    "name" => options[:name],
    "payment_method_id" => options[:payment_method_id]
  }

  request(
    :expects => [201],
    :method => "POST",
    :path => "/projects",
    :body => Fog::JSON.encode(project)
  )
end

#create_snapshot(storage_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/create_snapshot.rb', line 6

def create_snapshot(storage_id)
  request(
    :expects => [202],
    :method => "POST",
    :path => "/storage/" + storage_id + "/snapshots"
  )
end

#create_ssh_key(options) ⇒ Object



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

def create_ssh_key(options)
  sshkey = {
    "label" => options[:label],
    "key" => options[:key]
  }

  request(
    :expects => [201],
    :method => "POST",
    :path => "/ssh-keys",
    :body => Fog::JSON.encode(sshkey)
  )
end

#create_virtual_network(options) ⇒ Object



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

def create_virtual_network(options)
  vnet = {
    "project_id" => options[:project_id],
    "description" => options[:description],
    "facility" => options[:facility],
    "vxlan" => options[:vxlan],
    "vlan" => options[:vlan]
  }

  request(
    :expects => [201],
    :method => "POST",
    :path => "/projects/" + options[:project_id] + "/virtual-networks",
    :body => Fog::JSON.encode(vnet)
  )
end

#create_volume(project_id, options) ⇒ Object



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

def create_volume(project_id, options)
  volume = {
    "facility" => options[:facility],
    "plan" => options[:plan],
    "size" => options[:size]
  }

  volume["description"] = options[:description] if options[:description]
  volume["billing_cycle"] = options[:billing_cycle] if options[:billing_cycle]
  volume["snapshot_policies"] = options[:snapshot_policies] if options[:snapshot_policies]

  request(
    :expects => [201],
    :method => "POST",
    :path => "/projects/" + project_id + "/storage",
    :body => Fog::JSON.encode(volume)
  )
end

#decline_invitation(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/decline_invitation.rb', line 6

def decline_invitation(id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/invitations/" + id
  )
end

#decline_transfer_request(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/decline_transfer_request.rb', line 6

def decline_transfer_request(id)
  request(
    :expects => [204],
    :method => "PUT",
    :path => "/transfers/" + id
  )
end

#delete_bgp_session(session_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/delete_bgp_session.rb', line 6

def delete_bgp_session(session_id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/bgp/sessions/" + session_id
  )
end

#delete_device(device_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/delete_device.rb', line 6

def delete_device(device_id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/devices/" + device_id
  )
end

#delete_email(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/delete_email.rb', line 6

def delete_email(id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/emails/" + id
  )
end

#delete_license(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/delete_license.rb', line 6

def delete_license(id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/licenses/" + id
  )
end

#delete_membership(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/delete_membership.rb', line 6

def delete_membership(id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/memberships/" + id
  )
end

#delete_organization(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/delete_organization.rb', line 6

def delete_organization(id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/organizations/" + id
  )
end

#delete_payment_method(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/delete_payment_method.rb', line 6

def delete_payment_method(id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/payment-methods/" + id
  )
end

#delete_project(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/delete_project.rb', line 6

def delete_project(id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/projects/" + id
  )
end

#delete_session(session_id = "") ⇒ Object



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

def delete_session(session_id = "")
  url = "/session"
  url = "/sessions/" + session_id if session_id != ""
  request(
    :expects => [204],
    :method => "DELETE",
    :path => url
  )
end

#delete_snapshot(storage_id, snapshot_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/delete_snapshot.rb', line 6

def delete_snapshot(storage_id, snapshot_id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/storage/" + storage_id + "/snapshots/" + snapshot_id
  )
end

#delete_ssh_key(id) ⇒ Object



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

def delete_ssh_key(id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/ssh-keys/" + id
  )
end

#delete_virtual_network(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/delete_virtual_network.rb', line 6

def delete_virtual_network(id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/virtual-networks/" + id
  )
end

#delete_volume(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/delete_volume.rb', line 6

def delete_volume(id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/storage/" + id
  )
end

#detach_volume(attachment_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/detach_volume.rb', line 6

def detach_volume(attachment_id)
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/storage/attachments/" + attachment_id
  )
end

#disable_two_factor_auth(type) ⇒ Object



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

def disable_two_factor_auth(type)
  url = "/user/otp/" + type

  request(
    :expects => [204],
    :method => "DELETE",
    :path => url
  )
end

#disable_vpnObject



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/disable_vpn.rb', line 6

def disable_vpn
  request(
    :expects => [204],
    :method => "DELETE",
    :path => "/user/vpn"
  )
end

#disbond_ports(port_id, bulk_disable) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/disbond_ports.rb', line 6

def disbond_ports(port_id, bulk_disable)
  request(
    :expects => [200],
    :method => "POST",
    :path => "/ports/" + port_id + "/disbond?bulk_disable=" + (bulk_disable ? "true" : "false")
  )
end

#enable_two_factor_auth(type) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/enable_two_factor_auth.rb', line 6

def enable_two_factor_auth(type)
  url = "/user/otp/" + type
  request(
    :expects => [200],
    :method => "POST",
    :path => url
  )
end

#enable_vpnObject



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/enable_vpn.rb', line 6

def enable_vpn
  request(
    :expects => [201],
    :method => "POST",
    :path => "/user/vpn"
  )
end

#get_bandwidth(device_id, params) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/get_bandwidth.rb', line 6

def get_bandwidth(device_id, params)
  request(
    :expects => [201],
    :method => "GET",
    :path => "/devices/" + device_id + "/bandwidth",
    :params => params
  )
end

#get_batch(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_batch.rb', line 6

def get_batch(id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/batches/" + id
  )
end

#get_bgp_session(session_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_bgp_session.rb', line 6

def get_bgp_session(session_id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/bgp/sessions/" + session_id
  )
end

#get_capacityObject



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_capacity.rb', line 6

def get_capacity
  request(
    :expects => [200],
    :method => "GET",
    :path => "/capacity"
  )
end

#get_device(device_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_device.rb', line 6

def get_device(device_id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/devices/" + device_id
  )
end

#get_email(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_email.rb', line 6

def get_email(id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/emails/" + id
  )
end

#get_hardware_reservation(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_hardware_reservation.rb', line 6

def get_hardware_reservation(id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/hardware_reservations/" + id
  )
end

#get_invitation(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_invitation.rb', line 6

def get_invitation(id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/invitations/" + id
  )
end

#get_ip(ip_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_ip.rb', line 6

def get_ip(ip_id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/ips/" + ip_id
  )
end

#get_license(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_license.rb', line 6

def get_license(id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/licenses/" + id
  )
end

#get_membership(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_membership.rb', line 6

def get_membership(id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/memberships/" + id
  )
end

#get_notification(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_notification.rb', line 6

def get_notification(id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/notifications/" + id
  )
end

#get_organization(id, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/get_organization.rb', line 6

def get_organization(id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/organizations/" + id,
    :params => params
  )
end

#get_payment_method(id, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/get_payment_method.rb', line 6

def get_payment_method(id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/payment-methods/" + id,
    :params => params
  )
end

#get_project(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_project.rb', line 6

def get_project(id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/projects/" + id
  )
end

#get_project_facilities(project_id) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/fog/compute/packet/requests/list_facilities.rb', line 14

def get_project_facilities(project_id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/projects/" + project_id + "/facilities"
  )
end

#get_project_plans(project_id) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/fog/compute/packet/requests/list_plans.rb', line 15

def get_project_plans(project_id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/projects/" + project_id + "/plans"
  )
end

#get_ssh_key(id) ⇒ Object



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

def get_ssh_key(id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/ssh-keys/" + id
  )
end

#get_transfer_request(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_transfer_request.rb', line 6

def get_transfer_request(id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/transfers/" + id
  )
end

#get_user(id = "") ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_user.rb', line 6

def get_user(id = "")
  request(
    :expects => [200],
    :method => "GET",
    :path => "/users/" + id
  )
end

#get_volume(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_volume.rb', line 6

def get_volume(id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/storage/" + id
  )
end

#get_vpn(facility_code) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/get_vpn.rb', line 6

def get_vpn(facility_code)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/user/vpn?code=" + facility_code
  )
end

#list_batches(project_id, params) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_batches.rb', line 6

def list_batches(project_id, params)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/projects/" + project_id + "/batches",
    :params => params
  )
end

#list_bgp_sessions(device_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/list_bgp_sessions.rb', line 6

def list_bgp_sessions(device_id)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/devices/" + device_id + "/bgp/sessions"
  )
end

#list_devices(project_id, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_devices.rb', line 6

def list_devices(project_id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/projects/" + project_id + "/devices",
    :params => params
  )
end

#list_events(device_id, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_events.rb', line 6

def list_events(device_id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/devices/" + device_id + "/events",
    :params => params
  )
end

#list_facilitiesObject



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/list_facilities.rb', line 6

def list_facilities
  request(
    :expects => [200],
    :method => "GET",
    :path => "/facilities"
  )
end

#list_hardware_reservations(project_id, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_hardware_reservations.rb', line 6

def list_hardware_reservations(project_id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/projects/" + project_id + "/hardware-reservations",
    :params => params
  )
end

#list_invitations(device_id, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_invitations.rb', line 6

def list_invitations(device_id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/invitations/" + device_id,
    :params => params
  )
end

#list_ips(project_id, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_ips.rb', line 6

def list_ips(project_id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/projects/" + project_id + "/ips",
    :params => params
  )
end

#list_licenses(project_id, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_licenses.rb', line 6

def list_licenses(project_id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/projects/" + project_id + "/licenses",
    :params => params
  )
end

#list_memberships(project_id, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_memberships.rb', line 6

def list_memberships(project_id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/projects/" + project_id + "/memberships",
    :pramas => params
  )
end

#list_notifications(params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_notifications.rb', line 6

def list_notifications(params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/notifications",
    :params => params
  )
end

#list_operating_systemsObject



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/list_operating_systems.rb', line 6

def list_operating_systems
  request(
    :expects => [200],
    :method => "GET",
    :path => "/operating-systems"
  )
end

#list_organizations(params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_organizations.rb', line 6

def list_organizations(params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/organizations",
    :params => params
  )
end

#list_payment_methods(org_id, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_payment_methods.rb', line 6

def list_payment_methods(org_id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/organizations/" + org_id + "/payment-methods",
    :params => params
  )
end

#list_plans(params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_plans.rb', line 6

def list_plans(params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/plans",
    :params => params
  )
end

#list_projects(params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_projects.rb', line 6

def list_projects(params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/projects",
    :params => params
  )
end

#list_sessions(params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_sessions.rb', line 6

def list_sessions(params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/sessions",
    :params => params
  )
end

#list_snapshots(volume_id, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_snapshots.rb', line 6

def list_snapshots(volume_id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/storage/" + volume_id + "/snapshots",
    :params => params
  )
end

#list_spotmarketpricesObject



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/list_spotmarketprices.rb', line 6

def list_spotmarketprices
  request(
    :expects => [200],
    :method => "GET",
    :path => "/market/spot/prices"
  )
end

#list_spotmarketprices_history(facility, plan) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/list_spotmarketprices_history.rb', line 6

def list_spotmarketprices_history(facility, plan)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/market/spot/prices/history?facility=" + facility + "&plan=" + plan
  )
end

#list_ssh_keys(project_id = "", params = {}) ⇒ Object



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

def list_ssh_keys(project_id = "", params = {})
  p project_id
  p params
  url = "/ssh-keys"
  if project_id.class == Hash
    params = project_id
  elsif project_id.class == String
    url = "/projects/" + project_id + "/ssh-keys" unless project_id == ""
  end
  request(
    :expects => [200],
    :method => "GET",
    :path => url,
    :params => params
  )
end

#list_transfers(organization_id, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_transfer_requests.rb', line 6

def list_transfers(organization_id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/organizations/" + organization_id + "/transfers",
    :params => params
  )
end

#list_users(params = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_users.rb', line 6

def list_users(params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/users",
    :params => params
  )
end

#list_virtual_networks(project_id, params) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/compute/packet/requests/list_virtual_networks.rb', line 6

def list_virtual_networks(project_id, params)
  request(
    :expects => [200],
    :method => "GET",
    :path => "/projects/" + project_id + "/virtual-networks",
    :params => params
  )
end

#list_volumes(project_id, params = {}) ⇒ Object



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

def list_volumes(project_id, params = {})
  request(
    :expects => [200],
    :method => "GET",
    :path => "/projects/" + project_id + "/storage",
    :params => params
  )
end

#move_hardware_reservation(reservation_id, project_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/move_hardware_reservation.rb', line 6

def move_hardware_reservation(reservation_id, project_id)
  request(
    :expects => [200],
    :method => "POST",
    :path => "/hardware-reservations/" + reservation_id + "/move/" + project_id
  )
end

#poweroff_device(device_id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/compute/packet/requests/poweroff_device.rb', line 6

def poweroff_device(device_id)
  action = {
    "type" => "power_off"
  }

  request(
    :expects => [201],
    :method => "POST",
    :path => "/devices/" + device_id + "/actions",
    :body => Fog::JSON.encode(action)
  )
end

#poweron_device(device_id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/compute/packet/requests/poweron_device.rb', line 6

def poweron_device(device_id)
  action = {
    "type" => "power_on"
  }

  request(
    :expects => [201],
    :method => "POST",
    :path => "/devices/" + device_id + "/actions",
    :body => Fog::JSON.encode(action)
  )
end

#reboot_device(device_id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/compute/packet/requests/reboot_device.rb', line 6

def reboot_device(device_id)
  action = {
    "type" => "reboot"
  }

  request(
    :expects => [201],
    :method => "POST",
    :path => "/devices/" + device_id + "/actions",
    :body => Fog::JSON.encode(action)
  )
end

#request(params) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/fog/compute/packet/compute.rb', line 261

def request(params)
  # Perform Request

  begin
    response = @connection.request(:method => params[:method],
                                   :path => params[:path],
                                   :headers => @header,
                                   :body => params[:body],
                                   :query => params[:params])
  rescue Excon::Errors::Unauthorized => error
    raise error
  rescue Excon::Errors::HTTPStatusError => error
    raise error
  rescue Excon::Errors::InternalServerError => error
    raise error
  rescue Fog::Errors::NotFound => error
    raise error
  end

  # Parse body
  response.body = Fog::JSON.decode(response.body) if response.body != ""

  #
  # Check for server error
  if response.status == 500
    raise "Internal Server Error. Please try again."
  end
  # Raise exception if a bad status code is returned
  unless SUCCESS_CODES.include? response.status
    raise response.status.to_s + " " + response.body.to_s
  end

  response
end

#request_email_verification(email) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/request_email_verification.rb', line 6

def request_email_verification(email)
  request(
    :expects => [201],
    :method => "POST",
    :path => "/verify-email?login=" + email
  )
end

#reserve_ip(project_id, options) ⇒ Object



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

def reserve_ip(project_id, options)
  ip = {
    "facility" => options[:facility],
    "quantity" => options[:quantity],
    "type" => options[:type]
  }

  ip["comments"] = options[:comments] if options[:comments]

  request(
    :expects => [201],
    :method => "POST",
    :path => "/projects/" + project_id + "/ips",
    :body => Fog::JSON.encode(ip)
  )
end

#session_login(login_params) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/session_login.rb', line 6

def ()
  request(
    :expects => [201],
    :method => "POST",
    :path => "/sessions?login=" + [:username] + "&password=" + [:password]
  )
end

#transfer_project(project_id, organization_id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/compute/packet/requests/transfer_project.rb', line 6

def transfer_project(project_id, organization_id)
  transfer_request = {
    "target_organization_id" => organization_id
  }

  request(
    :expects => [201],
    :method => "POST",
    :path => "/projects/" + project_id + "/transfers",
    :body => Fog::JSON.encode(transfer_request)
  )
end

#unassign_ip(ip_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/unassign_ip.rb', line 6

def unassign_ip(ip_id)
  request(
    :expects => [204],
    :method => "POST",
    :path => "/ips/" + ip_id
  )
end

#unassign_port(port_id, vnid) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/unassign_port.rb', line 6

def unassign_port(port_id, vnid)
  request(
    :expects => [200],
    :method => "POST",
    :path => "/ports/" + port_id + "/unassign?vnid=" + vnid
  )
end

#update_device(device_id, options) ⇒ Object



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

def update_device(device_id, options)
  device = Hash.new {}
  device["hostname"] = options[:hostname] if options[:hostname]
  device["description"] = options[:description] if options[:description]
  device["billing_cycle"] = options[:billing_cycle] if options[:billing_cycle]
  device["userdata"] = options[:userdata] if options[:userdata]
  device["locked"] = options[:locked] if options[:locked]
  device["tags"] = options[:tags] if options[:tags]
  device["always_pxe"] = options[:always_pxe] if options[:always_pxe]
  device["ipxe_script_url"] = options[:ipxe_script_url] if options[:ipxe_script_url]
  device["spot_instance"] = options[:spot_instance] if options[:spot_instance]

  request(
    :expects => [200],
    :method => "PUT",
    :path => "/devices/" + device_id,
    :body => Fog::JSON.encode(device)
  )
end

#update_email(email_id, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/compute/packet/requests/update_email.rb', line 6

def update_email(email_id, options)
  project = Hash.new {}
  project["address"] = options[:address] if options[:address]
  project["default"] = options[:default] if options[:default]

  request(
    :expects => [200],
    :method => "PUT",
    :path => "/emails/" + email_id,
    :body => Fog::JSON.encode(project)
  )
end

#update_license(id, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/compute/packet/requests/update_license.rb', line 6

def update_license(id, options)
  project = Hash.new {}
  project["description"] = options[:description] if options[:description]
  project["size"] = options[:size] if options[:size]

  request(
    :expects => [200],
    :method => "PUT",
    :path => "/licenses/" + id,
    :body => Fog::JSON.encode(project)
  )
end

#update_membership(id, options) ⇒ Object



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

def update_membership(id, options)
  roles = Hash.new {}
  roles["roles"] = options[:roles] if options[:roles]
  request(
    :expects => [200],
    :method => "PUT",
    :path => "/memberships/" + id,
    :body => Fog::JSON.encode(roles)
  )
end

#update_notification(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/update_notification.rb', line 6

def update_notification(id)
  request(
    :expects => [200],
    :method => "PUT",
    :path => "/notifications/" + id
  )
end

#update_organization(id, options) ⇒ Object



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

def update_organization(id, options)
  org = {}
  org["name"] = options[:name] if options[:name]
  org["description"] = options[:description] if options[:description]
  org["website"] = options[:website] if options[:website]
  org["twitter"] = options[:twitter] if options[:twitter]
  org["logo"] = options[:logo] if options[:logo]
  org["address"] = options[:address] if options[:address]
  org["customdata"] = options[:customdata] if options[:customdata]

  request(
    :expects => [200],
    :method => "PUT",
    :path => "/organizations/" + id,
    :body => Fog::JSON.encode(org)
  )
end

#update_payment_method(id, options) ⇒ Object



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

def update_payment_method(id, options)
  payment_method = {}
  payment_method["name"] = options[:name] if options[:name]
  payment_method["cardholder_name"] = options[:cardholder_name] if options[:cardholder_name]
  payment_method["expiration_month"] = options[:expiration_month] if options[:expiration_month]
  payment_method["expiration_year"] = options[:expiration_year] if options[:expiration_year]

  request(
    :expects => [200],
    :method => "POST",
    :path => "/payment_methods/" + id,
    :body => Fog::JSON.encode(payment_method)
  )
end

#update_project(project_id, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/compute/packet/requests/update_project.rb', line 6

def update_project(project_id, options)
  project = Hash.new {}
  project["name"] = options[:name] if options[:name]
  project["payment_method_id"] = options[:payment_method_id] if options[:payment_method_id]

  request(
    :expects => [200],
    :method => "PUT",
    :path => "/projects/" + project_id,
    :body => Fog::JSON.encode(project)
  )
end

#update_ssh_key(id, options) ⇒ Object



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

def update_ssh_key(id, options)
  sshkey = {
    "label" => options[:label],
    "key" => options[:key]
  }

  request(
    :expects => [200],
    :method => "PUT",
    :path => "/ssh-keys/" + id,
    :body => Fog::JSON.encode(sshkey)
  )
end

#update_user(user_id, options) ⇒ Object



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

def update_user(user_id, options)
  project = Hash.new {}
  project["first_name"] = options[:first_name] if options[:first_name]
  project["last_name"] = options[:last_name] if options[:last_name]
  project["phone_number"] = options[:phone_number] if options[:phone_number]
  project["timezone"] = options[:timezone] if options[:timezone]
  project["password"] = options[:password] if options[:password]
  project["avatar"] = options[:timezone] if options[:avatar]

  request(
    :expects => [200],
    :method => "PUT",
    :path => "/users/" + user_id,
    :body => Fog::JSON.encode(project)
  )
end

#update_volume(volume_id, options) ⇒ Object



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

def update_volume(volume_id, options)
  device = Hash.new {}
  device["description"] = options[:description] if options[:description]
  device["billing_cycle"] = options[:billing_cycle] if options[:billing_cycle]
  device["size"] = options[:size] if options[:size]
  device["locked"] = options[:locked] if options[:locked]

  request(
    :expects => [200],
    :method => "PUT",
    :path => "/storage/" + volume_id,
    :body => Fog::JSON.encode(device)
  )
end

#validate_capacity(options) ⇒ Object



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

def validate_capacity(options)
  cap = {
    "servers" => []
  }
  options[:servers].each do |server|
    srv = {}
    srv["facility"] = server[:facility] if server[:facility]
    srv["plan"] = server[:plan] if server[:plan]
    srv["quantity"] = server[:quantity] if server[:quantity]

    cap["servers"] << srv
  end

  request(
    :expects => [204],
    :method => "POST",
    :path => "/capacity",
    :body => Fog::JSON.encode(cap)
  )
end

#verify_email(token) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/compute/packet/requests/verify_email.rb', line 6

def verify_email(token)
  request(
    :expects => [200],
    :method => "POST",
    :path => "/verify-email?token=" + token
  )
end