ExAzureCore.Operation protocol (ex_azure_core v0.3.0)

Copy Markdown

Protocol for Azure service operations.

Service modules (like ExAzureStorage, ExAzureKeyVault) implement this protocol to define how requests are built and responses are parsed.

Example

# Service module builds an operation
operation = ExAzureStorage.list_containers()

# ExAzureCore executes it
{:ok, result} = ExAzureCore.request(operation)

Implementing Custom Operations

defmodule MyOperation do
  defstruct [:service, :path, :method]
end

defimpl ExAzureCore.Operation, for: MyOperation do
  def perform(op, config) do
    # Build and execute request
  end

  def stream!(op, config) do
    # Return enumerable for paginated results
  end
end

Summary

Types

t()

All the types that implement this protocol.

Functions

Executes the operation and returns the result.

Drives a long-running operation to completion.

Returns a stream for paginated Azure resources.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

perform(operation, config)

@spec perform(t(), map()) :: {:ok, term()} | {:error, term()}

Executes the operation and returns the result.

The config map contains merged configuration from:

  1. Service defaults
  2. Global application config
  3. Service-specific config
  4. Per-request overrides

poll(operation, config)

@spec poll(t(), map()) :: {:ok, term()} | {:error, term()}

Drives a long-running operation to completion.

Raises ArgumentError if the operation is not a long-running operation.

stream!(operation, config)

@spec stream!(t(), map()) :: Enumerable.t()

Returns a stream for paginated Azure resources.

Raises ArgumentError if the operation does not support streaming.