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

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

action(resource, name, type \\ nil)

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

action_input?(resource, action, input)

@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

action_inputs(resource, action)

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

Returns the list of possible accepted keys by an action

action_select(resource, action)

@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

actions(resource)

Returns all actions of a resource

aggregate(resource, name)

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

Get an aggregate by name

aggregate_type(resource, aggregate)

@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.

aggregates(resource)

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

Returns all aggregates of a resource

always_selected_attribute_names(resource)

@spec always_selected_attribute_names(Spark.Dsl.t() | Ash.Resource.t()) :: MapSet.t()

attribute(resource, name)

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

Get an attribute name from the resource

attribute_names(resource)

@spec attribute_names(Spark.Dsl.t() | Ash.Resource.t()) :: MapSet.t()

attributes(resource)

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

Returns all attributes of a resource

attributes_to_require(resource)

attributes_to_require(resource, action_name)

authorizers(resource)

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

A list of authorizers to be used when accessing

base_filter(resource)

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

The base filter of the resource

calculation(resource, name)

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

Get a calculation by name

calculation_interface(resource, name)

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

Get an calculation interface by name from the resource

calculation_interfaces(resource)

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

The list of code interface calculation definitions.

calculations(resource)

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

Returns all calculations of a resource

changes(resource)

A list of all changes for the resource

changes(resource, type)

@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

code_interface_domain(resource)

@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

data_layer(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

default_actions(resource)

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

Returns the configured default actions

default_context(resource)

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

The default context of the resource

define_interface?(resource)

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

Whether or not to define the interface on the resource

description(resource)

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

The description of the resource

domain(resource)

Returns the statically configured domain for the resource.

embedded?(resource)

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

Whether or not the resource is an embedded resource

field(resource, name)

Get a field from a resource by name

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

@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

identities(resource)

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

A list of identities for the resource

identity(resource, name)

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

Get an identity by name from the resource

interface(resource, name)

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

Get an interface by name from the resource

interfaces(resource)

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

The list of code interface definitions.

lazy_matching_default_attributes(resource, atom)

@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

lazy_non_matching_default_attributes(resource, atom)

@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

multitenancy_attribute(resource)

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

The multitenancy attribute for a resource

multitenancy_global?(resource)

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

The MFA to parse the tenant from the attribute

multitenancy_parse_attribute(resource)

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

The function to parse the tenant from the attribute

multitenancy_strategy(resource)

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

The multitenancy strategy for a resource

multitenancy_template(resource)

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

The template for creating the tenant name

notifiers(resource)

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

A list of notifiers to be used when accessing

plural_name(resource)

The plural_name of the resource

preparations(resource)

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

primary_action(resource, type)

Returns the primary action of a given type

primary_action!(resource, type)

Returns the primary action of the given type

primary_key(resource)

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

A list of field names corresponding to the primary key

primary_key_simple_equality?(resource)

@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

public_aggregate(resource, name)

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

Get an aggregate by name

public_aggregates(resource)

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

Returns all public aggregates of a resource

public_attribute(resource, name)

@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

public_attributes(resource)

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

Returns all public attributes of a resource

public_calculation(resource, name)

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

Get a public calculation by name

public_calculations(resource)

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

Returns all public calculations of a resource

public_field(resource, name)

Get a public field from a resource by name

public_fields(resource)

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

public_relationship(resource, relationship_name)

Get a public relationship by name or path

public_relationships(resource)

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

Returns all public relationships of a resource

related(resource, relationship)

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

relationship(resource, relationship_name)

@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

relationships(resource)

Returns all relationships of a resource

required_belongs_to_relationships(resource)

The required belongs_to relationships

resource?(module)

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

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

@spec selected_by_default_attribute_names(Spark.Dsl.t() | Ash.Resource.t()) ::
  MapSet.t()

short_name(resource)

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

The short_name of the resource

simple_notifiers(resource)

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

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

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

@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

static_default_attributes(resource, atom)

@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

trace_name(resource)

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

The trace_name of the resource

unique_keys(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

validations(resource)

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

A list of all validations for the resource

validations(resource, type)

@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