Package oracle.nosql.driver.iam
Class OCIConfigFileReader
java.lang.Object
oracle.nosql.driver.iam.OCIConfigFileReader
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 ClassesModifier and TypeClassDescriptionstatic final classCloud service only. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionparse(InputStream configStream, String profile) Create a new instance using an UTF-8 input stream.parse(InputStream configStream, String profile, Charset charset) Create a new instance using an input stream.Create a new instance using a file at a given location.Create a new instance using a file at a given location.
-
Field Details
-
DEFAULT_FILE_PATH
Default configuration file at~/.oci/config -
DEFAULT_PROFILE_NAME
Default profile in config file- See Also:
-
-
Method Details
-
parse
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.
-