View Source Ash.Api behaviour (ash v2.7.1)

An Api allows you to interact with your resources, and holds non-resource-specific configuration.

For example, the json api extension adds an api extension that lets you toggle authorization on/off for all resources in that Api. You include them in an Api like so:

defmodule MyApp.Registry do
  use Ash.Registry,
    extensions: [Ash.Registry.ResourceValidations]

  entries do
    entry OneResource
    entry SecondResource
  end
end

defmodule MyApp.Api do
  use Ash.Api

  resources do
    registry MyApp.Registry
  end
end

Then you can interact through that Api with the actions that those resources expose. For example: MyApp.Api.create(changeset), or MyApp.Api.read(query). Corresponding actions must be defined in your resources in order to call them through the Api.

interface

Interface

The functions documented here can be used to call any action on any resource in the Api. For example, MyApi.read(Myresource, [...]).

Additionally, you can define a code_interface on each resource. See the code interface guide for more.

Link to this section Summary

Callbacks

Get the avg of a given field from the given query, raising any errors

Get the avg of a given field from the given query

Returns wether or not the user can perform the action, or :maybe, returning any errors.

Returns wether or not the user can perform the action, or raises on errors.

Create a record. See create/2 for more information.

Create a record.

Destroy a record. See destroy/2 for more information.

Destroy a record.

Get the first of a given field from the given query, raising any errors

Get the first of a given field from the given query

Get a record by a primary key. See get/3 for more.

Get a record by a primary key.

Get the list of a given field from the given query, raising any errors

Get list of a given field from the given query

Load fields or relationships on already fetched records. See load/3 for more information.

Load fields or relationships on already fetched records.

Get the max of a given field from the given query, raising any errors

Get the max of a given field from the given query

Get the min of a given field from the given query, raising any errors

Get the min of a given field from the given query

Fetch a page relative to the provided page.

Fetch a page relative to the provided page.

Run an ash query. See read/2 for more.

Run a query on a resource.

Run an ash query, raising on more than one result. See read_one/2 for more.

Run a query on a resource, but fail on more than one result.

Refetches a record by primary key. See reload/1 for more.

Refetches a record by primary key.

Get the sum of a given field from the given query, raising any errors

Get the sum of a given field from the given query

Update a record. See update/2 for more information.

Update a record.

Link to this section Types

@type load_statement() ::
  Ash.Query.t()
  | [atom()]
  | atom()
  | Keyword.t()
  | [atom() | {atom(), atom() | Keyword.t()}]
@type page_request() :: :next | :prev | :first | :last | integer()
@type t() :: module()

Link to this section Callbacks

@callback avg!(Ash.Query.t(), field :: atom(), opts :: Keyword.t()) ::
  term() | no_return()

Get the avg of a given field from the given query, raising any errors

@callback avg(Ash.Query.t(), field :: atom(), opts :: Keyword.t()) ::
  {:ok, term()} | {:error, Ash.Error.t()}

Get the avg of a given field from the given query

Link to this callback

calculate!(resource, calculation, opts)

View Source
@callback calculate!(
  resource :: Ash.Resource.t(),
  calculation :: atom(),
  opts :: Keyword.t()
) ::
  term() | no_return()
Link to this callback

calculate(resource, calculation, opts)

View Source
@callback calculate(
  resource :: Ash.Resource.t(),
  calculation :: atom(),
  opts :: Keyword.t()
) ::
  {:ok, term()} | {:error, term()}
Link to this callback

can( action_or_query_or_changeset, actor )

View Source
@callback can(
  action_or_query_or_changeset ::
    Ash.Query.t()
    | Ash.Changeset.t()
    | {Ash.Resource.t(), atom() | Ash.Resource.Actions.action()},
  actor :: term()
) :: {:ok, boolean() | :maybe} | {:error, term()}
Link to this callback

can( action_or_query_or_changeset, actor, opts )

