shared/api/endpoints/
resource.rs1use crate::{
2 api::Method,
3 domain::{
4 resource::{
5 ListLikedPath, ListLikedRequest, ListLikedResponse, ResourceAdminDataUpdatePath,
6 ResourceBrowsePath, ResourceBrowseQuery, ResourceBrowseResponse, ResourceClonePath,
7 ResourceCountPath, ResourceCountResponse, ResourceCoverPath, ResourceCreatePath,
8 ResourceCreateRequest, ResourceDeleteAllPath, ResourceDeletePath, ResourceGetDraftPath,
9 ResourceGetLivePath, ResourceId, ResourceLikePath, ResourceLikedPath,
10 ResourceLikedResponse, ResourcePublishPath, ResourceResponse, ResourceSearchPath,
11 ResourceSearchQuery, ResourceSearchResponse, ResourceUnlikePath,
12 ResourceUpdateAdminDataRequest, ResourceUpdateDraftDataPath,
13 ResourceUpdateDraftDataRequest, ResourceViewPath,
14 },
15 CreateResponse,
16 },
17 error::{EmptyError, MetadataNotFound},
18};
19
20use super::ApiEndpoint;
21
22pub mod curation;
24
25pub mod report;
27
28pub struct Create;
43impl ApiEndpoint for Create {
44 type Path = ResourceCreatePath;
45 type Req = ResourceCreateRequest;
46 type Res = CreateResponse<ResourceId>;
47 type Err = MetadataNotFound;
48 const METHOD: Method = Method::Post;
49}
50
51pub struct GetLive;
59impl ApiEndpoint for GetLive {
60 type Path = ResourceGetLivePath;
61 type Req = ();
62 type Res = ResourceResponse;
63 type Err = EmptyError;
64 const METHOD: Method = Method::Get;
65}
66
67pub struct GetDraft;
76impl ApiEndpoint for GetDraft {
77 type Path = ResourceGetDraftPath;
78 type Req = ();
79 type Res = ResourceResponse;
80 type Err = EmptyError;
81 const METHOD: Method = Method::Get;
82}
83
84pub struct UpdateDraftData;
96impl ApiEndpoint for UpdateDraftData {
97 type Path = ResourceUpdateDraftDataPath;
98 type Req = ResourceUpdateDraftDataRequest;
99 type Res = ();
100 type Err = MetadataNotFound;
101 const METHOD: Method = Method::Patch;
102}
103
104pub struct Publish;
109impl ApiEndpoint for Publish {
110 type Path = ResourcePublishPath;
111 type Req = ();
112 type Res = ();
113 type Err = EmptyError;
114 const METHOD: Method = Method::Put;
115}
116
117pub struct Browse;
122impl ApiEndpoint for Browse {
123 type Path = ResourceBrowsePath;
124 type Req = ResourceBrowseQuery;
125 type Res = ResourceBrowseResponse;
126 type Err = EmptyError;
127 const METHOD: Method = Method::Get;
128}
129
130pub struct Search;
135impl ApiEndpoint for Search {
136 type Path = ResourceSearchPath;
137 type Req = ResourceSearchQuery;
138 type Res = ResourceSearchResponse;
139 type Err = EmptyError;
140 const METHOD: Method = Method::Get;
141}
142
143pub struct Clone;
154impl ApiEndpoint for Clone {
155 type Path = ResourceClonePath;
156 type Req = ();
157 type Res = CreateResponse<ResourceId>;
158 type Err = EmptyError;
159 const METHOD: Method = Method::Post;
160}
161
162pub struct Delete;
167impl ApiEndpoint for Delete {
168 type Path = ResourceDeletePath;
169 type Req = ();
170 type Res = ();
171 type Err = EmptyError;
172 const METHOD: Method = Method::Delete;
173}
174
175pub struct DeleteAll;
180impl ApiEndpoint for DeleteAll {
181 type Path = ResourceDeleteAllPath;
182 type Req = ();
183 type Res = ();
184 type Err = EmptyError;
185 const METHOD: Method = Method::Delete;
186}
187
188pub struct Cover;
193impl ApiEndpoint for Cover {
194 type Path = ResourceCoverPath;
195 type Req = ();
196 type Res = ();
197 type Err = EmptyError;
198 const METHOD: Method = Method::Patch;
199}
200
201pub struct Count;
206impl ApiEndpoint for Count {
207 type Path = ResourceCountPath;
208 type Req = ();
209 type Res = ResourceCountResponse;
210 type Err = EmptyError;
211 const METHOD: Method = Method::Get;
212}
213
214pub struct Like;
219impl ApiEndpoint for Like {
220 type Path = ResourceLikePath;
221 type Req = ();
222 type Res = ();
223 type Err = EmptyError;
224 const METHOD: Method = Method::Put;
225}
226
227pub struct Unlike;
232impl ApiEndpoint for Unlike {
233 type Path = ResourceUnlikePath;
234 type Req = ();
235 type Res = ();
236 type Err = EmptyError;
237 const METHOD: Method = Method::Delete;
238}
239
240pub struct Liked;
245impl ApiEndpoint for Liked {
246 type Path = ResourceLikedPath;
247 type Req = ();
248 type Res = ResourceLikedResponse;
249 type Err = EmptyError;
250 const METHOD: Method = Method::Get;
251}
252
253pub struct ListLiked;
255impl ApiEndpoint for ListLiked {
256 type Req = ListLikedRequest;
257 type Res = ListLikedResponse;
258 type Path = ListLikedPath;
259 type Err = EmptyError;
260 const METHOD: Method = Method::Get;
261}
262
263pub struct View;
268impl ApiEndpoint for View {
269 type Path = ResourceViewPath;
270 type Req = ();
271 type Res = ();
272 type Err = EmptyError;
273 const METHOD: Method = Method::Put;
274}
275
276pub struct ResourceAdminDataUpdate;
288impl ApiEndpoint for ResourceAdminDataUpdate {
289 type Path = ResourceAdminDataUpdatePath;
290 type Req = ResourceUpdateAdminDataRequest;
291 type Res = ();
292 type Err = EmptyError;
293 const METHOD: Method = Method::Patch;
294}