Immich.API.Client (ex_immich v0.1.1)

Copy Markdown

Generic HTTP client for Immich API requests.

Summary

Functions

Sends a JSON GET request and returns the decoded JSON body for 2xx responses.

Sends a streaming JSON POST request and decodes the response as NDJSON.

Sends a JSON POST request and returns the decoded JSON body for 2xx responses.

Types

api_error()

@type api_error() ::
  {:authentication, term()}
  | {:authorization, term()}
  | {:transport, term()}
  | {:unexpected_response, non_neg_integer(), term()}

headers()

@type headers() :: [{String.t(), String.t()}]

request_fun()

@type request_fun() :: (keyword() -> {:ok, Req.Response.t()} | {:error, term()})

t()

@type t() :: module()

Functions

get(url, headers)

@spec get(String.t(), headers()) :: {:ok, map() | term()} | {:error, api_error()}

Sends a JSON GET request and returns the decoded JSON body for 2xx responses.

Non-2xx responses are mapped to typed API error tuples.

get(url, headers, request_fun)

@spec get(String.t(), headers(), request_fun()) ::
  {:ok, map() | term()} | {:error, api_error()}

ndjson_stream(url, body, headers)

@spec ndjson_stream(String.t(), map(), headers()) ::
  {:ok, Enumerable.t(map())} | {:error, api_error()}

Sends a streaming JSON POST request and decodes the response as NDJSON.

Returns a lazy stream of decoded map events for 2xx responses.

ndjson_stream(url, body, headers, request_fun)

@spec ndjson_stream(String.t(), map(), headers(), request_fun()) ::
  {:ok, Enumerable.t(map())} | {:error, api_error()}

post(url, body, headers)

@spec post(String.t(), map(), headers()) ::
  {:ok, map() | term()} | {:error, api_error()}

Sends a JSON POST request and returns the decoded JSON body for 2xx responses.

Non-2xx responses are mapped to typed API error tuples.

post(url, body, headers, request_fun)

@spec post(String.t(), map(), headers(), request_fun()) ::
  {:ok, map() | term()} | {:error, api_error()}