View Source
@callback can(
  action_or_query_or_changeset ::
    Ash.Query.t()
    | Ash.Changeset.t()
    | {Ash.Resource.t(), atom() | Ash.Resource.Actions.action()},
  actor :: term(),
  opts :: Keyword.t()
) :: {:ok, boolean() | :maybe} | {:error, term()}

Returns wether or not the user can perform the action, or :maybe, returning any errors.

In cases with "runtime" checks (checks after the action), we may not be able to determine an answer, and so the value :maybe will be returned from can/2. The can? function assumes that :maybe means false. Keep in mind, this is just for doing things like "can they do this" in a UI, so assuming :maybe is false is fine. The actual action invocation will be properly checked regardless. If you have runtime checks, you may need to use can instead of can?, or configure what :maybe means.

options

Options

  • maybe_is - What to treat :maybe results as, defaults to true if using can?, or :maybe if using can.
  • run_queries? - In order to determine authorization status for changesets that use filter checks, we may need to run queries (almost always only one query). Set this to false to disable (returning :maybe instead). The default value is true.
  • data - A record or list of records. For authorizing reads with filter checks, this can be provided and a filter check will only be true if all records match the filter. This is detected by running a query.
Link to this callback

can?( query_or_changeset_or_action, actor )

View Source
@callback can?(
  query_or_changeset_or_action ::
    Ash.Query.t()
    | Ash.Changeset.t()
    | {Ash.Resource.t(), atom() | Ash.Resource.Actions.action()},
  actor :: term()
) :: boolean() | no_return()
Link to this callback

can?( query_or_changeset_or_action, actor, opts )

View Source
@callback can?(
  query_or_changeset_or_action ::
    Ash.Query.t()
    | Ash.Changeset.t()
    | {Ash.Resource.t(), atom() | Ash.Resource.Actions.action()},
  actor :: term(),
  opts :: Keyword.t()
) :: boolean() | no_return()

Returns wether or not the user can perform the action, or raises on errors.

See can/3 for more info.

@callback count!(Ash.Query.t(), opts :: Keyword.t()) :: integer() | no_return()
@callback count(Ash.Query.t(), opts :: Keyword.t()) ::
  {:ok, integer()} | {:error, Ash.Error.t()}

Create a record. See create/2 for more information.

@callback create(Ash.Changeset.t(), params :: Keyword.t()) ::
  {:ok, Ash.Resource.record()}
  | {:ok, Ash.Resource.record(), [Ash.Notifier.Notification.t()]}
  | {:error, term()}

Create a record.

  • :upsert? (boolean/0) - If a conflict is found based on the primary key, the record is updated in the database (requires upsert support) The default value is false.

  • :upsert_identity (atom/0) - The identity to use when detecting conflicts for upsert?, e.g. upsert_identity: :full_name. By default, the primary key is used. Has no effect if upsert?: true is not provided

  • :timeout (timeout/0) - A positive integer, or :infinity. If none is provided, the timeout configured on the api is used (which defaults to 30_000).

  • :tracer (atom/0) - A tracer that implements the Ash.Tracer behaviour. See that module for more.

  • :verbose? (boolean/0) - Log engine operations (very verbose!) The default value is false.

  • :action (term/0) - The action to use, either an Action struct or the name of the action

  • :authorize? - If an actor option is provided (even if it is nil), authorization happens automatically. If not, this flag can be used to authorize with no user.

  • :stacktraces? (boolean/0) - For Ash errors, whether or not each error has a stacktrace. See the error_handling guide for more. The default value is true.

  • :tenant (term/0) - A tenant to set on the query or changeset

  • :actor (term/0) - If an actor is provided, it will be used in conjunction with the authorizers of a resource to authorize access

  • :after_action (term/0) - A hook to be run just before the action returns, but before fields are selected (still inside the same transaction, if your data layer supports transactions). This is mostly important if you want to load calculations after the action, which depend on having fields selected, but you want to authorize with the minimal set of fields that are actually being selected. Runs only if the action is successful, and is passed the changeset and result of the action. Should return {:ok, result} or {:error, error}.
    For example, if you had a full_name calculation, but were only selecting, first_name and full_name, you might do something like this:

      MyApp.User
      |> Ash.Changeset.for_create(:create, %{first_name: "first_name", last_name: "last_name"}
      |> Ash.Changeset.select(:first_name))
      |> Api.create(after_action: fn _changeset, user -> Api.load(user, :full_name) end)

    If you tried to load that :full_name calculation after receiving the data, the last_name would not be selected and as such would not be usable in the calculation, regardless of whether or not the calculation includes that field in its select list.

  • :return_notifications? (boolean/0) - Use this if you're running ash actions in your own transaction and you want notifications to happen still.
    If a transaction is ongoing, and this is false, notifications will be discarded, otherwise the return value is {:ok, result, notifications} (or {:ok, notifications})
    To send notifications later, use Ash.Notifier.notify(notifications). It sends any notifications that can be sent, and returns the rest. The default value is false.

  • :notification_metadata (term/0) - Metadata to be merged into the metadata field for all notifications sent from this operation. The default value is %{}.

