noinspection RubyStringKeysInHashInspection
noinspection RubyStringKeysInHashInspection
noinspection RubyStringKeysInHashInspection
noinspection RubyStringKeysInHashInspection
noinspection RubyStringKeysInHashInspection
noinspection RubyStringKeysInHashInspection
noinspection RubyStringKeysInHashInspection
# File lib/fog/digitalocean/compute.rb, line 90 def initialize(options={}) digitalocean_token = options[:digitalocean_token] persistent = false options = { headers: { 'Authorization' => "Bearer #{digitalocean_token}", } } @connection = Fog::Core::Connection.new 'https://api.digitalocean.com', persistent, options end
# File lib/fog/digitalocean/requests/compute/attach_volume.rb, line 5 def attach_volume(volume_id, droplet_id, region) body = { :type => 'attach', droplet_id: droplet_id, region: region} encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/volumes/#{volume_id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/attach_volume.rb, line 21 def attach_volume_by_name(volume_name, droplet_id, region) body = { :type => 'attach', volume_name: volume_name, droplet_id: droplet_id, region: region} encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/volumes/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/change_kernel.rb, line 5 def change_kernel(id, kernel) body = { :type => "change_kernel", :kernel => kernel } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/convert_to_snapshot.rb, line 5 def convert_to_snapshot(id) body = { :type => 'convert',} encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/images/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/create_server.rb, line 7 def create_server(name, size, image, region, options = {}) create_options = { :name => name, :region => region, :size => size, :image => image, } [:backups, :ipv6, :private_networking].each do |opt| create_options[opt] = !!options[opt] if options[opt] end [:user_data, :ssh_keys].each do |opt| create_options[opt] = options[opt] if options[opt] end create_options[:volume] = options[:volume] || [] encoded_body = Fog::JSON.encode(create_options) request( :expects => [202], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => '/v2/droplets', :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/create_ssh_key.rb, line 7 def create_ssh_key(name, public_key) create_options = { :name => name, :public_key => public_key, } encoded_body = Fog::JSON.encode(create_options) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => '/v2/account/keys', :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/create_volume.rb, line 7 def create_volume(options={}) create_options = { :name => "name", :region => "nyc1", :size_gigabytes => 1 }.merge(options) encoded_body = Fog::JSON.encode(create_options) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => '/v2/volumes', :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/destroy_server.rb, line 6 def delete_server(server_id) Fog::Logger.warning("delete_server method has been deprecated, use destroy_server instead") destroy_server(server_id) end
# File lib/fog/digitalocean/requests/compute/delete_ssh_key.rb, line 6 def delete_ssh_key(id) request( :expects => [204], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'DELETE', :path => "/v2/account/keys/#{id}", ) end
# File lib/fog/digitalocean/requests/compute/destroy_server.rb, line 10 def destroy_server(server_id) request( :expects => [204], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'DELETE', :path => "/v2/droplets/#{server_id}", ) end
# File lib/fog/digitalocean/requests/compute/destroy_volume.rb, line 6 def destroy_volume(id) request( :expects => [204], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'DELETE', :path => "/v2/volumes/#{id}", ) end
# File lib/fog/digitalocean/requests/compute/detach_volume.rb, line 5 def detach_volume(volume_id, droplet_id, region) body = { :type => 'detach', droplet_id: droplet_id, region: region} encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/volumes/#{volume_id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/detach_volume.rb, line 20 def detach_volume_by_name(volume_name, droplet_id, region) body = { :type => 'detach', volume_name: volume_name, droplet_id: droplet_id, region: region} encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/volumes/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/disable_backups.rb, line 5 def disable_backups(id) body = { :type => "disable_backups" } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/enable_ipv6.rb, line 5 def enable_ipv6(id) body = { :type => "enable_ipv6" } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/enable_private_networking.rb, line 5 def enable_private_networking(id) body = { :type => "enable_private_networking" } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/get_droplet_action.rb, line 5 def get_droplet_action(droplet_id, action_id) request( :expects => [200], :method => 'GET', :path => "v2/droplets/#{droplet_id}/actions/#{action_id}", ) end
# File lib/fog/digitalocean/requests/compute/get_image_details.rb, line 5 def get_image_details(image_id) request( :expects => [200], :method => 'GET', :path => "/v2/images/#{image_id}" ) end
# File lib/fog/digitalocean/requests/compute/get_server_details.rb, line 5 def get_server_details(server_id) request( :expects => [200], :method => 'GET', :path => "/v2/droplets/#{server_id}" ) end
# File lib/fog/digitalocean/requests/compute/get_ssh_key.rb, line 5 def get_ssh_key(key_id) request( :expects => [200], :method => 'GET', :path => "/v2/account/keys/#{key_id}" ) end
# File lib/fog/digitalocean/requests/compute/get_volume_details.rb, line 5 def get_volume_details(volume_id) request( :expects => [200], :method => 'GET', :path => "/v2/volumes/#{volume_id}" ) end
# File lib/fog/digitalocean/requests/compute/list_droplet_actions.rb, line 5 def list_droplet_actions(id) request( :expects => [200], :method => 'GET', :path => "v2/droplets/#{id}/actions", ) end
# File lib/fog/digitalocean/requests/compute/list_flavors.rb, line 5 def list_flavors(filters = {}) request( :expects => [200], :method => 'GET', :path => "/v2/sizes", :query => filters ) end
# File lib/fog/digitalocean/requests/compute/list_images.rb, line 5 def list_images(filters = {}) request( :expects => [200], :method => 'GET', :path => "/v2/images", :query => filters ) end
# File lib/fog/digitalocean/requests/compute/list_regions.rb, line 5 def list_regions(filters = {}) request( :expects => [200], :method => 'GET', :path => "/v2/regions", :query => filters ) end
# File lib/fog/digitalocean/requests/compute/list_servers.rb, line 5 def list_servers(filters = {}) request( :expects => [200], :method => 'GET', :path => "/v2/droplets", :query => filters ) end
# File lib/fog/digitalocean/requests/compute/list_ssh_keys.rb, line 5 def list_ssh_keys(filters = {}) request( :expects => [200], :method => 'GET', :path => "v2/account/keys", :query => filters ) end
# File lib/fog/digitalocean/requests/compute/list_volume_actions.rb, line 5 def list_volume_actions(id) request( :expects => [200], :method => 'GET', :path => "v2/volumes/#{id}/actions", ) end
# File lib/fog/digitalocean/requests/compute/list_volumes.rb, line 5 def list_volumes(filters = {}) request( :expects => [200], :method => 'GET', :path => "/v2/volumes", :query => filters ) end
# File lib/fog/digitalocean/requests/compute/password_reset.rb, line 5 def password_reset(id) body = { :type => "password_reset" } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/power_cycle.rb, line 5 def power_cycle(id) body = { :type => "power_cycle" } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/power_off.rb, line 5 def power_off(id) body = { :type => "power_off" } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/power_on.rb, line 5 def power_on(id) body = { :type => "power_on" } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/reboot_server.rb, line 5 def reboot_server(id) body = { :type => "reboot" } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/rebuild.rb, line 5 def rebuild(id, image) body = { :type => "rebuild", :image => image } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/rename.rb, line 5 def rename(id, name) body = { :type => "rename", :name => name } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/compute.rb, line 101 def request(params) params[:headers] ||= {} begin response = @connection.request(params) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound NotFound.slurp(error) else error end end unless response.body.empty? response.body = Fog::JSON.decode(response.body) end response end
# File lib/fog/digitalocean/requests/compute/resize.rb, line 5 def resize(id, resize_disk, size) body = { :type => "resize", :disk => resize_disk, :size => size } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/resize_volume.rb, line 5 def resize_volume(volume_id, size, region) body = { :type => 'resize', size_gigabytes: size, region: region} encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/images/#{volume_id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/restore.rb, line 5 def restore(id, image) body = { :type => "restore", :image => image } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/shutdown.rb, line 5 def shutdown(id) body = { :type => "shutdown" } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/snapshot.rb, line 5 def snapshot(id, name) body = { :type => "snapshot", :name => name } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/transfer_image.rb, line 5 def transfer_image(id, region) body = { :type => 'transfer', :region => region } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/images/#{id}/actions", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/update_ssh_key.rb, line 7 def update_ssh_key(key_id, name) update_options = { :name => name, } encoded_body = Fog::JSON.encode(update_options) request( :expects => [200], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'PUT', :path => "/v2/account/keys/#{key_id}", :body => encoded_body, ) end
# File lib/fog/digitalocean/requests/compute/upgrade.rb, line 5 def upgrade(id) body = { :type => "upgrade" } encoded_body = Fog::JSON.encode(body) request( :expects => [201], :headers => { 'Content-Type' => "application/json; charset=UTF-8", }, :method => 'POST', :path => "v2/droplets/#{id}/actions", :body => encoded_body, ) end