View Source ExOciSdk.Config (ex_oci_sdk v0.2.1)

Provides configuration structure and validation for Oracle Cloud Infrastructure (OCI) credentials.

This module manages the configuration required for authenticating with OCI services, including user, tenancy information, and private key authentication.

Summary

Types

Options for creating a new configuration.

t()

Configuration structure for OCI authentication.

Functions

Creates a new configuration from an OCI config file.

Creates a new configuration struct with the provided options.

Types

config_options()

@type config_options() :: %{
  user: String.t(),
  fingerprint: String.t(),
  tenancy: String.t(),
  region: String.t(),
  key_content: String.t() | nil,
  key_file: String.t() | nil
}

Options for creating a new configuration.

Fields

  • user - The OCID of the user making the request
  • fingerprint - Fingerprint of the public key uploaded to OCI
  • tenancy - The OCID of your tenancy
  • region - The region of the OCI services being accessed
  • key_content - The private key content as a string (mutually exclusive with key_content_file)
  • key_content_file - Path to the private key file (mutually exclusive with key_content)

t()

@type t() :: %ExOciSdk.Config{
  fingerprint: String.t(),
  key_content: String.t(),
  region: String.t(),
  tenancy: String.t(),
  user: String.t()
}

Configuration structure for OCI authentication.

Fields

  • user - The OCID of the user making the request
  • fingerprint - Fingerprint of the public key uploaded to OCI
  • tenancy - The OCID of your tenancy
  • region - The region of the OCI services being accessed
  • key_content - The private key content used for signing requests

Functions

from_file!(config_file_path \\ "~/.oci/config", profile \\ "DEFAULT")

@spec from_file!(config_file_path :: String.t(), profile :: String.t()) ::
  t() | no_return()

Creates a new configuration from an OCI config file.

The function reads and parses an INI-formatted OCI configuration file and creates a new configuration struct based on the specified profile.

Parameters

  • config_file_path - Path to the OCI config file. Defaults to "~/.oci/config"
  • profile - The profile name to use from the config file. Defaults to "DEFAULT"

Returns

  • t/0 - The configuration struct

Raises

  • ArgumentError - If the config file cannot be parsed or if the specified profile is not found
  • All raises from new!/1

new!(map)

@spec new!(config_options()) :: t() | no_return()
@spec new!(config_options()) :: t() | no_return()

Creates a new configuration struct with the provided options.

This function accepts either direct key content or a path to a key file, but not both. The private key content will be validated to ensure it's in the correct PEM format.

Parameters

  • options - Map containing configuration values. See config_options/0 for details.

Returns

  • t/0 - The configuration struct

Raises

  • ArgumentError - If the key content is invalid or not in PEM format
  • File.Error - If the key file cannot be read (when using key_content_file)