Destroy a record. See destroy/2 for more information.

@callback destroy(Ash.Changeset.t() | Ash.Resource.record(), params :: Keyword.t()) ::
  :ok
  | {:ok, Ash.Resource.record()}
  | {:ok, [Ash.Notifier.Notification.t()]}
  | {:ok, Ash.Resource.record(), [Ash.Notifier.Notification.t()]}
  | {:error, term()}

Destroy a record.

  • :return_destroyed? (boolean/0) - If true, the destroyed record is included in the return result, e.g {:ok, destroyed} or {:ok, destroyed, notifications} The default value is false.

  • :timeout (timeout/0) - A positive integer, or :infinity. If none is provided, the timeout configured on the api is used (which defaults to 30_000).

  • :tracer (atom/0) - A tracer that implements the Ash.Tracer behaviour. See that module for more.

  • :verbose? (boolean/0) - Log engine operations (very verbose!) The default value is false.

  • :action (term/0) - The action to use, either an Action struct or the name of the action

  • :authorize? - If an actor option is provided (even if it is nil), authorization happens automatically. If not, this flag can be used to authorize with no user.

  • :stacktraces? (boolean/0) - For Ash errors, whether or not each error has a stacktrace. See the error_handling guide for more. The default value is true.

  • :tenant (term/0) - A tenant to set on the query or changeset

  • :actor (term/0) - If an actor is provided, it will be used in conjunction with the authorizers of a resource to authorize access

  • :return_notifications? (boolean/0) - Use this if you're running ash actions in your own transaction and you want notifications to happen still.
    If a transaction is ongoing, and this is false, notifications will be discarded, otherwise the return value is {:ok, result, notifications} (or {:ok, notifications})
    To send notifications later, use Ash.Notifier.notify(notifications). It sends any notifications that can be sent, and returns the rest. The default value is false.

  • :notification_metadata (term/0) - Metadata to be merged into the metadata field for all notifications sent from this operation. The default value is %{}.

@callback first!(Ash.Query.t(), field :: atom(), opts :: Keyword.t()) ::
  term() | no_return()

Get the first of a given field from the given query, raising any errors

@callback first(Ash.Query.t(), field :: atom(), opts :: Keyword.t()) ::
  {:ok, term()} | {:error, Ash.Error.t()}

Get the first of a given field from the given query

Link to this callback

get!( resource, id_or_filter, params )

View Source
@callback get!(
  resource :: Ash.Resource.t(),
  id_or_filter :: term(),
  params :: Keyword.t()
) :: Ash.Resource.record() | no_return()

Get a record by a primary key. See get/3 for more.

Link to this callback

get( resource, id_or_filter, params )

