Search documentation of ash

# Ash.Resource.Igniter (ash v3.4.71)

View Source

Codemods for working with Ash.Resource modules

## Important Details

This interrogates the source code of a resource, not its ultimate compiled state. What this means, is that things like `defines_attribute` will not return `true` if the attribute is added by an extension. Only if it appears literally in the source code of the resource or one of its `Spark.Dsl.Fragment`s.

# Summary

## Functions

add_action(igniter, resource, action)

Adds the given code block to the resource's `actions` block

add_attribute(igniter, resource, attribute)

Adds the given code block to the resource's `attributes` block

add_block(igniter, resource, block, chunk)

Adds the given code block to the block of the resource specified

add_bypass(igniter, resource, condition, body)

Adds a bypass to the top of the resource's `policies` block

add_identity(igniter, resource, identity)

Adds the given code block to the resource's `identities` block

add_new_action(igniter, resource, name, action)

Adds an action if it doesn't already exist

add_new_attribute(igniter, resource, name, attribute)

Adds the given code block to the resource's `attributes` block if there is no existing attribute with the given name

add_new_identity(igniter, resource, name, identity)

Adds the given code block to the resource's `identities` block if there is no existing identity with the given name

add_new_relationship(igniter, resource, name, relationship)

Adds the given code block to the resource's `relationships` block

add_policy(igniter, resource, condition, body)

Adds a policy to the bottom of the resource's `policies` block

add_relationship(igniter, resource, relationship)

Adds the given code block to the resource's `relationships` block

add_resource_configuration(igniter, resource, resource_configuration)

Adds the given code block to the resource's `resource` block

defines_action(igniter, resource, name)

Returns true if the given resource defines an action with the provided name

defines_attribute(igniter, resource, name)

Returns true if the given resource defines an attribute with the provided name

defines_identity(igniter, resource, name)

Returns true if the given resource defines an identity with the provided name

defines_relationship(igniter, resource, name)

Returns true if the given resource defines a relationship with the provided name

domain(igniter, resource)

Gets the domain from the given resource module

ensure_primary_action(igniter, resource, type)
ensure_timestamps(igniter, resource)

Ensures that created_at and updated_at timestamps exist on the resource

has_action_with_primary(igniter, resource, type)
list_resources(igniter)

List all resource modules found in the project

resource_mods(igniter)

# Functions

# add_action(igniter, resource, action)

Adds the given code block to the resource's `actions` block

# add_attribute(igniter, resource, attribute)

Adds the given code block to the resource's `attributes` block

# add_block(igniter, resource, block, chunk)

Adds the given code block to the block of the resource specified

# add_bypass(igniter, resource, condition, body)

Adds a bypass to the top of the resource's `policies` block

# add_identity(igniter, resource, identity)

Adds the given code block to the resource's `identities` block

# add_new_action(igniter, resource, name, action)

Adds an action if it doesn't already exist

# add_new_attribute(igniter, resource, name, attribute)

Adds the given code block to the resource's `attributes` block if there is no existing attribute with the given name

# add_new_identity(igniter, resource, name, identity)

Adds the given code block to the resource's `identities` block if there is no existing identity with the given name

# add_new_relationship(igniter, resource, name, relationship)

Adds the given code block to the resource's `relationships` block

# add_policy(igniter, resource, condition, body)

Adds a policy to the bottom of the resource's `policies` block

# add_relationship(igniter, resource, relationship)

Adds the given code block to the resource's `relationships` block

# add_resource_configuration(igniter, resource, resource_configuration)

Adds the given code block to the resource's `resource` block

# defines_action(igniter, resource, name)

    @spec defines_action(Igniter.t(), Ash.Resource.t(), atom()) ::
      {Igniter.t(), true | false}

Returns true if the given resource defines an action with the provided name

# defines_attribute(igniter, resource, name)

    @spec defines_attribute(Igniter.t(), Ash.Resource.t(), atom()) ::
      {Igniter.t(), true | false}

Returns true if the given resource defines an attribute with the provided name

# defines_identity(igniter, resource, name)

    @spec defines_identity(Igniter.t(), Ash.Resource.t(), atom()) ::
      {Igniter.t(), true | false}

Returns true if the given resource defines an identity with the provided name

# defines_relationship(igniter, resource, name)

    @spec defines_relationship(Igniter.t(), Ash.Resource.t(), atom()) ::
      {Igniter.t(), true | false}

Returns true if the given resource defines a relationship with the provided name

# domain(igniter, resource)

    @spec domain(Igniter.t(), Ash.Resource.t()) ::
      {:ok, Igniter.t(), Ash.Domain.t()} | {:error, Igniter.t()}

Gets the domain from the given resource module

# ensure_primary_action(igniter, resource, type)

    @spec ensure_primary_action(
      Igniter.t(),
      Ash.Resource.t(),
      :create | :read | :update | :destroy
    ) :: Igniter.t()

# ensure_timestamps(igniter, resource)

Ensures that created_at and updated_at timestamps exist on the resource

# has_action_with_primary(igniter, resource, type)

    @spec has_action_with_primary(Igniter.t(), Ash.Resource.t(), atom()) ::
      {Igniter.t(), true | false}

# list_resources(igniter)

List all resource modules found in the project

# resource_mods(igniter)