Class: Fog::OracleCloud::Monitoring::Real
- Inherits:
-
Object
- Object
- Fog::OracleCloud::Monitoring::Real
- Defined in:
- lib/fog/oraclecloud/monitoring.rb,
lib/fog/oraclecloud/requests/monitoring/list_metrics_reports.rb
Instance Method Summary collapse
- #auth_header ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_metrics_reports ⇒ Object
- #password ⇒ Object
- #request(params, parse_json = true, &block) ⇒ Object
- #username ⇒ 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/monitoring.rb', line 18 def initialize(={}) @username = [:oracle_username] @password = [:oracle_password] @identity_domain = [:oracle_domain] region = [:oracle_region].nil? ? 'us' : [:oracle_region] url = "https://monitoring.#{region}.oraclecloud.com" Excon.ssl_verify_peer = false @connection = Fog::XML::Connection.new(url) end |
Instance Method Details
#auth_header ⇒ Object
37 38 39 |
# File 'lib/fog/oraclecloud/monitoring.rb', line 37 def auth_header auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'') end |
#list_metrics_reports ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/oraclecloud/requests/monitoring/list_metrics_reports.rb', line 5 def list_metrics_reports response = request( :expects => 200, :method => 'GET', :path => "/monitoring/monitoring/#{@identity_domain}/.customer/api/v1/metricReports" ) response end |
#password ⇒ Object
32 33 34 |
# File 'lib/fog/oraclecloud/monitoring.rb', line 32 def password @password end |
#request(params, parse_json = true, &block) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fog/oraclecloud/monitoring.rb', line 41 def request(params, parse_json = true, &block) begin Fog::Logger.debug("Sending #{params[:body].to_s} to #{params[:path]}") 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 |
#username ⇒ Object
28 29 30 |
# File 'lib/fog/oraclecloud/monitoring.rb', line 28 def username @username end |