#
API Reference ash v2.6.31

##

modules

Modules

Ash

General purpose tools for working with Ash.

Ash.Actions.Flows.Read

Execute a read action.

Ash.Actions.Flows.Read.FakeResult

Generates a fake result, as the flow has to actually return something.

Ash.Api

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

Ash.Api.Dsl

A small DSL for declaring APIs

Ash.Api.Info

Introspection tools for Ash.Api

Ash.Api.Info.Diagram

Generate Mermaid diagrams from a specified API.

Ash.Api.Info.Livebook

Generate a Livebook from a specified API.

Ash.Authorizer

The interface for an ash authorizer

Ash.Calculation

The behaviour for a calculation module

Ash.Changeset

Changesets are used to create and update data in Ash.

Ash.Changeset.ManagedRelationshipHelpers

Tools for introspecting managed relationships.

Ash.CiString

Represents a case insensitive string

Ash.CodeInterface

Used to define the functions of a code interface for a resource.

Ash.DataLayer

The interface for being an ash data layer.

Ash.DataLayer.Ets

An ETS (Erlang Term Storage) backed Ash Datalayer, for testing and lightweight usage.

Ash.DataLayer.Ets.Info

Introspection helpers for the Ets data layer

Ash.DataLayer.Mnesia

An Mnesia backed Ash Datalayer.

Ash.DataLayer.Mnesia.Info

Introspection helpers for Ash.DataLayer.Mnesia

Ash.DataLayer.Simple

A data layer that returns structs.

Ash.DataLayer.Transformers.RequirePreCheckWith

Ensures that all identities have a `pre_check_with` configured, or raises.

Ash.Engine

The Ash engine handles the parallelization/running of requests to Ash.

Ash.Engine.Request

Represents an individual request to be processed by the engine.

Ash.Engine.Request.UnresolvedField

Represents an unresolved field to be resolved by the engine.

Ash.Error

Tools and utilities used by Ash to manage and conform errors

Ash.Error.Changes.InvalidArgument

Used when an invalid value is provided for an action argument

Ash.Error.Changes.InvalidAttribute

Used when an invalid value is provided for an attribute change

Ash.Error.Changes.InvalidChanges

Used when a change is provided that covers multiple attributes/relationships

Ash.Error.Changes.InvalidRelationship

Used when an invalid value is provided for a relationship change

Ash.Error.Changes.NoSuchAttribute

Used when a change is provided for an attribute that does not exist

Ash.Error.Changes.NoSuchRelationship

Used when a change is provided for an relationship that does not exist

Ash.Error.Changes.Required

Used when an attribute or relationship is required

Ash.Error.Changes.UnknownError

Used when a change fails for an unknown reason

Ash.Error.EngineError

Used when the Ash engine has an internal error

Ash.Error.Exception

Tooling for creating an Ash exception

Ash.Error.Flow.Halted

Used when a flow has been halted for some reason

Ash.Error.Forbidden

Used when authorization for an action fails

Ash.Error.Forbidden.ApiRequiresActor

Used when an api that has `require_actor? true` is provided no actor

Ash.Error.Forbidden.CannotFilterCreates

Used when a create action would be filtered

Ash.Error.Forbidden.MustPassStrictCheck

Used when unreachable code/conditions are reached in the framework

Ash.Error.Forbidden.Policy

Raised when policy authorization for an action fails

Ash.Error.Framework

Used when an unknown/generic framework error occurs

Ash.Error.Framework.AssumptionFailed

Used when unreachable code/conditions are reached in the framework

Ash.Error.Framework.FlagAssertionFailed

Used when unreachable code/conditions are reached in the framework

Ash.Error.Framework.ManualActionMissed

Used when a manual action should have produced a result, but did not

Ash.Error.Framework.SynchronousEngineStuck

Used when the sycnrhonous engine cannot proceed

Ash.Error.Invalid

The top level invalid error

Ash.Error.Invalid.DuplicatedPath

