weaviate-community 0.2.2

Community client for handling Weaviate vector database transactions written in Rust, for Rust.
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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
/// All objects associated type components
use serde::{Deserialize, Serialize};
use uuid::Uuid;

/// Wrapper for multiple objects.
#[derive(Serialize, Deserialize, Debug)]
pub struct MultiObjects {
    pub objects: Vec<Object>,
}

impl MultiObjects {
    /// Create a new MultiObjects object
    ///
    /// # Parameters
    /// - objects: the objects to encapsulate
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::{Object, MultiObjects};
    ///
    /// let object = Object::builder("Object", serde_json::json![{}]).build();
    /// let objects = MultiObjects::new(vec![object]);
    /// ```
    pub fn new(objects: Vec<Object>) -> MultiObjects {
        MultiObjects { objects }
    }
}

/// Object struct used for creating a new Object.
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Object {
    pub class: String,
    pub properties: serde_json::Value,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub id: Option<Uuid>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub vector: Option<Vec<f64>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub tenant: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub creation_time_unix: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub last_update_time_unix: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub vector_weights: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub additional: Option<serde_json::Value>,
}

impl Object {
    /// Create a new builder for the Object.
    ///
    /// This is the same as `ObjectBuilder::new()`.
    ///
    /// # Parameters
    /// - class: the name of the class that the object belongs to.
    /// - properties: the properties associated with the new object.
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::Object;
    ///
    /// let builder = Object::builder("Object", serde_json::json![{}]);
    /// ```
    pub fn builder(class: &str, properties: serde_json::Value) -> ObjectBuilder {
        ObjectBuilder::new(class, properties)
    }
}

/// The builder for an Object
///
/// Note that you should not adjust the creation_time_unix or the last_update_time_unix values.
pub struct ObjectBuilder {
    pub class: String,
    pub properties: serde_json::Value,
    pub id: Option<Uuid>,
    pub vector: Option<Vec<f64>>,
    pub tenant: Option<String>,
    pub creation_time_unix: Option<u64>,
    pub last_update_time_unix: Option<u64>,
    pub vector_weights: Option<u64>,
}

impl ObjectBuilder {
    /// Create a new builder for the Object.
    ///
    /// This is the same as `Object::builder()`.
    ///
    /// # Parameters
    /// - class: the name of the class that the object belongs to.
    /// - properties: the properties associated with the new object.
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectBuilder;
    ///
    /// let builder = ObjectBuilder::new("Object", serde_json::json![{}]);
    /// ```
    pub fn new(class: &str, properties: serde_json::Value) -> ObjectBuilder {
        ObjectBuilder {
            class: class.into(),
            properties,
            id: None,
            vector: None,
            tenant: None,
            creation_time_unix: None,
            last_update_time_unix: None,
            vector_weights: None,
        }
    }

    /// Add a value to the optional `id` value of the object.
    ///
    /// # Parameters
    /// - id: the uuid to set
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectBuilder;
    /// use uuid::Uuid;
    ///
    /// let builder = ObjectBuilder::new("Object", serde_json::json![{}]).with_id(Uuid::new_v4());
    /// ```
    pub fn with_id(mut self, id: Uuid) -> ObjectBuilder {
        self.id = Some(id);
        self
    }

    /// Add a value to the optional `vector` value of the object.
    ///
    /// # Parameters
    /// - vector: the vector to set
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectBuilder;
    ///
    /// let builder = ObjectBuilder::new("Object", serde_json::json![{}])
    ///     .with_vector(vec![1.0, 1.0, 1.0]);
    /// ```
    pub fn with_vector(mut self, vector: Vec<f64>) -> ObjectBuilder {
        self.vector = Some(vector);
        self
    }

    /// Add a value to the optional `tenant` value of the object.
    ///
    /// # Parameters
    /// - tenant: the tenant to set
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectBuilder;
    ///
    /// let builder = ObjectBuilder::new("Object", serde_json::json![{}])
    ///     .with_tenant("TENANT_A");
    /// ```
    pub fn with_tenant(mut self, tenant: &str) -> ObjectBuilder {
        self.tenant = Some(tenant.into());
        self
    }

