#
View Source Ash.Resource.Info (ash v2.4.22)

Introspection for resources

# Link to this section Summary

## Functions

action(resource, name, type \\ nil)

Returns the action with the matching name and type on the resource

actions(resource)

Returns all actions of a resource

aggregate(resource, name)

Get an aggregate by name

aggregate_type(resource, aggregate)

Gets the type of an aggregate for a given resource.

aggregates(resource)

Returns all aggregates of a resource

attribute(resource, name)

Get an attribute name from the resource

attributes(resource)

Returns all attributes of a resource

authorizers(resource)

A list of authorizers to be used when accessing

base_filter(resource)

The base filter of the resource

calculation(resource, name)

Get a calculation by name

calculations(resource)

Returns all calculations of a resource

changes(resource)

A list of all changes for the resource

changes(resource, type)

A list of all changes for the resource for a given action type

default_actions(resource)

Returns the configured default actions

default_context(resource)

The default context of the resource

define_interface_for(resource)

The Api to define the interface for, when defining it in the resource

description(resource)

The description of the resource

embedded?(resource)

Whether or not the resource is an embedded resource

field(resource, name)

Get a field from a resource by name

get_metadata(record, key_or_path) deprecated

See `Ash.Resource.get_metadata/2`.

identities(resource)

A list of identities for the resource

identity(resource, name)

Get an identity by name from the resource

interfaces(resource)

The list of code interface definitions.

multitenancy_attribute(resource)

The multitenancy attribute for a resource

multitenancy_global?(resource)

The MFA to parse the tenant from the attribute

multitenancy_parse_attribute(resource)

The function to parse the tenant from the attribute

multitenancy_strategy(resource)

The multitenancy strategy for a resource

multitenancy_template(resource)

The template for creating the tenant name

notifiers(resource)

A list of notifiers to be used when accessing

preparations(resource)
primary_action!(resource, type)

Returns the primary action of the given type

primary_action(resource, type)

Returns the primary action of a given type

primary_key(resource)

A list of field names corresponding to the primary key

primary_key_simple_equality?(resource)

Wether or not all primary key attributes can be compared with simple_equality

public_aggregate(resource, name)

Get an aggregate by name

public_aggregates(resource)

Returns all public aggregates of a resource

public_attribute(resource, name)

Get a public attribute name from the resource

public_attributes(resource)

Returns all public attributes of a resource

public_calculation(resource, name)

Get a public calculation by name

public_calculations(resource)

Returns all public calculations of a resource

public_field(resource, name)

Get a public field from a resource by name

public_relationship(resource, relationship_name)

Get a public relationship by name or path

public_relationships(resource)

Returns all public relationships of a resource

put_metadata(record, key, term) deprecated

See `Ash.Resource.put_metadata/3`.

related(resource, relationship)
relationship(resource, relationship_name)

Get a relationship by name or path

relationships(resource)

Returns all relationships of a resource

resource?(module)

Whether or not a given module is a resource module

reverse_relationship(resource, path, acc \\ [])

Retrieves a relationship path from the resource related by path, to the provided resource.

selected?(record, field) deprecated

See `Ash.Resource.selected?/2`.

set_metadata(record, map) deprecated

See `Ash.Resource.set_metadata/2`.

short_name(resource)

The short_name of the resource

sortable?(resource, name, opts \\ [])

Determine if a field is sortable by name

trace_name(resource)

The trace_name of the resource

unload(record, key_or_path) deprecated

See `Ash.Resource.unload/2`.

unload_many(record, loads) deprecated

See `Ash.Resource.unload_many/2`.

validations(resource)

A list of all validations for the resource

validations(resource, type)

A list of all validations for the resource for a given action type

# Link to this section Functions

Link to this function

# action(resource, name, type \\ nil)

View Source

    @spec action(
      Spark.Dsl.t() | Ash.Resource.t(),
      atom(),
      Ash.Resource.Actions.action_type() | nil
    ) ::
      Ash.Resource.Actions.action() | nil

Returns the action with the matching name and type on the resource

Link to this function

# actions(resource)

View Source

    @spec actions(Spark.Dsl.t() | Ash.Resource.t()) :: [Ash.Resource.Actions.action()]

