Package oracle.nosql.driver.iam

# Class OCIConfigFileReader

java.lang.Object
oracle.nosql.driver.iam.OCIConfigFileReader

public class OCIConfigFileReader extends Object
Cloud service only.

An instance that reads an Oracle Cloud Infrastructure (OCI) configuration file. Note, an OCI configuration file MUST contain a "DEFAULT" profile, additional profiles are optional.

An OCI configuration file allows use of custom key-value pairs, which can be loaded and referenced using this class. For example, the frequently used compartment OCID can be put in a configuration file.

     In the configuration file, add one custom parameter "custom_compartment_id"
     [DEFAULT]
     ...
     custom_compartment_id=ocid1.compartment.oc1..aaa...

     Then it can be retrieved using this class:
     OCIConfigFile config = OCIConfigFileReader.parse("~/.oci/config");
     String compartmentId = config.get("custom_compartment_id");

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `OCIConfigFileReader.OCIConfigFile`
  Cloud service only.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DEFAULT_FILE_PATH`
  Default configuration file at `~/.oci/config`
  `static final String`
  `DEFAULT_PROFILE_NAME`
  Default profile in config file

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static OCIConfigFileReader.OCIConfigFile`
  `parse(InputStream configStream, String profile)`
  Create a new instance using an UTF-8 input stream.
  `static OCIConfigFileReader.OCIConfigFile`
  `parse(InputStream configStream, String profile, Charset charset)`
  Create a new instance using an input stream.
  `static OCIConfigFileReader.OCIConfigFile`
  `parse(String configFilePath)`
  Create a new instance using a file at a given location.
  `static OCIConfigFileReader.OCIConfigFile`
  `parse(String configFilePath, String profile)`
  Create a new instance using a file at a given location.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### DEFAULT_FILE_PATH

    public static final String DEFAULT_FILE_PATH
    Default configuration file at `~/.oci/config`

  - ### DEFAULT_PROFILE_NAME

    public static final String DEFAULT_PROFILE_NAME
    Default profile in config file
    See Also:
      - Constant Field Values

- ## Method Details

  - ### parse

    public static OCIConfigFileReader.OCIConfigFile parse(String configFilePath) throws IOException
    Create a new instance using a file at a given location.

    This method is the same as calling `parse(String, String)` with "DEFAULT" as the profile.

    Parameters:
      `configFilePath` - The path to the config file.
    Returns:
      A new OCIConfigFile instance.
    Throws:
      `IOException` - if the file could not be read.

  - ### parse

    public static OCIConfigFileReader.OCIConfigFile parse(String configFilePath, String profile) throws IOException
    Create a new instance using a file at a given location.
    Parameters:
      `configFilePath` - The path to the config file.
      `profile` - The profile name to load, or null if you want to load the "DEFAULT" profile.
    Returns:
      A new OCIConfigFile instance.
    Throws:
      `IOException` - if the file could not be read.

  - ### parse

    public static OCIConfigFileReader.OCIConfigFile parse(InputStream configStream, String profile) throws IOException
    Create a new instance using an UTF-8 input stream.
    Parameters:
      `configStream` - The path to the config file.
      `profile` - The profile name to load, or null if you want to load the "DEFAULT" profile.
    Returns:
      A new OCIConfigFile instance.
    Throws:
      `IOException` - if the file could not be read.

  - ### parse

    public static OCIConfigFileReader.OCIConfigFile parse(InputStream configStream, String profile, Charset charset) throws IOException
    Create a new instance using an input stream.
    Parameters:
      `configStream` - The path to the config file.
      `profile` - The profile name to load, or null if you want to load the "DEFAULT" profile.
      `charset` - The charset used when parsing the input stream
    Returns:
      A new OCIConfigFile instance.
    Throws:
      `IOException` - if the file could not be read.