module OCI::Auth::Signers::RptPathProvider

Resource Principal Path Provider Classes under this module will provide the complete path for getting the Resource Principal Token

Constants

OCI_RESOURCE_PRINCIPAL_RPT_ID
OCI_RESOURCE_PRINCIPAL_RPT_PATH

Public Class Methods

instance_id_from_imds(metadata_url_base) click to toggle source
# File lib/oci/auth/signers/resource_principal_token_path_provider/rpt_path_provider.rb, line 34
def self.instance_id_from_imds(metadata_url_base)
  # Get the instance id from the metadata service
  instance_id_endpoint = "#{metadata_url_base}/instance/id"
  uri = URI(instance_id_endpoint)
  raw_client = Net::HTTP.new(uri.hostname, uri.port)
  raw_response = nil
  raw_client.request(OCI::Auth::Util.get_metadata_request(instance_id_endpoint, 'get')) do |response|
    raw_response = response.body.strip.downcase
    raise 'Get Metadata request failed, response code is: ' + response.code if response.code != '200'
  end
  raw_response
end