Skip to main content

firebase_admin_sdk/firestore/
models.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4/// Represents a Firestore document.
5#[derive(Serialize, Deserialize, Debug, Clone)]
6#[serde(rename_all = "camelCase")]
7pub struct Document {
8    /// The resource name of the document.
9    pub name: String,
10    /// The document's fields.
11    pub fields: HashMap<String, Value>,
12    /// The time at which the document was created.
13    pub create_time: String,
14    /// The time at which the document was last changed.
15    pub update_time: String,
16}
17
18/// A message that can hold any of the supported value types.
19#[derive(Serialize, Deserialize, Debug, Clone)]
20#[serde(rename_all = "camelCase")]
21pub struct Value {
22    /// The type of the value.
23    #[serde(flatten)]
24    pub value_type: ValueType,
25}
26
27/// The type of the value.
28#[derive(Serialize, Deserialize, Debug, Clone)]
29#[serde(rename_all = "camelCase")]
30pub enum ValueType {
31    /// A string value.
32    StringValue(String),
33    /// An integer value.
34    IntegerValue(String), // Firestore sends integers as strings
35    /// A double value.
36    DoubleValue(f64),
37    /// A boolean value.
38    BooleanValue(bool),
39    /// A map value.
40    MapValue(MapValue),
41    /// An array value.
42    ArrayValue(ArrayValue),
43    /// A null value.
44    NullValue(()),
45    /// A timestamp value.
46    TimestampValue(String),
47    /// A geo point value.
48    GeoPointValue(GeoPoint),
49    /// A bytes value (base64 encoded).
50    BytesValue(String), // base64 encoded
51    /// A reference to a document.
52    ReferenceValue(String),
53}
54
55/// A map value.
56#[derive(Serialize, Deserialize, Debug, Clone)]
57pub struct MapValue {
58    /// The map's fields.
59    pub fields: HashMap<String, Value>,
60}
61
62/// An array value.
63#[derive(Serialize, Deserialize, Debug, Clone)]
64pub struct ArrayValue {
65    /// The array's values.
66    pub values: Vec<Value>,
67}
68
69/// An object representing a latitude/longitude pair.
70#[derive(Serialize, Deserialize, Debug, Clone)]
71pub struct GeoPoint {
72    /// The latitude in degrees.
73    pub latitude: f64,
74    /// The longitude in degrees.
75    pub longitude: f64,
76}
77
78/// The response from listing documents.
79#[derive(Serialize, Deserialize, Debug, Clone)]
80pub struct ListDocumentsResponse {
81    /// The documents found.
82    pub documents: Vec<Document>,
83    /// The next page token.
84    #[serde(rename = "nextPageToken")]
85    pub next_page_token: Option<String>,
86}
87
88// --- Transaction Models ---
89
90/// A request to begin a transaction.
91#[derive(Serialize, Deserialize, Debug, Clone)]
92#[serde(rename_all = "camelCase")]
93pub struct BeginTransactionRequest {
94    /// Options for the transaction.
95    #[serde(skip_serializing_if = "Option::is_none")]
96    pub options: Option<TransactionOptions>,
97}
98
99/// Options for a transaction.
100#[derive(Serialize, Deserialize, Debug, Clone)]
101#[serde(rename_all = "camelCase")]
102pub struct TransactionOptions {
103    /// The mode of the transaction.
104    #[serde(flatten)]
105    pub mode: Option<TransactionMode>,
106}
107
108/// The mode of a transaction.
109#[derive(Serialize, Deserialize, Debug, Clone)]
110#[serde(rename_all = "camelCase")]
111pub enum TransactionMode {
112    /// Read-only transaction.
113    ReadOnly(ReadOnlyOptions),
114    /// Read-write transaction.
115    ReadWrite(ReadWriteOptions),
116}
117
118/// Options for a read-only transaction.
119#[derive(Serialize, Deserialize, Debug, Clone)]
120#[serde(rename_all = "camelCase")]
121pub struct ReadOnlyOptions {
122    /// Reads documents at the given time.
123    #[serde(skip_serializing_if = "Option::is_none")]
124    pub read_time: Option<String>,
125}
126
127/// Options for a read-write transaction.
128#[derive(Serialize, Deserialize, Debug, Clone)]
129#[serde(rename_all = "camelCase")]
130pub struct ReadWriteOptions {
131    /// An optional transaction to retry.
132    #[serde(skip_serializing_if = "Option::is_none")]
133    pub retry_transaction: Option<String>, // Previous transaction ID
134}
135
136/// The response from beginning a transaction.
137#[derive(Serialize, Deserialize, Debug, Clone)]
138#[serde(rename_all = "camelCase")]
139pub struct BeginTransactionResponse {
140    /// The transaction ID (bytes as string).
141    pub transaction: String,
142}
143
144/// A request to rollback a transaction.
145#[derive(Serialize, Deserialize, Debug, Clone)]
146#[serde(rename_all = "camelCase")]
147pub struct RollbackRequest {
148    /// The transaction ID to rollback.
149    pub transaction: String,
150}
151
152/// A request to commit a transaction.
153#[derive(Serialize, Deserialize, Debug, Clone)]
154#[serde(rename_all = "camelCase")]
155pub struct CommitRequest {
156    /// The transaction ID to commit.
157    #[serde(skip_serializing_if = "Option::is_none")]
158    pub transaction: Option<String>,
159    /// The writes to apply.
160    pub writes: Vec<Write>,
161}
162
163/// The response from committing a transaction.
164#[derive(Serialize, Deserialize, Debug, Clone)]
165#[serde(rename_all = "camelCase")]
166pub struct CommitResponse {
167    /// The result of the writes.
168    #[serde(default)]
169    pub write_results: Vec<WriteResult>,
170    /// The time at which the commit occurred.
171    #[serde(skip_serializing_if = "Option::is_none")]
172    pub commit_time: Option<String>,
173}
174
175/// The result of a single write.
176#[derive(Serialize, Deserialize, Debug, Clone)]
177#[serde(rename_all = "camelCase")]
178pub struct WriteResult {
179    /// The time at which the document was updated.
180    #[serde(skip_serializing_if = "Option::is_none")]
181    pub update_time: Option<String>,
182    /// The results of applying each transform.
183    #[serde(default)]
184    pub transform_results: Vec<Value>,
185}
186
187/// A write operation.
188#[derive(Serialize, Deserialize, Debug, Clone)]
189#[serde(rename_all = "camelCase")]
190pub struct Write {
191    /// The fields to update.
192    #[serde(skip_serializing_if = "Option::is_none")]
193    pub update_mask: Option<DocumentMask>,
194    /// The transforms to perform after update.
195    #[serde(skip_serializing_if = "Option::is_none")]
196    pub update_transforms: Option<Vec<FieldTransform>>,
197    /// An optional precondition on the document.
198    #[serde(skip_serializing_if = "Option::is_none")]
199    pub current_document: Option<Precondition>,
200    /// The operation to perform.
201    #[serde(flatten)]
202    pub operation: WriteOperation,
203}
204
205/// The type of write operation.
206#[derive(Serialize, Deserialize, Debug, Clone)]
207#[serde(rename_all = "camelCase")]
208pub enum WriteOperation {
209    /// Updates a document.
210    Update(Document),
211    /// Deletes a document.
212    Delete(String), // Document name
213    /// Applies a transformation to a document.
214    Transform(DocumentTransform),
215}
216
217/// A set of field paths on a document.
218#[derive(Serialize, Deserialize, Debug, Clone)]
219#[serde(rename_all = "camelCase")]
220pub struct DocumentMask {
221    /// The list of field paths in the mask.
222    pub field_paths: Vec<String>,
223}
224
225/// A precondition on a document, used for conditional writes.
226#[derive(Serialize, Deserialize, Debug, Clone)]
227#[serde(rename_all = "camelCase")]
228pub struct Precondition {
229    /// When set to `true`, the target document must exist.
230    /// When set to `false`, the target document must not exist.
231    #[serde(skip_serializing_if = "Option::is_none")]
232    pub exists: Option<bool>,
233    /// When set, the target document must exist and have been last updated at that time.
234    #[serde(skip_serializing_if = "Option::is_none")]
235    pub update_time: Option<String>,
236}
237
238/// A transformation of a document.
239#[derive(Serialize, Deserialize, Debug, Clone)]
240#[serde(rename_all = "camelCase")]
241pub struct DocumentTransform {
242    /// The name of the document to transform.
243    pub document: String,
244    /// The list of transformations to apply to the fields of the document.
245    pub field_transforms: Vec<FieldTransform>,
246}
247
248/// A transformation of a field of the document.
249#[derive(Serialize, Deserialize, Debug, Clone)]
250#[serde(rename_all = "camelCase")]
251pub struct FieldTransform {
252    /// The path of the field.
253    pub field_path: String,
254    /// The transformation to apply.
255    #[serde(flatten)]
256    pub transform_type: TransformType,
257}
258
259/// The type of transformation to apply.
260#[derive(Serialize, Deserialize, Debug, Clone)]
261#[serde(rename_all = "camelCase")]
262pub enum TransformType {
263    /// Sets the field to the given server value.
264    SetToServerValue(String), // e.g. "REQUEST_TIME"
265    /// Adds the given value to the field's current value.
266    Increment(Value),
267    /// Sets the field to the maximum of its current value and the given value.
268    Maximum(Value),
269    /// Sets the field to the minimum of its current value and the given value.
270    Minimum(Value),
271    /// Appends the given elements in order if they are not already present in the current array value.
272    AppendMissingElements(ArrayValue),
273    /// Removes all of the given elements from the array in the field.
274    RemoveAllFromArray(ArrayValue),
275}
276
277// --- Listen API Models ---
278
279/// A request to listen to changes in documents.
280#[derive(Serialize, Deserialize, Debug, Clone)]
281#[serde(rename_all = "camelCase")]
282pub struct ListenRequest {
283    /// The database name.
284    pub database: String,
285    /// A target to add to this stream.
286    #[serde(skip_serializing_if = "Option::is_none")]
287    pub add_target: Option<Target>,
288    /// The ID of a target to remove from this stream.
289    #[serde(skip_serializing_if = "Option::is_none")]
290    pub remove_target: Option<i32>,
291    /// Labels associated with this request.
292    #[serde(skip_serializing_if = "Option::is_none")]
293    pub labels: Option<HashMap<String, String>>,
294}
295
296/// A specification of a set of documents to listen to.
297#[derive(Serialize, Deserialize, Debug, Clone)]
298#[serde(rename_all = "camelCase")]
299pub struct Target {
300    /// The type of target to listen to.
301    #[serde(flatten)]
302    pub target_type: Option<TargetType>,
303    /// A resume token from a prior `ListenResponse`.
304    #[serde(skip_serializing_if = "Option::is_none")]
305    pub resume_token: Option<String>, // byte string
306    /// Start listening after a specific `read_time`.
307    #[serde(skip_serializing_if = "Option::is_none")]
308    pub read_time: Option<String>, // timestamp
309    /// The target ID that identifies the target on the stream.
310    #[serde(skip_serializing_if = "Option::is_none")]
311    pub target_id: Option<i32>,
312    /// If the target should be removed once it is current and consistent.
313    #[serde(skip_serializing_if = "Option::is_none")]
314    pub once: Option<bool>,
315    /// The number of documents that last matched the query at the resume token or read time.
316    #[serde(skip_serializing_if = "Option::is_none")]
317    pub expected_count: Option<i32>,
318}
319
320/// The type of target to listen to.
321#[derive(Serialize, Deserialize, Debug, Clone)]
322#[serde(rename_all = "camelCase")]
323pub enum TargetType {
324    /// A target specified by a query.
325    Query(QueryTarget),
326    /// A target specified by a set of document names.
327    Documents(DocumentsTarget),
328}
329
330/// A target specified by a query.
331#[derive(Serialize, Deserialize, Debug, Clone)]
332#[serde(rename_all = "camelCase")]
333pub struct QueryTarget {
334    /// The parent resource name.
335    pub parent: String,
336    /// The structured query.
337    #[serde(skip_serializing_if = "Option::is_none")]
338    pub structured_query: Option<StructuredQuery>,
339}
340
341/// A target specified by a set of document names.
342#[derive(Serialize, Deserialize, Debug, Clone)]
343#[serde(rename_all = "camelCase")]
344pub struct DocumentsTarget {
345    /// The names of the documents to retrieve.
346    pub documents: Vec<String>,
347}
348
349/// The response for `ListenRequest`.
350#[derive(Serialize, Deserialize, Debug, Clone)]
351#[serde(rename_all = "camelCase")]
352pub struct ListenResponse {
353    /// Targets have changed.
354    #[serde(skip_serializing_if = "Option::is_none")]
355    pub target_change: Option<TargetChange>,
356    /// A Document has changed.
357    #[serde(skip_serializing_if = "Option::is_none")]
358    pub document_change: Option<DocumentChange>,
359    /// A Document has been deleted.
360    #[serde(skip_serializing_if = "Option::is_none")]
361    pub document_delete: Option<DocumentDelete>,
362    /// A Document has been removed from a target (but not deleted).
363    #[serde(skip_serializing_if = "Option::is_none")]
364    pub document_remove: Option<DocumentRemove>,
365    /// A filter to apply to the set of documents matching the targets.
366    #[serde(skip_serializing_if = "Option::is_none")]
367    pub filter: Option<ExistenceFilter>,
368}
369
370/// Targets being watched have changed.
371#[derive(Serialize, Deserialize, Debug, Clone)]
372#[serde(rename_all = "camelCase")]
373pub struct TargetChange {
374    /// The type of change that occurred.
375    #[serde(default)]
376    pub target_change_type: TargetChangeType,
377    /// The target IDs of targets that have changed.
378    #[serde(default)]
379    pub target_ids: Vec<i32>,
380    /// The error that resulted in this change, if applicable.
381    #[serde(skip_serializing_if = "Option::is_none")]
382    pub cause: Option<Status>,
383    /// A token that can be used to resume the stream for the given `target_ids`,
384    /// or all targets if `target_ids` is empty.
385    #[serde(skip_serializing_if = "Option::is_none")]
386    pub resume_token: Option<String>, // byte string
387    /// The consistent `read_time` for the given `target_ids`.
388    #[serde(skip_serializing_if = "Option::is_none")]
389    pub read_time: Option<String>,
390}
391
392/// The type of change.
393#[derive(Serialize, Deserialize, Debug, Clone)]
394#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
395pub enum TargetChangeType {
396    /// No change has occurred.
397    NoChange,
398    /// The targets have been added.
399    Add,
400    /// The targets have been removed.
401    Remove,
402    /// The targets reflect all changes committed before the targets were added
403    /// to the stream.
404    Current,
405    /// The targets have been reset.
406    Reset,
407}
408
409impl Default for TargetChangeType {
410    fn default() -> Self {
411        TargetChangeType::NoChange
412    }
413}
414
415/// A Document has changed.
416#[derive(Serialize, Deserialize, Debug, Clone)]
417#[serde(rename_all = "camelCase")]
418pub struct DocumentChange {
419    /// The new state of the document.
420    #[serde(skip_serializing_if = "Option::is_none")]
421    pub document: Option<Document>,
422    /// A set of target IDs of targets that match this document.
423    #[serde(default)]
424    pub target_ids: Vec<i32>,
425    /// A set of target IDs for targets that no longer match this document.
426    #[serde(default)]
427    pub removed_target_ids: Vec<i32>,
428}
429
430/// A Document has been deleted.
431#[derive(Serialize, Deserialize, Debug, Clone)]
432#[serde(rename_all = "camelCase")]
433pub struct DocumentDelete {
434    /// The resource name of the Document that was deleted.
435    pub document: String,
436    /// A set of target IDs for targets that previously matched this entity.
437    #[serde(default)]
438    pub removed_target_ids: Vec<i32>,
439    /// The read timestamp at which the delete was observed.
440    #[serde(skip_serializing_if = "Option::is_none")]
441    pub read_time: Option<String>,
442}
443
444/// A Document has been removed from the view of the targets.
445#[derive(Serialize, Deserialize, Debug, Clone)]
446#[serde(rename_all = "camelCase")]
447pub struct DocumentRemove {
448    /// The resource name of the Document that has gone out of view.
449    pub document: String,
450    /// A set of target IDs for targets that previously matched this document.
451    #[serde(default)]
452    pub removed_target_ids: Vec<i32>,
453    /// The read timestamp at which the remove was observed.
454    #[serde(skip_serializing_if = "Option::is_none")]
455    pub read_time: Option<String>,
456}
457
458/// A Digest of documents that match the given target.
459#[derive(Serialize, Deserialize, Debug, Clone)]
460#[serde(rename_all = "camelCase")]
461pub struct ExistenceFilter {
462    /// The total count of documents that match target_id.
463    pub count: i32,
464    /// The target ID to which this filter applies.
465    pub target_id: i32,
466    /// A Bloom filter for the documents.
467    #[serde(skip_serializing_if = "Option::is_none")]
468    pub unchanged_names: Option<BloomFilter>,
469}
470
471/// A Bloom filter.
472#[derive(Serialize, Deserialize, Debug, Clone)]
473#[serde(rename_all = "camelCase")]
474pub struct BloomFilter {
475    /// The bloom filter data.
476    #[serde(skip_serializing_if = "Option::is_none")]
477    pub bits: Option<BitSequence>,
478    /// The number of hashes used by the algorithm.
479    pub hash_count: i32,
480}
481
482/// A sequence of bits.
483#[derive(Serialize, Deserialize, Debug, Clone)]
484#[serde(rename_all = "camelCase")]
485pub struct BitSequence {
486    /// The bytes that encode the bit sequence.
487    pub bitmap: String,
488    /// The number of padding bits in the last byte.
489    pub padding: i32,
490}
491
492/// The RPC status.
493#[derive(Serialize, Deserialize, Debug, Clone)]
494#[serde(rename_all = "camelCase")]
495pub struct Status {
496    /// The status code.
497    pub code: i32,
498    /// The error message.
499    pub message: String,
500    /// A list of messages that carry the error details.
501    #[serde(default)]
502    pub details: Vec<HashMap<String, serde_json::Value>>,
503}
504
505// --- Structured Query Models ---
506
507/// A Firestore query.
508#[derive(Serialize, Deserialize, Debug, Clone)]
509#[serde(rename_all = "camelCase")]
510pub struct StructuredQuery {
511    /// The projection to return.
512    #[serde(skip_serializing_if = "Option::is_none")]
513    pub select: Option<Projection>,
514    /// The collections to query.
515    #[serde(skip_serializing_if = "Option::is_none")]
516    pub from: Option<Vec<CollectionSelector>>,
517    /// The filter to apply.
518    #[serde(rename = "where", skip_serializing_if = "Option::is_none")]
519    pub where_clause: Option<QueryFilter>,
520    /// The order to apply to the query results.
521    #[serde(skip_serializing_if = "Option::is_none")]
522    pub order_by: Option<Vec<Order>>,
523    /// A potential prefix of a position in the result set to start the query at.
524    #[serde(skip_serializing_if = "Option::is_none")]
525    pub start_at: Option<Cursor>,
526    /// A potential prefix of a position in the result set to end the query at.
527    #[serde(skip_serializing_if = "Option::is_none")]
528    pub end_at: Option<Cursor>,
529    /// The number of results to skip.
530    #[serde(skip_serializing_if = "Option::is_none")]
531    pub offset: Option<i32>,
532    /// The maximum number of results to return.
533    #[serde(skip_serializing_if = "Option::is_none")]
534    pub limit: Option<i32>,
535}
536
537/// The request for `runQuery`.
538#[derive(Serialize, Deserialize, Debug, Clone)]
539#[serde(rename_all = "camelCase")]
540pub struct RunQueryRequest {
541    /// The parent resource name.
542    pub parent: String,
543    /// The structured query.
544    #[serde(skip_serializing_if = "Option::is_none")]
545    pub structured_query: Option<StructuredQuery>,
546    // TODO: Add support for transactions
547    // pub transaction: Option<String>,
548    // pub new_transaction: Option<TransactionOptions>,
549    // pub read_time: Option<String>,
550}
551
552/// The response for `runQuery`.
553#[derive(Serialize, Deserialize, Debug, Clone)]
554#[serde(rename_all = "camelCase")]
555pub struct RunQueryResponse {
556    /// The transaction that was started or is being used.
557    #[serde(skip_serializing_if = "Option::is_none")]
558    pub transaction: Option<String>,
559    /// A query result, not set when reporting partial progress.
560    #[serde(skip_serializing_if = "Option::is_none")]
561    pub document: Option<Document>,
562    /// The time at which the document was read.
563    #[serde(skip_serializing_if = "Option::is_none")]
564    pub read_time: Option<String>,
565    /// The number of results that have been skipped due to an offset between
566    /// the last response and the current response.
567    #[serde(skip_serializing_if = "Option::is_none")]
568    pub skipped_results: Option<i32>,
569}
570
571/// The projection of document's fields to return.
572#[derive(Serialize, Deserialize, Debug, Clone)]
573#[serde(rename_all = "camelCase")]
574pub struct Projection {
575    /// The fields to return. If empty, all fields are returned.
576    #[serde(skip_serializing_if = "Option::is_none")]
577    pub fields: Option<Vec<FieldReference>>,
578}
579
580/// A selection of a collection, such as `messages as m1`.
581#[derive(Serialize, Deserialize, Debug, Clone)]
582#[serde(rename_all = "camelCase")]
583pub struct CollectionSelector {
584    /// The collection ID.
585    pub collection_id: String,
586    /// When false, selects only collections that are immediate children of
587    /// the `parent` specified in the containing `RunQueryRequest`.
588    /// When true, selects all descendant collections.
589    #[serde(skip_serializing_if = "Option::is_none")]
590    pub all_descendants: Option<bool>,
591}
592
593/// A filter.
594#[derive(Serialize, Deserialize, Debug, Clone)]
595#[serde(rename_all = "camelCase")]
596pub struct QueryFilter {
597    /// The type of filter.
598    #[serde(flatten)]
599    pub filter_type: Option<FilterType>,
600}
601
602/// The type of filter.
603#[derive(Serialize, Deserialize, Debug, Clone)]
604#[serde(rename_all = "camelCase")]
605pub enum FilterType {
606    /// A composite filter.
607    CompositeFilter(CompositeFilter),
608    /// A filter on a document field.
609    FieldFilter(FieldFilter),
610    /// A filter that takes exactly one argument.
611    UnaryFilter(UnaryFilter),
612}
613
614/// A filter that merges multiple other filters using the given operator.
615#[derive(Serialize, Deserialize, Debug, Clone)]
616#[serde(rename_all = "camelCase")]
617pub struct CompositeFilter {
618    /// The operator for combining multiple filters.
619    pub op: CompositeOperator,
620    /// The list of filters to combine.
621    pub filters: Vec<QueryFilter>,
622}
623
624/// A composite operator.
625#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
626#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
627pub enum CompositeOperator {
628    /// Unspecified operator.
629    OperatorUnspecified,
630    /// The results are required to satisfy each of the combined filters.
631    And,
632    /// The results are required to satisfy at least one of the combined filters.
633    Or,
634}
635
636/// A filter on a specific field.
637#[derive(Serialize, Deserialize, Debug, Clone)]
638#[serde(rename_all = "camelCase")]
639pub struct FieldFilter {
640    /// The field to filter by.
641    pub field: FieldReference,
642    /// The operator to use for comparison.
643    pub op: FieldOperator,
644    /// The value to compare to.
645    pub value: Value,
646}
647
648/// A field filter operator.
649#[derive(Serialize, Deserialize, Debug, Clone)]
650#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
651pub enum FieldOperator {
652    /// Unspecified operator.
653    OperatorUnspecified,
654    /// Less than.
655    LessThan,
656    /// Less than or equal.
657    LessThanOrEqual,
658    /// Greater than.
659    GreaterThan,
660    /// Greater than or equal.
661    GreaterThanOrEqual,
662    /// Equal.
663    Equal,
664    /// Not equal.
665    NotEqual,
666    /// Array contains.
667    ArrayContains,
668    /// In.
669    In,
670    /// Array contains any.
671    ArrayContainsAny,
672    /// Not in.
673    NotIn,
674}
675
676/// A filter with a single operand.
677#[derive(Serialize, Deserialize, Debug, Clone)]
678#[serde(rename_all = "camelCase")]
679pub struct UnaryFilter {
680    /// The unary operator.
681    pub op: UnaryOperator,
682    /// The field to which to apply the operator.
683    pub field: FieldReference,
684}
685
686/// A unary operator.
687#[derive(Serialize, Deserialize, Debug, Clone)]
688#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
689pub enum UnaryOperator {
690    /// Unspecified operator.
691    OperatorUnspecified,
692    /// IS NAN.
693    IsNan,
694    /// IS NULL.
695    IsNull,
696    /// IS NOT NAN.
697    IsNotNan,
698    /// IS NOT NULL.
699    IsNotNull,
700}
701
702/// An order on a field.
703#[derive(Serialize, Deserialize, Debug, Clone)]
704#[serde(rename_all = "camelCase")]
705pub struct Order {
706    /// The field to order by.
707    pub field: FieldReference,
708    /// The direction to order by.
709    pub direction: Direction,
710}
711
712/// A sort direction.
713#[derive(Serialize, Deserialize, Debug, Clone)]
714#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
715pub enum Direction {
716    /// Unspecified direction.
717    DirectionUnspecified,
718    /// Ascending.
719    Ascending,
720    /// Descending.
721    Descending,
722}
723
724/// A reference to a field.
725#[derive(Serialize, Deserialize, Debug, Clone)]
726#[serde(rename_all = "camelCase")]
727pub struct FieldReference {
728    /// The path of the field.
729    pub field_path: String,
730}
731
732/// A position in a result set.
733#[derive(Serialize, Deserialize, Debug, Clone)]
734#[serde(rename_all = "camelCase")]
735pub struct Cursor {
736    /// The values that represent the position, in the order they appear in
737    /// the order by clause of a query.
738    pub values: Vec<Value>,
739    /// If the position is just before or just after the given values.
740    #[serde(skip_serializing_if = "Option::is_none")]
741    pub before: Option<bool>,
742}
743
744// --- List Collections Models ---
745
746/// The request for `listCollectionIds`.
747#[derive(Serialize, Deserialize, Debug, Clone)]
748#[serde(rename_all = "camelCase")]
749pub struct ListCollectionIdsRequest {
750    /// The maximum number of results to return.
751    #[serde(skip_serializing_if = "Option::is_none")]
752    pub page_size: Option<i32>,
753    /// A page token.
754    #[serde(skip_serializing_if = "Option::is_none")]
755    pub page_token: Option<String>,
756}
757
758/// The response for `listCollectionIds`.
759#[derive(Serialize, Deserialize, Debug, Clone)]
760#[serde(rename_all = "camelCase")]
761pub struct ListCollectionIdsResponse {
762    /// The collection IDs.
763    #[serde(default)]
764    pub collection_ids: Vec<String>,
765    /// The next page token.
766    #[serde(skip_serializing_if = "Option::is_none")]
767    pub next_page_token: Option<String>,
768}