View Source Ash.ActionInput (ash v3.4.43)

Input for a custom action

Summary

Functions

Adds an error to the input errors list, and marks the input as valid?: false

Fetches the value of an argument provided to the input or :error.

Creates a new input for a generic action

Gets the value of an argument provided to the input.

Set an argument value

Deep merges the provided map into the input context that can be used later

Types

@type t() :: %Ash.ActionInput{
  action: Ash.Resource.Actions.Action.t() | nil,
  arguments: map(),
  context: map(),
  domain: Ash.Domain.t(),
  errors: term(),
  invalid_keys: MapSet.t(),
  params: map(),
  resource: Ash.Resource.t(),
  tenant: term(),
  valid?: boolean()
}

Functions

Link to this function

add_error(input, errors, path \\ [])

View Source

Adds an error to the input errors list, and marks the input as valid?: false

Link to this function

fetch_argument(input, argument)

View Source
@spec fetch_argument(t(), atom() | String.t()) :: {:ok, term()} | :error

Fetches the value of an argument provided to the input or :error.

Link to this function

for_action(resource_or_input, action, params, opts \\ [])

View Source
@spec for_action(
  resource_or_input :: Ash.Resource.t() | t(),
  action :: atom(),
  params :: map(),
  opts :: Keyword.t()
) :: t()

Creates a new input for a generic action

Options

  • :domain (Ash.Domain) - The domain to use for the action. The resource's domain is used by default.

  • :context (map/0) - Context to set on the action input. The default value is %{}.

  • :authorize? - Whether or not to run authorization on the action. Default behavior of this option is controlled by the domain.

  • :tenant (term/0) - The tenant to use for the action.

  • :actor (term/0) - The actor performing the action

  • :skip_unknown_inputs - A list of unknow inputs to skip. Use :* to skip all unknown inputs.

  • :tracer (term/0) - A tracer or list of tracers to trace action execution.

  • :private_arguments (map/0) - A list of private arguments to be set before the action is invoked. The default value is %{}.

Link to this function

get_argument(input, argument)

View Source
@spec get_argument(t(), atom() | String.t()) :: term()

Gets the value of an argument provided to the input.

Link to this function

new(resource, domain \\ nil)

View Source
Link to this function

set_argument(input, argument, value)

View Source
@spec set_argument(input :: t(), name :: atom(), value :: term()) :: t()

Set an argument value

@spec set_context(t(), map() | nil) :: t()

Deep merges the provided map into the input context that can be used later

Do not use the private key in your custom context, as that is reserved for internal use.

Link to this function

set_tenant(input, tenant)

View Source
@spec set_tenant(t(), Ash.ToTenant.t()) :: t()