    /// Add a value to the optional `vector_weights` value of the object.
    ///
    /// # Parameters
    /// - vector_weights: the vector_weights to set
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectBuilder;
    ///
    /// let builder = ObjectBuilder::new("Object", serde_json::json![{}])
    ///     .with_vector_weights(10);
    /// ```
    pub fn with_vector_weights(mut self, vector_weights: u64) -> ObjectBuilder {
        self.vector_weights = Some(vector_weights);
        self
    }

    /// Build the Object from the ObjectBuilder
    ///
    /// # Example
    /// Using ObjectBuilder
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectBuilder;
    ///
    /// let object = ObjectBuilder::new("Object", serde_json::json![{}]).build();
    /// ```
    ///
    /// Using Object
    /// ```rust
    /// use weaviate_community::collections::objects::Object;
    ///
    /// let object = Object::builder("Object", serde_json::json![{}]).build();
    /// ```
    pub fn build(self) -> Object {
        Object {
            class: self.class,
            properties: self.properties,
            id: self.id,
            vector: self.vector,
            tenant: self.tenant,
            creation_time_unix: self.creation_time_unix,
            last_update_time_unix: self.last_update_time_unix,
            vector_weights: self.vector_weights,
            additional: None
        }
    }
}

/// Strict definitions for ordering queries.
///
/// The options available are ASC and DESC.
pub enum OrderBy {
    ASC,
    DESC,
}

impl OrderBy {
    /// Get the text value for a given OrderBy.
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::OrderBy;
    ///
    /// let val = OrderBy::ASC.value();
    /// ```
    pub fn value(&self) -> &str {
        match self {
            OrderBy::ASC => "asc",
            OrderBy::DESC => "desc",
        }
    }
}

/// Strict definitions of consistency levels.
///
/// For more information on consistency levels in Weaviate, check out the replication architecture
/// documentation [here](https://weaviate.io/developers/weaviate/concepts/replication-architecture/consistency#tunable-read-consistency)
///
/// Tunable consistency strategies:
/// - QUORUM / QUORUM => balanced write and read latency
/// - ONE / ALL => fast write and slow read (optimized for write)
/// - ALL / ONE => slow write and fast read (optimized for read)
#[derive(Serialize, Deserialize, Debug)]
pub enum ConsistencyLevel {
    ONE,
    QUORUM,
    ALL,
}

impl ConsistencyLevel {
    /// Get the text value for a given ConsistencyLevel.
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ConsistencyLevel;
    ///
    /// let val = ConsistencyLevel::ONE.value();
    /// ```
    pub fn value(&self) -> &str {
        match self {
            ConsistencyLevel::ONE => "ONE",
            ConsistencyLevel::QUORUM => "QUORUM",
            ConsistencyLevel::ALL => "ALL",
        }
    }
}

#[derive(Debug, Default)]
pub struct ObjectListParameters {
    pub class_name: Option<String>,
    pub limit: Option<u64>,
    pub offset: Option<u64>,
    pub after: Option<String>,
    pub include: Option<String>,
    pub sort: Option<Vec<String>>,
    pub order: Option<Vec<String>>,
}

impl ObjectListParameters {
    /// Create a new ObjectListParameters with all parameters set to None.
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectListParameters;
    ///
    /// let builder = ObjectListParameters::new();
    /// ```
    pub fn new() -> ObjectListParameters {
        ObjectListParameters::default()
    }

    /// Create a new builder for the ObjectListParameters.
    ///
    /// This is the same as `ObjectListParametersBuilder::new()`.
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectListParameters;
    ///
    /// let builder = ObjectListParameters::builder();
    /// ```
    pub fn builder() -> ObjectListParametersBuilder {
        ObjectListParametersBuilder::default()
    }
}

#[derive(Debug, Default)]
pub struct ObjectListParametersBuilder {
    pub class_name: Option<String>,
    pub limit: Option<u64>,
    pub offset: Option<u64>,
    pub after: Option<String>,
    pub include: Option<String>,
    pub sort: Option<Vec<String>>,
    pub order: Option<Vec<String>>,
}

impl ObjectListParametersBuilder {
    /// Create a new builder for the ObjectListParameters.
    ///
    /// This is the same as `ObjectListParameters::builder()`.
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectListParametersBuilder;
    ///
    /// let builder = ObjectListParametersBuilder::new();
    /// ```
    pub fn new() -> ObjectListParametersBuilder {
        ObjectListParametersBuilder::default()
    }