Used when multiple requests with the same path are passed to the internal engine

Ash.Error.Invalid.ImpossiblePath

Used when a request expresses a dependency on another request that doesn't exist

Ash.Error.Invalid.InvalidPrimaryKey

Used when an invalid primary key is given to an Api's `get`

Ash.Error.Invalid.LimitRequired

Used when no limit is provided, pagination is required, and no default page size is configured

Ash.Error.Invalid.MultipleResults

Used when multiple requests with the same path are passed to the internal engine

Ash.Error.Invalid.NoPrimaryAction

Used when an action name is provided that doesn't exist

Ash.Error.Invalid.NoSuchAction

Used when an action name is provided that doesn't exist

Ash.Error.Invalid.NoSuchResource

Used when a resource or alias is provided that doesn't exist

Ash.Error.Invalid.PageRequiresPagination

Used when page option is passed but pagination is not enabled.

Ash.Error.Invalid.PaginationRequired

Used when `page: false` is provided but pagination is required

Ash.Error.Invalid.TenantRequired

Used when a tenant is not specified

Ash.Error.Invalid.Timeout

Used when a request to the api times out.

Ash.Error.Invalid.TimeoutNotSupported

Used when timeouts are not supported by the data layer, but one is set

Ash.Error.Load.InvalidQuery

Used when an invalid query is provided in a load

Ash.Error.Load.NoSuchRelationship

Used when attempting to load a relationship that does not exist

Ash.Error.Page.InvalidKeyset

Used when a value is provided for a keyset that cannot be Base64 decoded.

Ash.Error.Query.AggregatesNotSupported

Used when the data_layer does not support aggregates, or filtering/sorting them

Ash.Error.Query.CalculationsNotSupported

Used when the data_layer does not support calculations, or filtering/sorting them

Ash.Error.Query.InvalidArgument

Used when an invalid value is provided for an action argument

Ash.Error.Query.InvalidCalculationArgument

Used when an invalid value is provided for a calculation argument

Ash.Error.Query.InvalidExpression

Used when an invalid expression is used in a filter

Ash.Error.Query.InvalidFilterReference

Used when an invalid reference is used in a filter

Ash.Error.Query.InvalidFilterValue

Used when an invalid value is provided for a filter

Ash.Error.Query.InvalidLimit

Used when an invalid limit is provided

Ash.Error.Query.InvalidLoad

Used when an invalid load is provided

Ash.Error.Query.InvalidOffset

Used when an invalid offset is provided

Ash.Error.Query.InvalidQuery

A generic error that can be used to add an error to a query for a specific field

Ash.Error.Query.InvalidSortOrder

Used when an invalid sort order is provided

Ash.Error.Query.NoComplexSortsWithKeysetPagination

Due to the filter-based implementation of keyset pagination, it cannot be used with sorts on calculations.

Ash.Error.Query.NoReadAction

Used when a resource would be read but has no read action

Ash.Error.Query.NoSuchAttribute

Used when an attribute that doesn't exist is used in a query

Ash.Error.Query.NoSuchAttributeOrRelationship

Used when a key in a filter contains something that is neither an attribute or a relationship

Ash.Error.Query.NoSuchFilterPredicate

Used when a filter predicate that does not exist is referenced

Ash.Error.Query.NoSuchFunction

Used when an function that doesn't exist is used in a query

Ash.Error.Query.NoSuchOperator

Used when an operator that doesn't exist is used in a query

Ash.Error.Query.NoSuchRelationship

Used when an relationship that doesn't exist is used in a query

Ash.Error.Query.NotFound

Used when an entity that not exist is referenced

Ash.Error.Query.ReadActionRequired

Used when a relationship is filtered and the destination does not have a default read action

Ash.Error.Query.ReadActionRequiresActor

Used when an actor is referenced in a filter template, but no actor exists

Ash.Error.Query.Required

Used when a filter or argument is required in a query

