shared/api/endpoints/animation.rs
1//! routes for the global animation library
2
3use super::ApiEndpoint;
4use crate::{
5 api::Method,
6 domain::{
7 animation::{
8 AnimationCreatePath, AnimationCreateRequest, AnimationDeletePath, AnimationGetPath,
9 AnimationId, AnimationResponse, AnimationUploadPath, AnimationUploadRequest,
10 AnimationUploadResponse,
11 },
12 CreateResponse,
13 },
14 error::EmptyError,
15};
16
17/// Get an animation by ID.
18pub struct Get;
19impl ApiEndpoint for Get {
20 type Path = AnimationGetPath;
21 type Req = ();
22 type Res = AnimationResponse;
23 type Err = EmptyError;
24 const METHOD: Method = Method::Get;
25}
26/// Create an animation.
27pub struct Create;
28impl ApiEndpoint for Create {
29 type Path = AnimationCreatePath;
30 type Req = AnimationCreateRequest;
31 type Res = CreateResponse<AnimationId>;
32 type Err = EmptyError;
33 const METHOD: Method = Method::Post;
34}
35
36/// Upload an animation
37///
38/// # Flow:
39///
40/// 1. User requests an upload session URI directly to Google Cloud Storage
41/// a. User uploads to processing bucket
42/// 2. Firestore is notified of `processing = true, ready = false` status at document `uploads/media/global/{id}`
43/// 3. Animation is processed and uploaded to the final bucket
44/// 4. Firestore is notified of `processing = true, ready = true` status at document `uploads/media/global/{id}`
45///
46/// # Notes:
47///
48/// * Can be used to update the raw data associated with the animation.
49/// * If the client wants to re-upload an image after it has been successfully processed, it must repeat
50/// the entire flow instead of uploading to the same session URI.
51///
52/// Errors:
53/// * [`401 - Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
54/// * [`403 - Forbidden`](http::StatusCode::FORBIDDEN) if the user does not have sufficient permission to perform the action.
55/// * [`501 - NotImplemented`](http::StatusCode::NOT_IMPLEMENTED) when the s3/gcs service is disabled.
56pub struct Upload;
57impl ApiEndpoint for Upload {
58 type Path = AnimationUploadPath;
59 // raw bytes
60 type Req = AnimationUploadRequest;
61 type Res = AnimationUploadResponse;
62 type Err = EmptyError;
63 const METHOD: Method = Method::Put;
64}
65
66/// Delete an animation.
67pub struct Delete;
68impl ApiEndpoint for Delete {
69 type Path = AnimationDeletePath;
70 type Req = ();
71 type Res = ();
72 type Err = EmptyError;
73 const METHOD: Method = Method::Delete;
74}