From b7979bf6bafc30fae1fed7275beb7fdd3a8c6799 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Wed, 21 May 2025 19:41:28 +0300 Subject: [PATCH] Add descriptions for resources' actions. --- lib/decentralised_book_index/metadata/author.ex | 8 ++++++++ .../metadata/author_role.ex | 13 ++++++++++++- lib/decentralised_book_index/metadata/book.ex | 10 ++++++++++ lib/decentralised_book_index/metadata/book_id.ex | 12 +++++++++++- .../metadata/dbi_server.ex | 8 ++++++++ .../metadata/publisher.ex | 15 ++++++++++++++- 6 files changed, 63 insertions(+), 3 deletions(-) diff --git a/lib/decentralised_book_index/metadata/author.ex b/lib/decentralised_book_index/metadata/author.ex index d6bba46..28a7bae 100644 --- a/lib/decentralised_book_index/metadata/author.ex +++ b/lib/decentralised_book_index/metadata/author.ex @@ -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 diff --git a/lib/decentralised_book_index/metadata/author_role.ex b/lib/decentralised_book_index/metadata/author_role.ex index 80bb2c8..b5456d6 100644 --- a/lib/decentralised_book_index/metadata/author_role.ex +++ b/lib/decentralised_book_index/metadata/author_role.ex @@ -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 diff --git a/lib/decentralised_book_index/metadata/book.ex b/lib/decentralised_book_index/metadata/book.ex index d30cff5..07bc797 100644 --- a/lib/decentralised_book_index/metadata/book.ex +++ b/lib/decentralised_book_index/metadata/book.ex @@ -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 diff --git a/lib/decentralised_book_index/metadata/book_id.ex b/lib/decentralised_book_index/metadata/book_id.ex index e872ee3..8f89016 100644 --- a/lib/decentralised_book_index/metadata/book_id.ex +++ b/lib/decentralised_book_index/metadata/book_id.ex @@ -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)) diff --git a/lib/decentralised_book_index/metadata/dbi_server.ex b/lib/decentralised_book_index/metadata/dbi_server.ex index dfd5090..4b21851 100644 --- a/lib/decentralised_book_index/metadata/dbi_server.ex +++ b/lib/decentralised_book_index/metadata/dbi_server.ex @@ -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 diff --git a/lib/decentralised_book_index/metadata/publisher.ex b/lib/decentralised_book_index/metadata/publisher.ex index 61a875a..26065fc 100644 --- a/lib/decentralised_book_index/metadata/publisher.ex +++ b/lib/decentralised_book_index/metadata/publisher.ex @@ -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