class Fog::OracleCloud::Monitoring::Real

Public Class Methods

new(options={}) click to toggle source
# File lib/fog/oraclecloud/monitoring.rb, line 18
def initialize(options={})
        @username = options[:oracle_username]
        @password = options[:oracle_password]
        @identity_domain   = options[:oracle_domain]
  region = options[:oracle_region].nil? ? 'us' : options[:oracle_region]
  url = "https://monitoring.#{region}.oraclecloud.com"
  Excon.ssl_verify_peer = false
  @connection = Fog::XML::Connection.new(url)
end

Public Instance Methods

auth_header() click to toggle source
# File lib/fog/oraclecloud/monitoring.rb, line 37
def auth_header
        auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'')
end
list_metrics_reports() click to toggle source
# 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() click to toggle source
# File lib/fog/oraclecloud/monitoring.rb, line 32
def password
  @password
end
request(params, parse_json = true, &block) click to toggle source
# 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() click to toggle source
# File lib/fog/oraclecloud/monitoring.rb, line 28
def username
  @username
end