Returns all actions of a resource

Link to this function

# aggregate(resource, name)

View Source

    @spec aggregate(Spark.Dsl.t() | Ash.Resource.t(), atom() | String.t()) ::
      Ash.Resource.Aggregate.t() | nil

Get an aggregate by name

Link to this function

# aggregate_type(resource, aggregate)

View Source

    @spec aggregate_type(
      Spark.Dsl.t() | Ash.Resource.t(),
      Ash.Resource.Aggregate.t() | atom()
    ) ::
      {:ok, Ash.Type.t()} | {:error, String.t()}

Gets the type of an aggregate for a given resource.

Link to this function

# aggregates(resource)

View Source

    @spec aggregates(Spark.Dsl.t() | Ash.Resource.t()) :: [Ash.Resource.Aggregate.t()]

Returns all aggregates of a resource

Link to this function

# attribute(resource, name)

View Source

    @spec attribute(Spark.Dsl.t() | Ash.Resource.t(), String.t() | atom()) ::
      Ash.Resource.Attribute.t() | nil

Get an attribute name from the resource

Link to this function

# attributes(resource)

View Source

    @spec attributes(Spark.Dsl.t() | Ash.Resource.t()) :: [Ash.Resource.Attribute.t()]

Returns all attributes of a resource

Link to this function

# authorizers(resource)

View Source

    @spec authorizers(Spark.Dsl.t() | Ash.Resource.t()) :: [module()]

A list of authorizers to be used when accessing

Link to this function

# base_filter(resource)

View Source

    @spec base_filter(Spark.Dsl.t() | Ash.Resource.t()) :: term()

The base filter of the resource

Link to this function

# calculation(resource, name)

View Source

    @spec calculation(Spark.Dsl.t() | Ash.Resource.t(), atom() | String.t()) ::
      Ash.Resource.Calculation.t() | nil

Get a calculation by name

Link to this function

# calculations(resource)

View Source

    @spec calculations(Spark.Dsl.t() | Ash.Resource.t()) :: [Ash.Resource.Calculation.t()]

Returns all calculations of a resource

Link to this function

# changes(resource)

View Source

    @spec changes(Spark.Dsl.t() | Ash.Resource.t()) :: [
      Ash.Resource.Validation.t() | Ash.Resource.Change.t()
    ]

A list of all changes for the resource

Link to this function

# changes(resource, type)

View Source

    @spec changes(Spark.Dsl.t() | Ash.Resource.t(), :create | :update | :destroy) :: [
      Ash.Resource.Validation.t() | Ash.Resource.Change.t()
    ]

A list of all changes for the resource for a given action type

Link to this function

# default_actions(resource)

View Source

    @spec default_actions(Spark.Dsl.t() | Ash.Resource.t()) :: [
      :create | :read | :update | :destroy
    ]

Returns the configured default actions

Link to this function

# default_context(resource)

View Source

    @spec default_context(Spark.Dsl.t() | Ash.Resource.t()) :: term()

The default context of the resource

Link to this function

# define_interface_for(resource)

View Source

    @spec define_interface_for(Spark.Dsl.t() | Ash.Resource.t()) :: atom() | nil

The Api to define the interface for, when defining it in the resource

Link to this function

# description(resource)

View Source

    @spec description(Spark.Dsl.t() | Ash.Resource.t()) :: String.t() | nil

The description of the resource

Link to this function

# embedded?(resource)

View Source

    @spec embedded?(Spark.Dsl.t() | Ash.Resource.t()) :: boolean()

Whether or not the resource is an embedded resource

Link to this function

# field(resource, name)

View Source

    @spec field(Spark.Dsl.t() | Ash.Resource.t(), String.t() | atom()) ::
      Ash.Resource.Attribute.t()
      | Ash.Resource.Aggregate.t()
      | Ash.Resource.Calculation.t()
      | Ash.Resource.Relationships.relationship()
      | nil

Get a field from a resource by name

Link to this function

# get_metadata(record, key_or_path)

View Source
This function is deprecated. Use `Ash.Resource.get_metadata/2` instead.

See `Ash.Resource.get_metadata/2`.

Link to this function

