1#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gax;
23extern crate lazy_static;
24extern crate reqwest;
25extern crate serde;
26extern crate serde_json;
27extern crate serde_with;
28extern crate std;
29extern crate tracing;
30extern crate wkt;
31
32#[serde_with::serde_as]
34#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
35#[serde(default, rename_all = "camelCase")]
36#[non_exhaustive]
37pub struct Document {
38 #[serde(rename = "type")]
41 pub r#type: crate::model::document::Type,
42
43 #[serde(skip_serializing_if = "std::string::String::is_empty")]
52 pub language_code: std::string::String,
53
54 #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
57 pub source: std::option::Option<crate::model::document::Source>,
58}
59
60impl Document {
61 pub fn new() -> Self {
62 std::default::Default::default()
63 }
64
65 pub fn set_type<T: std::convert::Into<crate::model::document::Type>>(mut self, v: T) -> Self {
67 self.r#type = v.into();
68 self
69 }
70
71 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
73 self.language_code = v.into();
74 self
75 }
76
77 pub fn set_source<
79 T: std::convert::Into<std::option::Option<crate::model::document::Source>>,
80 >(
81 mut self,
82 v: T,
83 ) -> Self {
84 self.source = v.into();
85 self
86 }
87
88 pub fn get_content(&self) -> std::option::Option<&std::string::String> {
92 #[allow(unreachable_patterns)]
93 self.source.as_ref().and_then(|v| match v {
94 crate::model::document::Source::Content(v) => std::option::Option::Some(v),
95 _ => std::option::Option::None,
96 })
97 }
98
99 pub fn get_gcs_content_uri(&self) -> std::option::Option<&std::string::String> {
103 #[allow(unreachable_patterns)]
104 self.source.as_ref().and_then(|v| match v {
105 crate::model::document::Source::GcsContentUri(v) => std::option::Option::Some(v),
106 _ => std::option::Option::None,
107 })
108 }
109
110 pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
116 self.source = std::option::Option::Some(crate::model::document::Source::Content(v.into()));
117 self
118 }
119
120 pub fn set_gcs_content_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
126 self.source =
127 std::option::Option::Some(crate::model::document::Source::GcsContentUri(v.into()));
128 self
129 }
130}
131
132impl wkt::message::Message for Document {
133 fn typename() -> &'static str {
134 "type.googleapis.com/google.cloud.language.v2.Document"
135 }
136}
137
138pub mod document {
140 #[allow(unused_imports)]
141 use super::*;
142
143 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
145 pub struct Type(std::borrow::Cow<'static, str>);
146
147 impl Type {
148 pub const fn new(v: &'static str) -> Self {
150 Self(std::borrow::Cow::Borrowed(v))
151 }
152
153 pub fn value(&self) -> &str {
155 &self.0
156 }
157 }
158
159 pub mod r#type {
161 use super::Type;
162
163 pub const TYPE_UNSPECIFIED: Type = Type::new("TYPE_UNSPECIFIED");
165
166 pub const PLAIN_TEXT: Type = Type::new("PLAIN_TEXT");
168
169 pub const HTML: Type = Type::new("HTML");
171 }
172
173 impl std::convert::From<std::string::String> for Type {
174 fn from(value: std::string::String) -> Self {
175 Self(std::borrow::Cow::Owned(value))
176 }
177 }
178
179 #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
182 #[serde(rename_all = "camelCase")]
183 #[non_exhaustive]
184 pub enum Source {
185 Content(std::string::String),
188 GcsContentUri(std::string::String),
193 }
194}
195
196#[serde_with::serde_as]
198#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
199#[serde(default, rename_all = "camelCase")]
200#[non_exhaustive]
201pub struct Sentence {
202 #[serde(skip_serializing_if = "std::option::Option::is_none")]
204 pub text: std::option::Option<crate::model::TextSpan>,
205
206 #[serde(skip_serializing_if = "std::option::Option::is_none")]
212 pub sentiment: std::option::Option<crate::model::Sentiment>,
213}
214
215impl Sentence {
216 pub fn new() -> Self {
217 std::default::Default::default()
218 }
219
220 pub fn set_text<T: std::convert::Into<std::option::Option<crate::model::TextSpan>>>(
222 mut self,
223 v: T,
224 ) -> Self {
225 self.text = v.into();
226 self
227 }
228
229 pub fn set_sentiment<T: std::convert::Into<std::option::Option<crate::model::Sentiment>>>(
231 mut self,
232 v: T,
233 ) -> Self {
234 self.sentiment = v.into();
235 self
236 }
237}
238
239impl wkt::message::Message for Sentence {
240 fn typename() -> &'static str {
241 "type.googleapis.com/google.cloud.language.v2.Sentence"
242 }
243}
244
245#[serde_with::serde_as]
249#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
250#[serde(default, rename_all = "camelCase")]
251#[non_exhaustive]
252pub struct Entity {
253 #[serde(skip_serializing_if = "std::string::String::is_empty")]
255 pub name: std::string::String,
256
257 #[serde(rename = "type")]
259 pub r#type: crate::model::entity::Type,
260
261 #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
266 pub metadata: std::collections::HashMap<std::string::String, std::string::String>,
267
268 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
271 pub mentions: std::vec::Vec<crate::model::EntityMention>,
272
273 #[serde(skip_serializing_if = "std::option::Option::is_none")]
278 pub sentiment: std::option::Option<crate::model::Sentiment>,
279}
280
281impl Entity {
282 pub fn new() -> Self {
283 std::default::Default::default()
284 }
285
286 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
288 self.name = v.into();
289 self
290 }
291
292 pub fn set_type<T: std::convert::Into<crate::model::entity::Type>>(mut self, v: T) -> Self {
294 self.r#type = v.into();
295 self
296 }
297
298 pub fn set_sentiment<T: std::convert::Into<std::option::Option<crate::model::Sentiment>>>(
300 mut self,
301 v: T,
302 ) -> Self {
303 self.sentiment = v.into();
304 self
305 }
306
307 pub fn set_mentions<T, V>(mut self, v: T) -> Self
309 where
310 T: std::iter::IntoIterator<Item = V>,
311 V: std::convert::Into<crate::model::EntityMention>,
312 {
313 use std::iter::Iterator;
314 self.mentions = v.into_iter().map(|i| i.into()).collect();
315 self
316 }
317
318 pub fn set_metadata<T, K, V>(mut self, v: T) -> Self
320 where
321 T: std::iter::IntoIterator<Item = (K, V)>,
322 K: std::convert::Into<std::string::String>,
323 V: std::convert::Into<std::string::String>,
324 {
325 use std::iter::Iterator;
326 self.metadata = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
327 self
328 }
329}
330
331impl wkt::message::Message for Entity {
332 fn typename() -> &'static str {
333 "type.googleapis.com/google.cloud.language.v2.Entity"
334 }
335}
336
337pub mod entity {
339 #[allow(unused_imports)]
340 use super::*;
341
342 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
346 pub struct Type(std::borrow::Cow<'static, str>);
347
348 impl Type {
349 pub const fn new(v: &'static str) -> Self {
351 Self(std::borrow::Cow::Borrowed(v))
352 }
353
354 pub fn value(&self) -> &str {
356 &self.0
357 }
358 }
359
360 pub mod r#type {
362 use super::Type;
363
364 pub const UNKNOWN: Type = Type::new("UNKNOWN");
366
367 pub const PERSON: Type = Type::new("PERSON");
369
370 pub const LOCATION: Type = Type::new("LOCATION");
372
373 pub const ORGANIZATION: Type = Type::new("ORGANIZATION");
375
376 pub const EVENT: Type = Type::new("EVENT");
378
379 pub const WORK_OF_ART: Type = Type::new("WORK_OF_ART");
381
382 pub const CONSUMER_GOOD: Type = Type::new("CONSUMER_GOOD");
384
385 pub const OTHER: Type = Type::new("OTHER");
387
388 pub const PHONE_NUMBER: Type = Type::new("PHONE_NUMBER");
400
401 pub const ADDRESS: Type = Type::new("ADDRESS");
417
418 pub const DATE: Type = Type::new("DATE");
426
427 pub const NUMBER: Type = Type::new("NUMBER");
431
432 pub const PRICE: Type = Type::new("PRICE");
436 }
437
438 impl std::convert::From<std::string::String> for Type {
439 fn from(value: std::string::String) -> Self {
440 Self(std::borrow::Cow::Owned(value))
441 }
442 }
443}
444
445#[serde_with::serde_as]
448#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
449#[serde(default, rename_all = "camelCase")]
450#[non_exhaustive]
451pub struct Sentiment {
452 pub magnitude: f32,
456
457 pub score: f32,
460}
461
462impl Sentiment {
463 pub fn new() -> Self {
464 std::default::Default::default()
465 }
466
467 pub fn set_magnitude<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
469 self.magnitude = v.into();
470 self
471 }
472
473 pub fn set_score<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
475 self.score = v.into();
476 self
477 }
478}
479
480impl wkt::message::Message for Sentiment {
481 fn typename() -> &'static str {
482 "type.googleapis.com/google.cloud.language.v2.Sentiment"
483 }
484}
485
486#[serde_with::serde_as]
489#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
490#[serde(default, rename_all = "camelCase")]
491#[non_exhaustive]
492pub struct EntityMention {
493 #[serde(skip_serializing_if = "std::option::Option::is_none")]
495 pub text: std::option::Option<crate::model::TextSpan>,
496
497 #[serde(rename = "type")]
499 pub r#type: crate::model::entity_mention::Type,
500
501 #[serde(skip_serializing_if = "std::option::Option::is_none")]
506 pub sentiment: std::option::Option<crate::model::Sentiment>,
507
508 pub probability: f32,
513}
514
515impl EntityMention {
516 pub fn new() -> Self {
517 std::default::Default::default()
518 }
519
520 pub fn set_text<T: std::convert::Into<std::option::Option<crate::model::TextSpan>>>(
522 mut self,
523 v: T,
524 ) -> Self {
525 self.text = v.into();
526 self
527 }
528
529 pub fn set_type<T: std::convert::Into<crate::model::entity_mention::Type>>(
531 mut self,
532 v: T,
533 ) -> Self {
534 self.r#type = v.into();
535 self
536 }
537
538 pub fn set_sentiment<T: std::convert::Into<std::option::Option<crate::model::Sentiment>>>(
540 mut self,
541 v: T,
542 ) -> Self {
543 self.sentiment = v.into();
544 self
545 }
546
547 pub fn set_probability<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
549 self.probability = v.into();
550 self
551 }
552}
553
554impl wkt::message::Message for EntityMention {
555 fn typename() -> &'static str {
556 "type.googleapis.com/google.cloud.language.v2.EntityMention"
557 }
558}
559
560pub mod entity_mention {
562 #[allow(unused_imports)]
563 use super::*;
564
565 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
567 pub struct Type(std::borrow::Cow<'static, str>);
568
569 impl Type {
570 pub const fn new(v: &'static str) -> Self {
572 Self(std::borrow::Cow::Borrowed(v))
573 }
574
575 pub fn value(&self) -> &str {
577 &self.0
578 }
579 }
580
581 pub mod r#type {
583 use super::Type;
584
585 pub const TYPE_UNKNOWN: Type = Type::new("TYPE_UNKNOWN");
587
588 pub const PROPER: Type = Type::new("PROPER");
590
591 pub const COMMON: Type = Type::new("COMMON");
593 }
594
595 impl std::convert::From<std::string::String> for Type {
596 fn from(value: std::string::String) -> Self {
597 Self(std::borrow::Cow::Owned(value))
598 }
599 }
600}
601
602#[serde_with::serde_as]
604#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
605#[serde(default, rename_all = "camelCase")]
606#[non_exhaustive]
607pub struct TextSpan {
608 #[serde(skip_serializing_if = "std::string::String::is_empty")]
610 pub content: std::string::String,
611
612 pub begin_offset: i32,
619}
620
621impl TextSpan {
622 pub fn new() -> Self {
623 std::default::Default::default()
624 }
625
626 pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
628 self.content = v.into();
629 self
630 }
631
632 pub fn set_begin_offset<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
634 self.begin_offset = v.into();
635 self
636 }
637}
638
639impl wkt::message::Message for TextSpan {
640 fn typename() -> &'static str {
641 "type.googleapis.com/google.cloud.language.v2.TextSpan"
642 }
643}
644
645#[serde_with::serde_as]
647#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
648#[serde(default, rename_all = "camelCase")]
649#[non_exhaustive]
650pub struct ClassificationCategory {
651 #[serde(skip_serializing_if = "std::string::String::is_empty")]
653 pub name: std::string::String,
654
655 pub confidence: f32,
658
659 pub severity: f32,
663}
664
665impl ClassificationCategory {
666 pub fn new() -> Self {
667 std::default::Default::default()
668 }
669
670 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
672 self.name = v.into();
673 self
674 }
675
676 pub fn set_confidence<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
678 self.confidence = v.into();
679 self
680 }
681
682 pub fn set_severity<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
684 self.severity = v.into();
685 self
686 }
687}
688
689impl wkt::message::Message for ClassificationCategory {
690 fn typename() -> &'static str {
691 "type.googleapis.com/google.cloud.language.v2.ClassificationCategory"
692 }
693}
694
695#[serde_with::serde_as]
697#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
698#[serde(default, rename_all = "camelCase")]
699#[non_exhaustive]
700pub struct AnalyzeSentimentRequest {
701 #[serde(skip_serializing_if = "std::option::Option::is_none")]
703 pub document: std::option::Option<crate::model::Document>,
704
705 pub encoding_type: crate::model::EncodingType,
707}
708
709impl AnalyzeSentimentRequest {
710 pub fn new() -> Self {
711 std::default::Default::default()
712 }
713
714 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
716 mut self,
717 v: T,
718 ) -> Self {
719 self.document = v.into();
720 self
721 }
722
723 pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
725 mut self,
726 v: T,
727 ) -> Self {
728 self.encoding_type = v.into();
729 self
730 }
731}
732
733impl wkt::message::Message for AnalyzeSentimentRequest {
734 fn typename() -> &'static str {
735 "type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentRequest"
736 }
737}
738
739#[serde_with::serde_as]
741#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
742#[serde(default, rename_all = "camelCase")]
743#[non_exhaustive]
744pub struct AnalyzeSentimentResponse {
745 #[serde(skip_serializing_if = "std::option::Option::is_none")]
747 pub document_sentiment: std::option::Option<crate::model::Sentiment>,
748
749 #[serde(skip_serializing_if = "std::string::String::is_empty")]
753 pub language_code: std::string::String,
754
755 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
757 pub sentences: std::vec::Vec<crate::model::Sentence>,
758
759 pub language_supported: bool,
763}
764
765impl AnalyzeSentimentResponse {
766 pub fn new() -> Self {
767 std::default::Default::default()
768 }
769
770 pub fn set_document_sentiment<
772 T: std::convert::Into<std::option::Option<crate::model::Sentiment>>,
773 >(
774 mut self,
775 v: T,
776 ) -> Self {
777 self.document_sentiment = v.into();
778 self
779 }
780
781 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
783 self.language_code = v.into();
784 self
785 }
786
787 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
789 self.language_supported = v.into();
790 self
791 }
792
793 pub fn set_sentences<T, V>(mut self, v: T) -> Self
795 where
796 T: std::iter::IntoIterator<Item = V>,
797 V: std::convert::Into<crate::model::Sentence>,
798 {
799 use std::iter::Iterator;
800 self.sentences = v.into_iter().map(|i| i.into()).collect();
801 self
802 }
803}
804
805impl wkt::message::Message for AnalyzeSentimentResponse {
806 fn typename() -> &'static str {
807 "type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentResponse"
808 }
809}
810
811#[serde_with::serde_as]
813#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
814#[serde(default, rename_all = "camelCase")]
815#[non_exhaustive]
816pub struct AnalyzeEntitiesRequest {
817 #[serde(skip_serializing_if = "std::option::Option::is_none")]
819 pub document: std::option::Option<crate::model::Document>,
820
821 pub encoding_type: crate::model::EncodingType,
823}
824
825impl AnalyzeEntitiesRequest {
826 pub fn new() -> Self {
827 std::default::Default::default()
828 }
829
830 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
832 mut self,
833 v: T,
834 ) -> Self {
835 self.document = v.into();
836 self
837 }
838
839 pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
841 mut self,
842 v: T,
843 ) -> Self {
844 self.encoding_type = v.into();
845 self
846 }
847}
848
849impl wkt::message::Message for AnalyzeEntitiesRequest {
850 fn typename() -> &'static str {
851 "type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesRequest"
852 }
853}
854
855#[serde_with::serde_as]
857#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
858#[serde(default, rename_all = "camelCase")]
859#[non_exhaustive]
860pub struct AnalyzeEntitiesResponse {
861 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
863 pub entities: std::vec::Vec<crate::model::Entity>,
864
865 #[serde(skip_serializing_if = "std::string::String::is_empty")]
869 pub language_code: std::string::String,
870
871 pub language_supported: bool,
875}
876
877impl AnalyzeEntitiesResponse {
878 pub fn new() -> Self {
879 std::default::Default::default()
880 }
881
882 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
884 self.language_code = v.into();
885 self
886 }
887
888 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
890 self.language_supported = v.into();
891 self
892 }
893
894 pub fn set_entities<T, V>(mut self, v: T) -> Self
896 where
897 T: std::iter::IntoIterator<Item = V>,
898 V: std::convert::Into<crate::model::Entity>,
899 {
900 use std::iter::Iterator;
901 self.entities = v.into_iter().map(|i| i.into()).collect();
902 self
903 }
904}
905
906impl wkt::message::Message for AnalyzeEntitiesResponse {
907 fn typename() -> &'static str {
908 "type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesResponse"
909 }
910}
911
912#[serde_with::serde_as]
914#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
915#[serde(default, rename_all = "camelCase")]
916#[non_exhaustive]
917pub struct ClassifyTextRequest {
918 #[serde(skip_serializing_if = "std::option::Option::is_none")]
920 pub document: std::option::Option<crate::model::Document>,
921}
922
923impl ClassifyTextRequest {
924 pub fn new() -> Self {
925 std::default::Default::default()
926 }
927
928 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
930 mut self,
931 v: T,
932 ) -> Self {
933 self.document = v.into();
934 self
935 }
936}
937
938impl wkt::message::Message for ClassifyTextRequest {
939 fn typename() -> &'static str {
940 "type.googleapis.com/google.cloud.language.v2.ClassifyTextRequest"
941 }
942}
943
944#[serde_with::serde_as]
946#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
947#[serde(default, rename_all = "camelCase")]
948#[non_exhaustive]
949pub struct ClassifyTextResponse {
950 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
952 pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
953
954 #[serde(skip_serializing_if = "std::string::String::is_empty")]
958 pub language_code: std::string::String,
959
960 pub language_supported: bool,
964}
965
966impl ClassifyTextResponse {
967 pub fn new() -> Self {
968 std::default::Default::default()
969 }
970
971 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
973 self.language_code = v.into();
974 self
975 }
976
977 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
979 self.language_supported = v.into();
980 self
981 }
982
983 pub fn set_categories<T, V>(mut self, v: T) -> Self
985 where
986 T: std::iter::IntoIterator<Item = V>,
987 V: std::convert::Into<crate::model::ClassificationCategory>,
988 {
989 use std::iter::Iterator;
990 self.categories = v.into_iter().map(|i| i.into()).collect();
991 self
992 }
993}
994
995impl wkt::message::Message for ClassifyTextResponse {
996 fn typename() -> &'static str {
997 "type.googleapis.com/google.cloud.language.v2.ClassifyTextResponse"
998 }
999}
1000
1001#[serde_with::serde_as]
1003#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1004#[serde(default, rename_all = "camelCase")]
1005#[non_exhaustive]
1006pub struct ModerateTextRequest {
1007 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1009 pub document: std::option::Option<crate::model::Document>,
1010
1011 pub model_version: crate::model::moderate_text_request::ModelVersion,
1013}
1014
1015impl ModerateTextRequest {
1016 pub fn new() -> Self {
1017 std::default::Default::default()
1018 }
1019
1020 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
1022 mut self,
1023 v: T,
1024 ) -> Self {
1025 self.document = v.into();
1026 self
1027 }
1028
1029 pub fn set_model_version<
1031 T: std::convert::Into<crate::model::moderate_text_request::ModelVersion>,
1032 >(
1033 mut self,
1034 v: T,
1035 ) -> Self {
1036 self.model_version = v.into();
1037 self
1038 }
1039}
1040
1041impl wkt::message::Message for ModerateTextRequest {
1042 fn typename() -> &'static str {
1043 "type.googleapis.com/google.cloud.language.v2.ModerateTextRequest"
1044 }
1045}
1046
1047pub mod moderate_text_request {
1049 #[allow(unused_imports)]
1050 use super::*;
1051
1052 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1054 pub struct ModelVersion(std::borrow::Cow<'static, str>);
1055
1056 impl ModelVersion {
1057 pub const fn new(v: &'static str) -> Self {
1059 Self(std::borrow::Cow::Borrowed(v))
1060 }
1061
1062 pub fn value(&self) -> &str {
1064 &self.0
1065 }
1066 }
1067
1068 pub mod model_version {
1070 use super::ModelVersion;
1071
1072 pub const MODEL_VERSION_UNSPECIFIED: ModelVersion =
1074 ModelVersion::new("MODEL_VERSION_UNSPECIFIED");
1075
1076 pub const MODEL_VERSION_1: ModelVersion = ModelVersion::new("MODEL_VERSION_1");
1080
1081 pub const MODEL_VERSION_2: ModelVersion = ModelVersion::new("MODEL_VERSION_2");
1085 }
1086
1087 impl std::convert::From<std::string::String> for ModelVersion {
1088 fn from(value: std::string::String) -> Self {
1089 Self(std::borrow::Cow::Owned(value))
1090 }
1091 }
1092}
1093
1094#[serde_with::serde_as]
1096#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1097#[serde(default, rename_all = "camelCase")]
1098#[non_exhaustive]
1099pub struct ModerateTextResponse {
1100 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1102 pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
1103
1104 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1108 pub language_code: std::string::String,
1109
1110 pub language_supported: bool,
1114}
1115
1116impl ModerateTextResponse {
1117 pub fn new() -> Self {
1118 std::default::Default::default()
1119 }
1120
1121 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1123 self.language_code = v.into();
1124 self
1125 }
1126
1127 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1129 self.language_supported = v.into();
1130 self
1131 }
1132
1133 pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
1135 where
1136 T: std::iter::IntoIterator<Item = V>,
1137 V: std::convert::Into<crate::model::ClassificationCategory>,
1138 {
1139 use std::iter::Iterator;
1140 self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
1141 self
1142 }
1143}
1144
1145impl wkt::message::Message for ModerateTextResponse {
1146 fn typename() -> &'static str {
1147 "type.googleapis.com/google.cloud.language.v2.ModerateTextResponse"
1148 }
1149}
1150
1151#[serde_with::serde_as]
1154#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1155#[serde(default, rename_all = "camelCase")]
1156#[non_exhaustive]
1157pub struct AnnotateTextRequest {
1158 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1160 pub document: std::option::Option<crate::model::Document>,
1161
1162 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1164 pub features: std::option::Option<crate::model::annotate_text_request::Features>,
1165
1166 pub encoding_type: crate::model::EncodingType,
1168}
1169
1170impl AnnotateTextRequest {
1171 pub fn new() -> Self {
1172 std::default::Default::default()
1173 }
1174
1175 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
1177 mut self,
1178 v: T,
1179 ) -> Self {
1180 self.document = v.into();
1181 self
1182 }
1183
1184 pub fn set_features<
1186 T: std::convert::Into<std::option::Option<crate::model::annotate_text_request::Features>>,
1187 >(
1188 mut self,
1189 v: T,
1190 ) -> Self {
1191 self.features = v.into();
1192 self
1193 }
1194
1195 pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
1197 mut self,
1198 v: T,
1199 ) -> Self {
1200 self.encoding_type = v.into();
1201 self
1202 }
1203}
1204
1205impl wkt::message::Message for AnnotateTextRequest {
1206 fn typename() -> &'static str {
1207 "type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest"
1208 }
1209}
1210
1211pub mod annotate_text_request {
1213 #[allow(unused_imports)]
1214 use super::*;
1215
1216 #[serde_with::serde_as]
1219 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1220 #[serde(default, rename_all = "camelCase")]
1221 #[non_exhaustive]
1222 pub struct Features {
1223 pub extract_entities: bool,
1225
1226 pub extract_document_sentiment: bool,
1228
1229 pub classify_text: bool,
1231
1232 pub moderate_text: bool,
1234 }
1235
1236 impl Features {
1237 pub fn new() -> Self {
1238 std::default::Default::default()
1239 }
1240
1241 pub fn set_extract_entities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1243 self.extract_entities = v.into();
1244 self
1245 }
1246
1247 pub fn set_extract_document_sentiment<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1249 self.extract_document_sentiment = v.into();
1250 self
1251 }
1252
1253 pub fn set_classify_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1255 self.classify_text = v.into();
1256 self
1257 }
1258
1259 pub fn set_moderate_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1261 self.moderate_text = v.into();
1262 self
1263 }
1264 }
1265
1266 impl wkt::message::Message for Features {
1267 fn typename() -> &'static str {
1268 "type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest.Features"
1269 }
1270 }
1271}
1272
1273#[serde_with::serde_as]
1275#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1276#[serde(default, rename_all = "camelCase")]
1277#[non_exhaustive]
1278pub struct AnnotateTextResponse {
1279 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1284 pub sentences: std::vec::Vec<crate::model::Sentence>,
1285
1286 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1294 pub entities: std::vec::Vec<crate::model::Entity>,
1295
1296 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1301 pub document_sentiment: std::option::Option<crate::model::Sentiment>,
1302
1303 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1307 pub language_code: std::string::String,
1308
1309 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1311 pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
1312
1313 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1315 pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
1316
1317 pub language_supported: bool,
1321}
1322
1323impl AnnotateTextResponse {
1324 pub fn new() -> Self {
1325 std::default::Default::default()
1326 }
1327
1328 pub fn set_document_sentiment<
1330 T: std::convert::Into<std::option::Option<crate::model::Sentiment>>,
1331 >(
1332 mut self,
1333 v: T,
1334 ) -> Self {
1335 self.document_sentiment = v.into();
1336 self
1337 }
1338
1339 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1341 self.language_code = v.into();
1342 self
1343 }
1344
1345 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1347 self.language_supported = v.into();
1348 self
1349 }
1350
1351 pub fn set_sentences<T, V>(mut self, v: T) -> Self
1353 where
1354 T: std::iter::IntoIterator<Item = V>,
1355 V: std::convert::Into<crate::model::Sentence>,
1356 {
1357 use std::iter::Iterator;
1358 self.sentences = v.into_iter().map(|i| i.into()).collect();
1359 self
1360 }
1361
1362 pub fn set_entities<T, V>(mut self, v: T) -> Self
1364 where
1365 T: std::iter::IntoIterator<Item = V>,
1366 V: std::convert::Into<crate::model::Entity>,
1367 {
1368 use std::iter::Iterator;
1369 self.entities = v.into_iter().map(|i| i.into()).collect();
1370 self
1371 }
1372
1373 pub fn set_categories<T, V>(mut self, v: T) -> Self
1375 where
1376 T: std::iter::IntoIterator<Item = V>,
1377 V: std::convert::Into<crate::model::ClassificationCategory>,
1378 {
1379 use std::iter::Iterator;
1380 self.categories = v.into_iter().map(|i| i.into()).collect();
1381 self
1382 }
1383
1384 pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
1386 where
1387 T: std::iter::IntoIterator<Item = V>,
1388 V: std::convert::Into<crate::model::ClassificationCategory>,
1389 {
1390 use std::iter::Iterator;
1391 self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
1392 self
1393 }
1394}
1395
1396impl wkt::message::Message for AnnotateTextResponse {
1397 fn typename() -> &'static str {
1398 "type.googleapis.com/google.cloud.language.v2.AnnotateTextResponse"
1399 }
1400}
1401
1402#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1408pub struct EncodingType(std::borrow::Cow<'static, str>);
1409
1410impl EncodingType {
1411 pub const fn new(v: &'static str) -> Self {
1413 Self(std::borrow::Cow::Borrowed(v))
1414 }
1415
1416 pub fn value(&self) -> &str {
1418 &self.0
1419 }
1420}
1421
1422pub mod encoding_type {
1424 use super::EncodingType;
1425
1426 pub const NONE: EncodingType = EncodingType::new("NONE");
1429
1430 pub const UTF8: EncodingType = EncodingType::new("UTF8");
1434
1435 pub const UTF16: EncodingType = EncodingType::new("UTF16");
1439
1440 pub const UTF32: EncodingType = EncodingType::new("UTF32");
1444}
1445
1446impl std::convert::From<std::string::String> for EncodingType {
1447 fn from(value: std::string::String) -> Self {
1448 Self(std::borrow::Cow::Owned(value))
1449 }
1450}