annon_api v0.16.2 Annon.Configuration.API

The boundary for the API Configurations system.

Link to this section Summary

Functions

Creates a API

Deletes a API

Returns all APIs that have at least one enabled Plugin and preloads Plugins

Returns first API that match request parameters

Gets a single API

Returns list of apis statuses

Update a API

Link to this section Functions

Link to this function create_api(id, attrs)

Creates a API.

ID is not auto-generated, we recommend to use Ecto UUID’s: Ecto.UUID.generate/0.

Examples

iex> create_api(id, %{field: value})
{:ok, %Annon.Configuration.Schemas.API{}}

iex> create_api(id, %{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function delete_api(api)

Deletes a API.

Examples

iex> delete_api(123)
{:ok, %API{}}

iex> delete_api(007)
{:error, :not_found}

Returns all APIs that have at least one enabled Plugin and preloads Plugins.

Examples

iex> dump_apis()
[%Annon.Configuration.Schemas.API{}, ...]
Link to this function find_api(scheme, method, host, port, path)

Returns first API that match request parameters.

APIs are ordered by inserted_at field to make sure that new overlapping settings don’t break old gateway behaviors.

Examples

iex> find_api("POST", "HTTP", "example.com", 80, "/my_path")
%Annon.Configuration.Schemas.API{}

Gets a single API.

Examples

iex> get_api(123)
{:ok, %Annon.Configuration.Schemas.API{}}

iex> get_api(456)
{:error, :not_found}
Link to this function list_apis(conditions \\ %{}, paging \\ %Paging{limit: 50})

Returns the list of APIs.

Response can be filtered by title if there is a "title" filed in conditions.

Examples

iex> list_apis()
{[%Annon.Configuration.Schemas.API{}, ...], %Ecto.Paging{}}
Link to this function list_disclosed_apis()

Returns list of apis statuses

Link to this function request_changeset(request, attrs)
Link to this function update_api(api, attrs)

Update a API.

Update requires all fields to be present. Old API will be deleted, but id and inserted_at values will be persisted in new record.

Examples

iex> update_api(api, %{field: new_value})
{:ok, %Annon.Configuration.Schemas.API{}}

iex> update_api(api, %{field: bad_value})
{:error, %Ecto.Changeset{}}