    /// Add a value to the optional `class_name` value to the parameters.
    ///
    /// # Parameters
    /// - class_name: the class_name to set
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectListParametersBuilder;
    ///
    /// let builder = ObjectListParametersBuilder::new()
    ///     .with_class_name("Article");
    /// ```
    pub fn with_class_name(mut self, class_name: &str) -> ObjectListParametersBuilder {
        self.class_name = Some(class_name.into());
        self
    }

    /// Add a value to the optional `limit` value to the parameters.
    ///
    /// If not set, defaults to 25.
    ///
    /// # Parameters
    /// - limit: the limit value to set
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectListParametersBuilder;
    ///
    /// let builder = ObjectListParametersBuilder::new()
    ///     .with_limit(25);
    /// ```
    pub fn with_limit(mut self, limit: u64) -> ObjectListParametersBuilder {
        self.limit = Some(limit);
        self
    }

    /// Add a value to the optional `offset` value to the parameters.
    ///
    /// Cannot be used with `after`.
    /// Should be used with `limit`.
    ///
    /// # Parameters
    /// - offset: the offset value to set
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectListParametersBuilder;
    ///
    /// let builder = ObjectListParametersBuilder::new()
    ///     .with_offset(2);
    /// ```
    pub fn with_offset(mut self, offset: u64) -> ObjectListParametersBuilder {
        self.offset = Some(offset);
        self
    }

    /// Add a value to the optional `after` value to the parameters.
    ///
    /// Must be used in conjunction with `class`.
    /// Cannot be used with `offset` or `sort`.
    /// Should be used with `limit`.
    ///
    /// # Parameters
    /// - after: the after value to set
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectListParametersBuilder;
    ///
    /// let builder = ObjectListParametersBuilder::new()
    ///     .with_after("dcfbe06f-fb69-48d7-9a13-e8e78e422486");
    /// ```
    pub fn with_after(mut self, after: &str) -> ObjectListParametersBuilder {
        self.after = Some(after.into());
        self
    }

    /// Add a value to the optional `include` value to the parameters.
    ///
    /// Allowed values include:
    /// - classification
    /// - vector
    /// - featureProjection
    /// and other module specific additional properties.
    ///
    /// # Parameters
    /// - include: the include value to set
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectListParametersBuilder;
    ///
    /// let builder = ObjectListParametersBuilder::new().with_include("classification");
    /// ```
    pub fn with_include(mut self, include: &str) -> ObjectListParametersBuilder {
        self.include = Some(include.into());
        self
    }

    /// Add a value to the optional `sort` value to the parameters.
    ///
    /// # Parameters
    /// - sort: the sort value to set
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectListParametersBuilder;
    ///
    /// let builder = ObjectListParametersBuilder::new().with_sort(vec!["title"]);
    /// ```
    pub fn with_sort(mut self, sort: Vec<&str>) -> ObjectListParametersBuilder {
        let sort = sort.iter().map(|field| field.to_string()).collect();
        self.sort = Some(sort);
        self
    }

    /// Add a value to the optional `order` value to the parameters.
    ///
    /// # Parameters
    /// - order: the order to set
    ///
    /// # Example
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectListParametersBuilder;
    ///
    /// let builder = ObjectListParametersBuilder::new().with_order(vec!["asc"]);
    /// ```
    pub fn with_order(mut self, order: Vec<&str>) -> ObjectListParametersBuilder {
        let order = order.iter().map(|field| field.to_string()).collect();
        self.order = Some(order);
        self
    }

    /// Build the ObjectListParameters from the ObjectListParametersBuilder
    ///
    /// # Example
    /// Using ObjectListParametersBuilder
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectListParametersBuilder;
    ///
    /// let object = ObjectListParametersBuilder::new().build();
    /// ```
    ///
    /// Using ObjectListParameters
    /// ```rust
    /// use weaviate_community::collections::objects::ObjectListParameters;
    ///
    /// let object = ObjectListParameters::builder().build();
    /// ```
    pub fn build(self) -> ObjectListParameters {
        ObjectListParameters {
            class_name: self.class_name,
            limit: self.limit,
            offset: self.offset,
            after: self.after,
            include: self.include,
            sort: self.sort,
            order: self.order,
        }
    }
}