Ash.Error.Query.UnsortableAttribute

Used when attempting to sort on a field that cannot be used for sorting

Ash.Error.Query.UnsupportedPredicate

Used when the data_layer does not support a provided predicate

Ash.Error.SimpleDataLayer.NoDataProvided

Used when no data was provided to the simple data layer

Ash.Error.Stacktrace

A placeholder for a stacktrace so that we can avoid printing it everywhere

Ash.Error.Unknown

The top level unknown error container

Ash.Error.Unknown.UnknownError

Used when an unknown error occurs

Ash.Expr

Tools to build Ash expressions

Ash.Filter

The representation of a filter in Ash.

Ash.Filter.Predicate

Represents a predicate which can be simplified and/or compared with other predicates

Ash.Filter.Runtime

Checks a record to see if it matches a filter statement.

Ash.Filter.Simple

Represents a simplified filter, with a simple list of predicates

Ash.Filter.Simple.Not

A negated predicate

Ash.Filter.TemplateHelpers

Helpers for building filter templates

Ash.Flags

Feature flagging support for Ash internals.

Ash.Flow

A flow is a static definition of a set of steps to be run.

Ash.Flow.Argument

An argument to a flow

Ash.Flow.Chart.Mermaid

Tools to render an Ash.Flow as a mermaid chart.

Ash.Flow.Dsl

The built in flow DSL.

Ash.Flow.Executor

A flow executor runs a given flow module

Ash.Flow.Executor.AshEngine

Executes the requests using the Ash engine, which can parallelize individual steps when possible.

Ash.Flow.Info

Flow introspection functions.

Ash.Flow.Result

The result of running a flow.

Ash.Flow.Step

A behaviour for implementing a custom step in a flow.

Ash.Flow.StepHelpers

Template functions available while declaring steps.

Ash.Flow.Template

Helpers for working with Ash.Flow templates.

Ash.Flow.Transformers.SetApi

Sets the api on the steps of a flow to the default api, unless an api is set explicitly.

Ash.Flow.Verifiers.ValidateNoEmptySteps

Validates that no nested steps contain no steps

Ash.Flow.Verifiers.ValidateUniqueNames

Validates that steps have unique names.

Ash.Flow.Verifiers.VerifyReturn

Ensures that all steps in a return statement are returnable

Ash.Generator

Tools for generating input to Ash resource actions, as well as for seeds.

Ash.NotLoaded

Used when an aggregate or relationship hasn't been loaded.

Ash.Notifier

A notifier is an extension that receives various events

Ash.Notifier.Notification

Represents a notification that will be handled by a resource's notifiers

Ash.Notifier.PubSub

A pubsub notifier extension.

Ash.Notifier.PubSub.Info

Introspection helpers for Ash.Notifier.PubSub

Ash.OptionsHelpers

Helpers for working with nimble options

Ash.Page

Types for Ash pages

Ash.Page.Keyset

A page of results from `keyset` based pagination.

Ash.Page.Offset

A page of results from `offset` based pagination.

Ash.PlugHelpers

Helpers for working with the Plug connection.

Ash.Policy.Authorizer

An authorization extension for ash resources.

Ash.Policy.Check

A behaviour for declaring checks, which can be used to easily construct authorization rules.

Ash.Policy.Check.Builtins

The global authorization checks built into ash

Ash.Policy.Check.Expression

The check module used for `expr`s in policies

Ash.Policy.FilterCheck

A type of check that is represented by a filter statement

Ash.Policy.FilterCheckWithContext

A type of check that is represented by a filter statement, and has access to the context.

Ash.Policy.Info

An authorization extension for ash resources.

Ash.Policy.SimpleCheck

A type of check that operates only on request context, never on the data

Ash.Query

Utilities around constructing/manipulating ash queries.

Ash.Query.Aggregate

Represents an aggregated association value

Ash.Query.BooleanExpression

Represents a boolean expression

Ash.Query.Calculation