# identities(resource)

View Source

    @spec identities(Spark.Dsl.t() | Ash.Resource.t()) :: [Ash.Resource.Identity.t()]

A list of identities for the resource

Link to this function

# identity(resource, name)

View Source

    @spec identity(Spark.Dsl.t() | Ash.Resource.t(), atom()) ::
      Ash.Resource.Identity.t() | nil

Get an identity by name from the resource

Link to this function

# interfaces(resource)

View Source

    @spec interfaces(Spark.Dsl.t() | Ash.Resource.t()) :: [Ash.Resource.Interface.t()]

The list of code interface definitions.

Link to this function

# multitenancy_attribute(resource)

View Source

    @spec multitenancy_attribute(Spark.Dsl.t() | Ash.Resource.t()) :: atom() | nil

The multitenancy attribute for a resource

Link to this function

# multitenancy_global?(resource)

View Source

    @spec multitenancy_global?(Spark.Dsl.t() | Ash.Resource.t()) :: atom() | nil

The MFA to parse the tenant from the attribute

Link to this function

# multitenancy_parse_attribute(resource)

View Source

    @spec multitenancy_parse_attribute(Spark.Dsl.t() | Ash.Resource.t()) ::
      {atom(), atom(), [any()]}

The function to parse the tenant from the attribute

Link to this function

# multitenancy_strategy(resource)

View Source

    @spec multitenancy_strategy(Spark.Dsl.t() | Ash.Resource.t()) ::
      :context | :attribute | nil

The multitenancy strategy for a resource

Link to this function

# multitenancy_template(resource)

View Source

    @spec multitenancy_template(Spark.Dsl.t() | Ash.Resource.t()) :: atom() | nil

The template for creating the tenant name

Link to this function

# notifiers(resource)

View Source

    @spec notifiers(Spark.Dsl.t() | Ash.Resource.t()) :: [module()]

A list of notifiers to be used when accessing

Link to this function

# preparations(resource)

View Source

    @spec preparations(Spark.Dsl.t() | Ash.Resource.t()) :: [Ash.Resource.Preparation.t()]

Link to this function

# primary_action!(resource, type)

View Source

    @spec primary_action!(
      Spark.Dsl.t() | Ash.Resource.t(),
      Ash.Resource.Actions.action_type()
    ) ::
      Ash.Resource.Actions.action() | no_return()

Returns the primary action of the given type

Link to this function

# primary_action(resource, type)

View Source

    @spec primary_action(
      Spark.Dsl.t() | Ash.Resource.t(),
      Ash.Resource.Actions.action_type()
    ) ::
      Ash.Resource.Actions.action() | nil

Returns the primary action of a given type

Link to this function

# primary_key(resource)

View Source

    @spec primary_key(Spark.Dsl.t() | Ash.Resource.t()) :: [atom()]

A list of field names corresponding to the primary key

Link to this function

# primary_key_simple_equality?(resource)

View Source

    @spec primary_key_simple_equality?(Spark.Dsl.t() | Ash.Resource.t()) :: boolean()

Wether or not all primary key attributes can be compared with simple_equality

Link to this function

# public_aggregate(resource, name)

View Source

    @spec public_aggregate(Spark.Dsl.t() | Ash.Resource.t(), atom() | String.t()) ::
      Ash.Resource.Aggregate.t() | nil

Get an aggregate by name

Link to this function

# public_aggregates(resource)

View Source

    @spec public_aggregates(Spark.Dsl.t() | Ash.Resource.t()) :: [
      Ash.Resource.Aggregate.t()
    ]

Returns all public aggregates of a resource

Link to this function

# public_attribute(resource, name)

View Source

    @spec public_attribute(Spark.Dsl.t() | Ash.Resource.t(), String.t() | atom()) ::
      Ash.Resource.Attribute.t() | nil

Get a public attribute name from the resource

Link to this function

# public_attributes(resource)

View Source

    @spec public_attributes(Spark.Dsl.t() | Ash.Resource.t()) :: [
      Ash.Resource.Attribute.t()
    ]

Returns all public attributes of a resource

Link to this function

# public_calculation(resource, name)

