View Source Ash.Resource.Info (ash v3.4.28)

Introspection for resources

Summary

Functions

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

Returns true or false if the input is accepted by the action, as an argument or an attribute

Returns the list of possible accepted keys by an action

Returns the list of attributes that must be selected for an action invocation

Returns all actions of a resource

Get an aggregate by name

Gets the type of an aggregate for a given resource.

Returns all aggregates of a resource

Get an attribute name from the resource

Returns all attributes of a resource

A list of authorizers to be used when accessing

The base filter of the resource

Get a calculation by name

Get an calculation interface by name from the resource

The list of code interface calculation definitions.

Returns all calculations of a resource

A list of all changes for the resource

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

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

The data layer of the resource, or nil if it does not have one

Returns the configured default actions

The default context of the resource

Whether or not to define the interface on the resource

The description of the resource

Returns the statically configured domain for the resource.

Whether or not the resource is an embedded resource

Get a field from a resource by name

Returns all attributes, aggregates, calculations and relationships of a resource

A list of identities for the resource

Get an identity by name from the resource

Get an interface by name from the resource

The list of code interface definitions.

Returns all attributes of a resource with lazy matching defaults

Returns all attributes of a resource with lazy non-matching-defaults

The multitenancy attribute for a resource

The MFA to parse the tenant from the attribute

The function to parse the tenant from the attribute

The multitenancy strategy for a resource

The template for creating the tenant name

A list of notifiers to be used when accessing

The plural_name of the resource

Returns the primary action of a given type

Returns the primary action of the given type

A list of field names corresponding to the primary key

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

Get an aggregate by name

Returns all public aggregates of a resource

Get a public attribute name from the resource

Returns all public attributes of a resource

Get a public calculation by name

Returns all public calculations of a resource

Get a public field from a resource by name

Returns all public attributes, aggregates, calculations and relationships of a resource

Get a public relationship by name or path

Returns all public relationships of a resource

Get a relationship by name or path

Returns all relationships of a resource

The required belongs_to relationships

Whether or not a given module is a resource module

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

The short_name of the resource

A list of simple notifiers (require no DSL, used to avoid compile time dependencies)

Determine if a field is sortable by name

Returns all attributes of a resource with static defaults

The trace_name of the resource

A list of unique keys and information for a resource

A list of all validations for the resource

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

Functions

Link to this function

action(resource, name, type \\ nil)

View Source

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

Link to this function

action_input?(resource, action, input)

View Source
@spec action_input?(Ash.Resource.t(), action :: atom(), input :: atom() | String.t()) ::
  boolean()

Returns true or false if the input is accepted by the action, as an argument or an attribute

Link to this function

action_inputs(resource, action)

View Source
@spec action_inputs(Ash.Resource.t(), action :: atom()) :: MapSet.t()

Returns the list of possible accepted keys by an action

Link to this function

action_select(resource, action)

View Source
@spec action_select(
  Ash.Resource.t(),
  action :: atom() | Ash.Resource.Actions.action()
) ::
  [atom()] | nil

Returns the list of attributes that must be selected for an action invocation

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.

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

Returns all aggregates of a resource

Link to this function

always_selected_attribute_names(resource)

View Source
@spec always_selected_attribute_names(Spark.Dsl.t() | Ash.Resource.t()) :: MapSet.t()
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

attribute_names(resource)

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

Returns all attributes of a resource

Link to this function

attributes_to_require(resource)

View Source
Link to this function

attributes_to_require(resource, action_name)

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

A list of authorizers to be used when accessing

@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

calculation_interface(resource, name)

View Source
@spec calculation_interface(Spark.Dsl.t() | Ash.Resource.t(), atom()) ::
  Ash.Resource.CalculationInterface.t() | nil

Get an calculation interface by name from the resource

Link to this function

calculation_interfaces(resource)

View Source
@spec calculation_interfaces(Spark.Dsl.t() | Ash.Resource.t()) :: [
  Ash.Resource.CalculationInterface.t()
]

The list of code interface calculation definitions.

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

Returns all calculations of a resource

A list of all changes for the resource

@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

code_interface_domain(resource)

View Source
@spec code_interface_domain(Spark.Dsl.t() | Ash.Resource.t()) :: atom() | nil

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

@spec data_layer(Ash.Resource.t()) :: Ash.DataLayer.t() | nil

The data layer of the resource, or nil if it does not have one

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?(resource)

View Source
@spec define_interface?(Spark.Dsl.t() | Ash.Resource.t()) :: boolean()

Whether or not to define the interface on the resource

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

The description of the resource

Returns the statically configured domain for the resource.

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

Whether or not the resource is an embedded resource

Get a field from a resource by name

Link to this function

fields(resource, types \\ [:attributes, :aggregates, :calculations, :relationships])

View Source
@spec fields(
  Spark.Dsl.t() | Ash.Resource.t(),
  types :: [:attributes | :aggregates | :calculations | :relationships]
) :: [
  Ash.Resource.Attribute.t()
  | Ash.Resource.Aggregate.t()
  | Ash.Resource.Calculation.t()
  | Ash.Resource.Relationships.relationship()
]

Returns all attributes, aggregates, calculations and relationships of a resource

@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

interface(resource, name)

View Source
@spec interface(Spark.Dsl.t() | Ash.Resource.t(), atom()) ::
  Ash.Resource.Interface.t() | nil

Get an interface by name from the resource

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

The list of code interface definitions.

Link to this function

lazy_matching_default_attributes(resource, atom)

View Source
@spec lazy_matching_default_attributes(
  Spark.Dsl.t() | Ash.Resource.t(),
  type :: :create | :update
) :: [Ash.Resource.Attribute.t()]

Returns all attributes of a resource with lazy matching defaults

Link to this function

lazy_non_matching_default_attributes(resource, atom)

View Source
@spec lazy_non_matching_default_attributes(
  Spark.Dsl.t() | Ash.Resource.t(),
  type :: :create | :update
) :: [Ash.Resource.Attribute.t()]

Returns all attributes of a resource with lazy non-matching-defaults

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

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

A list of notifiers to be used when accessing

The plural_name of the resource

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

primary_action(resource, type)

View Source

Returns the primary action of a given type

Link to this function

primary_action!(resource, type)

View Source

Returns the primary action of the given type

@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()

Whether 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

Get a public field from a resource by name

Returns all public attributes, aggregates, calculations and relationships of a resource

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

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

Returns all relationships of a resource

Link to this function

required_belongs_to_relationships(resource)

View Source

The required belongs_to relationships

@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_by_default_attribute_names(resource)

View Source
@spec selected_by_default_attribute_names(Spark.Dsl.t() | Ash.Resource.t()) ::
  MapSet.t()
@spec short_name(Spark.Dsl.t() | Ash.Resource.t()) :: atom() | nil

The short_name of the resource

Link to this function

simple_notifiers(resource)

View Source
@spec simple_notifiers(Spark.Dsl.t() | Ash.Resource.t()) :: [module()]

A list of simple notifiers (require no DSL, used to avoid compile time dependencies)

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

static_default_attributes(resource, atom)

View Source
@spec static_default_attributes(
  Spark.Dsl.t() | Ash.Resource.t(),
  type :: :create | :update
) :: [Ash.Resource.Attribute.t()]

Returns all attributes of a resource with static defaults

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

The trace_name of the resource

@spec unique_keys(Spark.Dsl.t() | Ash.Resource.t()) :: [
  %{type: atom(), keys: [atom()], nils_distinct?: boolean()}
]

A list of unique keys and information for a resource

@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