jacquard-api 0.11.0

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

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
use jacquard_common::types::string::{Did, Nsid, Datetime, UriValue};
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};
use crate::tools_ozone::moderation::ModEventView;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct QueryEvents<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub added_labels: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub added_tags: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub age_assurance_state: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub batch_id: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub collections: Option<Vec<Nsid<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub comment: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_after: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_before: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub created_by: Option<Did<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cursor: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_comment: Option<bool>,
    /// Defaults to `false`.
    #[serde(default = "_default_include_all_user_records")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_all_user_records: Option<bool>,
    ///Defaults to `50`. Min: 1. Max: 100.
    #[serde(default = "_default_limit")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub mod_tool: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub policies: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub removed_labels: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub removed_tags: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub report_types: Option<Vec<CowStr<'a>>>,
    ///Defaults to `"desc"`.
    #[serde(default = "_default_sort_direction")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub sort_direction: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub subject: Option<UriValue<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub subject_type: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub types: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub with_strike: Option<bool>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct QueryEventsOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cursor: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub events: Vec<ModEventView<'a>>,
}

/// Response type for tools.ozone.moderation.queryEvents
pub struct QueryEventsResponse;
impl jacquard_common::xrpc::XrpcResp for QueryEventsResponse {
    const NSID: &'static str = "tools.ozone.moderation.queryEvents";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = QueryEventsOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for QueryEvents<'a> {
    const NSID: &'static str = "tools.ozone.moderation.queryEvents";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = QueryEventsResponse;
}

/// Endpoint type for tools.ozone.moderation.queryEvents
pub struct QueryEventsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for QueryEventsRequest {
    const PATH: &'static str = "/xrpc/tools.ozone.moderation.queryEvents";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = QueryEvents<'de>;
    type Response = QueryEventsResponse;
}

fn _default_include_all_user_records() -> Option<bool> {
    Some(false)
}

fn _default_limit() -> Option<i64> {
    Some(50i64)
}

fn _default_sort_direction() -> Option<CowStr<'static>> {
    Some(CowStr::from("desc"))
}

pub mod query_events_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {}
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {}
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {}
}

/// Builder for constructing an instance of this type
pub struct QueryEventsBuilder<'a, S: query_events_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<Vec<Nsid<'a>>>,
        Option<CowStr<'a>>,
        Option<Datetime>,
        Option<Datetime>,
        Option<Did<'a>>,
        Option<CowStr<'a>>,
        Option<bool>,
        Option<bool>,
        Option<i64>,
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<CowStr<'a>>,
        Option<UriValue<'a>>,
        Option<CowStr<'a>>,
        Option<Vec<CowStr<'a>>>,
        Option<bool>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> QueryEvents<'a> {
    /// Create a new builder for this type
    pub fn new() -> QueryEventsBuilder<'a, query_events_state::Empty> {
        QueryEventsBuilder::new()
    }
}

