Skip to main content

nominal_api/conjure/endpoints/attachments/api/
attachment_service.rs

1use conjure_http::endpoint;
2/// The attachment service provides functionality for creating, updating, and archiving attachments uploaded to S3.
3#[conjure_http::conjure_endpoints(
4    name = "AttachmentService",
5    use_legacy_error_serialization
6)]
7pub trait AttachmentService<#[response_writer] O> {
8    ///The body type returned by the `get_content` method.
9    type GetContentBody: conjure_http::server::WriteBody<O> + 'static;
10    /// Create a new attachment. Assumes the file is already uploaded to S3 through the upload service.
11    #[endpoint(
12        method = POST,
13        path = "/attachments/v1/attachments",
14        name = "create",
15        produces = conjure_http::server::StdResponseSerializer
16    )]
17    fn create(
18        &self,
19        #[auth]
20        auth_: conjure_object::BearerToken,
21        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
22        request: super::super::super::super::objects::attachments::api::CreateAttachmentRequest,
23    ) -> Result<
24        super::super::super::super::objects::attachments::api::Attachment,
25        conjure_http::private::Error,
26    >;
27    /// Get an attachment by its RID.
28    #[endpoint(
29        method = GET,
30        path = "/attachments/v1/attachments/{rid}",
31        name = "get",
32        produces = conjure_http::server::StdResponseSerializer
33    )]
34    fn get(
35        &self,
36        #[auth]
37        auth_: conjure_object::BearerToken,
38        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
39        rid: conjure_object::ResourceIdentifier,
40    ) -> Result<
41        super::super::super::super::objects::attachments::api::Attachment,
42        conjure_http::private::Error,
43    >;
44    /// Get a set of attachments by their RIDs.
45    #[endpoint(
46        method = POST,
47        path = "/attachments/v1/attachments/batch",
48        name = "getBatch",
49        produces = conjure_http::server::StdResponseSerializer
50    )]
51    fn get_batch(
52        &self,
53        #[auth]
54        auth_: conjure_object::BearerToken,
55        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
56        request: super::super::super::super::objects::attachments::api::GetAttachmentsRequest,
57    ) -> Result<
58        super::super::super::super::objects::attachments::api::GetAttachmentsResponse,
59        conjure_http::private::Error,
60    >;
61    /// Get the binary content of an attachment.
62    #[endpoint(
63        method = GET,
64        path = "/attachments/v1/attachments/{rid}/content",
65        name = "getContent",
66        produces = conjure_http::server::conjure::BinaryResponseSerializer
67    )]
68    fn get_content(
69        &self,
70        #[auth]
71        auth_: conjure_object::BearerToken,
72        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
73        rid: conjure_object::ResourceIdentifier,
74    ) -> Result<Self::GetContentBody, conjure_http::private::Error>;
75    /// Get a pre-signed URI to download an attachment. The link expires in 1 minute.
76    #[endpoint(
77        method = GET,
78        path = "/attachments/v1/attachments/{rid}/uri",
79        name = "getUri",
80        produces = conjure_http::server::StdResponseSerializer
81    )]
82    fn get_uri(
83        &self,
84        #[auth]
85        auth_: conjure_object::BearerToken,
86        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
87        rid: conjure_object::ResourceIdentifier,
88    ) -> Result<
89        super::super::super::super::objects::attachments::api::AttachmentUri,
90        conjure_http::private::Error,
91    >;
92    /// Update an attachment. Only the fields that are set in the request will be updated.
93    #[endpoint(
94        method = PUT,
95        path = "/attachments/v1/attachments/{rid}",
96        name = "update",
97        produces = conjure_http::server::StdResponseSerializer
98    )]
99    fn update(
100        &self,
101        #[auth]
102        auth_: conjure_object::BearerToken,
103        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
104        rid: conjure_object::ResourceIdentifier,
105        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
106        request: super::super::super::super::objects::attachments::api::UpdateAttachmentRequest,
107    ) -> Result<
108        super::super::super::super::objects::attachments::api::Attachment,
109        conjure_http::private::Error,
110    >;
111    /// Archive an attachment.
112    #[endpoint(
113        method = PUT,
114        path = "/attachments/v1/attachments/{rid}/archive",
115        name = "archive"
116    )]
117    fn archive(
118        &self,
119        #[auth]
120        auth_: conjure_object::BearerToken,
121        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
122        rid: conjure_object::ResourceIdentifier,
123    ) -> Result<(), conjure_http::private::Error>;
124    /// Unarchive an attachment.
125    #[endpoint(
126        method = PUT,
127        path = "/attachments/v1/attachments/{rid}/unarchive",
128        name = "unarchive"
129    )]
130    fn unarchive(
131        &self,
132        #[auth]
133        auth_: conjure_object::BearerToken,
134        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
135        rid: conjure_object::ResourceIdentifier,
136    ) -> Result<(), conjure_http::private::Error>;
137}
138/// The attachment service provides functionality for creating, updating, and archiving attachments uploaded to S3.
139#[conjure_http::conjure_endpoints(
140    name = "AttachmentService",
141    use_legacy_error_serialization
142)]
143pub trait AsyncAttachmentService<#[response_writer] O> {
144    ///The body type returned by the `get_content` method.
145    type GetContentBody: conjure_http::server::AsyncWriteBody<O> + 'static + Send;
146    /// Create a new attachment. Assumes the file is already uploaded to S3 through the upload service.
147    #[endpoint(
148        method = POST,
149        path = "/attachments/v1/attachments",
150        name = "create",
151        produces = conjure_http::server::StdResponseSerializer
152    )]
153    async fn create(
154        &self,
155        #[auth]
156        auth_: conjure_object::BearerToken,
157        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
158        request: super::super::super::super::objects::attachments::api::CreateAttachmentRequest,
159    ) -> Result<
160        super::super::super::super::objects::attachments::api::Attachment,
161        conjure_http::private::Error,
162    >;
163    /// Get an attachment by its RID.
164    #[endpoint(
165        method = GET,
166        path = "/attachments/v1/attachments/{rid}",
167        name = "get",
168        produces = conjure_http::server::StdResponseSerializer
169    )]
170    async fn get(
171        &self,
172        #[auth]
173        auth_: conjure_object::BearerToken,
174        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
175        rid: conjure_object::ResourceIdentifier,
176    ) -> Result<
177        super::super::super::super::objects::attachments::api::Attachment,
178        conjure_http::private::Error,
179    >;
180    /// Get a set of attachments by their RIDs.
181    #[endpoint(
182        method = POST,
183        path = "/attachments/v1/attachments/batch",
184        name = "getBatch",
185        produces = conjure_http::server::StdResponseSerializer
186    )]
187    async fn get_batch(
188        &self,
189        #[auth]
190        auth_: conjure_object::BearerToken,
191        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
192        request: super::super::super::super::objects::attachments::api::GetAttachmentsRequest,
193    ) -> Result<
194        super::super::super::super::objects::attachments::api::GetAttachmentsResponse,
195        conjure_http::private::Error,
196    >;
197    /// Get the binary content of an attachment.
198    #[endpoint(
199        method = GET,
200        path = "/attachments/v1/attachments/{rid}/content",
201        name = "getContent",
202        produces = conjure_http::server::conjure::BinaryResponseSerializer
203    )]
204    async fn get_content(
205        &self,
206        #[auth]
207        auth_: conjure_object::BearerToken,
208        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
209        rid: conjure_object::ResourceIdentifier,
210    ) -> Result<Self::GetContentBody, conjure_http::private::Error>;
211    /// Get a pre-signed URI to download an attachment. The link expires in 1 minute.
212    #[endpoint(
213        method = GET,
214        path = "/attachments/v1/attachments/{rid}/uri",
215        name = "getUri",
216        produces = conjure_http::server::StdResponseSerializer
217    )]
218    async fn get_uri(
219        &self,
220        #[auth]
221        auth_: conjure_object::BearerToken,
222        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
223        rid: conjure_object::ResourceIdentifier,
224    ) -> Result<
225        super::super::super::super::objects::attachments::api::AttachmentUri,
226        conjure_http::private::Error,
227    >;
228    /// Update an attachment. Only the fields that are set in the request will be updated.
229    #[endpoint(
230        method = PUT,
231        path = "/attachments/v1/attachments/{rid}",
232        name = "update",
233        produces = conjure_http::server::StdResponseSerializer
234    )]
235    async fn update(
236        &self,
237        #[auth]
238        auth_: conjure_object::BearerToken,
239        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
240        rid: conjure_object::ResourceIdentifier,
241        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
242        request: super::super::super::super::objects::attachments::api::UpdateAttachmentRequest,
243    ) -> Result<
244        super::super::super::super::objects::attachments::api::Attachment,
245        conjure_http::private::Error,
246    >;
247    /// Archive an attachment.
248    #[endpoint(
249        method = PUT,
250        path = "/attachments/v1/attachments/{rid}/archive",
251        name = "archive"
252    )]
253    async fn archive(
254        &self,
255        #[auth]
256        auth_: conjure_object::BearerToken,
257        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
258        rid: conjure_object::ResourceIdentifier,
259    ) -> Result<(), conjure_http::private::Error>;
260    /// Unarchive an attachment.
261    #[endpoint(
262        method = PUT,
263        path = "/attachments/v1/attachments/{rid}/unarchive",
264        name = "unarchive"
265    )]
266    async fn unarchive(
267        &self,
268        #[auth]
269        auth_: conjure_object::BearerToken,
270        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
271        rid: conjure_object::ResourceIdentifier,
272    ) -> Result<(), conjure_http::private::Error>;
273}
274/// The attachment service provides functionality for creating, updating, and archiving attachments uploaded to S3.
275#[conjure_http::conjure_endpoints(
276    name = "AttachmentService",
277    use_legacy_error_serialization,
278    local
279)]
280pub trait LocalAsyncAttachmentService<#[response_writer] O> {
281    ///The body type returned by the `get_content` method.
282    type GetContentBody: conjure_http::server::LocalAsyncWriteBody<O> + 'static;
283    /// Create a new attachment. Assumes the file is already uploaded to S3 through the upload service.
284    #[endpoint(
285        method = POST,
286        path = "/attachments/v1/attachments",
287        name = "create",
288        produces = conjure_http::server::StdResponseSerializer
289    )]
290    async fn create(
291        &self,
292        #[auth]
293        auth_: conjure_object::BearerToken,
294        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
295        request: super::super::super::super::objects::attachments::api::CreateAttachmentRequest,
296    ) -> Result<
297        super::super::super::super::objects::attachments::api::Attachment,
298        conjure_http::private::Error,
299    >;
300    /// Get an attachment by its RID.
301    #[endpoint(
302        method = GET,
303        path = "/attachments/v1/attachments/{rid}",
304        name = "get",
305        produces = conjure_http::server::StdResponseSerializer
306    )]
307    async fn get(
308        &self,
309        #[auth]
310        auth_: conjure_object::BearerToken,
311        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
312        rid: conjure_object::ResourceIdentifier,
313    ) -> Result<
314        super::super::super::super::objects::attachments::api::Attachment,
315        conjure_http::private::Error,
316    >;
317    /// Get a set of attachments by their RIDs.
318    #[endpoint(
319        method = POST,
320        path = "/attachments/v1/attachments/batch",
321        name = "getBatch",
322        produces = conjure_http::server::StdResponseSerializer
323    )]
324    async fn get_batch(
325        &self,
326        #[auth]
327        auth_: conjure_object::BearerToken,
328        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
329        request: super::super::super::super::objects::attachments::api::GetAttachmentsRequest,
330    ) -> Result<
331        super::super::super::super::objects::attachments::api::GetAttachmentsResponse,
332        conjure_http::private::Error,
333    >;
334    /// Get the binary content of an attachment.
335    #[endpoint(
336        method = GET,
337        path = "/attachments/v1/attachments/{rid}/content",
338        name = "getContent",
339        produces = conjure_http::server::conjure::BinaryResponseSerializer
340    )]
341    async fn get_content(
342        &self,
343        #[auth]
344        auth_: conjure_object::BearerToken,
345        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
346        rid: conjure_object::ResourceIdentifier,
347    ) -> Result<Self::GetContentBody, conjure_http::private::Error>;
348    /// Get a pre-signed URI to download an attachment. The link expires in 1 minute.
349    #[endpoint(
350        method = GET,
351        path = "/attachments/v1/attachments/{rid}/uri",
352        name = "getUri",
353        produces = conjure_http::server::StdResponseSerializer
354    )]
355    async fn get_uri(
356        &self,
357        #[auth]
358        auth_: conjure_object::BearerToken,
359        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
360        rid: conjure_object::ResourceIdentifier,
361    ) -> Result<
362        super::super::super::super::objects::attachments::api::AttachmentUri,
363        conjure_http::private::Error,
364    >;
365    /// Update an attachment. Only the fields that are set in the request will be updated.
366    #[endpoint(
367        method = PUT,
368        path = "/attachments/v1/attachments/{rid}",
369        name = "update",
370        produces = conjure_http::server::StdResponseSerializer
371    )]
372    async fn update(
373        &self,
374        #[auth]
375        auth_: conjure_object::BearerToken,
376        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
377        rid: conjure_object::ResourceIdentifier,
378        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
379        request: super::super::super::super::objects::attachments::api::UpdateAttachmentRequest,
380    ) -> Result<
381        super::super::super::super::objects::attachments::api::Attachment,
382        conjure_http::private::Error,
383    >;
384    /// Archive an attachment.
385    #[endpoint(
386        method = PUT,
387        path = "/attachments/v1/attachments/{rid}/archive",
388        name = "archive"
389    )]
390    async fn archive(
391        &self,
392        #[auth]
393        auth_: conjure_object::BearerToken,
394        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
395        rid: conjure_object::ResourceIdentifier,
396    ) -> Result<(), conjure_http::private::Error>;
397    /// Unarchive an attachment.
398    #[endpoint(
399        method = PUT,
400        path = "/attachments/v1/attachments/{rid}/unarchive",
401        name = "unarchive"
402    )]
403    async fn unarchive(
404        &self,
405        #[auth]
406        auth_: conjure_object::BearerToken,
407        #[path(name = "rid", decoder = conjure_http::server::conjure::FromPlainDecoder)]
408        rid: conjure_object::ResourceIdentifier,
409    ) -> Result<(), conjure_http::private::Error>;
410}