Class: Fog::OracleCloud::Database::Real
- Inherits:
-
Object
- Object
- Fog::OracleCloud::Database::Real
- Defined in:
- lib/fog/oraclecloud/database.rb,
lib/fog/oraclecloud/requests/database/get_instance.rb,
lib/fog/oraclecloud/requests/database/list_instances.rb,
lib/fog/oraclecloud/requests/database/create_instance.rb,
lib/fog/oraclecloud/requests/database/delete_instance.rb
Instance Method Summary collapse
- #auth_header ⇒ Object
- #create_instance(service_name, edition, vmPublicKey, shape, version, options = {}) ⇒ Object
- #delete_instance(service_name) ⇒ Object
- #get_instance(instance_id) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_instances ⇒ Object
- #request(params, parse_json = true, &block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/oraclecloud/database.rb', line 18 def initialize(={}) @username = [:oracle_username] @password = [:oracle_password] @identity_domain = [:oracle_domain] region_url = [:oracle_region] == 'emea' ? 'https://dbcs.emea.oraclecloud.com' : 'https://dbaas.oraclecloud.com' Excon.ssl_verify_peer = false @connection = Fog::XML::Connection.new(region_url) end |
Instance Method Details
#auth_header ⇒ Object
28 29 30 |
# File 'lib/fog/oraclecloud/database.rb', line 28 def auth_header auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'') end |
#create_instance(service_name, edition, vmPublicKey, shape, version, 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 |
# File 'lib/fog/oraclecloud/requests/database/create_instance.rb', line 6 def create_instance(service_name, edition, vmPublicKey, shape, version, ={}) body_data = { 'serviceName' => service_name, 'version' => [:version], 'level' => [:level], 'edition' => edition, 'subscriptionType' => [:subscriptionType], 'description' => [:description], 'shape' => [:shape], 'vmPublicKeyText' => vmPublicKey, 'parameters' => { 'shape' => shape, 'version' => version } } body_data = body_data.reject {|key, value| value.nil?} request( :method => 'POST', :expects => 202, :path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}", :body => Fog::JSON.encode(body_data), #:headers => { # 'Content-Type'=>'application/vnd.com.oracle.oracloud.provisioning.Service+json' #} ) end |
#delete_instance(service_name) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/oraclecloud/requests/database/delete_instance.rb', line 6 def delete_instance(service_name) request( :method => 'DELETE', :expects => 202, :path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}/#{service_name}" ) end |
#get_instance(instance_id) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/oraclecloud/requests/database/get_instance.rb', line 6 def get_instance(instance_id) response = request( :expects => 200, :method => 'GET', :path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}/#{instance_id}" ) response end |
#list_instances ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/oraclecloud/requests/database/list_instances.rb', line 5 def list_instances response = request( :expects => 200, :method => 'GET', :path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}?outputLevel=verbose" ) response end |
#request(params, parse_json = true, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fog/oraclecloud/database.rb', line 32 def request(params, parse_json = true, &block) begin response = @connection.request(params.merge!({ :headers => { 'Authorization' => auth_header, 'X-ID-TENANT-NAME' => @identity_domain, 'Content-Type' => 'application/json', #'Accept' => 'application/json' }.merge!(params[:headers] || {}) }), &block) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::OracleCloud::Database::NotFound.slurp(error) else error end end #https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/agriculture/status/create/job/2781084 if !response.body.empty? && parse_json # The Oracle Cloud doesn't return the Content-Type header as application/json, rather as application/vnd.com.oracle.oracloud.provisioning.Pod+json # Should add check here to validate, but not sure if this might change in future response.body = Fog::JSON.decode(response.body) end response end |