Represents a calculated attribute requested on a query

Ash.Query.Call

Represents a function call/AST node in an Ash query expression

Ash.Query.Exists

Determines if a given related entity exists.

Ash.Query.Function

A function is a predicate with an arguments list.

Ash.Query.Function.Ago

Subtracts the given interval from the current time in UTC.

Ash.Query.Function.Contains

Returns true if the first string contains the second.

Ash.Query.Function.DateAdd

Adds the given interval to the current time in UTC

Ash.Query.Function.DateTimeAdd

Adds the given interval to the current time in UTC

Ash.Query.Function.FromNow

Adds the given interval from the current time in UTC.

Ash.Query.Function.GetPath

Gets the value at the provided path in the value, which must be a map or embed.

Ash.Query.Function.If

If predicate is truthy, then the second argument is returned, otherwise the third.

Ash.Query.Function.IsNil

true if the provided field is nil

Ash.Query.Function.Length

Returns the length of a list attribute defined by the composite type `{:array, Type}`.

Ash.Query.Function.Now

Returns the current datetime

Ash.Query.Function.StringJoin

Joins a list of values.

Ash.Query.Function.Today

Returns the current datetime

Ash.Query.Function.Type

Casts the value to a given type. Can also be used to provide type hints to data layers, where appropriate.

Ash.Query.Not

Represents the negation of the contained expression

Ash.Query.Operator

An operator is a predicate with a `left` and a `right`

Ash.Query.Operator.Basic
Ash.Query.Operator.Eq

left == right

Ash.Query.Operator.GreaterThan

left > right

Ash.Query.Operator.GreaterThanOrEqual

left >= right

Ash.Query.Operator.In

left in [1, 2, 3]

Ash.Query.Operator.IsNil

left is_nil true/false

Ash.Query.Operator.LessThan

left < right

Ash.Query.Operator.LessThanOrEqual

left <= right

Ash.Query.Operator.NotEq

left != right

Ash.Query.Parent

true if the provided field is nil Used to access values from the "source" of a given expression.

Ash.Query.Ref

Represents a relation/attribute reference

Ash.Registry

A registry allows you to separate your resources from your `api` module, to reduce improve compile times and reduce compile time dependencies.

Ash.Registry.Dsl

A small DSL for declaring an `Ash.Registry`.

Ash.Registry.Info

Introspection helpers for `Ash.Registry`

Ash.Registry.ResourceValidations

Adds some top level validations of resources present in a registry

Ash.Registry.ResourceValidations.Verifiers.EnsureNoEmbeds

Ensures that all resources for a given registry are not embeds.

Ash.Registry.ResourceValidations.Verifiers.EnsureResourcesCompiled

Ensures that all resources for a given registry are compiled.

Ash.Registry.ResourceValidations.Verifiers.ValidateRelatedResourceInclusion

Ensures that all related resources are included in an API.

Ash.Registry.Transformers.WarnOnEmpty

Warns if a registry has no entries in it

Ash.Resource

A resource is a static definition of an entity in your system.

Ash.Resource.Actions

Types for Ash actions

Ash.Resource.Actions.Argument

Represents an argument to an action

Ash.Resource.Actions.Create

Represents a create action on a resource.

Ash.Resource.Actions.Destroy

Represents a destroy action on a resource.

Ash.Resource.Actions.Metadata

Represents metadata from an action

Ash.Resource.Actions.Read

Represents a read action on a resource.

Ash.Resource.Actions.Read.Pagination

Represents the pagination configuration of a read action

Ash.Resource.Actions.Update

Represents a update action on a resource.

Ash.Resource.Aggregate

Represents a named aggregate on the resource that can be loaded

Ash.Resource.Aggregate.CustomAggregate

The root behavior for a custom aggregate.

Ash.Resource.Attribute

Represents an attribute on a resource

Ash.Resource.Attribute.Helpers

Helpers for building attributes