View Source
@callback get(
  resource :: Ash.Resource.t(),
  id_or_filter :: term(),
  params :: Keyword.t()
) :: {:ok, Ash.Resource.record()} | {:ok, nil} | {:error, term()}

Get a record by a primary key.

For a resource with a composite primary key, pass a keyword list, e.g MyApi.get(MyResource, first_key: 1, second_key: 2)

  • :error? (boolean/0) - Whether or not an error should be returned or raised when the record is not found. If set to false, nil will be returned. The default value is true.

  • :load (term/0) - Fields or relationships to load in the query. See Ash.Query.load/2

  • :context (term/0) - Context to be set on the query being run

  • :reselect_all? (boolean/0) - Wether or not to reselect all attributes depended on by loads. By default, we only reselect fields that weren't already selected. The default value is false.

  • :timeout (timeout/0) - A positive integer, or :infinity. If none is provided, the timeout configured on the api is used (which defaults to 30_000).

  • :tracer (atom/0) - A tracer that implements the Ash.Tracer behaviour. See that module for more.

  • :verbose? (boolean/0) - Log engine operations (very verbose!) The default value is false.

  • :action (term/0) - The action to use, either an Action struct or the name of the action

  • :authorize? - If an actor option is provided (even if it is nil), authorization happens automatically. If not, this flag can be used to authorize with no user.

  • :stacktraces? (boolean/0) - For Ash errors, whether or not each error has a stacktrace. See the error_handling guide for more. The default value is true.

  • :tenant (term/0) - A tenant to set on the query or changeset

  • :actor (term/0) - If an actor is provided, it will be used in conjunction with the authorizers of a resource to authorize access

@callback list!(Ash.Query.t(), field :: atom(), opts :: Keyword.t()) ::
  [term()] | no_return()

Get the list of a given field from the given query, raising any errors

@callback list(Ash.Query.t(), field :: atom(), opts :: Keyword.t()) ::
  {:ok, [term()]} | {:error, Ash.Error.t()}

Get list of a given field from the given query

Link to this callback

load!( record_or_records, query, opts )

View Source
@callback load!(
  record_or_records :: Ash.Resource.record() | [Ash.Resource.record()],
  query :: load_statement(),
  opts :: Keyword.t()
) :: Ash.Resource.record() | [Ash.Resource.record()] | no_return()

Load fields or relationships on already fetched records. See load/3 for more information.

Link to this callback

load( record_or_records, query, opts )

View Source
@callback load(
  record_or_records :: Ash.Resource.record() | [Ash.Resource.record()],
  query :: load_statement(),
  opts :: Keyword.t()
) :: {:ok, Ash.Resource.record() | [Ash.Resource.record()]} | {:error, term()}

Load fields or relationships on already fetched records.

Accepts a list of non-loaded fields and loads them on the provided records or a query, in which case the loaded fields of the query are used. Relationship loads can be nested, for example: MyApi.load(record, [posts: [:comments]]).

  • :lazy? (boolean/0) - If set to true, values will only be loaded if the related value isn't currently loaded. The default value is false.

  • :reselect_all? (boolean/0) - Wether or not to reselect all attributes depended on by loads. By default, we only reselect fields that weren't already selected. The default value is false.

  • :timeout (timeout/0) - A positive integer, or :infinity. If none is provided, the timeout configured on the api is used (which defaults to 30_000).

  • :tracer (atom/0) - A tracer that implements the Ash.Tracer behaviour. See that module for more.

  • :verbose? (boolean/0) - Log engine operations (very verbose!) The default value is false.

  • :action (term/0) - The action to use, either an Action struct or the name of the action

  • :authorize? - If an actor option is provided (even if it is nil), authorization happens automatically. If not, this flag can be used to authorize with no user.

  • :stacktraces? (boolean/0) - For Ash errors, whether or not each error has a stacktrace. See the error_handling guide for more. The default value is true.

  • :tenant (term/0) - A tenant to set on the query or changeset

  • :actor (term/0) - If an actor is provided, it will be used in conjunction with the authorizers of a resource to authorize access