/// Wrapper for multiple references.
pub struct References(pub Vec<Reference>);

impl References {
    /// Create a new References wrapper.
    ///
    /// # Example
    /// ```rust
    /// use uuid::Uuid;
    /// use weaviate_community::collections::objects::{References, Reference};
    ///
    /// let uuid1 = Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap();
    /// let uuid2 = Uuid::parse_str("20ffc68d-986b-5e71-a680-228dba18d7ef").unwrap();
    ///
    /// let reference = Reference::new(
    ///     "JeopardyQuestion",
    ///     &uuid1,
    ///     "hasCategory",
    ///     "JeopardyCategory",
    ///     &uuid2,
    /// );

    /// let references = References::new(
    ///    vec![reference]
    /// );
    /// ```
    pub fn new(references: Vec<Reference>) -> References {
        References(references)
    }
}

/// The Reference type for adding a reference between classes
pub struct Reference {
    pub from_class_name: String,
    pub from_uuid: Uuid,
    pub from_property_name: String,
    pub to_class_name: String,
    pub to_uuid: Uuid,
    pub consistency_level: Option<ConsistencyLevel>,
    pub tenant_name: Option<String>,
}

impl Reference {
    /// Create a new Reference with all optional parameters set to None.
    ///
    /// # Example
    /// ```rust
    /// use uuid::Uuid;
    /// use weaviate_community::collections::objects::Reference;
    ///
    /// let uuid1 = Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap();
    /// let uuid2 = Uuid::parse_str("20ffc68d-986b-5e71-a680-228dba18d7ef").unwrap();
    ///
    /// let reference = Reference::new(
    ///     "JeopardyQuestion",
    ///     &uuid1,
    ///     "hasCategory",
    ///     "JeopardyCategory",
    ///     &uuid2,
    /// );
    /// ```
    pub fn new(
        from_class_name: &str,
        from_uuid: &Uuid,
        from_property_name: &str,
        to_class_name: &str,
        to_uuid: &Uuid,
    ) -> Reference {
        Reference {
            from_class_name: from_class_name.into(),
            from_uuid: from_uuid.clone(),
            from_property_name: from_property_name.into(),
            to_class_name: to_class_name.into(),
            to_uuid: to_uuid.clone(),
            consistency_level: None,
            tenant_name: None,
        }
    }

    /// Create a new builder for the Reference.
    ///
    /// This is the same as `ReferenceBuilder::new()`.
    ///
    /// # Example
    /// ```rust
    /// use uuid::Uuid;
    /// use weaviate_community::collections::objects::Reference;
    ///
    /// let uuid1 = Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap();
    /// let uuid2 = Uuid::parse_str("20ffc68d-986b-5e71-a680-228dba18d7ef").unwrap();
    ///
    /// let reference = Reference::new(
    ///     "JeopardyQuestion",
    ///     &uuid1,
    ///     "hasCategory",
    ///     "JeopardyCategory",
    ///     &uuid2,
    /// );
    /// ```
    pub fn builder(
        from_class_name: &str,
        from_uuid: &Uuid,
        from_property_name: &str,
        to_class_name: &str,
        to_uuid: &Uuid,
    ) -> ReferenceBuilder {
        ReferenceBuilder::new(
            from_class_name,
            from_uuid,
            from_property_name,
            to_class_name,
            to_uuid,
        )
    }
}

/// The builder for a Reference
pub struct ReferenceBuilder {
    pub from_class_name: String,
    pub from_uuid: Uuid,
    pub from_property_name: String,
    pub to_class_name: String,
    pub to_uuid: Uuid,
    pub consistency_level: Option<ConsistencyLevel>,
    pub tenant_name: Option<String>,
}

