ExAzureCore.Credentials.AzureKeyCredential (ex_azure_core v0.3.0)

Copy Markdown

Credential type for API key authentication.

Stores a single API key that can be used with services requiring api-key, Ocp-Apim-Subscription-Key, or similar header-based authentication.

Example

{:ok, credential} = AzureKeyCredential.new("my-secret-key")
credential.key
#=> "my-secret-key"

# Update returns a new credential (immutable)
{:ok, updated} = AzureKeyCredential.update(credential, "new-key")

Summary

Functions

Creates a new key credential.

Creates a new key credential, raising on invalid input.

Updates the key value, returning a new credential.

Types

t()

@type t() :: %ExAzureCore.Credentials.AzureKeyCredential{key: String.t()}

Functions

new(key)

@spec new(String.t()) ::
  {:ok, t()} | {:error, ExAzureCore.Credentials.Errors.CredentialError.t()}

Creates a new key credential.

Returns {:ok, credential} if the key is a non-empty string, or {:error, CredentialError} otherwise.

new!(key)

@spec new!(String.t()) :: t()

Creates a new key credential, raising on invalid input.

update(azure_key_credential, new_key)

@spec update(t(), String.t()) ::
  {:ok, t()} | {:error, ExAzureCore.Credentials.Errors.CredentialError.t()}

Updates the key value, returning a new credential.

This is immutable - returns a new struct rather than modifying in-place.