@callback max!(Ash.Query.t(), field :: atom(), opts :: Keyword.t()) ::
  term() | no_return()

Get the max of a given field from the given query, raising any errors

@callback max(Ash.Query.t(), field :: atom(), opts :: Keyword.t()) ::
  {:ok, term()} | {:error, Ash.Error.t()}

Get the max of a given field from the given query

@callback min!(Ash.Query.t(), field :: atom(), opts :: Keyword.t()) ::
  term() | no_return()

Get the min of a given field from the given query, raising any errors

@callback min(Ash.Query.t(), field :: atom(), opts :: Keyword.t()) ::
  {:ok, term()} | {:error, Ash.Error.t()}

Get the min of a given field from the given query

Link to this callback

page!(page, page_request)

View Source
@callback page!(Ash.Page.page(), page_request()) :: Ash.Page.page() | no_return()

Fetch a page relative to the provided page.

Link to this callback

page(page, page_request)

View Source
@callback page(Ash.Page.page(), page_request()) ::
  {:ok, Ash.Page.page()} | {:error, term()}

Fetch a page relative to the provided page.

A page is the return value of a paginated action called via read/2.

@callback read!(Ash.Query.t() | Ash.Resource.t(), params :: Keyword.t()) ::
  [Ash.Resource.record()]
  | {[Ash.Resource.record()], Ash.Query.t()}
  | no_return()

Run an ash query. See read/2 for more.

@callback read(Ash.Query.t(), params :: Keyword.t()) ::
  {:ok, [Ash.Resource.record()]}
  | {:ok, [Ash.Resource.record()], Ash.Query.t()}
  | {:error, term()}

Run a query on a resource.

For more information on building a query, see Ash.Query.

  • :page - Pagination options, see the pagination docs for more

  • :load (term/0) - A load statement to add onto the query

  • :return_query? (boolean/0) - If true, the query that was ultimately used is returned as a third tuple element.
    The query goes through many potential changes during a request, potentially adding authorization filters, or replacing relationships for other data layers with their corresponding ids. This option can be used to get the true query that was sent to the data layer. The default value is false.

  • :reselect_all? (boolean/0) - Wether or not to reselect all attributes depended on by loads. By default, we only reselect fields that weren't already selected. The default value is false.

  • :timeout (timeout/0) - A positive integer, or :infinity. If none is provided, the timeout configured on the api is used (which defaults to 30_000).

  • :tracer (atom/0) - A tracer that implements the Ash.Tracer behaviour. See that module for more.

  • :verbose? (boolean/0) - Log engine operations (very verbose!) The default value is false.

  • :action (term/0) - The action to use, either an Action struct or the name of the action

  • :authorize? - If an actor option is provided (even if it is nil), authorization happens automatically. If not, this flag can be used to authorize with no user.

  • :stacktraces? (boolean/0) - For Ash errors, whether or not each error has a stacktrace. See the error_handling guide for more. The default value is true.

  • :tenant (term/0) - A tenant to set on the query or changeset

  • :actor (term/0) - If an actor is provided, it will be used in conjunction with the authorizers of a resource to authorize access

pagination

Pagination

Limit/offset pagination

  • :offset (non_neg_integer/0) - The number of records to skip from the beginning of the query

  • :limit (pos_integer/0) - The number of records to include in the page

  • :filter (term/0) - A filter to apply for pagination purposes, that should not be considered in the full count.
    This is used by the liveview paginator to only fetch the records that were already on the page when refreshing data, to avoid pages jittering.

  • :count (boolean/0) - Whether or not to return the page with a full count of all records

Keyset pagination

  • :before (String.t/0) - Get records that appear before the provided keyset (mutually exclusive with after)

  • :after (String.t/0) - Get records that appear after the provided keyset (mutually exclusive with before)

  • :limit (pos_integer/0) - How many records to include in the page

  • :filter (term/0) - See the filter option for offset pagination, this behaves the same.

  • :count (boolean/0) - Whether or not to return the page with a full count of all records

