Class: Fog::Rackspace::Databases::Real
- Defined in:
- lib/fog/rackspace/databases.rb,
lib/fog/rackspace/requests/databases/get_flavor.rb,
lib/fog/rackspace/requests/databases/list_users.rb,
lib/fog/rackspace/requests/databases/create_user.rb,
lib/fog/rackspace/requests/databases/delete_user.rb,
lib/fog/rackspace/requests/databases/get_instance.rb,
lib/fog/rackspace/requests/databases/list_flavors.rb,
lib/fog/rackspace/requests/databases/list_databases.rb,
lib/fog/rackspace/requests/databases/list_instances.rb,
lib/fog/rackspace/requests/databases/check_root_user.rb,
lib/fog/rackspace/requests/databases/create_database.rb,
lib/fog/rackspace/requests/databases/create_instance.rb,
lib/fog/rackspace/requests/databases/delete_database.rb,
lib/fog/rackspace/requests/databases/delete_instance.rb,
lib/fog/rackspace/requests/databases/resize_instance.rb,
lib/fog/rackspace/requests/databases/enable_root_user.rb,
lib/fog/rackspace/requests/databases/restart_instance.rb,
lib/fog/rackspace/requests/databases/resize_instance_volume.rb
Instance Method Summary collapse
- #authenticate ⇒ Object
- #check_root_user(instance_id) ⇒ Object
- #create_database(instance_id, name, options = {}) ⇒ Object
- #create_instance(name, flavor_id, volume_size, options = {}) ⇒ Object
- #create_user(instance_id, name, password, options = {}) ⇒ Object
- #delete_database(instance_id, name) ⇒ Object
- #delete_instance(instance_id) ⇒ Object
- #delete_user(instance_id, name) ⇒ Object
- #enable_root_user(instance_id) ⇒ Object
- #endpoint_uri(service_endpoint_url = nil) ⇒ Object
- #get_flavor(flavor_id) ⇒ Object
- #get_instance(instance_id) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_databases(instance_id) ⇒ Object
- #list_flavors ⇒ Object
- #list_instances ⇒ Object
- #list_users(instance_id) ⇒ Object
- #region ⇒ Object
- #request(params) ⇒ Object
- #resize_instance(instance_id, flavor_id) ⇒ Object
- #resize_instance_volume(instance_id, volume_size) ⇒ Object
- #restart_instance(instance_id) ⇒ Object
- #service_name ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/fog/rackspace/databases.rb', line 71 def initialize( = {}) @rackspace_api_key = [:rackspace_api_key] @rackspace_username = [:rackspace_username] @rackspace_auth_url = [:rackspace_auth_url] @rackspace_must_reauthenticate = false @connection_options = [:connection_options] || {} setup_custom_endpoint() authenticate deprecation_warnings() @persistent = [:persistent] || false @connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options) end |
Instance Method Details
#authenticate ⇒ Object
117 118 119 120 121 122 123 124 125 |
# File 'lib/fog/rackspace/databases.rb', line 117 def authenticate = { :rackspace_api_key => @rackspace_api_key, :rackspace_username => @rackspace_username, :rackspace_auth_url => @rackspace_auth_url } super() end |
#check_root_user(instance_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/rackspace/requests/databases/check_root_user.rb', line 5 def check_root_user(instance_id) request( :expects => 200, :method => 'GET', :path => "instances/#{instance_id}/root" ) end |
#create_database(instance_id, name, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/rackspace/requests/databases/create_database.rb', line 5 def create_database(instance_id, name, = {}) data = { 'databases' => [{ 'name' => name, 'character_set' => [:character_set], 'collate' => [:collate] }] } request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'POST', :path => "instances/#{instance_id}/databases" ) end |
#create_instance(name, flavor_id, volume_size, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fog/rackspace/requests/databases/create_instance.rb', line 5 def create_instance(name, flavor_id, volume_size, = {}) data = { 'instance' => { 'name' => name, 'flavorRef' => flavor_id, 'volume' => { 'size' => volume_size } } } request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'POST', :path => 'instances' ) end |
#create_user(instance_id, name, password, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/rackspace/requests/databases/create_user.rb', line 5 def create_user(instance_id, name, password, = {}) data = { 'users' => [{ 'name' => name, 'password' => password, 'databases' => [:databases] }] } request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'POST', :path => "instances/#{instance_id}/users" ) end |
#delete_database(instance_id, name) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/rackspace/requests/databases/delete_database.rb', line 5 def delete_database(instance_id, name) request( :expects => 202, :method => 'DELETE', :path => "instances/#{instance_id}/databases/#{name}" ) end |
#delete_instance(instance_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/rackspace/requests/databases/delete_instance.rb', line 5 def delete_instance(instance_id) request( :expects => 202, :method => 'DELETE', :path => "instances/#{instance_id}" ) end |
#delete_user(instance_id, name) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/rackspace/requests/databases/delete_user.rb', line 5 def delete_user(instance_id, name) request( :expects => 202, :method => 'DELETE', :path => "instances/#{instance_id}/users/#{name}" ) end |
#enable_root_user(instance_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/rackspace/requests/databases/enable_root_user.rb', line 5 def enable_root_user(instance_id) request( :expects => 200, :method => 'POST', :path => "instances/#{instance_id}/root" ) end |
#endpoint_uri(service_endpoint_url = nil) ⇒ Object
113 114 115 |
# File 'lib/fog/rackspace/databases.rb', line 113 def endpoint_uri(service_endpoint_url=nil) @uri = super(@rackspace_endpoint || service_endpoint_url, :rackspace_database_url) end |
#get_flavor(flavor_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/rackspace/requests/databases/get_flavor.rb', line 5 def get_flavor(flavor_id) request( :expects => 200, :method => 'GET', :path => "flavors/#{flavor_id}" ) end |
#get_instance(instance_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/rackspace/requests/databases/get_instance.rb', line 5 def get_instance(instance_id) request( :expects => 200, :method => 'GET', :path => "instances/#{instance_id}" ) end |
#list_databases(instance_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/rackspace/requests/databases/list_databases.rb', line 5 def list_databases(instance_id) request( :expects => 200, :method => 'GET', :path => "instances/#{instance_id}/databases" ) end |
#list_flavors ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/rackspace/requests/databases/list_flavors.rb', line 5 def list_flavors() request( :expects => 200, :method => 'GET', :path => 'flavors' ) end |
#list_instances ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/rackspace/requests/databases/list_instances.rb', line 5 def list_instances() request( :expects => 200, :method => 'GET', :path => 'instances' ) end |
#list_users(instance_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/rackspace/requests/databases/list_users.rb', line 5 def list_users(instance_id) request( :expects => 200, :method => 'GET', :path => "instances/#{instance_id}/users" ) end |
#region ⇒ Object
67 68 69 |
# File 'lib/fog/rackspace/databases.rb', line 67 def region @rackspace_region end |
#request(params) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/fog/rackspace/databases.rb', line 87 def request(params) begin response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Auth-Token' => auth_token }.merge!(params[:headers] || {}), :host => endpoint_uri.host, :path => "#{endpoint_uri.path}/#{params[:path]}" })) rescue Excon::Errors::NotFound => error raise NotFound.slurp error rescue Excon::Errors::BadRequest => error raise BadRequest.slurp error rescue Excon::Errors::InternalServerError => error raise InternalServerError.slurp error rescue Excon::Errors::HTTPStatusError => error raise ServiceError.slurp error end unless response.body.empty? response.body = Fog::JSON.decode(response.body) end response end |
#resize_instance(instance_id, flavor_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fog/rackspace/requests/databases/resize_instance.rb', line 5 def resize_instance(instance_id, flavor_id) data = { 'resize' => { 'flavorRef' => flavor_id } } request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'POST', :path => "instances/#{instance_id}/action" ) end |
#resize_instance_volume(instance_id, volume_size) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/rackspace/requests/databases/resize_instance_volume.rb', line 5 def resize_instance_volume(instance_id, volume_size) data = { 'resize' => { 'volume' => { 'size' => volume_size } } } request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'POST', :path => "instances/#{instance_id}/action" ) end |
#restart_instance(instance_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/rackspace/requests/databases/restart_instance.rb', line 5 def restart_instance(instance_id) data = { 'restart' => {} } request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'POST', :path => "instances/#{instance_id}/action" ) end |
#service_name ⇒ Object
63 64 65 |
# File 'lib/fog/rackspace/databases.rb', line 63 def service_name :cloudDatabases end |