Ash.Resource.Builder

Tools for transforming resources in DSL Transformers.

Ash.Resource.Calculation

Represents a named calculation on a resource

Ash.Resource.Calculation.Argument

An argument to a calculation

Ash.Resource.Calculation.Builtins

Built in calculations that are automatically imported in the calculations section

Ash.Resource.CalculationInterface

Represents a function that evaluates a calculation in a resource's code interface

Ash.Resource.Change

The behaviour for an action-specific resource change.

Ash.Resource.Change.Builtins

Built in changes that are available to all resources

Ash.Resource.Dsl

The built in resource DSL.

Ash.Resource.Identity

Represents a unique constraint on a resource

Ash.Resource.Info

Introspection for resources

Ash.Resource.Interface

Represents a function in a resource's code interface

Ash.Resource.ManualCreate

A module to implement manual create actions.

Ash.Resource.ManualDestroy

A module to implement manual destroy actions.

Ash.Resource.ManualRead

A module to implement manual read actions.

Ash.Resource.ManualRelationship

A module to implement manual relationships.

Ash.Resource.ManualUpdate

A module to implement manual update actions.

Ash.Resource.Preparation

The behaviour for an action-specific query preparation.

Ash.Resource.Preparation.Builtins

Builtin query preparations

Ash.Resource.Relationships

Types Ash relationships

Ash.Resource.Relationships.BelongsTo

Represents a belongs_to relationship on a resource

Ash.Resource.Relationships.HasMany

Represents a has_many relationship on a resource

Ash.Resource.Relationships.HasOne

Represents a has_one relationship on a resource

Ash.Resource.Relationships.ManyToMany

Represents a many_to_many relationship on a resource

Ash.Resource.Transformers.BelongsToAttribute

Creates the attribute for belongs_to relationships that have `define_attribute?: true`

Ash.Resource.Transformers.BelongsToSourceField

Sets the default `source_attribute` for belongs_to attributes

Ash.Resource.Transformers.CachePrimaryKey

Validates and caches the primary key of a resource

Ash.Resource.Transformers.CountableActions

Ensures that countable paginated actions do not exist for resources that are not countable

Ash.Resource.Transformers.CreateJoinRelationship

Creates an automatically named `has_many` relationship for each many_to_many.

Ash.Resource.Transformers.DefaultAccept

Sets the default `accept` for each action

Ash.Resource.Transformers.DefaultPrimaryKey

Creates the default primary key if one applies.

Ash.Resource.Transformers.GetByReadActions

Transform any read actions which contain a `get_by` option.

Ash.Resource.Transformers.HasDestinationField

Guesses the `destination_attribute` for has many and has one relationships unless provided

Ash.Resource.Transformers.NoReservedFieldNames

Confirms that a resource does not use reserved names for field names.

Ash.Resource.Transformers.RequireUniqueActionNames

Ensures that all actions have unique names.

Ash.Resource.Transformers.RequireUniqueFieldNames

Confirms that a resource does not have multiple fields(attributes, calculations, aggregates, and relationships) with the same name.

Ash.Resource.Transformers.SetRelationshipSource

Sets the `source` key on relationships to be the resource they were defined on

Ash.Resource.Transformers.ValidateAccept

Validates that accept and reject lists only contain valid attributes

Ash.Resource.Transformers.ValidateActionTypesSupported

Confirms that all action types declared on a resource are supported by its data layer

Ash.Resource.Transformers.ValidateAggregatesSupported

Confirms that all aggregates are supported by the data layer

Ash.Resource.Transformers.ValidateEagerIdentities

Confirms that eager identities are not declared on a resource with no primary read.

Ash.Resource.Transformers.ValidateManagedRelationshipOpts

Confirms that all action types declared on a resource are supported by its data layer

Ash.Resource.Transformers.ValidateMultitenancy

Ensures that the multitenancy configuration is valid for the given resource

Ash.Resource.Transformers.ValidatePrimaryActions