impl<'a> QueryEventsBuilder<'a, query_events_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        QueryEventsBuilder {
            _state: PhantomData,
            _fields: (
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
            ),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `addedLabels` field (optional)
    pub fn added_labels(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `addedLabels` field to an Option value (optional)
    pub fn maybe_added_labels(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `addedTags` field (optional)
    pub fn added_tags(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `addedTags` field to an Option value (optional)
    pub fn maybe_added_tags(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `ageAssuranceState` field (optional)
    pub fn age_assurance_state(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `ageAssuranceState` field to an Option value (optional)
    pub fn maybe_age_assurance_state(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `batchId` field (optional)
    pub fn batch_id(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `batchId` field to an Option value (optional)
    pub fn maybe_batch_id(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `collections` field (optional)
    pub fn collections(mut self, value: impl Into<Option<Vec<Nsid<'a>>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `collections` field to an Option value (optional)
    pub fn maybe_collections(mut self, value: Option<Vec<Nsid<'a>>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `comment` field (optional)
    pub fn comment(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `comment` field to an Option value (optional)
    pub fn maybe_comment(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `createdAfter` field (optional)
    pub fn created_after(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `createdAfter` field to an Option value (optional)
    pub fn maybe_created_after(mut self, value: Option<Datetime>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `createdBefore` field (optional)
    pub fn created_before(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `createdBefore` field to an Option value (optional)
    pub fn maybe_created_before(mut self, value: Option<Datetime>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `createdBy` field (optional)
    pub fn created_by(mut self, value: impl Into<Option<Did<'a>>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `createdBy` field to an Option value (optional)
    pub fn maybe_created_by(mut self, value: Option<Did<'a>>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `cursor` field (optional)
    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `cursor` field to an Option value (optional)
    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `hasComment` field (optional)
    pub fn has_comment(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `hasComment` field to an Option value (optional)
    pub fn maybe_has_comment(mut self, value: Option<bool>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `includeAllUserRecords` field (optional)
    pub fn include_all_user_records(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `includeAllUserRecords` field to an Option value (optional)
    pub fn maybe_include_all_user_records(mut self, value: Option<bool>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `limit` field (optional)
    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `limit` field to an Option value (optional)
    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `modTool` field (optional)
    pub fn mod_tool(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.13 = value.into();
        self
    }
    /// Set the `modTool` field to an Option value (optional)
    pub fn maybe_mod_tool(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.13 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `policies` field (optional)
    pub fn policies(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `policies` field to an Option value (optional)
    pub fn maybe_policies(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `removedLabels` field (optional)
    pub fn removed_labels(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.15 = value.into();
        self
    }
    /// Set the `removedLabels` field to an Option value (optional)
    pub fn maybe_removed_labels(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.15 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `removedTags` field (optional)
    pub fn removed_tags(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.16 = value.into();
        self
    }
    /// Set the `removedTags` field to an Option value (optional)
    pub fn maybe_removed_tags(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.16 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `reportTypes` field (optional)
    pub fn report_types(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.17 = value.into();
        self
    }
    /// Set the `reportTypes` field to an Option value (optional)
    pub fn maybe_report_types(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.17 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `sortDirection` field (optional)
    pub fn sort_direction(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.18 = value.into();
        self
    }
    /// Set the `sortDirection` field to an Option value (optional)
    pub fn maybe_sort_direction(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.18 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `subject` field (optional)
    pub fn subject(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
        self._fields.19 = value.into();
        self
    }
    /// Set the `subject` field to an Option value (optional)
    pub fn maybe_subject(mut self, value: Option<UriValue<'a>>) -> Self {
        self._fields.19 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `subjectType` field (optional)
    pub fn subject_type(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.20 = value.into();
        self
    }
    /// Set the `subjectType` field to an Option value (optional)
    pub fn maybe_subject_type(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.20 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `types` field (optional)
    pub fn types(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.21 = value.into();
        self
    }
    /// Set the `types` field to an Option value (optional)
    pub fn maybe_types(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.21 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `withStrike` field (optional)
    pub fn with_strike(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.22 = value.into();
        self
    }
    /// Set the `withStrike` field to an Option value (optional)
    pub fn maybe_with_strike(mut self, value: Option<bool>) -> Self {
        self._fields.22 = value;
        self
    }
}

impl<'a, S> QueryEventsBuilder<'a, S>
where
    S: query_events_state::State,
{
    /// Build the final struct
    pub fn build(self) -> QueryEvents<'a> {
        QueryEvents {
            added_labels: self._fields.0,
            added_tags: self._fields.1,
            age_assurance_state: self._fields.2,
            batch_id: self._fields.3,
            collections: self._fields.4,
            comment: self._fields.5,
            created_after: self._fields.6,
            created_before: self._fields.7,
            created_by: self._fields.8,
            cursor: self._fields.9,
            has_comment: self._fields.10,
            include_all_user_records: self._fields.11,
            limit: self._fields.12,
            mod_tool: self._fields.13,
            policies: self._fields.14,
            removed_labels: self._fields.15,
            removed_tags: self._fields.16,
            report_types: self._fields.17,
            sort_direction: self._fields.18,
            subject: self._fields.19,
            subject_type: self._fields.20,
            types: self._fields.21,
            with_strike: self._fields.22,
        }
    }
}