alibabacloud-imm 0.1.0

A modern, easy-to-use, and reqwest-powered Rust SDK for Alibaba Cloud Intelligent Media Management (IMM)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
//! Story operations.

use std::future::Future;

use serde::{Deserialize, Serialize};

use crate::error::Result;
use crate::response::BodyResponseProcessor;
use crate::{Client, Ops, Request};

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct CreateStoryQuery {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tags: Option<serde_json::Value>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub user_data: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub notification: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct CreateStoryBody {
    pub project_name: String,
    pub dataset_name: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub object_id: Option<String>,
    pub story_type: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub story_sub_type: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub story_start_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub story_end_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub story_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_file_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_file_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub notify_topic_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub custom_labels: Option<serde_json::Value>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub custom_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub address: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct CreateStoryResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub task_id: Option<String>,
    #[serde(default)]
    pub event_id: Option<String>,
}

/// Create a story.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-createstory>
pub struct CreateStory {
    pub query: CreateStoryQuery,
    pub body: CreateStoryBody,
}

impl Ops for CreateStory {
    const ACTION: &'static str = "CreateStory";
    type Query = CreateStoryQuery;
    type Body = CreateStoryBody;
    type Response = BodyResponseProcessor<CreateStoryResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, self.body)
    }
}

pub trait CreateStoryOps {
    /// Create a story.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-createstory>
    fn create_story(
        &self,
        query: CreateStoryQuery,
        body: CreateStoryBody,
    ) -> impl Future<Output = Result<CreateStoryResponse>>;
}