@callback read_one!(Ash.Query.t() | Ash.Resource.t(), params :: Keyword.t()) ::
  Ash.Resource.record()
  | {Ash.Resource.record(), Ash.Query.t()}
  | nil
  | no_return()

Run an ash query, raising on more than one result. See read_one/2 for more.

@callback read_one(Ash.Query.t() | Ash.Resource.t(), params :: Keyword.t()) ::
  {:ok, Ash.Resource.record()}
  | {:ok, Ash.Resource.record(), Ash.Query.t()}
  | {:ok, nil}
  | {:error, term()}

Run a query on a resource, but fail on more than one result.

This is useful if you have a query that doesn't include a primary key but you know that it will only ever return a single result.

@callback reload!(record :: Ash.Resource.record(), params :: Keyword.t()) ::
  Ash.Resource.record() | no_return()

Refetches a record by primary key. See reload/1 for more.

@callback reload(record :: Ash.Resource.record()) ::
  {:ok, Ash.Resource.record()} | {:error, term()}

Refetches a record by primary key.

@callback sum!(Ash.Query.t(), field :: atom(), opts :: Keyword.t()) ::
  term() | no_return()

Get the sum of a given field from the given query, raising any errors

@callback sum(Ash.Query.t(), field :: atom(), opts :: Keyword.t()) ::
  {:ok, term()} | {:error, Ash.Error.t()}

Get the sum of a given field from the given query

Update a record. See update/2 for more information.

@callback update(Ash.Changeset.t(), params :: Keyword.t()) ::
  {:ok, Ash.Resource.record()}
  | {:ok, Ash.Resource.record(), [Ash.Notifier.Notification.t()]}
  | {:error, term()}

Update a record.

  • :timeout (timeout/0) - A positive integer, or :infinity. If none is provided, the timeout configured on the api is used (which defaults to 30_000).

  • :tracer (atom/0) - A tracer that implements the Ash.Tracer behaviour. See that module for more.

  • :verbose? (boolean/0) - Log engine operations (very verbose!) The default value is false.

  • :action (term/0) - The action to use, either an Action struct or the name of the action

  • :authorize? - If an actor option is provided (even if it is nil), authorization happens automatically. If not, this flag can be used to authorize with no user.

  • :stacktraces? (boolean/0) - For Ash errors, whether or not each error has a stacktrace. See the error_handling guide for more. The default value is true.

  • :tenant (term/0) - A tenant to set on the query or changeset

  • :actor (term/0) - If an actor is provided, it will be used in conjunction with the authorizers of a resource to authorize access

  • :after_action (term/0) - A hook to be run just before the action returns, but before fields are selected (still inside the same transaction, if your data layer supports transactions). This is mostly important if you want to load calculations after the action, which depend on having fields selected, but you want to authorize with the minimal set of fields that are actually being selected. Runs only if the action is successful, and is passed the changeset and result of the action. Should return {:ok, result} or {:error, error}.
    For example, if you had a full_name calculation, but were only selecting, first_name and full_name, you might do something like this:

      MyApp.User
      |> Ash.Changeset.for_create(:create, %{first_name: "first_name", last_name: "last_name"}
      |> Ash.Changeset.select(:first_name))
      |> Api.create(after_action: fn _changeset, user -> Api.load(user, :full_name) end)

    If you tried to load that :full_name calculation after receiving the data, the last_name would not be selected and as such would not be usable in the calculation, regardless of whether or not the calculation includes that field in its select list.

  • :return_notifications? (boolean/0) - Use this if you're running ash actions in your own transaction and you want notifications to happen still.
    If a transaction is ongoing, and this is false, notifications will be discarded, otherwise the return value is {:ok, result, notifications} (or {:ok, notifications})
    To send notifications later, use Ash.Notifier.notify(notifications). It sends any notifications that can be sent, and returns the rest. The default value is false.

  • :notification_metadata (term/0) - Metadata to be merged into the metadata field for all notifications sent from this operation. The default value is %{}.

