Class: Fog::Compute::Packet::Real
- Inherits:
-
Object
- Object
- Fog::Compute::Packet::Real
- 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
- #accept_invitation(id) ⇒ Object
- #accept_transfer_request(id) ⇒ Object
- #assign_ip(device_id, options) ⇒ Object
- #assign_port(port_id, vnid) ⇒ Object
- #attach_volume(volume_id, device_id) ⇒ Object
- #bond_ports(port_id, bulk_enable) ⇒ Object
- #create_batch(project_id, options) ⇒ Object
- #create_bgp_session(device_id, address_family) ⇒ Object
- #create_device(project_id, options) ⇒ Object
- #create_email(options) ⇒ Object
- #create_license(project_id, options) ⇒ Object
- #create_organization(options) ⇒ Object
- #create_payment_method(org_id, options) ⇒ Object
- #create_project(options) ⇒ Object
- #create_snapshot(storage_id) ⇒ Object
- #create_ssh_key(options) ⇒ Object
- #create_virtual_network(options) ⇒ Object
- #create_volume(project_id, options) ⇒ Object
- #decline_invitation(id) ⇒ Object
- #decline_transfer_request(id) ⇒ Object
- #delete_bgp_session(session_id) ⇒ Object
- #delete_device(device_id) ⇒ Object
- #delete_email(id) ⇒ Object
- #delete_license(id) ⇒ Object
- #delete_membership(id) ⇒ Object
- #delete_organization(id) ⇒ Object
- #delete_payment_method(id) ⇒ Object
- #delete_project(id) ⇒ Object
- #delete_session(session_id = "") ⇒ Object
- #delete_snapshot(storage_id, snapshot_id) ⇒ Object
- #delete_ssh_key(id) ⇒ Object
- #delete_virtual_network(id) ⇒ Object
- #delete_volume(id) ⇒ Object
- #detach_volume(attachment_id) ⇒ Object
- #disable_two_factor_auth(type) ⇒ Object
- #disable_vpn ⇒ Object
- #disbond_ports(port_id, bulk_disable) ⇒ Object
- #enable_two_factor_auth(type) ⇒ Object
- #enable_vpn ⇒ Object
- #get_bandwidth(device_id, params) ⇒ Object
- #get_batch(id) ⇒ Object
- #get_bgp_session(session_id) ⇒ Object
- #get_capacity ⇒ Object
- #get_device(device_id) ⇒ Object
- #get_email(id) ⇒ Object
- #get_hardware_reservation(id) ⇒ Object
- #get_invitation(id) ⇒ Object
- #get_ip(ip_id) ⇒ Object
- #get_license(id) ⇒ Object
- #get_membership(id) ⇒ Object
- #get_notification(id) ⇒ Object
- #get_organization(id, params = {}) ⇒ Object
- #get_payment_method(id, params = {}) ⇒ Object
- #get_project(id) ⇒ Object
- #get_project_facilities(project_id) ⇒ Object
- #get_project_plans(project_id) ⇒ Object
- #get_ssh_key(id) ⇒ Object
- #get_transfer_request(id) ⇒ Object
- #get_user(id = "") ⇒ Object
- #get_volume(id) ⇒ Object
- #get_vpn(facility_code) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_batches(project_id, params) ⇒ Object
- #list_bgp_sessions(device_id) ⇒ Object
- #list_devices(project_id, params = {}) ⇒ Object
- #list_events(device_id, params = {}) ⇒ Object
- #list_facilities ⇒ Object
- #list_hardware_reservations(project_id, params = {}) ⇒ Object
- #list_invitations(device_id, params = {}) ⇒ Object
- #list_ips(project_id, params = {}) ⇒ Object
- #list_licenses(project_id, params = {}) ⇒ Object
- #list_memberships(project_id, params = {}) ⇒ Object
- #list_notifications(params = {}) ⇒ Object
- #list_operating_systems ⇒ Object
- #list_organizations(params = {}) ⇒ Object
- #list_payment_methods(org_id, params = {}) ⇒ Object
- #list_plans(params = {}) ⇒ Object
- #list_projects(params = {}) ⇒ Object
- #list_sessions(params = {}) ⇒ Object
- #list_snapshots(volume_id, params = {}) ⇒ Object
- #list_spotmarketprices ⇒ Object
- #list_spotmarketprices_history(facility, plan) ⇒ Object
- #list_ssh_keys(project_id = "", params = {}) ⇒ Object
- #list_transfers(organization_id, params = {}) ⇒ Object
- #list_users(params = {}) ⇒ Object
- #list_virtual_networks(project_id, params) ⇒ Object
- #list_volumes(project_id, params = {}) ⇒ Object
- #move_hardware_reservation(reservation_id, project_id) ⇒ Object
- #poweroff_device(device_id) ⇒ Object
- #poweron_device(device_id) ⇒ Object
- #reboot_device(device_id) ⇒ Object
- #request(params) ⇒ Object
- #request_email_verification(email) ⇒ Object
- #reserve_ip(project_id, options) ⇒ Object
- #session_login(login_params) ⇒ Object
- #transfer_project(project_id, organization_id) ⇒ Object
- #unassign_ip(ip_id) ⇒ Object
- #unassign_port(port_id, vnid) ⇒ Object
- #update_device(device_id, options) ⇒ Object
- #update_email(email_id, options) ⇒ Object
- #update_license(id, options) ⇒ Object
- #update_membership(id, options) ⇒ Object
- #update_notification(id) ⇒ Object
- #update_organization(id, options) ⇒ Object
- #update_payment_method(id, options) ⇒ Object
- #update_project(project_id, options) ⇒ Object
- #update_ssh_key(id, options) ⇒ Object
- #update_user(user_id, options) ⇒ Object
- #update_volume(volume_id, options) ⇒ Object
- #validate_capacity(options) ⇒ Object
- #verify_email(token) ⇒ Object
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( = {}) if [:packet_token] @packet_token = [: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 = [:packet_url] ? [: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, ) req = { "address" => [:address] } req["manageable"] = [:manageable] if [: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, ) request( :expects => [201], :method => "POST", :path => "/projects/" + project_id + "/devices/batch", :body => Fog::JSON.encode() ) 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, ) device = { "facility" => [:facility], "plan" => [:plan], "hostname" => [:hostname], "operating_system" => [:operating_system] } device["description"] = [:description] if [:description] device["billing_cycle"] = [:billing_cycle] if [:billing_cycle] device["always_pxe"] = [:always_pxe] if [:always_pxe] device["ipxe_script_url"] = [:ipxe_script_url] if [:ipxe_script_url] device["userdata"] = [:userdata] if [:userdata] device["locked"] = [:locked] if [:locked] device["hardware_reservation_id"] = [:hardware_reservation_id] if [:hardware_reservation_id] device["spot_instance"] = [:spot_instance] if [:spot_instance] device["spot_price_max"] = [:spot_price_max] if [:spot_price_max] device["termination_time"] = [:termination_time] if [:termination_time] device["tags"] = [:tags] if [:tags] device["project_ssh_keys"] = [:project_ssh_keys] if [:project_ssh_keys] device["user_ssh_keys"] = [:user_ssh_keys] if [:user_ssh_keys] device["features"] = [:features] if [: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() email = { "address" => [:address], "default" => [: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, ) license = { "description" => [:description], "size" => [:size] } license["license_product_id"] = [:license_product_id] if [: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() org = { "name" => [:name], "description" => [:description] } org["website"] = [:website] if [:website] org["twitter"] = [:twitter] if [:twitter] org["logo"] = [:logo] if [:logo] org["address"] = [:address] if [:address] org["customdata"] = [:customdata] if [: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, ) payment_method = { "name" => [:name] } payment_method["default"] = [:default] if [:default] payment_method["nonce"] = [:nonce] if [: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() project = { "name" => [:name], "payment_method_id" => [: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() sshkey = { "label" => [:label], "key" => [: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() vnet = { "project_id" => [:project_id], "description" => [:description], "facility" => [:facility], "vxlan" => [:vxlan], "vlan" => [:vlan] } request( :expects => [201], :method => "POST", :path => "/projects/" + [: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, ) volume = { "facility" => [:facility], "plan" => [:plan], "size" => [:size] } volume["description"] = [:description] if [:description] volume["billing_cycle"] = [:billing_cycle] if [:billing_cycle] volume["snapshot_policies"] = [:snapshot_policies] if [: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() request( :expects => [204], :method => "DELETE", :path => "/storage/attachments/" + ) 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_vpn ⇒ Object
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_vpn ⇒ Object
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_capacity ⇒ Object
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_facilities ⇒ Object
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_systems ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/compute/packet/requests/list_operating_systems.rb', line 6 def 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_spotmarketprices ⇒ Object
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, ) ip = { "facility" => [:facility], "quantity" => [:quantity], "type" => [:type] } ip["comments"] = [:comments] if [: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 session_login(login_params) request( :expects => [201], :method => "POST", :path => "/sessions?login=" + login_params[:username] + "&password=" + login_params[: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, ) device = Hash.new {} device["hostname"] = [:hostname] if [:hostname] device["description"] = [:description] if [:description] device["billing_cycle"] = [:billing_cycle] if [:billing_cycle] device["userdata"] = [:userdata] if [:userdata] device["locked"] = [:locked] if [:locked] device["tags"] = [:tags] if [:tags] device["always_pxe"] = [:always_pxe] if [:always_pxe] device["ipxe_script_url"] = [:ipxe_script_url] if [:ipxe_script_url] device["spot_instance"] = [:spot_instance] if [: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, ) project = Hash.new {} project["address"] = [:address] if [:address] project["default"] = [:default] if [: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, ) project = Hash.new {} project["description"] = [:description] if [:description] project["size"] = [:size] if [: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, ) roles = Hash.new {} roles["roles"] = [:roles] if [: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, ) org = {} org["name"] = [:name] if [:name] org["description"] = [:description] if [:description] org["website"] = [:website] if [:website] org["twitter"] = [:twitter] if [:twitter] org["logo"] = [:logo] if [:logo] org["address"] = [:address] if [:address] org["customdata"] = [:customdata] if [: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, ) payment_method = {} payment_method["name"] = [:name] if [:name] payment_method["cardholder_name"] = [:cardholder_name] if [:cardholder_name] payment_method["expiration_month"] = [:expiration_month] if [:expiration_month] payment_method["expiration_year"] = [:expiration_year] if [: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, ) project = Hash.new {} project["name"] = [:name] if [:name] project["payment_method_id"] = [:payment_method_id] if [: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, ) sshkey = { "label" => [:label], "key" => [: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, ) project = Hash.new {} project["first_name"] = [:first_name] if [:first_name] project["last_name"] = [:last_name] if [:last_name] project["phone_number"] = [:phone_number] if [:phone_number] project["timezone"] = [:timezone] if [:timezone] project["password"] = [:password] if [:password] project["avatar"] = [:timezone] if [: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, ) device = Hash.new {} device["description"] = [:description] if [:description] device["billing_cycle"] = [:billing_cycle] if [:billing_cycle] device["size"] = [:size] if [:size] device["locked"] = [:locked] if [: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() cap = { "servers" => [] } [: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 |