paperless_api_client/
documents.rs

1use crate::Client;
2use anyhow::Result;
3#[derive(Clone, Debug)]
4pub struct Documents {
5    pub client: Client,
6}
7
8impl Documents {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        Self { client }
12    }
13
14    #[doc = "Perform a `GET` request to `/api/documents/`.\n\nDocument views including search\n\n**Parameters:**\n\n- `added_date_gt: Option<chrono::NaiveDate>`\n- `added_date_gte: Option<chrono::NaiveDate>`\n- `added_date_lt: Option<chrono::NaiveDate>`\n- `added_date_lte: Option<chrono::NaiveDate>`\n- `added_day: Option<f64>`\n- `added_gt: Option<chrono::DateTime<chrono::Utc>>`\n- `added_gte: Option<chrono::DateTime<chrono::Utc>>`\n- `added_lt: Option<chrono::DateTime<chrono::Utc>>`\n- `added_lte: Option<chrono::DateTime<chrono::Utc>>`\n- `added_month: Option<f64>`\n- `added_year: Option<f64>`\n- `archive_serial_number: Option<i64>`\n- `archive_serial_number_gt: Option<i64>`\n- `archive_serial_number_gte: Option<i64>`\n- `archive_serial_number_isnull: Option<bool>`\n- `archive_serial_number_lt: Option<i64>`\n- `archive_serial_number_lte: Option<i64>`\n- `checksum_icontains: Option<String>`\n- `checksum_iendswith: Option<String>`\n- `checksum_iexact: Option<String>`\n- `checksum_istartswith: Option<String>`\n- `content_icontains: Option<String>`\n- `content_iendswith: Option<String>`\n- `content_iexact: Option<String>`\n- `content_istartswith: Option<String>`\n- `correspondent_id: Option<i64>`\n- `correspondent_id_in: Option<Vec<i64>>`: Multiple values may be separated by commas.\n- `correspondent_id_none: Option<i64>`\n- `correspondent_isnull: Option<bool>`\n- `correspondent_name_icontains: Option<String>`\n- `correspondent_name_iendswith: Option<String>`\n- `correspondent_name_iexact: Option<String>`\n- `correspondent_name_istartswith: Option<String>`\n- `created_date_gt: Option<chrono::NaiveDate>`\n- `created_date_gte: Option<chrono::NaiveDate>`\n- `created_date_lt: Option<chrono::NaiveDate>`\n- `created_date_lte: Option<chrono::NaiveDate>`\n- `created_day: Option<f64>`\n- `created_gt: Option<chrono::NaiveDate>`\n- `created_gte: Option<chrono::NaiveDate>`\n- `created_lt: Option<chrono::NaiveDate>`\n- `created_lte: Option<chrono::NaiveDate>`\n- `created_month: Option<f64>`\n- `created_year: Option<f64>`\n- `custom_field_query: Option<String>`\n- `custom_fields_icontains: Option<String>`\n- `custom_fields_id_all: Option<i64>`\n- `custom_fields_id_in: Option<i64>`\n- `custom_fields_id_none: Option<i64>`\n- `document_type_id: Option<i64>`\n- `document_type_id_in: Option<Vec<i64>>`: Multiple values may be separated by commas.\n- `document_type_id_none: Option<i64>`\n- `document_type_isnull: Option<bool>`\n- `document_type_name_icontains: Option<String>`\n- `document_type_name_iendswith: Option<String>`\n- `document_type_name_iexact: Option<String>`\n- `document_type_name_istartswith: Option<String>`\n- `fields: Option<Vec<String>>`\n- `full_perms: Option<bool>`\n- `has_custom_fields: Option<bool>`: Has custom field\n- `id: Option<i64>`\n- `id_in: Option<Vec<i64>>`: Multiple values may be separated by commas.\n- `is_in_inbox: Option<bool>`\n- `is_tagged: Option<bool>`: Is tagged\n- `mime_type: Option<String>`\n- `modified_date_gt: Option<chrono::NaiveDate>`\n- `modified_date_gte: Option<chrono::NaiveDate>`\n- `modified_date_lt: Option<chrono::NaiveDate>`\n- `modified_date_lte: Option<chrono::NaiveDate>`\n- `modified_day: Option<f64>`\n- `modified_gt: Option<chrono::DateTime<chrono::Utc>>`\n- `modified_gte: Option<chrono::DateTime<chrono::Utc>>`\n- `modified_lt: Option<chrono::DateTime<chrono::Utc>>`\n- `modified_lte: Option<chrono::DateTime<chrono::Utc>>`\n- `modified_month: Option<f64>`\n- `modified_year: Option<f64>`\n- `ordering: Option<String>`: Which field to use when ordering the results.\n- `original_filename_icontains: Option<String>`\n- `original_filename_iendswith: Option<String>`\n- `original_filename_iexact: Option<String>`\n- `original_filename_istartswith: Option<String>`\n- `owner_id: Option<i64>`\n- `owner_id_in: Option<Vec<i64>>`: Multiple values may be separated by commas.\n- `owner_id_none: Option<i64>`\n- `owner_isnull: Option<bool>`\n- `page: Option<i64>`: A page number within the paginated result set.\n- `page_size: Option<i64>`: Number of results to return per page.\n- `query: Option<String>`: Advanced search query string\n- `search: Option<String>`: A search term.\n- `shared_by_id: Option<bool>`\n- `storage_path_id: Option<i64>`\n- `storage_path_id_in: Option<Vec<i64>>`: Multiple values may be separated by commas.\n- `storage_path_id_none: Option<i64>`\n- `storage_path_isnull: Option<bool>`\n- `storage_path_name_icontains: Option<String>`\n- `storage_path_name_iendswith: Option<String>`\n- `storage_path_name_iexact: Option<String>`\n- `storage_path_name_istartswith: Option<String>`\n- `tags_id: Option<i64>`\n- `tags_id_all: Option<i64>`\n- `tags_id_in: Option<i64>`\n- `tags_id_none: Option<i64>`\n- `tags_name_icontains: Option<String>`\n- `tags_name_iendswith: Option<String>`\n- `tags_name_iexact: Option<String>`\n- `tags_name_istartswith: Option<String>`\n- `title_icontains: Option<String>`\n- `title_iendswith: Option<String>`\n- `title_iexact: Option<String>`\n- `title_istartswith: Option<String>`\n- `title_content: Option<String>`\n\n```rust,no_run\nuse futures_util::TryStreamExt;\nasync fn example_documents_list_stream() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let mut documents = client.documents();\n    let mut stream = documents.list_stream(\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(3.14 as f64),\n        Some(chrono::Utc::now()),\n        Some(chrono::Utc::now()),\n        Some(chrono::Utc::now()),\n        Some(chrono::Utc::now()),\n        Some(3.14 as f64),\n        Some(3.14 as f64),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(true),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(4 as i64),\n        Some(vec![4 as i64]),\n        Some(4 as i64),\n        Some(true),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(3.14 as f64),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(3.14 as f64),\n        Some(3.14 as f64),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(vec![4 as i64]),\n        Some(4 as i64),\n        Some(true),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(vec![\"some-string\".to_string()]),\n        Some(true),\n        Some(true),\n        Some(4 as i64),\n        Some(vec![4 as i64]),\n        Some(true),\n        Some(true),\n        Some(\"some-string\".to_string()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(3.14 as f64),\n        Some(chrono::Utc::now()),\n        Some(chrono::Utc::now()),\n        Some(chrono::Utc::now()),\n        Some(chrono::Utc::now()),\n        Some(3.14 as f64),\n        Some(3.14 as f64),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(4 as i64),\n        Some(vec![4 as i64]),\n        Some(4 as i64),\n        Some(true),\n        Some(4 as i64),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(true),\n        Some(4 as i64),\n        Some(vec![4 as i64]),\n        Some(4 as i64),\n        Some(true),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n    );\n    loop {\n        match stream.try_next().await {\n            Ok(Some(item)) => {\n                println!(\"{:?}\", item);\n            }\n            Ok(None) => {\n                break;\n            }\n            Err(err) => {\n                return Err(err.into());\n            }\n        }\n    }\n\n    Ok(())\n}\n```"]
15    #[tracing::instrument]
16    #[allow(non_snake_case)]
17    pub async fn list<'a>(
18        &'a self,
19        added_date_gt: Option<chrono::NaiveDate>,
20        added_date_gte: Option<chrono::NaiveDate>,
21        added_date_lt: Option<chrono::NaiveDate>,
22        added_date_lte: Option<chrono::NaiveDate>,
23        added_day: Option<f64>,
24        added_gt: Option<chrono::DateTime<chrono::Utc>>,
25        added_gte: Option<chrono::DateTime<chrono::Utc>>,
26        added_lt: Option<chrono::DateTime<chrono::Utc>>,
27        added_lte: Option<chrono::DateTime<chrono::Utc>>,
28        added_month: Option<f64>,
29        added_year: Option<f64>,
30        archive_serial_number: Option<i64>,
31        archive_serial_number_gt: Option<i64>,
32        archive_serial_number_gte: Option<i64>,
33        archive_serial_number_isnull: Option<bool>,
34        archive_serial_number_lt: Option<i64>,
35        archive_serial_number_lte: Option<i64>,
36        checksum_icontains: Option<String>,
37        checksum_iendswith: Option<String>,
38        checksum_iexact: Option<String>,
39        checksum_istartswith: Option<String>,
40        content_icontains: Option<String>,
41        content_iendswith: Option<String>,
42        content_iexact: Option<String>,
43        content_istartswith: Option<String>,
44        correspondent_id: Option<i64>,
45        correspondent_id_in: Option<Vec<i64>>,
46        correspondent_id_none: Option<i64>,
47        correspondent_isnull: Option<bool>,
48        correspondent_name_icontains: Option<String>,
49        correspondent_name_iendswith: Option<String>,
50        correspondent_name_iexact: Option<String>,
51        correspondent_name_istartswith: Option<String>,
52        created_date_gt: Option<chrono::NaiveDate>,
53        created_date_gte: Option<chrono::NaiveDate>,
54        created_date_lt: Option<chrono::NaiveDate>,
55        created_date_lte: Option<chrono::NaiveDate>,
56        created_day: Option<f64>,
57        created_gt: Option<chrono::NaiveDate>,
58        created_gte: Option<chrono::NaiveDate>,
59        created_lt: Option<chrono::NaiveDate>,
60        created_lte: Option<chrono::NaiveDate>,
61        created_month: Option<f64>,
62        created_year: Option<f64>,
63        custom_field_query: Option<String>,
64        custom_fields_icontains: Option<String>,
65        custom_fields_id_all: Option<i64>,
66        custom_fields_id_in: Option<i64>,
67        custom_fields_id_none: Option<i64>,
68        document_type_id: Option<i64>,
69        document_type_id_in: Option<Vec<i64>>,
70        document_type_id_none: Option<i64>,
71        document_type_isnull: Option<bool>,
72        document_type_name_icontains: Option<String>,
73        document_type_name_iendswith: Option<String>,
74        document_type_name_iexact: Option<String>,
75        document_type_name_istartswith: Option<String>,
76        fields: Option<Vec<String>>,
77        full_perms: Option<bool>,
78        has_custom_fields: Option<bool>,
79        id: Option<i64>,
80        id_in: Option<Vec<i64>>,
81        is_in_inbox: Option<bool>,
82        is_tagged: Option<bool>,
83        mime_type: Option<String>,
84        modified_date_gt: Option<chrono::NaiveDate>,
85        modified_date_gte: Option<chrono::NaiveDate>,
86        modified_date_lt: Option<chrono::NaiveDate>,
87        modified_date_lte: Option<chrono::NaiveDate>,
88        modified_day: Option<f64>,
89        modified_gt: Option<chrono::DateTime<chrono::Utc>>,
90        modified_gte: Option<chrono::DateTime<chrono::Utc>>,
91        modified_lt: Option<chrono::DateTime<chrono::Utc>>,
92        modified_lte: Option<chrono::DateTime<chrono::Utc>>,
93        modified_month: Option<f64>,
94        modified_year: Option<f64>,
95        ordering: Option<String>,
96        original_filename_icontains: Option<String>,
97        original_filename_iendswith: Option<String>,
98        original_filename_iexact: Option<String>,
99        original_filename_istartswith: Option<String>,
100        owner_id: Option<i64>,
101        owner_id_in: Option<Vec<i64>>,
102        owner_id_none: Option<i64>,
103        owner_isnull: Option<bool>,
104        page: Option<i64>,
105        page_size: Option<i64>,
106        query: Option<String>,
107        search: Option<String>,
108        shared_by_id: Option<bool>,
109        storage_path_id: Option<i64>,
110        storage_path_id_in: Option<Vec<i64>>,
111        storage_path_id_none: Option<i64>,
112        storage_path_isnull: Option<bool>,
113        storage_path_name_icontains: Option<String>,
114        storage_path_name_iendswith: Option<String>,
115        storage_path_name_iexact: Option<String>,
116        storage_path_name_istartswith: Option<String>,
117        tags_id: Option<i64>,
118        tags_id_all: Option<i64>,
119        tags_id_in: Option<i64>,
120        tags_id_none: Option<i64>,
121        tags_name_icontains: Option<String>,
122        tags_name_iendswith: Option<String>,
123        tags_name_iexact: Option<String>,
124        tags_name_istartswith: Option<String>,
125        title_icontains: Option<String>,
126        title_iendswith: Option<String>,
127        title_iexact: Option<String>,
128        title_istartswith: Option<String>,
129        title_content: Option<String>,
130    ) -> Result<crate::types::PaginatedDocumentList, crate::types::error::Error> {
131        let mut req = self.client.client.request(
132            http::Method::GET,
133            format!("{}/{}", self.client.base_url, "api/documents/"),
134        );
135        req = req.header("Authorization", format!("Token {}", &self.client.token));
136        let mut query_params = vec![];
137        if let Some(p) = added_date_gt {
138            query_params.push(("added__date__gt", format!("{p}")));
139        }
140
141        if let Some(p) = added_date_gte {
142            query_params.push(("added__date__gte", format!("{p}")));
143        }
144
145        if let Some(p) = added_date_lt {
146            query_params.push(("added__date__lt", format!("{p}")));
147        }
148
149        if let Some(p) = added_date_lte {
150            query_params.push(("added__date__lte", format!("{p}")));
151        }
152
153        if let Some(p) = added_day {
154            query_params.push(("added__day", format!("{p}")));
155        }
156
157        if let Some(p) = added_gt {
158            query_params.push(("added__gt", format!("{p}")));
159        }
160
161        if let Some(p) = added_gte {
162            query_params.push(("added__gte", format!("{p}")));
163        }
164
165        if let Some(p) = added_lt {
166            query_params.push(("added__lt", format!("{p}")));
167        }
168
169        if let Some(p) = added_lte {
170            query_params.push(("added__lte", format!("{p}")));
171        }
172
173        if let Some(p) = added_month {
174            query_params.push(("added__month", format!("{p}")));
175        }
176
177        if let Some(p) = added_year {
178            query_params.push(("added__year", format!("{p}")));
179        }
180
181        if let Some(p) = archive_serial_number {
182            query_params.push(("archive_serial_number", format!("{p}")));
183        }
184
185        if let Some(p) = archive_serial_number_gt {
186            query_params.push(("archive_serial_number__gt", format!("{p}")));
187        }
188
189        if let Some(p) = archive_serial_number_gte {
190            query_params.push(("archive_serial_number__gte", format!("{p}")));
191        }
192
193        if let Some(p) = archive_serial_number_isnull {
194            query_params.push(("archive_serial_number__isnull", format!("{p}")));
195        }
196
197        if let Some(p) = archive_serial_number_lt {
198            query_params.push(("archive_serial_number__lt", format!("{p}")));
199        }
200
201        if let Some(p) = archive_serial_number_lte {
202            query_params.push(("archive_serial_number__lte", format!("{p}")));
203        }
204
205        if let Some(p) = checksum_icontains {
206            query_params.push(("checksum__icontains", p));
207        }
208
209        if let Some(p) = checksum_iendswith {
210            query_params.push(("checksum__iendswith", p));
211        }
212
213        if let Some(p) = checksum_iexact {
214            query_params.push(("checksum__iexact", p));
215        }
216
217        if let Some(p) = checksum_istartswith {
218            query_params.push(("checksum__istartswith", p));
219        }
220
221        if let Some(p) = content_icontains {
222            query_params.push(("content__icontains", p));
223        }
224
225        if let Some(p) = content_iendswith {
226            query_params.push(("content__iendswith", p));
227        }
228
229        if let Some(p) = content_iexact {
230            query_params.push(("content__iexact", p));
231        }
232
233        if let Some(p) = content_istartswith {
234            query_params.push(("content__istartswith", p));
235        }
236
237        if let Some(p) = correspondent_id {
238            query_params.push(("correspondent__id", format!("{p}")));
239        }
240
241        if let Some(p) = correspondent_id_in {
242            query_params.push(("correspondent__id__in", itertools::join(p, ",")));
243        }
244
245        if let Some(p) = correspondent_id_none {
246            query_params.push(("correspondent__id__none", format!("{p}")));
247        }
248
249        if let Some(p) = correspondent_isnull {
250            query_params.push(("correspondent__isnull", format!("{p}")));
251        }
252
253        if let Some(p) = correspondent_name_icontains {
254            query_params.push(("correspondent__name__icontains", p));
255        }
256
257        if let Some(p) = correspondent_name_iendswith {
258            query_params.push(("correspondent__name__iendswith", p));
259        }
260
261        if let Some(p) = correspondent_name_iexact {
262            query_params.push(("correspondent__name__iexact", p));
263        }
264
265        if let Some(p) = correspondent_name_istartswith {
266            query_params.push(("correspondent__name__istartswith", p));
267        }
268
269        if let Some(p) = created_date_gt {
270            query_params.push(("created__date__gt", format!("{p}")));
271        }
272
273        if let Some(p) = created_date_gte {
274            query_params.push(("created__date__gte", format!("{p}")));
275        }
276
277        if let Some(p) = created_date_lt {
278            query_params.push(("created__date__lt", format!("{p}")));
279        }
280
281        if let Some(p) = created_date_lte {
282            query_params.push(("created__date__lte", format!("{p}")));
283        }
284
285        if let Some(p) = created_day {
286            query_params.push(("created__day", format!("{p}")));
287        }
288
289        if let Some(p) = created_gt {
290            query_params.push(("created__gt", format!("{p}")));
291        }
292
293        if let Some(p) = created_gte {
294            query_params.push(("created__gte", format!("{p}")));
295        }
296
297        if let Some(p) = created_lt {
298            query_params.push(("created__lt", format!("{p}")));
299        }
300
301        if let Some(p) = created_lte {
302            query_params.push(("created__lte", format!("{p}")));
303        }
304
305        if let Some(p) = created_month {
306            query_params.push(("created__month", format!("{p}")));
307        }
308
309        if let Some(p) = created_year {
310            query_params.push(("created__year", format!("{p}")));
311        }
312
313        if let Some(p) = custom_field_query {
314            query_params.push(("custom_field_query", p));
315        }
316
317        if let Some(p) = custom_fields_icontains {
318            query_params.push(("custom_fields__icontains", p));
319        }
320
321        if let Some(p) = custom_fields_id_all {
322            query_params.push(("custom_fields__id__all", format!("{p}")));
323        }
324
325        if let Some(p) = custom_fields_id_in {
326            query_params.push(("custom_fields__id__in", format!("{p}")));
327        }
328
329        if let Some(p) = custom_fields_id_none {
330            query_params.push(("custom_fields__id__none", format!("{p}")));
331        }
332
333        if let Some(p) = document_type_id {
334            query_params.push(("document_type__id", format!("{p}")));
335        }
336
337        if let Some(p) = document_type_id_in {
338            query_params.push(("document_type__id__in", itertools::join(p, ",")));
339        }
340
341        if let Some(p) = document_type_id_none {
342            query_params.push(("document_type__id__none", format!("{p}")));
343        }
344
345        if let Some(p) = document_type_isnull {
346            query_params.push(("document_type__isnull", format!("{p}")));
347        }
348
349        if let Some(p) = document_type_name_icontains {
350            query_params.push(("document_type__name__icontains", p));
351        }
352
353        if let Some(p) = document_type_name_iendswith {
354            query_params.push(("document_type__name__iendswith", p));
355        }
356
357        if let Some(p) = document_type_name_iexact {
358            query_params.push(("document_type__name__iexact", p));
359        }
360
361        if let Some(p) = document_type_name_istartswith {
362            query_params.push(("document_type__name__istartswith", p));
363        }
364
365        if let Some(p) = fields {
366            query_params.push(("fields", itertools::join(p, ",")));
367        }
368
369        if let Some(p) = full_perms {
370            query_params.push(("full_perms", format!("{p}")));
371        }
372
373        if let Some(p) = has_custom_fields {
374            query_params.push(("has_custom_fields", format!("{p}")));
375        }
376
377        if let Some(p) = id {
378            query_params.push(("id", format!("{p}")));
379        }
380
381        if let Some(p) = id_in {
382            query_params.push(("id__in", itertools::join(p, ",")));
383        }
384
385        if let Some(p) = is_in_inbox {
386            query_params.push(("is_in_inbox", format!("{p}")));
387        }
388
389        if let Some(p) = is_tagged {
390            query_params.push(("is_tagged", format!("{p}")));
391        }
392
393        if let Some(p) = mime_type {
394            query_params.push(("mime_type", p));
395        }
396
397        if let Some(p) = modified_date_gt {
398            query_params.push(("modified__date__gt", format!("{p}")));
399        }
400
401        if let Some(p) = modified_date_gte {
402            query_params.push(("modified__date__gte", format!("{p}")));
403        }
404
405        if let Some(p) = modified_date_lt {
406            query_params.push(("modified__date__lt", format!("{p}")));
407        }
408
409        if let Some(p) = modified_date_lte {
410            query_params.push(("modified__date__lte", format!("{p}")));
411        }
412
413        if let Some(p) = modified_day {
414            query_params.push(("modified__day", format!("{p}")));
415        }
416
417        if let Some(p) = modified_gt {
418            query_params.push(("modified__gt", format!("{p}")));
419        }
420
421        if let Some(p) = modified_gte {
422            query_params.push(("modified__gte", format!("{p}")));
423        }
424
425        if let Some(p) = modified_lt {
426            query_params.push(("modified__lt", format!("{p}")));
427        }
428
429        if let Some(p) = modified_lte {
430            query_params.push(("modified__lte", format!("{p}")));
431        }
432
433        if let Some(p) = modified_month {
434            query_params.push(("modified__month", format!("{p}")));
435        }
436
437        if let Some(p) = modified_year {
438            query_params.push(("modified__year", format!("{p}")));
439        }
440
441        if let Some(p) = ordering {
442            query_params.push(("ordering", p));
443        }
444
445        if let Some(p) = original_filename_icontains {
446            query_params.push(("original_filename__icontains", p));
447        }
448
449        if let Some(p) = original_filename_iendswith {
450            query_params.push(("original_filename__iendswith", p));
451        }
452
453        if let Some(p) = original_filename_iexact {
454            query_params.push(("original_filename__iexact", p));
455        }
456
457        if let Some(p) = original_filename_istartswith {
458            query_params.push(("original_filename__istartswith", p));
459        }
460
461        if let Some(p) = owner_id {
462            query_params.push(("owner__id", format!("{p}")));
463        }
464
465        if let Some(p) = owner_id_in {
466            query_params.push(("owner__id__in", itertools::join(p, ",")));
467        }
468
469        if let Some(p) = owner_id_none {
470            query_params.push(("owner__id__none", format!("{p}")));
471        }
472
473        if let Some(p) = owner_isnull {
474            query_params.push(("owner__isnull", format!("{p}")));
475        }
476
477        if let Some(p) = page {
478            query_params.push(("page", format!("{p}")));
479        }
480
481        if let Some(p) = page_size {
482            query_params.push(("page_size", format!("{p}")));
483        }
484
485        if let Some(p) = query {
486            query_params.push(("query", p));
487        }
488
489        if let Some(p) = search {
490            query_params.push(("search", p));
491        }
492
493        if let Some(p) = shared_by_id {
494            query_params.push(("shared_by__id", format!("{p}")));
495        }
496
497        if let Some(p) = storage_path_id {
498            query_params.push(("storage_path__id", format!("{p}")));
499        }
500
501        if let Some(p) = storage_path_id_in {
502            query_params.push(("storage_path__id__in", itertools::join(p, ",")));
503        }
504
505        if let Some(p) = storage_path_id_none {
506            query_params.push(("storage_path__id__none", format!("{p}")));
507        }
508
509        if let Some(p) = storage_path_isnull {
510            query_params.push(("storage_path__isnull", format!("{p}")));
511        }
512
513        if let Some(p) = storage_path_name_icontains {
514            query_params.push(("storage_path__name__icontains", p));
515        }
516
517        if let Some(p) = storage_path_name_iendswith {
518            query_params.push(("storage_path__name__iendswith", p));
519        }
520
521        if let Some(p) = storage_path_name_iexact {
522            query_params.push(("storage_path__name__iexact", p));
523        }
524
525        if let Some(p) = storage_path_name_istartswith {
526            query_params.push(("storage_path__name__istartswith", p));
527        }
528
529        if let Some(p) = tags_id {
530            query_params.push(("tags__id", format!("{p}")));
531        }
532
533        if let Some(p) = tags_id_all {
534            query_params.push(("tags__id__all", format!("{p}")));
535        }
536
537        if let Some(p) = tags_id_in {
538            query_params.push(("tags__id__in", format!("{p}")));
539        }
540
541        if let Some(p) = tags_id_none {
542            query_params.push(("tags__id__none", format!("{p}")));
543        }
544
545        if let Some(p) = tags_name_icontains {
546            query_params.push(("tags__name__icontains", p));
547        }
548
549        if let Some(p) = tags_name_iendswith {
550            query_params.push(("tags__name__iendswith", p));
551        }
552
553        if let Some(p) = tags_name_iexact {
554            query_params.push(("tags__name__iexact", p));
555        }
556
557        if let Some(p) = tags_name_istartswith {
558            query_params.push(("tags__name__istartswith", p));
559        }
560
561        if let Some(p) = title_icontains {
562            query_params.push(("title__icontains", p));
563        }
564
565        if let Some(p) = title_iendswith {
566            query_params.push(("title__iendswith", p));
567        }
568
569        if let Some(p) = title_iexact {
570            query_params.push(("title__iexact", p));
571        }
572
573        if let Some(p) = title_istartswith {
574            query_params.push(("title__istartswith", p));
575        }
576
577        if let Some(p) = title_content {
578            query_params.push(("title_content", p));
579        }
580
581        req = req.query(&query_params);
582        let resp = req.send().await?;
583        let status = resp.status();
584        if status.is_success() {
585            let text = resp.text().await.unwrap_or_default();
586            serde_json::from_str(&text).map_err(|err| {
587                crate::types::error::Error::from_serde_error(
588                    format_serde_error::SerdeError::new(text.to_string(), err),
589                    status,
590                )
591            })
592        } else {
593            let text = resp.text().await.unwrap_or_default();
594            Err(crate::types::error::Error::Server {
595                body: text.to_string(),
596                status,
597            })
598        }
599    }
600
601    #[doc = "Perform a `GET` request to `/api/documents/`.\n\nDocument views including search\n\n**Parameters:**\n\n- `added_date_gt: Option<chrono::NaiveDate>`\n- `added_date_gte: Option<chrono::NaiveDate>`\n- `added_date_lt: Option<chrono::NaiveDate>`\n- `added_date_lte: Option<chrono::NaiveDate>`\n- `added_day: Option<f64>`\n- `added_gt: Option<chrono::DateTime<chrono::Utc>>`\n- `added_gte: Option<chrono::DateTime<chrono::Utc>>`\n- `added_lt: Option<chrono::DateTime<chrono::Utc>>`\n- `added_lte: Option<chrono::DateTime<chrono::Utc>>`\n- `added_month: Option<f64>`\n- `added_year: Option<f64>`\n- `archive_serial_number: Option<i64>`\n- `archive_serial_number_gt: Option<i64>`\n- `archive_serial_number_gte: Option<i64>`\n- `archive_serial_number_isnull: Option<bool>`\n- `archive_serial_number_lt: Option<i64>`\n- `archive_serial_number_lte: Option<i64>`\n- `checksum_icontains: Option<String>`\n- `checksum_iendswith: Option<String>`\n- `checksum_iexact: Option<String>`\n- `checksum_istartswith: Option<String>`\n- `content_icontains: Option<String>`\n- `content_iendswith: Option<String>`\n- `content_iexact: Option<String>`\n- `content_istartswith: Option<String>`\n- `correspondent_id: Option<i64>`\n- `correspondent_id_in: Option<Vec<i64>>`: Multiple values may be separated by commas.\n- `correspondent_id_none: Option<i64>`\n- `correspondent_isnull: Option<bool>`\n- `correspondent_name_icontains: Option<String>`\n- `correspondent_name_iendswith: Option<String>`\n- `correspondent_name_iexact: Option<String>`\n- `correspondent_name_istartswith: Option<String>`\n- `created_date_gt: Option<chrono::NaiveDate>`\n- `created_date_gte: Option<chrono::NaiveDate>`\n- `created_date_lt: Option<chrono::NaiveDate>`\n- `created_date_lte: Option<chrono::NaiveDate>`\n- `created_day: Option<f64>`\n- `created_gt: Option<chrono::NaiveDate>`\n- `created_gte: Option<chrono::NaiveDate>`\n- `created_lt: Option<chrono::NaiveDate>`\n- `created_lte: Option<chrono::NaiveDate>`\n- `created_month: Option<f64>`\n- `created_year: Option<f64>`\n- `custom_field_query: Option<String>`\n- `custom_fields_icontains: Option<String>`\n- `custom_fields_id_all: Option<i64>`\n- `custom_fields_id_in: Option<i64>`\n- `custom_fields_id_none: Option<i64>`\n- `document_type_id: Option<i64>`\n- `document_type_id_in: Option<Vec<i64>>`: Multiple values may be separated by commas.\n- `document_type_id_none: Option<i64>`\n- `document_type_isnull: Option<bool>`\n- `document_type_name_icontains: Option<String>`\n- `document_type_name_iendswith: Option<String>`\n- `document_type_name_iexact: Option<String>`\n- `document_type_name_istartswith: Option<String>`\n- `fields: Option<Vec<String>>`\n- `full_perms: Option<bool>`\n- `has_custom_fields: Option<bool>`: Has custom field\n- `id: Option<i64>`\n- `id_in: Option<Vec<i64>>`: Multiple values may be separated by commas.\n- `is_in_inbox: Option<bool>`\n- `is_tagged: Option<bool>`: Is tagged\n- `mime_type: Option<String>`\n- `modified_date_gt: Option<chrono::NaiveDate>`\n- `modified_date_gte: Option<chrono::NaiveDate>`\n- `modified_date_lt: Option<chrono::NaiveDate>`\n- `modified_date_lte: Option<chrono::NaiveDate>`\n- `modified_day: Option<f64>`\n- `modified_gt: Option<chrono::DateTime<chrono::Utc>>`\n- `modified_gte: Option<chrono::DateTime<chrono::Utc>>`\n- `modified_lt: Option<chrono::DateTime<chrono::Utc>>`\n- `modified_lte: Option<chrono::DateTime<chrono::Utc>>`\n- `modified_month: Option<f64>`\n- `modified_year: Option<f64>`\n- `ordering: Option<String>`: Which field to use when ordering the results.\n- `original_filename_icontains: Option<String>`\n- `original_filename_iendswith: Option<String>`\n- `original_filename_iexact: Option<String>`\n- `original_filename_istartswith: Option<String>`\n- `owner_id: Option<i64>`\n- `owner_id_in: Option<Vec<i64>>`: Multiple values may be separated by commas.\n- `owner_id_none: Option<i64>`\n- `owner_isnull: Option<bool>`\n- `page: Option<i64>`: A page number within the paginated result set.\n- `page_size: Option<i64>`: Number of results to return per page.\n- `query: Option<String>`: Advanced search query string\n- `search: Option<String>`: A search term.\n- `shared_by_id: Option<bool>`\n- `storage_path_id: Option<i64>`\n- `storage_path_id_in: Option<Vec<i64>>`: Multiple values may be separated by commas.\n- `storage_path_id_none: Option<i64>`\n- `storage_path_isnull: Option<bool>`\n- `storage_path_name_icontains: Option<String>`\n- `storage_path_name_iendswith: Option<String>`\n- `storage_path_name_iexact: Option<String>`\n- `storage_path_name_istartswith: Option<String>`\n- `tags_id: Option<i64>`\n- `tags_id_all: Option<i64>`\n- `tags_id_in: Option<i64>`\n- `tags_id_none: Option<i64>`\n- `tags_name_icontains: Option<String>`\n- `tags_name_iendswith: Option<String>`\n- `tags_name_iexact: Option<String>`\n- `tags_name_istartswith: Option<String>`\n- `title_icontains: Option<String>`\n- `title_iendswith: Option<String>`\n- `title_iexact: Option<String>`\n- `title_istartswith: Option<String>`\n- `title_content: Option<String>`\n\n```rust,no_run\nuse futures_util::TryStreamExt;\nasync fn example_documents_list_stream() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let mut documents = client.documents();\n    let mut stream = documents.list_stream(\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(3.14 as f64),\n        Some(chrono::Utc::now()),\n        Some(chrono::Utc::now()),\n        Some(chrono::Utc::now()),\n        Some(chrono::Utc::now()),\n        Some(3.14 as f64),\n        Some(3.14 as f64),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(true),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(4 as i64),\n        Some(vec![4 as i64]),\n        Some(4 as i64),\n        Some(true),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(3.14 as f64),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(3.14 as f64),\n        Some(3.14 as f64),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(vec![4 as i64]),\n        Some(4 as i64),\n        Some(true),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(vec![\"some-string\".to_string()]),\n        Some(true),\n        Some(true),\n        Some(4 as i64),\n        Some(vec![4 as i64]),\n        Some(true),\n        Some(true),\n        Some(\"some-string\".to_string()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(chrono::Utc::now().date_naive()),\n        Some(3.14 as f64),\n        Some(chrono::Utc::now()),\n        Some(chrono::Utc::now()),\n        Some(chrono::Utc::now()),\n        Some(chrono::Utc::now()),\n        Some(3.14 as f64),\n        Some(3.14 as f64),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(4 as i64),\n        Some(vec![4 as i64]),\n        Some(4 as i64),\n        Some(true),\n        Some(4 as i64),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(true),\n        Some(4 as i64),\n        Some(vec![4 as i64]),\n        Some(4 as i64),\n        Some(true),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(4 as i64),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n        Some(\"some-string\".to_string()),\n    );\n    loop {\n        match stream.try_next().await {\n            Ok(Some(item)) => {\n                println!(\"{:?}\", item);\n            }\n            Ok(None) => {\n                break;\n            }\n            Err(err) => {\n                return Err(err.into());\n            }\n        }\n    }\n\n    Ok(())\n}\n```"]
602    #[tracing::instrument]
603    #[cfg(not(feature = "js"))]
604    #[allow(non_snake_case)]
605    pub fn list_stream<'a>(
606        &'a self,
607        added__date__gt: Option<chrono::NaiveDate>,
608        added__date__gte: Option<chrono::NaiveDate>,
609        added__date__lt: Option<chrono::NaiveDate>,
610        added__date__lte: Option<chrono::NaiveDate>,
611        added__day: Option<f64>,
612        added__gt: Option<chrono::DateTime<chrono::Utc>>,
613        added__gte: Option<chrono::DateTime<chrono::Utc>>,
614        added__lt: Option<chrono::DateTime<chrono::Utc>>,
615        added__lte: Option<chrono::DateTime<chrono::Utc>>,
616        added__month: Option<f64>,
617        added__year: Option<f64>,
618        archive_serial_number: Option<i64>,
619        archive_serial_number__gt: Option<i64>,
620        archive_serial_number__gte: Option<i64>,
621        archive_serial_number__isnull: Option<bool>,
622        archive_serial_number__lt: Option<i64>,
623        archive_serial_number__lte: Option<i64>,
624        checksum__icontains: Option<String>,
625        checksum__iendswith: Option<String>,
626        checksum__iexact: Option<String>,
627        checksum__istartswith: Option<String>,
628        content__icontains: Option<String>,
629        content__iendswith: Option<String>,
630        content__iexact: Option<String>,
631        content__istartswith: Option<String>,
632        correspondent__id: Option<i64>,
633        correspondent__id__in: Option<Vec<i64>>,
634        correspondent__id__none: Option<i64>,
635        correspondent__isnull: Option<bool>,
636        correspondent__name__icontains: Option<String>,
637        correspondent__name__iendswith: Option<String>,
638        correspondent__name__iexact: Option<String>,
639        correspondent__name__istartswith: Option<String>,
640        created__date__gt: Option<chrono::NaiveDate>,
641        created__date__gte: Option<chrono::NaiveDate>,
642        created__date__lt: Option<chrono::NaiveDate>,
643        created__date__lte: Option<chrono::NaiveDate>,
644        created__day: Option<f64>,
645        created__gt: Option<chrono::NaiveDate>,
646        created__gte: Option<chrono::NaiveDate>,
647        created__lt: Option<chrono::NaiveDate>,
648        created__lte: Option<chrono::NaiveDate>,
649        created__month: Option<f64>,
650        created__year: Option<f64>,
651        custom_field_query: Option<String>,
652        custom_fields__icontains: Option<String>,
653        custom_fields__id__all: Option<i64>,
654        custom_fields__id__in: Option<i64>,
655        custom_fields__id__none: Option<i64>,
656        document_type__id: Option<i64>,
657        document_type__id__in: Option<Vec<i64>>,
658        document_type__id__none: Option<i64>,
659        document_type__isnull: Option<bool>,
660        document_type__name__icontains: Option<String>,
661        document_type__name__iendswith: Option<String>,
662        document_type__name__iexact: Option<String>,
663        document_type__name__istartswith: Option<String>,
664        fields: Option<Vec<String>>,
665        full_perms: Option<bool>,
666        has_custom_fields: Option<bool>,
667        id: Option<i64>,
668        id__in: Option<Vec<i64>>,
669        is_in_inbox: Option<bool>,
670        is_tagged: Option<bool>,
671        mime_type: Option<String>,
672        modified__date__gt: Option<chrono::NaiveDate>,
673        modified__date__gte: Option<chrono::NaiveDate>,
674        modified__date__lt: Option<chrono::NaiveDate>,
675        modified__date__lte: Option<chrono::NaiveDate>,
676        modified__day: Option<f64>,
677        modified__gt: Option<chrono::DateTime<chrono::Utc>>,
678        modified__gte: Option<chrono::DateTime<chrono::Utc>>,
679        modified__lt: Option<chrono::DateTime<chrono::Utc>>,
680        modified__lte: Option<chrono::DateTime<chrono::Utc>>,
681        modified__month: Option<f64>,
682        modified__year: Option<f64>,
683        ordering: Option<String>,
684        original_filename__icontains: Option<String>,
685        original_filename__iendswith: Option<String>,
686        original_filename__iexact: Option<String>,
687        original_filename__istartswith: Option<String>,
688        owner__id: Option<i64>,
689        owner__id__in: Option<Vec<i64>>,
690        owner__id__none: Option<i64>,
691        owner__isnull: Option<bool>,
692        page_size: Option<i64>,
693        query: Option<String>,
694        search: Option<String>,
695        shared_by__id: Option<bool>,
696        storage_path__id: Option<i64>,
697        storage_path__id__in: Option<Vec<i64>>,
698        storage_path__id__none: Option<i64>,
699        storage_path__isnull: Option<bool>,
700        storage_path__name__icontains: Option<String>,
701        storage_path__name__iendswith: Option<String>,
702        storage_path__name__iexact: Option<String>,
703        storage_path__name__istartswith: Option<String>,
704        tags__id: Option<i64>,
705        tags__id__all: Option<i64>,
706        tags__id__in: Option<i64>,
707        tags__id__none: Option<i64>,
708        tags__name__icontains: Option<String>,
709        tags__name__iendswith: Option<String>,
710        tags__name__iexact: Option<String>,
711        tags__name__istartswith: Option<String>,
712        title__icontains: Option<String>,
713        title__iendswith: Option<String>,
714        title__iexact: Option<String>,
715        title__istartswith: Option<String>,
716        title_content: Option<String>,
717    ) -> impl futures::Stream<Item = Result<crate::types::Document, crate::types::error::Error>>
718           + Unpin
719           + '_ {
720        use crate::types::paginate::Pagination;
721        use futures::{StreamExt, TryFutureExt, TryStreamExt};
722        self.list(
723            added__date__gt,
724            added__date__gte,
725            added__date__lt,
726            added__date__lte,
727            added__day,
728            added__gt,
729            added__gte,
730            added__lt,
731            added__lte,
732            added__month,
733            added__year,
734            archive_serial_number,
735            archive_serial_number__gt,
736            archive_serial_number__gte,
737            archive_serial_number__isnull,
738            archive_serial_number__lt,
739            archive_serial_number__lte,
740            checksum__icontains,
741            checksum__iendswith,
742            checksum__iexact,
743            checksum__istartswith,
744            content__icontains,
745            content__iendswith,
746            content__iexact,
747            content__istartswith,
748            correspondent__id,
749            correspondent__id__in,
750            correspondent__id__none,
751            correspondent__isnull,
752            correspondent__name__icontains,
753            correspondent__name__iendswith,
754            correspondent__name__iexact,
755            correspondent__name__istartswith,
756            created__date__gt,
757            created__date__gte,
758            created__date__lt,
759            created__date__lte,
760            created__day,
761            created__gt,
762            created__gte,
763            created__lt,
764            created__lte,
765            created__month,
766            created__year,
767            custom_field_query,
768            custom_fields__icontains,
769            custom_fields__id__all,
770            custom_fields__id__in,
771            custom_fields__id__none,
772            document_type__id,
773            document_type__id__in,
774            document_type__id__none,
775            document_type__isnull,
776            document_type__name__icontains,
777            document_type__name__iendswith,
778            document_type__name__iexact,
779            document_type__name__istartswith,
780            fields,
781            full_perms,
782            has_custom_fields,
783            id,
784            id__in,
785            is_in_inbox,
786            is_tagged,
787            mime_type,
788            modified__date__gt,
789            modified__date__gte,
790            modified__date__lt,
791            modified__date__lte,
792            modified__day,
793            modified__gt,
794            modified__gte,
795            modified__lt,
796            modified__lte,
797            modified__month,
798            modified__year,
799            ordering,
800            original_filename__icontains,
801            original_filename__iendswith,
802            original_filename__iexact,
803            original_filename__istartswith,
804            owner__id,
805            owner__id__in,
806            owner__id__none,
807            owner__isnull,
808            None,
809            page_size,
810            query,
811            search,
812            shared_by__id,
813            storage_path__id,
814            storage_path__id__in,
815            storage_path__id__none,
816            storage_path__isnull,
817            storage_path__name__icontains,
818            storage_path__name__iendswith,
819            storage_path__name__iexact,
820            storage_path__name__istartswith,
821            tags__id,
822            tags__id__all,
823            tags__id__in,
824            tags__id__none,
825            tags__name__icontains,
826            tags__name__iendswith,
827            tags__name__iexact,
828            tags__name__istartswith,
829            title__icontains,
830            title__iendswith,
831            title__iexact,
832            title__istartswith,
833            title_content,
834        )
835        .map_ok(move |result| {
836            let items = futures::stream::iter(result.items().into_iter().map(Ok));
837            let next_pages = futures::stream::try_unfold(
838                (None, result),
839                move |(prev_page_token, new_result)| async move {
840                    if new_result.has_more_pages()
841                        && !new_result.items().is_empty()
842                        && prev_page_token != new_result.next_page_token()
843                    {
844                        async {
845                            let mut req = self.client.client.request(
846                                http::Method::GET,
847                                format!("{}/{}", self.client.base_url, "api/documents/"),
848                            );
849                            req = req
850                                .header("Authorization", format!("Token {}", &self.client.token));
851                            let mut request = req.build()?;
852                            request = new_result.next_page(request)?;
853                            let resp = self.client.client.execute(request).await?;
854                            let status = resp.status();
855                            if status.is_success() {
856                                let text = resp.text().await.unwrap_or_default();
857                                serde_json::from_str(&text).map_err(|err| {
858                                    crate::types::error::Error::from_serde_error(
859                                        format_serde_error::SerdeError::new(text.to_string(), err),
860                                        status,
861                                    )
862                                })
863                            } else {
864                                let text = resp.text().await.unwrap_or_default();
865                                Err(crate::types::error::Error::Server {
866                                    body: text.to_string(),
867                                    status,
868                                })
869                            }
870                        }
871                        .map_ok(|result: crate::types::PaginatedDocumentList| {
872                            Some((
873                                futures::stream::iter(result.items().into_iter().map(Ok)),
874                                (new_result.next_page_token(), result),
875                            ))
876                        })
877                        .await
878                    } else {
879                        Ok(None)
880                    }
881                },
882            )
883            .try_flatten();
884            items.chain(next_pages)
885        })
886        .try_flatten_stream()
887        .boxed()
888    }
889
890    #[doc = "Perform a `GET` request to `/api/documents/{doc_id}/`.\n\nRetrieve a single document\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n- `fields: Option<Vec<String>>`\n- `full_perms: Option<bool>`\n\n```rust,no_run\nasync fn example_documents_retrieve() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: paperless_api_client::types::Document = client\n        .documents()\n        .retrieve(4 as i64, Some(vec![\"some-string\".to_string()]), Some(true))\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
891    #[tracing::instrument]
892    #[allow(non_snake_case)]
893    pub async fn retrieve<'a>(
894        &'a self,
895        doc_id: i64,
896        fields: Option<Vec<String>>,
897        full_perms: Option<bool>,
898    ) -> Result<crate::types::Document, crate::types::error::Error> {
899        let mut req = self.client.client.request(
900            http::Method::GET,
901            format!(
902                "{}/{}",
903                self.client.base_url,
904                "api/documents/{doc_id}/".replace("{doc_id}", &format!("{doc_id}"))
905            ),
906        );
907        req = req.header("Authorization", format!("Token {}", &self.client.token));
908        let mut query_params = vec![];
909        if let Some(p) = fields {
910            query_params.push(("fields", itertools::join(p, ",")));
911        }
912
913        if let Some(p) = full_perms {
914            query_params.push(("full_perms", format!("{p}")));
915        }
916
917        req = req.query(&query_params);
918        let resp = req.send().await?;
919        let status = resp.status();
920        if status.is_success() {
921            let text = resp.text().await.unwrap_or_default();
922            serde_json::from_str(&text).map_err(|err| {
923                crate::types::error::Error::from_serde_error(
924                    format_serde_error::SerdeError::new(text.to_string(), err),
925                    status,
926                )
927            })
928        } else {
929            let text = resp.text().await.unwrap_or_default();
930            Err(crate::types::error::Error::Server {
931                body: text.to_string(),
932                status,
933            })
934        }
935    }
936
937    #[doc = "Perform a `PUT` request to `/api/documents/{doc_id}/`.\n\nPass a user object to serializer\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n\n```rust,no_run\nasync fn example_documents_update() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: paperless_api_client::types::Document = client\n        .documents()\n        .update(\n            4 as i64,\n            &paperless_api_client::types::DocumentRequest {\n                correspondent: Some(4 as i64),\n                document_type: Some(4 as i64),\n                storage_path: Some(4 as i64),\n                title: Some(\"some-string\".to_string()),\n                content: Some(\"some-string\".to_string()),\n                tags: vec![4 as i64],\n                created: Some(chrono::Utc::now().date_naive()),\n                created_date: Some(chrono::Utc::now().date_naive()),\n                deleted_at: Some(chrono::Utc::now()),\n                archive_serial_number: Some(4 as i64),\n                owner: Some(4 as i64),\n                set_permissions: Some(paperless_api_client::types::SetPermissions {\n                    view: Some(paperless_api_client::types::View {\n                        users: Some(vec![4 as i64]),\n                        groups: Some(vec![4 as i64]),\n                    }),\n                    change: Some(paperless_api_client::types::Change {\n                        users: Some(vec![4 as i64]),\n                        groups: Some(vec![4 as i64]),\n                    }),\n                }),\n                custom_fields: Some(vec![paperless_api_client::types::CustomFieldInstanceRequest {\n                    value: Some(serde_json::Value::String(\"some-string\".to_string())),\n                    field: 4 as i64,\n                }]),\n                remove_inbox_tags: Some(true),\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
938    #[tracing::instrument]
939    #[allow(non_snake_case)]
940    pub async fn update<'a>(
941        &'a self,
942        doc_id: i64,
943        body: &crate::types::DocumentRequest,
944    ) -> Result<crate::types::Document, crate::types::error::Error> {
945        let mut req = self.client.client.request(
946            http::Method::PUT,
947            format!(
948                "{}/{}",
949                self.client.base_url,
950                "api/documents/{doc_id}/".replace("{doc_id}", &format!("{doc_id}"))
951            ),
952        );
953        req = req.header("Authorization", format!("Token {}", &self.client.token));
954        req = req.json(body);
955        let resp = req.send().await?;
956        let status = resp.status();
957        if status.is_success() {
958            let text = resp.text().await.unwrap_or_default();
959            serde_json::from_str(&text).map_err(|err| {
960                crate::types::error::Error::from_serde_error(
961                    format_serde_error::SerdeError::new(text.to_string(), err),
962                    status,
963                )
964            })
965        } else {
966            let text = resp.text().await.unwrap_or_default();
967            Err(crate::types::error::Error::Server {
968                body: text.to_string(),
969                status,
970            })
971        }
972    }
973
974    #[doc = "Perform a `DELETE` request to `/api/documents/{doc_id}/`.\n\nPass a user object to serializer\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n\n```rust,no_run\nasync fn example_documents_destroy() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    client.documents().destroy(4 as i64).await?;\n    Ok(())\n}\n```"]
975    #[tracing::instrument]
976    #[allow(non_snake_case)]
977    pub async fn destroy<'a>(&'a self, doc_id: i64) -> Result<(), crate::types::error::Error> {
978        let mut req = self.client.client.request(
979            http::Method::DELETE,
980            format!(
981                "{}/{}",
982                self.client.base_url,
983                "api/documents/{doc_id}/".replace("{doc_id}", &format!("{doc_id}"))
984            ),
985        );
986        req = req.header("Authorization", format!("Token {}", &self.client.token));
987        let resp = req.send().await?;
988        let status = resp.status();
989        if status.is_success() {
990            Ok(())
991        } else {
992            let text = resp.text().await.unwrap_or_default();
993            Err(crate::types::error::Error::Server {
994                body: text.to_string(),
995                status,
996            })
997        }
998    }
999
1000    #[doc = "Perform a `PATCH` request to `/api/documents/{doc_id}/`.\n\nPass a user object to serializer\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n\n```rust,no_run\nasync fn example_documents_partial_update() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: paperless_api_client::types::Document = client\n        .documents()\n        .partial_update(\n            4 as i64,\n            &paperless_api_client::types::PatchedDocumentRequest {\n                correspondent: Some(4 as i64),\n                document_type: Some(4 as i64),\n                storage_path: Some(4 as i64),\n                title: Some(\"some-string\".to_string()),\n                content: Some(\"some-string\".to_string()),\n                tags: Some(vec![4 as i64]),\n                created: Some(chrono::Utc::now().date_naive()),\n                created_date: Some(chrono::Utc::now().date_naive()),\n                deleted_at: Some(chrono::Utc::now()),\n                archive_serial_number: Some(4 as i64),\n                owner: Some(4 as i64),\n                set_permissions: Some(paperless_api_client::types::SetPermissions {\n                    view: Some(paperless_api_client::types::View {\n                        users: Some(vec![4 as i64]),\n                        groups: Some(vec![4 as i64]),\n                    }),\n                    change: Some(paperless_api_client::types::Change {\n                        users: Some(vec![4 as i64]),\n                        groups: Some(vec![4 as i64]),\n                    }),\n                }),\n                custom_fields: Some(vec![paperless_api_client::types::CustomFieldInstanceRequest {\n                    value: Some(serde_json::Value::String(\"some-string\".to_string())),\n                    field: 4 as i64,\n                }]),\n                remove_inbox_tags: Some(true),\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1001    #[tracing::instrument]
1002    #[allow(non_snake_case)]
1003    pub async fn partial_update<'a>(
1004        &'a self,
1005        doc_id: i64,
1006        body: &crate::types::PatchedDocumentRequest,
1007    ) -> Result<crate::types::Document, crate::types::error::Error> {
1008        let mut req = self.client.client.request(
1009            http::Method::PATCH,
1010            format!(
1011                "{}/{}",
1012                self.client.base_url,
1013                "api/documents/{doc_id}/".replace("{doc_id}", &format!("{doc_id}"))
1014            ),
1015        );
1016        req = req.header("Authorization", format!("Token {}", &self.client.token));
1017        req = req.json(body);
1018        let resp = req.send().await?;
1019        let status = resp.status();
1020        if status.is_success() {
1021            let text = resp.text().await.unwrap_or_default();
1022            serde_json::from_str(&text).map_err(|err| {
1023                crate::types::error::Error::from_serde_error(
1024                    format_serde_error::SerdeError::new(text.to_string(), err),
1025                    status,
1026                )
1027            })
1028        } else {
1029            let text = resp.text().await.unwrap_or_default();
1030            Err(crate::types::error::Error::Server {
1031                body: text.to_string(),
1032                status,
1033            })
1034        }
1035    }
1036
1037    #[doc = "Perform a `GET` request to `/api/documents/{doc_id}/download/`.\n\nDownload the document\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n- `original: Option<bool>`\n\n```rust,no_run\nasync fn example_documents_download_retrieve() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: bytes::Bytes = client\n        .documents()\n        .download_retrieve(4 as i64, Some(true))\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1038    #[tracing::instrument]
1039    #[allow(non_snake_case)]
1040    pub async fn download_retrieve<'a>(
1041        &'a self,
1042        doc_id: i64,
1043        original: Option<bool>,
1044    ) -> Result<bytes::Bytes, crate::types::error::Error> {
1045        let mut req = self.client.client.request(
1046            http::Method::GET,
1047            format!(
1048                "{}/{}",
1049                self.client.base_url,
1050                "api/documents/{doc_id}/download/".replace("{doc_id}", &format!("{doc_id}"))
1051            ),
1052        );
1053        req = req.header("Authorization", format!("Token {}", &self.client.token));
1054        let mut query_params = vec![];
1055        if let Some(p) = original {
1056            query_params.push(("original", format!("{p}")));
1057        }
1058
1059        req = req.query(&query_params);
1060        let resp = req.send().await?;
1061        let status = resp.status();
1062        if status.is_success() {
1063            let text = resp.text().await.unwrap_or_default();
1064            serde_json::from_str(&text).map_err(|err| {
1065                crate::types::error::Error::from_serde_error(
1066                    format_serde_error::SerdeError::new(text.to_string(), err),
1067                    status,
1068                )
1069            })
1070        } else {
1071            let text = resp.text().await.unwrap_or_default();
1072            Err(crate::types::error::Error::Server {
1073                body: text.to_string(),
1074                status,
1075            })
1076        }
1077    }
1078
1079    #[doc = "Perform a `POST` request to `/api/documents/{doc_id}/email/`.\n\nEmail the document to one or more recipients as an attachment.\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n\n```rust,no_run\nasync fn example_documents_email_create() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: paperless_api_client::types::EmailResponse = client\n        .documents()\n        .email_create(\n            4 as i64,\n            &paperless_api_client::types::EmailRequestRequest {\n                addresses: \"some-string\".to_string(),\n                subject: \"some-string\".to_string(),\n                message: \"some-string\".to_string(),\n                use_archive_version: true,\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1080    #[tracing::instrument]
1081    #[allow(non_snake_case)]
1082    pub async fn email_create<'a>(
1083        &'a self,
1084        doc_id: i64,
1085        body: &crate::types::EmailRequestRequest,
1086    ) -> Result<crate::types::EmailResponse, crate::types::error::Error> {
1087        let mut req = self.client.client.request(
1088            http::Method::POST,
1089            format!(
1090                "{}/{}",
1091                self.client.base_url,
1092                "api/documents/{doc_id}/email/".replace("{doc_id}", &format!("{doc_id}"))
1093            ),
1094        );
1095        req = req.header("Authorization", format!("Token {}", &self.client.token));
1096        req = req.json(body);
1097        let resp = req.send().await?;
1098        let status = resp.status();
1099        if status.is_success() {
1100            let text = resp.text().await.unwrap_or_default();
1101            serde_json::from_str(&text).map_err(|err| {
1102                crate::types::error::Error::from_serde_error(
1103                    format_serde_error::SerdeError::new(text.to_string(), err),
1104                    status,
1105                )
1106            })
1107        } else {
1108            let text = resp.text().await.unwrap_or_default();
1109            Err(crate::types::error::Error::Server {
1110                body: text.to_string(),
1111                status,
1112            })
1113        }
1114    }
1115
1116    #[doc = "Perform a `GET` request to `/api/documents/{doc_id}/history/`.\n\nView the document history\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n- `page: Option<i64>`: A page number within the paginated result set.\n- `page_size: Option<i64>`: Number of results to return per page.\n\n```rust,no_run\nuse futures_util::TryStreamExt;\nasync fn example_documents_history_list_stream() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let mut documents = client.documents();\n    let mut stream = documents.history_list_stream(4 as i64, Some(4 as i64));\n    loop {\n        match stream.try_next().await {\n            Ok(Some(item)) => {\n                println!(\"{:?}\", item);\n            }\n            Ok(None) => {\n                break;\n            }\n            Err(err) => {\n                return Err(err.into());\n            }\n        }\n    }\n\n    Ok(())\n}\n```"]
1117    #[tracing::instrument]
1118    #[allow(non_snake_case)]
1119    pub async fn history_list<'a>(
1120        &'a self,
1121        doc_id: i64,
1122        page: Option<i64>,
1123        page_size: Option<i64>,
1124    ) -> Result<crate::types::PaginatedLogEntryList, crate::types::error::Error> {
1125        let mut req = self.client.client.request(
1126            http::Method::GET,
1127            format!(
1128                "{}/{}",
1129                self.client.base_url,
1130                "api/documents/{doc_id}/history/".replace("{doc_id}", &format!("{doc_id}"))
1131            ),
1132        );
1133        req = req.header("Authorization", format!("Token {}", &self.client.token));
1134        let mut query_params = vec![];
1135        if let Some(p) = page {
1136            query_params.push(("page", format!("{p}")));
1137        }
1138
1139        if let Some(p) = page_size {
1140            query_params.push(("page_size", format!("{p}")));
1141        }
1142
1143        req = req.query(&query_params);
1144        let resp = req.send().await?;
1145        let status = resp.status();
1146        if status.is_success() {
1147            let text = resp.text().await.unwrap_or_default();
1148            serde_json::from_str(&text).map_err(|err| {
1149                crate::types::error::Error::from_serde_error(
1150                    format_serde_error::SerdeError::new(text.to_string(), err),
1151                    status,
1152                )
1153            })
1154        } else {
1155            let text = resp.text().await.unwrap_or_default();
1156            Err(crate::types::error::Error::Server {
1157                body: text.to_string(),
1158                status,
1159            })
1160        }
1161    }
1162
1163    #[doc = "Perform a `GET` request to `/api/documents/{doc_id}/history/`.\n\nView the document history\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n- `page: Option<i64>`: A page number within the paginated result set.\n- `page_size: Option<i64>`: Number of results to return per page.\n\n```rust,no_run\nuse futures_util::TryStreamExt;\nasync fn example_documents_history_list_stream() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let mut documents = client.documents();\n    let mut stream = documents.history_list_stream(4 as i64, Some(4 as i64));\n    loop {\n        match stream.try_next().await {\n            Ok(Some(item)) => {\n                println!(\"{:?}\", item);\n            }\n            Ok(None) => {\n                break;\n            }\n            Err(err) => {\n                return Err(err.into());\n            }\n        }\n    }\n\n    Ok(())\n}\n```"]
1164    #[tracing::instrument]
1165    #[cfg(not(feature = "js"))]
1166    #[allow(non_snake_case)]
1167    pub fn history_list_stream<'a>(
1168        &'a self,
1169        doc_id: i64,
1170        page_size: Option<i64>,
1171    ) -> impl futures::Stream<Item = Result<crate::types::LogEntry, crate::types::error::Error>>
1172           + Unpin
1173           + '_ {
1174        use crate::types::paginate::Pagination;
1175        use futures::{StreamExt, TryFutureExt, TryStreamExt};
1176        self.history_list(doc_id, None, page_size)
1177            .map_ok(move |result| {
1178                let items = futures::stream::iter(result.items().into_iter().map(Ok));
1179                let next_pages = futures::stream::try_unfold(
1180                    (None, result),
1181                    move |(prev_page_token, new_result)| async move {
1182                        if new_result.has_more_pages()
1183                            && !new_result.items().is_empty()
1184                            && prev_page_token != new_result.next_page_token()
1185                        {
1186                            async {
1187                                let mut req = self.client.client.request(
1188                                    http::Method::GET,
1189                                    format!(
1190                                        "{}/{}",
1191                                        self.client.base_url,
1192                                        "api/documents/{doc_id}/history/"
1193                                            .replace("{doc_id}", &format!("{}", doc_id))
1194                                    ),
1195                                );
1196                                req = req.header(
1197                                    "Authorization",
1198                                    format!("Token {}", &self.client.token),
1199                                );
1200                                let mut request = req.build()?;
1201                                request = new_result.next_page(request)?;
1202                                let resp = self.client.client.execute(request).await?;
1203                                let status = resp.status();
1204                                if status.is_success() {
1205                                    let text = resp.text().await.unwrap_or_default();
1206                                    serde_json::from_str(&text).map_err(|err| {
1207                                        crate::types::error::Error::from_serde_error(
1208                                            format_serde_error::SerdeError::new(
1209                                                text.to_string(),
1210                                                err,
1211                                            ),
1212                                            status,
1213                                        )
1214                                    })
1215                                } else {
1216                                    let text = resp.text().await.unwrap_or_default();
1217                                    Err(crate::types::error::Error::Server {
1218                                        body: text.to_string(),
1219                                        status,
1220                                    })
1221                                }
1222                            }
1223                            .map_ok(|result: crate::types::PaginatedLogEntryList| {
1224                                Some((
1225                                    futures::stream::iter(result.items().into_iter().map(Ok)),
1226                                    (new_result.next_page_token(), result),
1227                                ))
1228                            })
1229                            .await
1230                        } else {
1231                            Ok(None)
1232                        }
1233                    },
1234                )
1235                .try_flatten();
1236                items.chain(next_pages)
1237            })
1238            .try_flatten_stream()
1239            .boxed()
1240    }
1241
1242    #[doc = "Perform a `GET` request to `/api/documents/{doc_id}/metadata/`.\n\nView the document metadata\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n\n```rust,no_run\nasync fn example_documents_metadata_retrieve() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: paperless_api_client::types::Metadata = client.documents().metadata_retrieve(4 as i64).await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1243    #[tracing::instrument]
1244    #[allow(non_snake_case)]
1245    pub async fn metadata_retrieve<'a>(
1246        &'a self,
1247        doc_id: i64,
1248    ) -> Result<crate::types::Metadata, crate::types::error::Error> {
1249        let mut req = self.client.client.request(
1250            http::Method::GET,
1251            format!(
1252                "{}/{}",
1253                self.client.base_url,
1254                "api/documents/{doc_id}/metadata/".replace("{doc_id}", &format!("{doc_id}"))
1255            ),
1256        );
1257        req = req.header("Authorization", format!("Token {}", &self.client.token));
1258        let resp = req.send().await?;
1259        let status = resp.status();
1260        if status.is_success() {
1261            let text = resp.text().await.unwrap_or_default();
1262            serde_json::from_str(&text).map_err(|err| {
1263                crate::types::error::Error::from_serde_error(
1264                    format_serde_error::SerdeError::new(text.to_string(), err),
1265                    status,
1266                )
1267            })
1268        } else {
1269            let text = resp.text().await.unwrap_or_default();
1270            Err(crate::types::error::Error::Server {
1271                body: text.to_string(),
1272                status,
1273            })
1274        }
1275    }
1276
1277    #[doc = "Perform a `GET` request to `/api/documents/{doc_id}/notes/`.\n\nView, add, or delete notes for the document\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n- `id: Option<i64>`: Note ID to delete (used only for DELETE requests)\n- `page: Option<i64>`: A page number within the paginated result set.\n- `page_size: Option<i64>`: Number of results to return per page.\n\n```rust,no_run\nuse futures_util::TryStreamExt;\nasync fn example_documents_notes_list_stream() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let mut documents = client.documents();\n    let mut stream = documents.notes_list_stream(4 as i64, Some(4 as i64), Some(4 as i64));\n    loop {\n        match stream.try_next().await {\n            Ok(Some(item)) => {\n                println!(\"{:?}\", item);\n            }\n            Ok(None) => {\n                break;\n            }\n            Err(err) => {\n                return Err(err.into());\n            }\n        }\n    }\n\n    Ok(())\n}\n```"]
1278    #[tracing::instrument]
1279    #[allow(non_snake_case)]
1280    pub async fn notes_list<'a>(
1281        &'a self,
1282        doc_id: i64,
1283        id: Option<i64>,
1284        page: Option<i64>,
1285        page_size: Option<i64>,
1286    ) -> Result<crate::types::PaginatedNotesList, crate::types::error::Error> {
1287        let mut req = self.client.client.request(
1288            http::Method::GET,
1289            format!(
1290                "{}/{}",
1291                self.client.base_url,
1292                "api/documents/{doc_id}/notes/".replace("{doc_id}", &format!("{doc_id}"))
1293            ),
1294        );
1295        req = req.header("Authorization", format!("Token {}", &self.client.token));
1296        let mut query_params = vec![];
1297        if let Some(p) = id {
1298            query_params.push(("id", format!("{p}")));
1299        }
1300
1301        if let Some(p) = page {
1302            query_params.push(("page", format!("{p}")));
1303        }
1304
1305        if let Some(p) = page_size {
1306            query_params.push(("page_size", format!("{p}")));
1307        }
1308
1309        req = req.query(&query_params);
1310        let resp = req.send().await?;
1311        let status = resp.status();
1312        if status.is_success() {
1313            let text = resp.text().await.unwrap_or_default();
1314            serde_json::from_str(&text).map_err(|err| {
1315                crate::types::error::Error::from_serde_error(
1316                    format_serde_error::SerdeError::new(text.to_string(), err),
1317                    status,
1318                )
1319            })
1320        } else {
1321            let text = resp.text().await.unwrap_or_default();
1322            Err(crate::types::error::Error::Server {
1323                body: text.to_string(),
1324                status,
1325            })
1326        }
1327    }
1328
1329    #[doc = "Perform a `GET` request to `/api/documents/{doc_id}/notes/`.\n\nView, add, or delete notes for the document\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n- `id: Option<i64>`: Note ID to delete (used only for DELETE requests)\n- `page: Option<i64>`: A page number within the paginated result set.\n- `page_size: Option<i64>`: Number of results to return per page.\n\n```rust,no_run\nuse futures_util::TryStreamExt;\nasync fn example_documents_notes_list_stream() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let mut documents = client.documents();\n    let mut stream = documents.notes_list_stream(4 as i64, Some(4 as i64), Some(4 as i64));\n    loop {\n        match stream.try_next().await {\n            Ok(Some(item)) => {\n                println!(\"{:?}\", item);\n            }\n            Ok(None) => {\n                break;\n            }\n            Err(err) => {\n                return Err(err.into());\n            }\n        }\n    }\n\n    Ok(())\n}\n```"]
1330    #[tracing::instrument]
1331    #[cfg(not(feature = "js"))]
1332    #[allow(non_snake_case)]
1333    pub fn notes_list_stream<'a>(
1334        &'a self,
1335        doc_id: i64,
1336        id: Option<i64>,
1337        page_size: Option<i64>,
1338    ) -> impl futures::Stream<Item = Result<crate::types::Notes, crate::types::error::Error>> + Unpin + '_
1339    {
1340        use crate::types::paginate::Pagination;
1341        use futures::{StreamExt, TryFutureExt, TryStreamExt};
1342        self.notes_list(doc_id, id, None, page_size)
1343            .map_ok(move |result| {
1344                let items = futures::stream::iter(result.items().into_iter().map(Ok));
1345                let next_pages = futures::stream::try_unfold(
1346                    (None, result),
1347                    move |(prev_page_token, new_result)| async move {
1348                        if new_result.has_more_pages()
1349                            && !new_result.items().is_empty()
1350                            && prev_page_token != new_result.next_page_token()
1351                        {
1352                            async {
1353                                let mut req = self.client.client.request(
1354                                    http::Method::GET,
1355                                    format!(
1356                                        "{}/{}",
1357                                        self.client.base_url,
1358                                        "api/documents/{doc_id}/notes/"
1359                                            .replace("{doc_id}", &format!("{}", doc_id))
1360                                    ),
1361                                );
1362                                req = req.header(
1363                                    "Authorization",
1364                                    format!("Token {}", &self.client.token),
1365                                );
1366                                let mut request = req.build()?;
1367                                request = new_result.next_page(request)?;
1368                                let resp = self.client.client.execute(request).await?;
1369                                let status = resp.status();
1370                                if status.is_success() {
1371                                    let text = resp.text().await.unwrap_or_default();
1372                                    serde_json::from_str(&text).map_err(|err| {
1373                                        crate::types::error::Error::from_serde_error(
1374                                            format_serde_error::SerdeError::new(
1375                                                text.to_string(),
1376                                                err,
1377                                            ),
1378                                            status,
1379                                        )
1380                                    })
1381                                } else {
1382                                    let text = resp.text().await.unwrap_or_default();
1383                                    Err(crate::types::error::Error::Server {
1384                                        body: text.to_string(),
1385                                        status,
1386                                    })
1387                                }
1388                            }
1389                            .map_ok(|result: crate::types::PaginatedNotesList| {
1390                                Some((
1391                                    futures::stream::iter(result.items().into_iter().map(Ok)),
1392                                    (new_result.next_page_token(), result),
1393                                ))
1394                            })
1395                            .await
1396                        } else {
1397                            Ok(None)
1398                        }
1399                    },
1400                )
1401                .try_flatten();
1402                items.chain(next_pages)
1403            })
1404            .try_flatten_stream()
1405            .boxed()
1406    }
1407
1408    #[doc = "Perform a `POST` request to `/api/documents/{doc_id}/notes/`.\n\nView, add, or delete notes for the document\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n- `id: Option<i64>`: Note ID to delete (used only for DELETE requests)\n- `page: Option<i64>`: A page number within the paginated result set.\n- `page_size: Option<i64>`: Number of results to return per page.\n\n```rust,no_run\nasync fn example_documents_notes_create() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: paperless_api_client::types::PaginatedNotesList = client\n        .documents()\n        .notes_create(\n            4 as i64,\n            Some(4 as i64),\n            Some(4 as i64),\n            Some(4 as i64),\n            &paperless_api_client::types::NoteCreateRequestRequest {\n                note: \"some-string\".to_string(),\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1409    #[tracing::instrument]
1410    #[allow(non_snake_case)]
1411    pub async fn notes_create<'a>(
1412        &'a self,
1413        doc_id: i64,
1414        id: Option<i64>,
1415        page: Option<i64>,
1416        page_size: Option<i64>,
1417        body: &crate::types::NoteCreateRequestRequest,
1418    ) -> Result<crate::types::PaginatedNotesList, crate::types::error::Error> {
1419        let mut req = self.client.client.request(
1420            http::Method::POST,
1421            format!(
1422                "{}/{}",
1423                self.client.base_url,
1424                "api/documents/{doc_id}/notes/".replace("{doc_id}", &format!("{doc_id}"))
1425            ),
1426        );
1427        req = req.header("Authorization", format!("Token {}", &self.client.token));
1428        let mut query_params = vec![];
1429        if let Some(p) = id {
1430            query_params.push(("id", format!("{p}")));
1431        }
1432
1433        if let Some(p) = page {
1434            query_params.push(("page", format!("{p}")));
1435        }
1436
1437        if let Some(p) = page_size {
1438            query_params.push(("page_size", format!("{p}")));
1439        }
1440
1441        req = req.query(&query_params);
1442        req = req.json(body);
1443        let resp = req.send().await?;
1444        let status = resp.status();
1445        if status.is_success() {
1446            let text = resp.text().await.unwrap_or_default();
1447            serde_json::from_str(&text).map_err(|err| {
1448                crate::types::error::Error::from_serde_error(
1449                    format_serde_error::SerdeError::new(text.to_string(), err),
1450                    status,
1451                )
1452            })
1453        } else {
1454            let text = resp.text().await.unwrap_or_default();
1455            Err(crate::types::error::Error::Server {
1456                body: text.to_string(),
1457                status,
1458            })
1459        }
1460    }
1461
1462    #[doc = "Perform a `DELETE` request to `/api/documents/{doc_id}/notes/`.\n\nView, add, or delete notes for the document\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n- `id: Option<i64>`: Note ID to delete (used only for DELETE requests)\n- `page: Option<i64>`: A page number within the paginated result set.\n- `page_size: Option<i64>`: Number of results to return per page.\n\n```rust,no_run\nasync fn example_documents_notes_destroy() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: paperless_api_client::types::PaginatedNotesList = client\n        .documents()\n        .notes_destroy(4 as i64, Some(4 as i64), Some(4 as i64), Some(4 as i64))\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1463    #[tracing::instrument]
1464    #[allow(non_snake_case)]
1465    pub async fn notes_destroy<'a>(
1466        &'a self,
1467        doc_id: i64,
1468        id: Option<i64>,
1469        page: Option<i64>,
1470        page_size: Option<i64>,
1471    ) -> Result<crate::types::PaginatedNotesList, crate::types::error::Error> {
1472        let mut req = self.client.client.request(
1473            http::Method::DELETE,
1474            format!(
1475                "{}/{}",
1476                self.client.base_url,
1477                "api/documents/{doc_id}/notes/".replace("{doc_id}", &format!("{doc_id}"))
1478            ),
1479        );
1480        req = req.header("Authorization", format!("Token {}", &self.client.token));
1481        let mut query_params = vec![];
1482        if let Some(p) = id {
1483            query_params.push(("id", format!("{p}")));
1484        }
1485
1486        if let Some(p) = page {
1487            query_params.push(("page", format!("{p}")));
1488        }
1489
1490        if let Some(p) = page_size {
1491            query_params.push(("page_size", format!("{p}")));
1492        }
1493
1494        req = req.query(&query_params);
1495        let resp = req.send().await?;
1496        let status = resp.status();
1497        if status.is_success() {
1498            let text = resp.text().await.unwrap_or_default();
1499            serde_json::from_str(&text).map_err(|err| {
1500                crate::types::error::Error::from_serde_error(
1501                    format_serde_error::SerdeError::new(text.to_string(), err),
1502                    status,
1503                )
1504            })
1505        } else {
1506            let text = resp.text().await.unwrap_or_default();
1507            Err(crate::types::error::Error::Server {
1508                body: text.to_string(),
1509                status,
1510            })
1511        }
1512    }
1513
1514    #[doc = "Perform a `GET` request to `/api/documents/{doc_id}/preview/`.\n\nView the document preview\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n\n```rust,no_run\nasync fn example_documents_preview_retrieve() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: bytes::Bytes = client.documents().preview_retrieve(4 as i64).await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1515    #[tracing::instrument]
1516    #[allow(non_snake_case)]
1517    pub async fn preview_retrieve<'a>(
1518        &'a self,
1519        doc_id: i64,
1520    ) -> Result<bytes::Bytes, crate::types::error::Error> {
1521        let mut req = self.client.client.request(
1522            http::Method::GET,
1523            format!(
1524                "{}/{}",
1525                self.client.base_url,
1526                "api/documents/{doc_id}/preview/".replace("{doc_id}", &format!("{doc_id}"))
1527            ),
1528        );
1529        req = req.header("Authorization", format!("Token {}", &self.client.token));
1530        let resp = req.send().await?;
1531        let status = resp.status();
1532        if status.is_success() {
1533            let text = resp.text().await.unwrap_or_default();
1534            serde_json::from_str(&text).map_err(|err| {
1535                crate::types::error::Error::from_serde_error(
1536                    format_serde_error::SerdeError::new(text.to_string(), err),
1537                    status,
1538                )
1539            })
1540        } else {
1541            let text = resp.text().await.unwrap_or_default();
1542            Err(crate::types::error::Error::Server {
1543                body: text.to_string(),
1544                status,
1545            })
1546        }
1547    }
1548
1549    #[doc = "Perform a `GET` request to `/api/documents/{doc_id}/share_links/`.\n\nView share links for the document\n\n**Parameters:**\n\n- `doc_id: &'astr` (required)\n\n```rust,no_run\nasync fn example_documents_share_links() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: Vec<paperless_api_client::types::DocumentShareLinksResponse> =\n        client.documents().share_links(\"some-string\").await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1550    #[tracing::instrument]
1551    #[allow(non_snake_case)]
1552    pub async fn share_links<'a>(
1553        &'a self,
1554        doc_id: &'a str,
1555    ) -> Result<Vec<crate::types::DocumentShareLinksResponse>, crate::types::error::Error> {
1556        let mut req = self.client.client.request(
1557            http::Method::GET,
1558            format!(
1559                "{}/{}",
1560                self.client.base_url,
1561                "api/documents/{doc_id}/share_links/".replace("{doc_id}", doc_id)
1562            ),
1563        );
1564        req = req.header("Authorization", format!("Token {}", &self.client.token));
1565        let resp = req.send().await?;
1566        let status = resp.status();
1567        if status.is_success() {
1568            let text = resp.text().await.unwrap_or_default();
1569            serde_json::from_str(&text).map_err(|err| {
1570                crate::types::error::Error::from_serde_error(
1571                    format_serde_error::SerdeError::new(text.to_string(), err),
1572                    status,
1573                )
1574            })
1575        } else {
1576            let text = resp.text().await.unwrap_or_default();
1577            Err(crate::types::error::Error::Server {
1578                body: text.to_string(),
1579                status,
1580            })
1581        }
1582    }
1583
1584    #[doc = "Perform a `GET` request to `/api/documents/{doc_id}/suggestions/`.\n\nView suggestions for the document\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n\n```rust,no_run\nasync fn example_documents_suggestions_retrieve() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: paperless_api_client::types::Suggestions =\n        client.documents().suggestions_retrieve(4 as i64).await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1585    #[tracing::instrument]
1586    #[allow(non_snake_case)]
1587    pub async fn suggestions_retrieve<'a>(
1588        &'a self,
1589        doc_id: i64,
1590    ) -> Result<crate::types::Suggestions, crate::types::error::Error> {
1591        let mut req = self.client.client.request(
1592            http::Method::GET,
1593            format!(
1594                "{}/{}",
1595                self.client.base_url,
1596                "api/documents/{doc_id}/suggestions/".replace("{doc_id}", &format!("{doc_id}"))
1597            ),
1598        );
1599        req = req.header("Authorization", format!("Token {}", &self.client.token));
1600        let resp = req.send().await?;
1601        let status = resp.status();
1602        if status.is_success() {
1603            let text = resp.text().await.unwrap_or_default();
1604            serde_json::from_str(&text).map_err(|err| {
1605                crate::types::error::Error::from_serde_error(
1606                    format_serde_error::SerdeError::new(text.to_string(), err),
1607                    status,
1608                )
1609            })
1610        } else {
1611            let text = resp.text().await.unwrap_or_default();
1612            Err(crate::types::error::Error::Server {
1613                body: text.to_string(),
1614                status,
1615            })
1616        }
1617    }
1618
1619    #[doc = "Perform a `GET` request to `/api/documents/{doc_id}/thumb/`.\n\nView the document thumbnail\n\n**Parameters:**\n\n- `doc_id: i64`: A unique integer value identifying this document. (required)\n\n```rust,no_run\nasync fn example_documents_thumb_retrieve() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: bytes::Bytes = client.documents().thumb_retrieve(4 as i64).await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1620    #[tracing::instrument]
1621    #[allow(non_snake_case)]
1622    pub async fn thumb_retrieve<'a>(
1623        &'a self,
1624        doc_id: i64,
1625    ) -> Result<bytes::Bytes, crate::types::error::Error> {
1626        let mut req = self.client.client.request(
1627            http::Method::GET,
1628            format!(
1629                "{}/{}",
1630                self.client.base_url,
1631                "api/documents/{doc_id}/thumb/".replace("{doc_id}", &format!("{doc_id}"))
1632            ),
1633        );
1634        req = req.header("Authorization", format!("Token {}", &self.client.token));
1635        let resp = req.send().await?;
1636        let status = resp.status();
1637        if status.is_success() {
1638            let text = resp.text().await.unwrap_or_default();
1639            serde_json::from_str(&text).map_err(|err| {
1640                crate::types::error::Error::from_serde_error(
1641                    format_serde_error::SerdeError::new(text.to_string(), err),
1642                    status,
1643                )
1644            })
1645        } else {
1646            let text = resp.text().await.unwrap_or_default();
1647            Err(crate::types::error::Error::Server {
1648                body: text.to_string(),
1649                status,
1650            })
1651        }
1652    }
1653
1654    #[doc = "Perform a `POST` request to `/api/documents/bulk_download/`.\n\n```rust,no_run\nasync fn example_documents_bulk_download_create() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: paperless_api_client::types::BulkDownload = client\n        .documents()\n        .bulk_download_create(&paperless_api_client::types::BulkDownloadRequest {\n            documents: vec![4 as i64],\n            content: Some(paperless_api_client::types::ContentEnum::Originals),\n            compression: Some(paperless_api_client::types::CompressionEnum::Bzip2),\n            follow_formatting: true,\n        })\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1655    #[tracing::instrument]
1656    #[allow(non_snake_case)]
1657    pub async fn bulk_download_create<'a>(
1658        &'a self,
1659        body: &crate::types::BulkDownloadRequest,
1660    ) -> Result<crate::types::BulkDownload, crate::types::error::Error> {
1661        let mut req = self.client.client.request(
1662            http::Method::POST,
1663            format!(
1664                "{}/{}",
1665                self.client.base_url, "api/documents/bulk_download/"
1666            ),
1667        );
1668        req = req.header("Authorization", format!("Token {}", &self.client.token));
1669        req = req.json(body);
1670        let resp = req.send().await?;
1671        let status = resp.status();
1672        if status.is_success() {
1673            let text = resp.text().await.unwrap_or_default();
1674            serde_json::from_str(&text).map_err(|err| {
1675                crate::types::error::Error::from_serde_error(
1676                    format_serde_error::SerdeError::new(text.to_string(), err),
1677                    status,
1678                )
1679            })
1680        } else {
1681            let text = resp.text().await.unwrap_or_default();
1682            Err(crate::types::error::Error::Server {
1683                body: text.to_string(),
1684                status,
1685            })
1686        }
1687    }
1688
1689    #[doc = "Perform a `POST` request to `/api/documents/bulk_edit/`.\n\nPerform a bulk edit operation on a list of documents\n\nSee <https://docs.paperless-ngx.com/api/#bulk-editing|Further documentation> for more information.\n\n```rust,no_run\nasync fn example_documents_bulk_edit() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: paperless_api_client::types::BulkEditDocumentsResult = client\n        .documents()\n        .bulk_edit(&paperless_api_client::types::BulkEditRequest {\n            documents: vec![4 as i64],\n            method: paperless_api_client::types::MethodEnum::SetPermissions,\n            parameters: Some(std::collections::HashMap::from([(\n                \"some-key\".to_string(),\n                serde_json::Value::String(\"some-string\".to_string()),\n            )])),\n        })\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1690    #[tracing::instrument]
1691    #[allow(non_snake_case)]
1692    pub async fn bulk_edit<'a>(
1693        &'a self,
1694        body: &crate::types::BulkEditRequest,
1695    ) -> Result<crate::types::BulkEditDocumentsResult, crate::types::error::Error> {
1696        let mut req = self.client.client.request(
1697            http::Method::POST,
1698            format!("{}/{}", self.client.base_url, "api/documents/bulk_edit/"),
1699        );
1700        req = req.header("Authorization", format!("Token {}", &self.client.token));
1701        req = req.json(body);
1702        let resp = req.send().await?;
1703        let status = resp.status();
1704        if status.is_success() {
1705            let text = resp.text().await.unwrap_or_default();
1706            serde_json::from_str(&text).map_err(|err| {
1707                crate::types::error::Error::from_serde_error(
1708                    format_serde_error::SerdeError::new(text.to_string(), err),
1709                    status,
1710                )
1711            })
1712        } else {
1713            let text = resp.text().await.unwrap_or_default();
1714            Err(crate::types::error::Error::Server {
1715                body: text.to_string(),
1716                status,
1717            })
1718        }
1719    }
1720
1721    #[doc = "Perform a `GET` request to `/api/documents/next_asn/`.\n\nGet the next available Archive Serial Number (ASN) for a new document\n\n```rust,no_run\nasync fn example_documents_next_asn_retrieve() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: i64 = client.documents().next_asn_retrieve().await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1722    #[tracing::instrument]
1723    #[allow(non_snake_case)]
1724    pub async fn next_asn_retrieve<'a>(&'a self) -> Result<i64, crate::types::error::Error> {
1725        let mut req = self.client.client.request(
1726            http::Method::GET,
1727            format!("{}/{}", self.client.base_url, "api/documents/next_asn/"),
1728        );
1729        req = req.header("Authorization", format!("Token {}", &self.client.token));
1730        let resp = req.send().await?;
1731        let status = resp.status();
1732        if status.is_success() {
1733            let text = resp.text().await.unwrap_or_default();
1734            serde_json::from_str(&text).map_err(|err| {
1735                crate::types::error::Error::from_serde_error(
1736                    format_serde_error::SerdeError::new(text.to_string(), err),
1737                    status,
1738                )
1739            })
1740        } else {
1741            let text = resp.text().await.unwrap_or_default();
1742            Err(crate::types::error::Error::Server {
1743                body: text.to_string(),
1744                status,
1745            })
1746        }
1747    }
1748
1749    #[doc = "Perform a `POST` request to `/api/documents/post_document/`.\n\nUpload a document via the API\n\nSee <https://docs.paperless-ngx.com/api/#file-uploads|Further documentation> for more information.\n\n```rust,no_run\nasync fn example_documents_post_create() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: String = client\n        .documents()\n        .post_create(\n            vec![paperless_api_client::types::multipart::Attachment {\n                name: \"thing\".to_string(),\n                filepath: Some(\"myfile.json\".into()),\n                content_type: Some(\"application/json\".to_string()),\n                data: std::fs::read(\"myfile.json\").unwrap(),\n            }],\n            &paperless_api_client::types::PostDocumentRequest {\n                created: Some(chrono::Utc::now()),\n                document: bytes::Bytes::from(\"some-string\"),\n                title: Some(\"some-string\".to_string()),\n                correspondent: Some(4 as i64),\n                document_type: Some(4 as i64),\n                storage_path: Some(4 as i64),\n                tags: Some(vec![4 as i64]),\n                archive_serial_number: Some(4 as i64),\n                custom_fields: Some(vec![4 as i64]),\n                from_webui: Some(true),\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1750    #[tracing::instrument]
1751    #[allow(non_snake_case)]
1752    pub async fn post_create<'a>(
1753        &'a self,
1754        attachments: Vec<crate::types::multipart::Attachment>,
1755        body: &crate::types::PostDocumentRequest,
1756    ) -> Result<String, crate::types::error::Error> {
1757        let mut req = self.client.client.request(
1758            http::Method::POST,
1759            format!(
1760                "{}/{}",
1761                self.client.base_url, "api/documents/post_document/"
1762            ),
1763        );
1764        req = req.header("Authorization", format!("Token {}", &self.client.token));
1765        use std::convert::TryInto;
1766        let mut form = reqwest::multipart::Form::new();
1767        let mut json_part = reqwest::multipart::Part::text(serde_json::to_string(&body)?);
1768        json_part = json_part.file_name(format!("{}.json", "body"));
1769        json_part = json_part.mime_str("application/json")?;
1770        form = form.part("body", json_part);
1771        for attachment in attachments {
1772            form = form.part(attachment.name.clone(), attachment.try_into()?);
1773        }
1774
1775        req = req.multipart(form);
1776        let resp = req.send().await?;
1777        let status = resp.status();
1778        if status.is_success() {
1779            let text = resp.text().await.unwrap_or_default();
1780            serde_json::from_str(&text).map_err(|err| {
1781                crate::types::error::Error::from_serde_error(
1782                    format_serde_error::SerdeError::new(text.to_string(), err),
1783                    status,
1784                )
1785            })
1786        } else {
1787            let text = resp.text().await.unwrap_or_default();
1788            Err(crate::types::error::Error::Server {
1789                body: text.to_string(),
1790                status,
1791            })
1792        }
1793    }
1794
1795    #[doc = "Perform a `POST` request to `/api/documents/selection_data/`.\n\nGet selection data for the selected documents\n\n```rust,no_run\nasync fn example_documents_selection_data_create() -> anyhow::Result<()> {\n    let client = paperless_api_client::Client::new_from_env();\n    let result: paperless_api_client::types::SelectionData = client\n        .documents()\n        .selection_data_create(\n            vec![paperless_api_client::types::multipart::Attachment {\n                name: \"thing\".to_string(),\n                filepath: Some(\"myfile.json\".into()),\n                content_type: Some(\"application/json\".to_string()),\n                data: std::fs::read(\"myfile.json\").unwrap(),\n            }],\n            &paperless_api_client::types::DocumentListRequest {\n                documents: vec![4 as i64],\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1796    #[tracing::instrument]
1797    #[allow(non_snake_case)]
1798    pub async fn selection_data_create<'a>(
1799        &'a self,
1800        attachments: Vec<crate::types::multipart::Attachment>,
1801        body: &crate::types::DocumentListRequest,
1802    ) -> Result<crate::types::SelectionData, crate::types::error::Error> {
1803        let mut req = self.client.client.request(
1804            http::Method::POST,
1805            format!(
1806                "{}/{}",
1807                self.client.base_url, "api/documents/selection_data/"
1808            ),
1809        );
1810        req = req.header("Authorization", format!("Token {}", &self.client.token));
1811        use std::convert::TryInto;
1812        let mut form = reqwest::multipart::Form::new();
1813        let mut json_part = reqwest::multipart::Part::text(serde_json::to_string(&body)?);
1814        json_part = json_part.file_name(format!("{}.json", "body"));
1815        json_part = json_part.mime_str("application/json")?;
1816        form = form.part("body", json_part);
1817        for attachment in attachments {
1818            form = form.part(attachment.name.clone(), attachment.try_into()?);
1819        }
1820
1821        req = req.multipart(form);
1822        let resp = req.send().await?;
1823        let status = resp.status();
1824        if status.is_success() {
1825            let text = resp.text().await.unwrap_or_default();
1826            serde_json::from_str(&text).map_err(|err| {
1827                crate::types::error::Error::from_serde_error(
1828                    format_serde_error::SerdeError::new(text.to_string(), err),
1829                    status,
1830                )
1831            })
1832        } else {
1833            let text = resp.text().await.unwrap_or_default();
1834            Err(crate::types::error::Error::Server {
1835                body: text.to_string(),
1836                status,
1837            })
1838        }
1839    }
1840}