Add descriptions for resources' actions.

This commit is contained in:
2025-05-21 19:41:28 +03:00
parent db025ece6a
commit b7979bf6ba
6 changed files with 63 additions and 3 deletions
@@ -25,6 +25,10 @@ defmodule DecentralisedBookIndex.Metadata.Author do
end
end
resource do
description "An author's metadata."
end
actions do
defaults [:read, :destroy]
@@ -100,6 +104,7 @@ defmodule DecentralisedBookIndex.Metadata.Author do
end
read :by_id do
description "Return the Author by its id."
argument :id, :uuid, allow_nil?: false
get? true
filter expr(id == ^arg(:id))
@@ -136,7 +141,10 @@ defmodule DecentralisedBookIndex.Metadata.Author do
end
read :search do
description "Return a list of Authors, optionally filtering by name."
argument :name, :ci_string do
description "Return Authors, which names includes the name."
constraints allow_empty?: true
default ""
end
@@ -21,8 +21,12 @@ defmodule DecentralisedBookIndex.Metadata.AuthorRole do
end
end
resource do
description "A metadata of an author's role."
end
actions do
defaults [:read, :destroy]
defaults [:destroy]
create :create do
primary? true
@@ -43,13 +47,20 @@ defmodule DecentralisedBookIndex.Metadata.AuthorRole do
end
end
read :read do
description "Return a list of AuthorRoles."
primary? true
end
read :by_id do
description "Return the AuthorRole by its id."
argument :id, :uuid, allow_nil?: false
get? true
filter expr(id == ^arg(:id))
end
read :by_book_id do
description "Return the AuthorRole by its BookId."
argument :book_id, :uuid, allow_nil?: false
filter expr(book_id == ^arg(:book_id))
end
@@ -25,6 +25,10 @@ defmodule DecentralisedBookIndex.Metadata.Book do
end
end
resource do
description "A book's metadata."
end
actions do
defaults [:read, :destroy]
@@ -142,6 +146,7 @@ defmodule DecentralisedBookIndex.Metadata.Book do
end
read :by_id do
description "Return the Book by its id."
argument :id, :uuid, allow_nil?: false
get? true
filter expr(id == ^arg(:id))
@@ -182,7 +187,10 @@ defmodule DecentralisedBookIndex.Metadata.Book do
end
read :search do
description "Return a list of Books, optionally filtering by title."
argument :query, :ci_string do
description "Return Books, which titles includes the query."
constraints allow_empty?: true
default ""
end
@@ -193,6 +201,8 @@ defmodule DecentralisedBookIndex.Metadata.Book do
end
read :search_by_bid do
description "Return a list of Books, optionally filtering by BookId."
argument :type, :string, allow_nil?: false
argument :bid, :string, allow_nil?: false
@@ -26,8 +26,12 @@ defmodule DecentralisedBookIndex.Metadata.BookId do
end
end
resource do
description "A book's identifier."
end
actions do
defaults [:read, :destroy]
defaults [:destroy]
create :create do
primary? true
@@ -39,7 +43,13 @@ defmodule DecentralisedBookIndex.Metadata.BookId do
accept [:id, :type, :bid, :order]
end
read :read do
description "Return a list of BookIds."
primary? true
end
read :by_id do
description "Return the BookId by its id."
argument :id, :uuid, allow_nil?: false
get? true
filter expr(id == ^arg(:id))
@@ -21,6 +21,10 @@ defmodule DecentralisedBookIndex.Metadata.DBIServer do
end
end
resource do
description "An DBIServer's metadata."
end
actions do
defaults [:read, :destroy]
@@ -43,13 +47,17 @@ defmodule DecentralisedBookIndex.Metadata.DBIServer do
end
read :by_id do
description "Return the DBIServer by its id."
argument :id, :uuid, allow_nil?: false
get? true
filter expr(id == ^arg(:id))
end
read :search do
description "Return a list of DBIServers, optionally filtering by name."
argument :name, :ci_string do
description "Return DBIServers, which names includes the name."
constraints allow_empty?: true
default ""
end
@@ -22,8 +22,12 @@ defmodule DecentralisedBookIndex.Metadata.Publisher do
end
end
resource do
description "An publisher's metadata."
end
actions do
defaults [:read, :destroy]
defaults [:destroy]
create :create do
primary? true
@@ -34,14 +38,23 @@ defmodule DecentralisedBookIndex.Metadata.Publisher do
accept [:id, :name, :inserted_at, :updated_at, :dbi_server_id]
end
read :read do
description "Return a list of Publishers."
primary? true
end
read :by_id do
description "Return the Publisher by its id."
argument :id, :uuid, allow_nil?: false
get? true
filter expr(id == ^arg(:id))
end
read :search do
description "Return a list of Publishers, optionally filtering by name."
argument :name, :ci_string do
description "Return Publishers, which names includes the name."
constraints allow_empty?: true
default ""
end