Validates the primary action configuration

Ash.Resource.Transformers.ValidatePrimaryKey

Validates and caches the primary key of a resource

Ash.Resource.Transformers.ValidateRelationshipAttributes

Validates that all relationships point to valid fields

Ash.Resource.Validation

Represents a validation in Ash.

Ash.Resource.Validation.ActionIs

Validates that the action is the specified action.

Ash.Resource.Validation.Builtins

Built in validations that are available to all resources

Ash.Resource.Verifiers.ValidateRelationshipAttributesMatch

Shows a warning on potentially incompatible relationship attributes.

Ash.SatSolver

Tools for working with the satsolver that drives filter subset checking (for authorization)

Ash.Seed

Helpers for seeding data, useful for quickly creating lots of data either for database seeding or testing.

Ash.Sort

Utilities and types for sorting.

Ash.Test

Testing helpers for Ash.

Ash.Tracer

A behaviour for implementing tracing for an Ash application.

Ash.Tracer.Simple

A simple tracer that can send traces to the current process or call a module with the trace.

Ash.Tracer.Simple.Span

A span produced by `Ash.Tracer.Simple`

Ash.Type

Describes how to convert data to `Ecto.Type` and eventually into the database.

Ash.Type.Atom

Stores an atom as a string in the database

Ash.Type.Binary

Represents a binary.

Ash.Type.Boolean

Represents a boolean.

Ash.Type.CiString

Stores a case insensitive string in the database

Ash.Type.Comparable

Helpers for working with `Comparable`

Ash.Type.Date

Represents a date in the database

Ash.Type.Decimal

Represents a decimal.

Ash.Type.DurationName

An interval of time, primarily meant to be used in expression functions

Ash.Type.Enum

A type for abstracting enums into a single type.

Ash.Type.Float

Represents a float (floating point number)

Ash.Type.Function

Represents a function.

Ash.Type.Integer

Represents a simple integer

Ash.Type.Map

Represents a map stored in the database.

Ash.Type.NaiveDatetime

Represents a Naive datetime

Ash.Type.NewType

Allows defining a new type that is the combination of an existing type and custom constraints

Ash.Type.String

Stores a string in the database.

Ash.Type.Struct

Represents a struct.

Ash.Type.Term

Represents a raw elixir term in the database

Ash.Type.Time

Represents a time in the database

Ash.Type.UUID

Represents a UUID.

Ash.Type.Union

A union between multiple types, distinguished with a tag or by attempting to validate.

Ash.Type.UrlEncodedBinary

Represents a binary that attempts to decode input strings as a url encoded base64 string.

Ash.Type.UtcDatetime

Represents a utc datetime

Ash.Type.UtcDatetimeUsec

Represents a utc datetime with microsecond precision.

Ash.UUID

Helpers for working with UUIDs

Ash.Union

A wrapper for values that are sourced from `Ash.Type.Union`.

Comparable.Type.Ash.CiString.To.Ash.CiString
Comparable.Type.Ash.CiString.To.BitString
Comparable.Type.BitString.To.Ash.CiString
Comparable.Type.BitString.To.Decimal
Comparable.Type.Decimal.To.BitString
Comparable.Type.Decimal.To.Decimal
Comparable.Type.Decimal.To.Float
Comparable.Type.Decimal.To.Integer
Comparable.Type.Float.To.Decimal
Comparable.Type.Integer.To.Decimal
Mix.Mermaid

Mermaid Diagram helper functions.

##

mix-tasks

Mix Tasks

mix ash.generate_flow_charts

Generates a Mermaid Flow Chart for each `Ash.Flow` alongside the flow.

mix ash.generate_livebook

Generates a Livebook for each Ash API.

mix ash.generate_resource_diagrams

Generates a Mermaid Resource Diagram for each Ash API.

mix ash.replace_doc_links

Replaces any documentation links with text appropriate for hex docs.

Next Page → Extending Resources