impl ReferenceBuilder {
    /// Create a new builder for the Reference.
    ///
    /// This is the same as `Reference::builder()`.
    ///
    /// # Example
    /// ```rust
    /// use uuid::Uuid;
    /// use weaviate_community::collections::objects::ReferenceBuilder;
    ///
    /// let uuid1 = Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap();
    /// let uuid2 = Uuid::parse_str("20ffc68d-986b-5e71-a680-228dba18d7ef").unwrap();
    ///
    /// let reference = ReferenceBuilder::new(
    ///     "JeopardyQuestion",
    ///     &uuid1,
    ///     "hasCategory",
    ///     "JeopardyCategory",
    ///     &uuid2,
    /// );
    /// ```
    pub fn new(
        from_class_name: &str,
        from_uuid: &Uuid,
        from_property_name: &str,
        to_class_name: &str,
        to_uuid: &Uuid,
    ) -> ReferenceBuilder {
        ReferenceBuilder {
            from_class_name: from_class_name.into(),
            from_uuid: from_uuid.clone(),
            from_property_name: from_property_name.into(),
            to_class_name: to_class_name.into(),
            to_uuid: to_uuid.clone(),
            consistency_level: None,
            tenant_name: None,
        }
    }

    /// Add a value to the optional `consistency_level` value to the reference.
    ///
    /// # Parameters
    /// - consistency_level: the consistency_level to set
    ///
    /// # Example
    /// ```rust
    /// use uuid::Uuid;
    /// use weaviate_community::collections::objects::ConsistencyLevel;
    /// use weaviate_community::collections::objects::ReferenceBuilder;
    ///
    /// let uuid1 = Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap();
    /// let uuid2 = Uuid::parse_str("20ffc68d-986b-5e71-a680-228dba18d7ef").unwrap();
    /// let reference = ReferenceBuilder::new(
    ///     "JeopardyQuestion",
    ///     &uuid1,
    ///     "hasCategory",
    ///     "JeopardyCategory",
    ///     &uuid2,
    /// ).with_consistency_level(ConsistencyLevel::ALL).build();
    /// ```
    pub fn with_consistency_level(
        mut self,
        consistency_level: ConsistencyLevel,
    ) -> ReferenceBuilder {
        self.consistency_level = Some(consistency_level);
        self
    }

    /// Add a value to the optional `tenant_name` value to the reference.
    ///
    /// # Parameters
    /// - tenant_name: the tenant_name to set
    ///
    /// # Example
    /// ```rust
    /// use uuid::Uuid;
    /// use weaviate_community::collections::objects::ReferenceBuilder;
    ///
    /// let uuid1 = Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap();
    /// let uuid2 = Uuid::parse_str("20ffc68d-986b-5e71-a680-228dba18d7ef").unwrap();
    /// let reference = ReferenceBuilder::new(
    ///     "JeopardyQuestion",
    ///     &uuid1,
    ///     "hasCategory",
    ///     "JeopardyCategory",
    ///     &uuid2,
    /// ).with_tenant_name("TENANT_A").build();
    /// ```
    pub fn with_tenant_name(mut self, tenant_name: &str) -> ReferenceBuilder {
        self.tenant_name = Some(tenant_name.into());
        self
    }

    /// Build the Reference from the ReferenceBuilder
    ///
    /// # Example
    /// Using ReferenceBuilder
    /// ```rust
    /// use uuid::Uuid;
    /// use weaviate_community::collections::objects::ReferenceBuilder;
    ///
    /// let uuid1 = Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap();
    /// let uuid2 = Uuid::parse_str("20ffc68d-986b-5e71-a680-228dba18d7ef").unwrap();
    /// let reference = ReferenceBuilder::new(
    ///     "JeopardyQuestion",
    ///     &uuid1,
    ///     "hasCategory",
    ///     "JeopardyCategory",
    ///     &uuid2,
    /// ).build();
    /// ```
    ///
    /// Using ObjectListParameters
    /// ```rust
    /// use uuid::Uuid;
    /// use weaviate_community::collections::objects::Reference;
    ///
    /// let uuid1 = Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap();
    /// let uuid2 = Uuid::parse_str("20ffc68d-986b-5e71-a680-228dba18d7ef").unwrap();
    /// let reference = Reference::builder(
    ///     "JeopardyQuestion",
    ///     &uuid1,
    ///     "hasCategory",
    ///     "JeopardyCategory",
    ///     &uuid2,
    /// ).build();
    ///
    /// ```
    pub fn build(self) -> Reference {
        Reference {
            from_class_name: self.from_class_name,
            from_uuid: self.from_uuid,
            from_property_name: self.from_property_name,
            to_class_name: self.to_class_name,
            to_uuid: self.to_uuid,
            consistency_level: self.consistency_level,
            tenant_name: self.tenant_name,
        }
    }
}