ExAzureCore. Http. Client
(ex_azure_core v0.3.0)
Copy Markdown
HTTP client for Azure services using Req.
Provides a pre-configured Req client with Azure-specific plugins for authentication, error handling, and retry logic.
Creating a Client
client = ExAzureCore.Http.Client.new(base_url: "https://management.azure.com")Making Requests
{:ok, response} = ExAzureCore.Http.Client.get(client, "/subscriptions")
{:ok, response} = ExAzureCore.Http.Client.post(client, "/resources", %{name: "example"})With Plugins
client = ExAzureCore.Http.Client.new(
base_url: "https://vault.azure.net",
plugins: [
{ExAzureCore.Http.Plugins.BearerToken, credential: :my_credential},
{ExAzureCore.Http.Plugins.AzureHeaders, api_version: "7.4"}
]
)
Summary
Functions
Executes a DELETE request.
Executes a GET request.
Executes a HEAD request.
Creates a new HTTP client with the given options.
Executes a PATCH request.
Executes a POST request.
Executes a PUT request.
Executes an HTTP request using the given client.
Executes a streaming request.
Types
@type client() :: Req.Request.t()
Functions
@spec delete(client(), String.t(), keyword()) :: {:ok, ExAzureCore.Http.Response.t()} | {:error, term()}
Executes a DELETE request.
@spec get(client(), String.t(), keyword()) :: {:ok, ExAzureCore.Http.Response.t()} | {:error, term()}
Executes a GET request.
@spec head(client(), String.t(), keyword()) :: {:ok, ExAzureCore.Http.Response.t()} | {:error, term()}
Executes a HEAD request.
Creates a new HTTP client with the given options.
Options
:base_url- Base URL for all requests:timeout- Request timeout in milliseconds (default: 30000):pool_timeout- Connection pool timeout (default: 5000):plugins- List of plugins to attach, as{Module, opts}orModule:headers- Default headers for all requests
@spec patch(client(), String.t(), term(), keyword()) :: {:ok, ExAzureCore.Http.Response.t()} | {:error, term()}
Executes a PATCH request.
@spec post(client(), String.t(), term(), keyword()) :: {:ok, ExAzureCore.Http.Response.t()} | {:error, term()}
Executes a POST request.
@spec put(client(), String.t(), term(), keyword()) :: {:ok, ExAzureCore.Http.Response.t()} | {:error, term()}
Executes a PUT request.
@spec request(client(), ExAzureCore.Http.Request.t()) :: {:ok, ExAzureCore.Http.Response.t()} | {:error, term()}
Executes an HTTP request using the given client.
Parameters
client- The Req clientrequest- AnExAzureCore.Http.Requeststruct
Returns
{:ok, response}- Successful response{:error, error}- Network or HTTP error
@spec stream(client(), ExAzureCore.Http.Request.t() | keyword(), keyword()) :: {:ok, ExAzureCore.Http.Response.t()} | {:error, term()}
Executes a streaming request.
The into option determines how the response body is streamed:
into: File.stream!(path)- Stream to a fileinto: fun- Stream to a functioninto: :self- Stream to the calling process