Class: Fog::OracleCloud::Java::Real
- Inherits:
-
Object
- Object
- Fog::OracleCloud::Java::Real
- Defined in:
- lib/fog/oraclecloud/java.rb,
lib/fog/oraclecloud/requests/java/get_instance.rb,
lib/fog/oraclecloud/requests/java/list_servers.rb,
lib/fog/oraclecloud/requests/java/list_instances.rb,
lib/fog/oraclecloud/requests/java/create_instance.rb,
lib/fog/oraclecloud/requests/java/delete_instance.rb
Instance Method Summary collapse
- #auth_header ⇒ Object
- #create_instance(service_name, cloudStorageContainer, cloudStorageUser, cloudStoragePassword, dbaName, dbaPassword, dbServiceName, shape, version, vmPublicKey, options = {}) ⇒ Object
- #delete_instance(service_name, dba_name, dba_password, options = {}) ⇒ Object
- #get_instance(service_name) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_instances ⇒ Object
- #list_servers(service_name) ⇒ Object
- #request(params, parse_json = true, &block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
21 22 23 24 25 26 27 28 |
# File 'lib/fog/oraclecloud/java.rb', line 21 def initialize(={}) @username = [:oracle_username] @password = [:oracle_password] @identity_domain = [:oracle_domain] region_url = [:oracle_region] == 'emea' ? 'https://jcs.emea.oraclecloud.com' : 'https://jaas.oraclecloud.com' Excon.ssl_verify_peer = false @connection = Fog::XML::Connection.new(region_url) end |
Instance Method Details
#auth_header ⇒ Object
30 31 32 |
# File 'lib/fog/oraclecloud/java.rb', line 30 def auth_header auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'') end |
#create_instance(service_name, cloudStorageContainer, cloudStorageUser, cloudStoragePassword, dbaName, dbaPassword, dbServiceName, shape, version, vmPublicKey, 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 |
# File 'lib/fog/oraclecloud/requests/java/create_instance.rb', line 6 def create_instance(service_name, cloudStorageContainer, cloudStorageUser, cloudStoragePassword, dbaName, dbaPassword, dbServiceName, shape, version, vmPublicKey, ={}) if !cloudStorageContainer.start_with?("/Storage-") then # They haven't provided a well formed container name, add their details in name = "/Storage-#{@identity_domain}/#{@username}/#{cloudStorageContainer}" end body_data = { 'serviceName' => service_name, 'cloudStorageContainer' => cloudStorageContainer, 'cloudStorageUser' => cloudStorageUser, 'cloudStoragePassword' => cloudStoragePassword, 'parameters' => parameters, 'level' => [:level], 'subscriptionType' => [:subscriptionType], 'description' => [:description], 'provisionOTD' => [:provisionOTD], 'sampleAppDeploymentRequests' => [:sampleAppDeploymentRequests] } body_data = body_data.reject {|key, value| value.nil?} request( :method => 'POST', :expects => 202, :path => "/paas/service/jcs/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, dba_name, dba_password, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fog/oraclecloud/requests/java/delete_instance.rb', line 6 def delete_instance(service_name, dba_name, dba_password, ={}) body_data = { 'dbaName' => dba_name, 'dbaPassword' => dba_password, 'forceDelete' => [:force_delete] } body_data = body_data.reject {|key, value| value.nil?} request( :method => 'PUT', :expects => 202, :path => "/paas/service/jcs/api/v1.1/instances/#{@identity_domain}/#{service_name}", :body => Fog::JSON.encode(body_data), :headers => { 'Content-Type'=>'application/vnd.com.oracle.oracloud.provisioning.Service+json' } ) end |
#get_instance(service_name) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/oraclecloud/requests/java/get_instance.rb', line 6 def get_instance(service_name) response = request( :expects => 200, :method => 'GET', :path => "/paas/service/jcs/api/v1.1/instances/#{@identity_domain}/#{service_name}" ) response end |
#list_instances ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/oraclecloud/requests/java/list_instances.rb', line 5 def list_instances response = request( :expects => 200, :method => 'GET', :path => "/paas/service/jcs/api/v1.1/instances/#{@identity_domain}?outputLevel=verbose" ) response end |
#list_servers(service_name) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/oraclecloud/requests/java/list_servers.rb', line 5 def list_servers(service_name) response = request( :expects => 200, :method => 'GET', :path => "/paas/service/jcs/api/v1.1/instances/#{@identity_domain}/#{service_name}/servers" ) response end |
#request(params, parse_json = true, &block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fog/oraclecloud/java.rb', line 34 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::Java::NotFound.slurp(error) else error end end 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 |