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 the list of APIs
Returns list of apis statuses
Update a API
Link to this section Functions
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{}}
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{}, ...]
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}
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{}}
Returns list of apis statuses
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{}}