AshOps
An extension for Ash.Domain
that adds the ability expose resource actions as
mix tasks.
mix_tasks
Resource actions to expose as mix tasks.
Nested DSLs
Examples
mix_tasks do
action Post, :publish_post, :publish
create Post, :create_post, :create
destroy Post, :destroy_post, :destroy
get Post, :get_post, :read
list Post, :list_posts, :read
update Post, :update_post, :update
end
mix_tasks.action
action resource, name, action
Generate a mix task which calls a generic action and returns the created record.
Example
Defining the following action
in your domain:
mix_tasks do
action Post, :publish_post, :publish, arguments: [:id, :platform]
end
Will result in the following mix task being available:
mix my_app.blog.publish_post <ID> <platform>
Arguments
Name | Type | Default | Docs |
---|---|---|---|
resource | module | The resource whose actions to use | |
name | atom | The name of the mix task to generate | |
action | atom | The name of the action to use |
Options
Name | Type | Default | Docs |
---|---|---|---|
arguments | atom | list(atom) | [] | A list of action arguments which should be taken as positional arguments on the command line |
description | String.t | Documentation to be displayed in the mix task's help section | |
prefix | atom | The prefix to use for the mix task name (ie the part before the first "."). Defaults to the otp_app setting of the domain |
Introspection
Target: AshOps.Entity.Action
mix_tasks.create
create resource, name, action
Generate a mix task which calls a create action and returns the created record.
Example
Defining the following create
in your domain:
mix_tasks do
create Post, :create_post, :create
end
Will result in the following mix task being available:
mix my_app.blog.create_post
Arguments
Name | Type | Default | Docs |
---|---|---|---|
resource | module | The resource whose actions to use | |
name | atom | The name of the mix task to generate | |
action | atom | The name of the create action to use |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | Documentation to be displayed in the mix task's help section | |
prefix | atom | The prefix to use for the mix task name (ie the part before the first "."). Defaults to the otp_app setting of the domain |
Introspection
Target: AshOps.Entity.Create
mix_tasks.destroy
destroy resource, name, action
Generate a mix task which calls a destroy action and removes a single record by primary key or identity.
Example
Defining the following destroy
in your domain:
mix_tasks do
destroy Post, :destroy_post, :destroy
end
Will result in the following mix task being available:
mix my_app.blog.destroy_post "01953abc-c4e9-7661-a79a-243b0d982ab7"
status: ok
Arguments
Name | Type | Default | Docs |
---|---|---|---|
resource | module | The resource whose action to use | |
name | atom | The name of the mix task to generate | |
action | atom | The name of the destroy action to use |
Options
Name | Type | Default | Docs |
---|---|---|---|
arguments | atom | list(atom) | [] | A list of action arguments which should be taken as positional arguments on the command line |
description | String.t | Documentation to be displayed in the mix task's help section | |
prefix | atom | The prefix to use for the mix task name (ie the part before the first "."). Defaults to the otp_app setting of the domain | |
read_action | atom | The read action to use to query for matching records to destroy. Defaults to the primary read action. |
Introspection
Target: AshOps.Entity.Destroy
mix_tasks.get
get resource, name, action
Generate a mix task which calls a read action and returns a single record by primary key or identity.
Example
Defining the following get
in your domain:
mix_tasks do
get Post, :get_post, :read
end
Will result in the following mix task being available:
mix my_app.blog.get_post "01953abc-c4e9-7661-a79a-243b0d982ab7"
title: Example blog post
body: This is the example blog post
Arguments
Name | Type | Default | Docs |
---|---|---|---|
resource | module | The resource whose action to use | |
name | atom | The name of the mix task to generate | |
action | atom | The name of the read action to use |
Options
Name | Type | Default | Docs |
---|---|---|---|
arguments | atom | list(atom) | [] | A list of action arguments which should be taken as positional arguments on the command line |
description | String.t | Documentation to be displayed in the mix task's help section | |
prefix | atom | The prefix to use for the mix task name (ie the part before the first "."). Defaults to the otp_app setting of the domain |
Introspection
Target: AshOps.Entity.Get
mix_tasks.list
list resource, name, action
Generate a mix task which calls a read action and returns any matching records.
Example
Define the following list
in your domain:application
mix_tasks do
list Post, :list_posts, :read
end
Will result in the following mix task being available:application
mix my_app.blog.list_posts
Arguments
Name | Type | Default | Docs |
---|---|---|---|
resource | module | The resource whose action to use | |
name | atom | The name of the mix task to generate | |
action | atom | The name of the read action to use |
Options
Name | Type | Default | Docs |
---|---|---|---|
arguments | atom | list(atom) | A comma-separated list of action arguments can be taken as positional arguments on the command line | |
description | String.t | Documentation to be displayed in the mix task's help section | |
prefix | atom | The prefix to use for the mix task name (ie the part before the first "."). Defaults to the otp_app setting of the domain |
Introspection
Target: AshOps.Entity.List
mix_tasks.update
update resource, name, action
Generate a mix task which calls an update action and updates a single record by primary key or identity.
Example
Defining the following update
in your domain:
mix_tasks do
update Post, :update_post, :update
end
Will result in the following mix task being available:
mix my_app.blog.update_post "01953abc-c4e9-7661-a79a-243b0d982ab7"
Arguments
Name | Type | Default | Docs |
---|---|---|---|
resource | module | The resource whose action to use | |
name | atom | The name of the mix task to generate | |
action | atom | The name of the destroy action to use |
Options
Name | Type | Default | Docs |
---|---|---|---|
arguments | atom | list(atom) | [] | A list of action arguments which should be taken as positional arguments on the command line |
description | String.t | Documentation to be displayed in the mix task's help section | |
prefix | atom | The prefix to use for the mix task name (ie the part before the first "."). Defaults to the otp_app setting of the domain | |
read_action | atom | The read action to use to query for matching records to update. Defaults to the primary read action. |
Introspection
Target: AshOps.Entity.Update