Link to this section Functions

Link to this function

aggregate(api, query, aggregate_or_aggregates, opts \\ [])

View Source

Runs an aggregate or aggregates over a resource query

  • :timeout (timeout/0) - A positive integer, or :infinity. If none is provided, the timeout configured on the api is used (which defaults to 30_000).

  • :tracer (atom/0) - A tracer that implements the Ash.Tracer behaviour. See that module for more.

  • :verbose? (boolean/0) - Log engine operations (very verbose!) The default value is false.

  • :action (term/0) - The action to use, either an Action struct or the name of the action

  • :authorize? - If an actor option is provided (even if it is nil), authorization happens automatically. If not, this flag can be used to authorize with no user.

  • :stacktraces? (boolean/0) - For Ash errors, whether or not each error has a stacktrace. See the error_handling guide for more. The default value is true.

  • :tenant (term/0) - A tenant to set on the query or changeset

  • :actor (term/0) - If an actor is provided, it will be used in conjunction with the authorizers of a resource to authorize access

This function is deprecated. use Ash.Api.Info.allow/1 instead.

See Ash.Api.Info.allow/1.

Link to this function

allow_unregistered?(api)

View Source
This function is deprecated. use Ash.Api.Info.allow_unregistered?/1 instead.

See Ash.Api.Info.allow_unregistered?/1.

This function is deprecated. use Ash.Api.Info.authorize/1 instead.

See Ash.Api.Info.authorize/1.

Link to this function

calculate(resource_or_record, calculation, opts \\ [])

View Source

Evaluates the calculation on the resource.

If a record is provided, its field values will be used to evaluate the calculation.

  • :args (map/0) - Values for arguments referenced by the calculation. The default value is %{}.

  • :refs (map/0) - Values for references used by the calculation. The default value is %{}.

  • :actor (term/0) - The actor for handling ^actor/1 templates, supplied to calculation context.

  • :tenant (term/0) - The tenant, supplied to calculation context.

  • :authorize? (boolean/0) - Wether or not the request is being authorized, provided to calculation context. The default value is true.

  • :tracer (term/0) - A tracer, provided to the calculation context.

  • :record (term/0) - A record to use as the base of the calculation

Link to this function

can(api, action_or_query_or_changeset, actor, opts \\ [])

View Source
@spec can(
  api :: t(),
  action_or_query_or_changeset ::
    Ash.Query.t()
    | Ash.Changeset.t()
    | {Ash.Resource.t(), atom() | Ash.Resource.Actions.action()},
  actor :: term(),
  opts :: Keyword.t()
) :: {:ok, boolean() | :maybe} | {:error, term()}
Link to this function

can?(api, action_or_query_or_changeset, actor, opts \\ [])

View Source
@spec can?(
  api :: t(),
  query_or_changeset_or_action ::
    Ash.Query.t()
    | Ash.Changeset.t()
    | {Ash.Resource.t(), atom() | Ash.Resource.Actions.action()},
  actor :: term(),
  opts :: Keyword.t()
) :: boolean() | no_return()
Link to this function

default_extension_kinds()

View Source

Callback implementation for Spark.Dsl.init/1.

This function is deprecated. use Ash.Api.Info.registry/1 instead.

See Ash.Api.Info.registry/1.

This function is deprecated. use Ash.Api.Info.require_actor?/1 instead.

See Ash.Api.Info.require_actor?/1.

This function is deprecated. use Ash.Api.Info.resource/2 instead.

See Ash.Api.Info.resource/2.

This function is deprecated. use Ash.Api.Info.resources/1 instead.

See Ash.Api.Info.resources/1.

Link to this function

single_extension_kinds()

View Source
This function is deprecated. use Ash.Api.Info.timeout/1 instead.

See Ash.Api.Info.timeout/1.