View Source

    @spec public_calculation(Spark.Dsl.t() | Ash.Resource.t(), atom() | String.t()) ::
      Ash.Resource.Calculation.t() | nil

Get a public calculation by name

Link to this function

# public_calculations(resource)

View Source

    @spec public_calculations(Spark.Dsl.t() | Ash.Resource.t()) :: [
      Ash.Resource.Calculation.t()
    ]

Returns all public calculations of a resource

Link to this function

# public_field(resource, name)

View Source

    @spec public_field(Spark.Dsl.t() | Ash.Resource.t(), String.t() | atom()) ::
      Ash.Resource.Attribute.t()
      | Ash.Resource.Aggregate.t()
      | Ash.Resource.Calculation.t()
      | Ash.Resource.Relationships.relationship()
      | nil

Get a public field from a resource by name

Link to this function

# public_relationship(resource, relationship_name)

View Source

Get a public relationship by name or path

Link to this function

# public_relationships(resource)

View Source

    @spec public_relationships(Spark.Dsl.t() | Ash.Resource.t()) :: [
      Ash.Resource.Relationships.relationship()
    ]

Returns all public relationships of a resource

Link to this function

# put_metadata(record, key, term)

View Source
This function is deprecated. Use `Ash.Resource.put_metadata/3` instead.

See `Ash.Resource.put_metadata/3`.

Link to this function

# related(resource, relationship)

View Source

    @spec related(
      Spark.Dsl.t() | Ash.Resource.t(),
      atom() | String.t() | [atom() | String.t()]
    ) ::
      Ash.Resource.t() | nil

Link to this function

# relationship(resource, relationship_name)

View Source

    @spec relationship(
      Spark.Dsl.t() | Ash.Resource.t(),
      atom() | String.t() | [atom() | String.t()]
    ) ::
      Ash.Resource.Relationships.relationship() | nil

Get a relationship by name or path

Link to this function

# relationships(resource)

View Source

    @spec relationships(Spark.Dsl.t() | Ash.Resource.t()) :: [
      Ash.Resource.Relationships.relationship()
    ]

Returns all relationships of a resource

Link to this function

# resource?(module)

View Source

    @spec resource?(module()) :: boolean()

Whether or not a given module is a resource module

Link to this function

# reverse_relationship(resource, path, acc \\ [])

View Source

Retrieves a relationship path from the resource related by path, to the provided resource.

Link to this function

# selected?(record, field)

View Source
This function is deprecated. Use `Ash.Resource.selected?/2` instead.

See `Ash.Resource.selected?/2`.

Link to this function

# set_metadata(record, map)

View Source
This function is deprecated. Use `Ash.Resource.set_metadata/2` instead.

See `Ash.Resource.set_metadata/2`.

Link to this function

# short_name(resource)

View Source

    @spec short_name(Spark.Dsl.t() | Ash.Resource.t()) :: String.t() | nil

The short_name of the resource

Link to this function

# sortable?(resource, name, opts \\ [])

View Source

    @spec sortable?(Spark.Dsl.t() | Ash.Resource.t(), String.t() | atom(),
      pagination_type: Ash.Page.type(),
      include_private?: boolean()
    ) :: boolean()

Determine if a field is sortable by name

Link to this function

# trace_name(resource)

View Source

    @spec trace_name(Spark.Dsl.t() | Ash.Resource.t()) :: String.t() | nil

The trace_name of the resource

Link to this function

# unload(record, key_or_path)

View Source
This function is deprecated. Use `Ash.Resource.unload/2` instead.

See `Ash.Resource.unload/2`.

Link to this function

# unload_many(record, loads)

View Source
This function is deprecated. Use `Ash.Resource.unload_many/2` instead.

See `Ash.Resource.unload_many/2`.

Link to this function

# validations(resource)

View Source

    @spec validations(Spark.Dsl.t() | Ash.Resource.t()) :: [Ash.Resource.Validation.t()]

A list of all validations for the resource

Link to this function

# validations(resource, type)

View Source

    @spec validations(Spark.Dsl.t() | Ash.Resource.t(), :create | :update | :destroy) :: [
      Ash.Resource.Validation.t()
    ]

A list of all validations for the resource for a given action type