View Source Ash.Api.Dsl (ash v2.9.24)
A small DSL for declaring APIs
Apis are the entrypoints for working with your resources.
Apis may optionally include a list of resources, in which case they can be
used as an Ash.Registry
in various places. This is for backwards compatibility,
but if at all possible you should define an Ash.Registry
if you are using an extension
that requires a list of resources. For example, most extensions look for two application
environment variables called :ash_apis
and :ash_registries
to find any potential registries
dsl-documentation
DSL Documentation
index
Index
docs
Docs
api
api
General Api configuration
Examples:
api do
description """
Resources related to the flux capacitor.
"""
end
:description
(String.t/0
) - A description for the api.
resources
resources
List the resources present in this API
Examples:
resources do
registry MyApp.Registry
en
:allow
- Support a dynamic resource list by providing a callback that checks whether or not the resource should be allowed.:allow_unregistered?
(boolean/0
) - Whether the Api will support only registered entries or not. The default value isfalse
.:registry
(atom/0
) - Configure the registry that contains the resources. It is recommended to use application config for this, to help with compile times. See the quick start guide for more.
execution
execution
Options for how requests are executed using this Api
Examples:
execution do
timeout :timer.seconds(30)
end
:timeout
(timeout/0
) - The default timeout to use for requests using this API. See the timeouts guide for more. The default value is30000
.:trace_name
(String.t/0
) - The name to use in traces. Defaults to the last part of the module.
See the monitoring guide for more
authorization
authorization
Options for how requests are authorized using this Api.
See the security guide for more.
Examples:
authorization do
authorize :by_default
end
:require_actor?
(boolean/0
) - Requires that an actor has been supplied. The default value isfalse
.:authorize
- When to run authorization for a given request. The default value is:when_requested
.