impl CreateStoryOps for Client {
    async fn create_story(
        &self,
        query: CreateStoryQuery,
        body: CreateStoryBody,
    ) -> Result<CreateStoryResponse> {
        self.request(CreateStory { query, body }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct CreateCustomizedStoryBody {
    pub project_name: String,
    pub dataset_name: String,
    pub story_type: String,
    pub story_sub_type: String,
    pub story_name: String,
    pub cover: serde_json::Value,
    pub files: serde_json::Value,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub custom_labels: Option<serde_json::Value>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct CreateCustomizedStoryResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub object_id: Option<String>,
}

/// Create a customized story using selected images and videos.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-createcustomizedstory>
pub struct CreateCustomizedStory {
    pub body: CreateCustomizedStoryBody,
}

impl Ops for CreateCustomizedStory {
    const ACTION: &'static str = "CreateCustomizedStory";
    type Query = ();
    type Body = CreateCustomizedStoryBody;
    type Response = BodyResponseProcessor<CreateCustomizedStoryResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        ((), self.body)
    }
}

pub trait CreateCustomizedStoryOps {
    /// Create a customized story using selected images and videos.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-createcustomizedstory>
    fn create_customized_story(
        &self,
        body: CreateCustomizedStoryBody,
    ) -> impl Future<Output = Result<CreateCustomizedStoryResponse>>;
}

impl CreateCustomizedStoryOps for Client {
    async fn create_customized_story(
        &self,
        body: CreateCustomizedStoryBody,
    ) -> Result<CreateCustomizedStoryResponse> {
        self.request(CreateCustomizedStory { body }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct GetStoryQuery {
    pub project_name: String,
    pub dataset_name: String,
    pub object_id: String,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct GetStoryResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub story: Option<String>,
}

/// Get story information.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-getstory>
pub struct GetStory {
    pub query: GetStoryQuery,
}

impl Ops for GetStory {
    const ACTION: &'static str = "GetStory";
    type Query = GetStoryQuery;
    type Body = ();
    type Response = BodyResponseProcessor<GetStoryResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait GetStoryOps {
    /// Get story information.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-getstory>
    fn get_story(&self, query: GetStoryQuery) -> impl Future<Output = Result<GetStoryResponse>>;
}

impl GetStoryOps for Client {
    async fn get_story(&self, query: GetStoryQuery) -> Result<GetStoryResponse> {
        self.request(GetStory { query }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct QueryStoriesQuery {
    pub project_name: String,
    pub dataset_name: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub object_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub story_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub story_type: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub story_sub_type: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub figure_cluster_ids: Option<serde_json::Value>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub create_time_range: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub story_start_time_range: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub story_end_time_range: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_token: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_results: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub custom_labels: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub with_empty_stories: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sort: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub order: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct QueryStoriesResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub stories: Vec<serde_json::Value>,
    #[serde(default)]
    pub next_token: Option<String>,
}

/// Query stories by various conditions.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-querystories>
pub struct QueryStories {
    pub query: QueryStoriesQuery,
}

impl Ops for QueryStories {
    const ACTION: &'static str = "QueryStories";
    type Query = QueryStoriesQuery;
    type Body = ();
    type Response = BodyResponseProcessor<QueryStoriesResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait QueryStoriesOps {
    /// Query stories by various conditions.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-querystories>
    fn query_stories(&self, query: QueryStoriesQuery) -> impl Future<Output = Result<QueryStoriesResponse>>;
}

impl QueryStoriesOps for Client {
    async fn query_stories(&self, query: QueryStoriesQuery) -> Result<QueryStoriesResponse> {
        self.request(QueryStories { query }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct UpdateStoryBody {
    pub project_name: String,
    pub dataset_name: String,
    pub object_id: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub story_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cover: Option<serde_json::Value>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub custom_labels: Option<serde_json::Value>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub custom_id: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct UpdateStoryResponse {
    #[serde(default)]
    pub request_id: String,
}

/// Update story information such as name, cover, and labels.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-updatestory>
pub struct UpdateStory {
    pub body: UpdateStoryBody,
}

impl Ops for UpdateStory {
    const ACTION: &'static str = "UpdateStory";
    type Query = ();
    type Body = UpdateStoryBody;
    type Response = BodyResponseProcessor<UpdateStoryResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        ((), self.body)
    }
}

pub trait UpdateStoryOps {
    /// Update story information such as name, cover, and labels.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-updatestory>
    fn update_story(&self, body: UpdateStoryBody) -> impl Future<Output = Result<UpdateStoryResponse>>;
}

impl UpdateStoryOps for Client {
    async fn update_story(&self, body: UpdateStoryBody) -> Result<UpdateStoryResponse> {
        self.request(UpdateStory { body }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DeleteStoryQuery {
    pub project_name: String,
    pub dataset_name: String,
    pub object_id: String,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DeleteStoryResponse {
    #[serde(default)]
    pub request_id: String,
}

/// Delete a story.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-deletestory>
pub struct DeleteStory {
    pub query: DeleteStoryQuery,
}

impl Ops for DeleteStory {
    const ACTION: &'static str = "DeleteStory";
    type Query = DeleteStoryQuery;
    type Body = ();
    type Response = BodyResponseProcessor<DeleteStoryResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait DeleteStoryOps {
    /// Delete a story.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-deletestory>
    fn delete_story(&self, query: DeleteStoryQuery) -> impl Future<Output = Result<DeleteStoryResponse>>;
}

impl DeleteStoryOps for Client {
    async fn delete_story(&self, query: DeleteStoryQuery) -> Result<DeleteStoryResponse> {
        self.request(DeleteStory { query }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct AddStoryFilesBody {
    pub project_name: String,
    pub dataset_name: String,
    pub object_id: String,
    pub files: serde_json::Value,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct AddStoryFilesResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub files: Vec<serde_json::Value>,
}

/// Add files to a story.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-addstoryfiles>
pub struct AddStoryFiles {
    pub body: AddStoryFilesBody,
}

impl Ops for AddStoryFiles {
    const ACTION: &'static str = "AddStoryFiles";
    type Query = ();
    type Body = AddStoryFilesBody;
    type Response = BodyResponseProcessor<AddStoryFilesResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        ((), self.body)
    }
}

pub trait AddStoryFilesOps {
    /// Add files to a story.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-addstoryfiles>
    fn add_story_files(&self, body: AddStoryFilesBody)
    -> impl Future<Output = Result<AddStoryFilesResponse>>;
}

impl AddStoryFilesOps for Client {
    async fn add_story_files(&self, body: AddStoryFilesBody) -> Result<AddStoryFilesResponse> {
        self.request(AddStoryFiles { body }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct RemoveStoryFilesBody {
    pub project_name: String,
    pub dataset_name: String,
    pub object_id: String,
    pub files: serde_json::Value,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct RemoveStoryFilesResponse {
    #[serde(default)]
    pub request_id: String,
}

/// Remove files from a story.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-removestoryfiles>
pub struct RemoveStoryFiles {
    pub body: RemoveStoryFilesBody,
}

impl Ops for RemoveStoryFiles {
    const ACTION: &'static str = "RemoveStoryFiles";
    type Query = ();
    type Body = RemoveStoryFilesBody;
    type Response = BodyResponseProcessor<RemoveStoryFilesResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        ((), self.body)
    }
}

pub trait RemoveStoryFilesOps {
    /// Remove files from a story.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-removestoryfiles>
    fn remove_story_files(
        &self,
        body: RemoveStoryFilesBody,
    ) -> impl Future<Output = Result<RemoveStoryFilesResponse>>;
}

impl RemoveStoryFilesOps for Client {
    async fn remove_story_files(&self, body: RemoveStoryFilesBody) -> Result<RemoveStoryFilesResponse> {
        self.request(RemoveStoryFiles { body }).await
    }
}

pub trait StoryOperations:
    CreateStoryOps
    + CreateCustomizedStoryOps
    + GetStoryOps
    + QueryStoriesOps
    + UpdateStoryOps
    + DeleteStoryOps
    + AddStoryFilesOps
    + RemoveStoryFilesOps
{
}
impl<T> StoryOperations for T where
    T: CreateStoryOps
        + CreateCustomizedStoryOps
        + GetStoryOps
        + QueryStoriesOps
        + UpdateStoryOps
        + DeleteStoryOps
        + AddStoryFilesOps
        + RemoveStoryFilesOps
{
}