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 gaxi;
24extern crate lazy_static;
25extern crate reqwest;
26extern crate serde;
27extern crate serde_json;
28extern crate serde_with;
29extern crate std;
30extern crate tracing;
31extern crate wkt;
32
33#[serde_with::serde_as]
35#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
36#[serde(default, rename_all = "camelCase")]
37#[non_exhaustive]
38pub struct Document {
39 #[serde(rename = "type")]
42 pub r#type: crate::model::document::Type,
43
44 #[serde(skip_serializing_if = "std::string::String::is_empty")]
53 pub language_code: std::string::String,
54
55 #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
58 pub source: std::option::Option<crate::model::document::Source>,
59
60 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
61 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
62}
63
64impl Document {
65 pub fn new() -> Self {
66 std::default::Default::default()
67 }
68
69 pub fn set_type<T: std::convert::Into<crate::model::document::Type>>(mut self, v: T) -> Self {
71 self.r#type = v.into();
72 self
73 }
74
75 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
77 self.language_code = v.into();
78 self
79 }
80
81 pub fn set_source<
86 T: std::convert::Into<std::option::Option<crate::model::document::Source>>,
87 >(
88 mut self,
89 v: T,
90 ) -> Self {
91 self.source = v.into();
92 self
93 }
94
95 pub fn content(&self) -> std::option::Option<&std::string::String> {
99 #[allow(unreachable_patterns)]
100 self.source.as_ref().and_then(|v| match v {
101 crate::model::document::Source::Content(v) => std::option::Option::Some(v),
102 _ => std::option::Option::None,
103 })
104 }
105
106 pub fn gcs_content_uri(&self) -> std::option::Option<&std::string::String> {
110 #[allow(unreachable_patterns)]
111 self.source.as_ref().and_then(|v| match v {
112 crate::model::document::Source::GcsContentUri(v) => std::option::Option::Some(v),
113 _ => std::option::Option::None,
114 })
115 }
116
117 pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
123 self.source = std::option::Option::Some(crate::model::document::Source::Content(v.into()));
124 self
125 }
126
127 pub fn set_gcs_content_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
133 self.source =
134 std::option::Option::Some(crate::model::document::Source::GcsContentUri(v.into()));
135 self
136 }
137}
138
139impl wkt::message::Message for Document {
140 fn typename() -> &'static str {
141 "type.googleapis.com/google.cloud.language.v2.Document"
142 }
143}
144
145pub mod document {
147 #[allow(unused_imports)]
148 use super::*;
149
150 #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
152 pub struct Type(i32);
153
154 impl Type {
155 pub const TYPE_UNSPECIFIED: Type = Type::new(0);
157
158 pub const PLAIN_TEXT: Type = Type::new(1);
160
161 pub const HTML: Type = Type::new(2);
163
164 pub(crate) const fn new(value: i32) -> Self {
166 Self(value)
167 }
168
169 pub fn value(&self) -> i32 {
171 self.0
172 }
173
174 pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
176 match self.0 {
177 0 => std::borrow::Cow::Borrowed("TYPE_UNSPECIFIED"),
178 1 => std::borrow::Cow::Borrowed("PLAIN_TEXT"),
179 2 => std::borrow::Cow::Borrowed("HTML"),
180 _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
181 }
182 }
183
184 pub fn from_str_name(name: &str) -> std::option::Option<Self> {
186 match name {
187 "TYPE_UNSPECIFIED" => std::option::Option::Some(Self::TYPE_UNSPECIFIED),
188 "PLAIN_TEXT" => std::option::Option::Some(Self::PLAIN_TEXT),
189 "HTML" => std::option::Option::Some(Self::HTML),
190 _ => std::option::Option::None,
191 }
192 }
193 }
194
195 impl std::convert::From<i32> for Type {
196 fn from(value: i32) -> Self {
197 Self::new(value)
198 }
199 }
200
201 impl std::default::Default for Type {
202 fn default() -> Self {
203 Self::new(0)
204 }
205 }
206
207 #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
210 #[serde(rename_all = "camelCase")]
211 #[non_exhaustive]
212 pub enum Source {
213 Content(std::string::String),
216 GcsContentUri(std::string::String),
221 }
222}
223
224#[serde_with::serde_as]
226#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
227#[serde(default, rename_all = "camelCase")]
228#[non_exhaustive]
229pub struct Sentence {
230 #[serde(skip_serializing_if = "std::option::Option::is_none")]
232 pub text: std::option::Option<crate::model::TextSpan>,
233
234 #[serde(skip_serializing_if = "std::option::Option::is_none")]
240 pub sentiment: std::option::Option<crate::model::Sentiment>,
241
242 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
243 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
244}
245
246impl Sentence {
247 pub fn new() -> Self {
248 std::default::Default::default()
249 }
250
251 pub fn set_text<T: std::convert::Into<std::option::Option<crate::model::TextSpan>>>(
253 mut self,
254 v: T,
255 ) -> Self {
256 self.text = v.into();
257 self
258 }
259
260 pub fn set_sentiment<T: std::convert::Into<std::option::Option<crate::model::Sentiment>>>(
262 mut self,
263 v: T,
264 ) -> Self {
265 self.sentiment = v.into();
266 self
267 }
268}
269
270impl wkt::message::Message for Sentence {
271 fn typename() -> &'static str {
272 "type.googleapis.com/google.cloud.language.v2.Sentence"
273 }
274}
275
276#[serde_with::serde_as]
280#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
281#[serde(default, rename_all = "camelCase")]
282#[non_exhaustive]
283pub struct Entity {
284 #[serde(skip_serializing_if = "std::string::String::is_empty")]
286 pub name: std::string::String,
287
288 #[serde(rename = "type")]
290 pub r#type: crate::model::entity::Type,
291
292 #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
297 pub metadata: std::collections::HashMap<std::string::String, std::string::String>,
298
299 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
302 pub mentions: std::vec::Vec<crate::model::EntityMention>,
303
304 #[serde(skip_serializing_if = "std::option::Option::is_none")]
309 pub sentiment: std::option::Option<crate::model::Sentiment>,
310
311 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
312 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
313}
314
315impl Entity {
316 pub fn new() -> Self {
317 std::default::Default::default()
318 }
319
320 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
322 self.name = v.into();
323 self
324 }
325
326 pub fn set_type<T: std::convert::Into<crate::model::entity::Type>>(mut self, v: T) -> Self {
328 self.r#type = v.into();
329 self
330 }
331
332 pub fn set_sentiment<T: std::convert::Into<std::option::Option<crate::model::Sentiment>>>(
334 mut self,
335 v: T,
336 ) -> Self {
337 self.sentiment = v.into();
338 self
339 }
340
341 pub fn set_mentions<T, V>(mut self, v: T) -> Self
343 where
344 T: std::iter::IntoIterator<Item = V>,
345 V: std::convert::Into<crate::model::EntityMention>,
346 {
347 use std::iter::Iterator;
348 self.mentions = v.into_iter().map(|i| i.into()).collect();
349 self
350 }
351
352 pub fn set_metadata<T, K, V>(mut self, v: T) -> Self
354 where
355 T: std::iter::IntoIterator<Item = (K, V)>,
356 K: std::convert::Into<std::string::String>,
357 V: std::convert::Into<std::string::String>,
358 {
359 use std::iter::Iterator;
360 self.metadata = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
361 self
362 }
363}
364
365impl wkt::message::Message for Entity {
366 fn typename() -> &'static str {
367 "type.googleapis.com/google.cloud.language.v2.Entity"
368 }
369}
370
371pub mod entity {
373 #[allow(unused_imports)]
374 use super::*;
375
376 #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
380 pub struct Type(i32);
381
382 impl Type {
383 pub const UNKNOWN: Type = Type::new(0);
385
386 pub const PERSON: Type = Type::new(1);
388
389 pub const LOCATION: Type = Type::new(2);
391
392 pub const ORGANIZATION: Type = Type::new(3);
394
395 pub const EVENT: Type = Type::new(4);
397
398 pub const WORK_OF_ART: Type = Type::new(5);
400
401 pub const CONSUMER_GOOD: Type = Type::new(6);
403
404 pub const OTHER: Type = Type::new(7);
406
407 pub const PHONE_NUMBER: Type = Type::new(9);
419
420 pub const ADDRESS: Type = Type::new(10);
436
437 pub const DATE: Type = Type::new(11);
445
446 pub const NUMBER: Type = Type::new(12);
450
451 pub const PRICE: Type = Type::new(13);
455
456 pub(crate) const fn new(value: i32) -> Self {
458 Self(value)
459 }
460
461 pub fn value(&self) -> i32 {
463 self.0
464 }
465
466 pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
468 match self.0 {
469 0 => std::borrow::Cow::Borrowed("UNKNOWN"),
470 1 => std::borrow::Cow::Borrowed("PERSON"),
471 2 => std::borrow::Cow::Borrowed("LOCATION"),
472 3 => std::borrow::Cow::Borrowed("ORGANIZATION"),
473 4 => std::borrow::Cow::Borrowed("EVENT"),
474 5 => std::borrow::Cow::Borrowed("WORK_OF_ART"),
475 6 => std::borrow::Cow::Borrowed("CONSUMER_GOOD"),
476 7 => std::borrow::Cow::Borrowed("OTHER"),
477 9 => std::borrow::Cow::Borrowed("PHONE_NUMBER"),
478 10 => std::borrow::Cow::Borrowed("ADDRESS"),
479 11 => std::borrow::Cow::Borrowed("DATE"),
480 12 => std::borrow::Cow::Borrowed("NUMBER"),
481 13 => std::borrow::Cow::Borrowed("PRICE"),
482 _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
483 }
484 }
485
486 pub fn from_str_name(name: &str) -> std::option::Option<Self> {
488 match name {
489 "UNKNOWN" => std::option::Option::Some(Self::UNKNOWN),
490 "PERSON" => std::option::Option::Some(Self::PERSON),
491 "LOCATION" => std::option::Option::Some(Self::LOCATION),
492 "ORGANIZATION" => std::option::Option::Some(Self::ORGANIZATION),
493 "EVENT" => std::option::Option::Some(Self::EVENT),
494 "WORK_OF_ART" => std::option::Option::Some(Self::WORK_OF_ART),
495 "CONSUMER_GOOD" => std::option::Option::Some(Self::CONSUMER_GOOD),
496 "OTHER" => std::option::Option::Some(Self::OTHER),
497 "PHONE_NUMBER" => std::option::Option::Some(Self::PHONE_NUMBER),
498 "ADDRESS" => std::option::Option::Some(Self::ADDRESS),
499 "DATE" => std::option::Option::Some(Self::DATE),
500 "NUMBER" => std::option::Option::Some(Self::NUMBER),
501 "PRICE" => std::option::Option::Some(Self::PRICE),
502 _ => std::option::Option::None,
503 }
504 }
505 }
506
507 impl std::convert::From<i32> for Type {
508 fn from(value: i32) -> Self {
509 Self::new(value)
510 }
511 }
512
513 impl std::default::Default for Type {
514 fn default() -> Self {
515 Self::new(0)
516 }
517 }
518}
519
520#[serde_with::serde_as]
523#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
524#[serde(default, rename_all = "camelCase")]
525#[non_exhaustive]
526pub struct Sentiment {
527 pub magnitude: f32,
531
532 pub score: f32,
535
536 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
537 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
538}
539
540impl Sentiment {
541 pub fn new() -> Self {
542 std::default::Default::default()
543 }
544
545 pub fn set_magnitude<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
547 self.magnitude = v.into();
548 self
549 }
550
551 pub fn set_score<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
553 self.score = v.into();
554 self
555 }
556}
557
558impl wkt::message::Message for Sentiment {
559 fn typename() -> &'static str {
560 "type.googleapis.com/google.cloud.language.v2.Sentiment"
561 }
562}
563
564#[serde_with::serde_as]
567#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
568#[serde(default, rename_all = "camelCase")]
569#[non_exhaustive]
570pub struct EntityMention {
571 #[serde(skip_serializing_if = "std::option::Option::is_none")]
573 pub text: std::option::Option<crate::model::TextSpan>,
574
575 #[serde(rename = "type")]
577 pub r#type: crate::model::entity_mention::Type,
578
579 #[serde(skip_serializing_if = "std::option::Option::is_none")]
584 pub sentiment: std::option::Option<crate::model::Sentiment>,
585
586 pub probability: f32,
591
592 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
593 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
594}
595
596impl EntityMention {
597 pub fn new() -> Self {
598 std::default::Default::default()
599 }
600
601 pub fn set_text<T: std::convert::Into<std::option::Option<crate::model::TextSpan>>>(
603 mut self,
604 v: T,
605 ) -> Self {
606 self.text = v.into();
607 self
608 }
609
610 pub fn set_type<T: std::convert::Into<crate::model::entity_mention::Type>>(
612 mut self,
613 v: T,
614 ) -> Self {
615 self.r#type = v.into();
616 self
617 }
618
619 pub fn set_sentiment<T: std::convert::Into<std::option::Option<crate::model::Sentiment>>>(
621 mut self,
622 v: T,
623 ) -> Self {
624 self.sentiment = v.into();
625 self
626 }
627
628 pub fn set_probability<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
630 self.probability = v.into();
631 self
632 }
633}
634
635impl wkt::message::Message for EntityMention {
636 fn typename() -> &'static str {
637 "type.googleapis.com/google.cloud.language.v2.EntityMention"
638 }
639}
640
641pub mod entity_mention {
643 #[allow(unused_imports)]
644 use super::*;
645
646 #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
648 pub struct Type(i32);
649
650 impl Type {
651 pub const TYPE_UNKNOWN: Type = Type::new(0);
653
654 pub const PROPER: Type = Type::new(1);
656
657 pub const COMMON: Type = Type::new(2);
659
660 pub(crate) const fn new(value: i32) -> Self {
662 Self(value)
663 }
664
665 pub fn value(&self) -> i32 {
667 self.0
668 }
669
670 pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
672 match self.0 {
673 0 => std::borrow::Cow::Borrowed("TYPE_UNKNOWN"),
674 1 => std::borrow::Cow::Borrowed("PROPER"),
675 2 => std::borrow::Cow::Borrowed("COMMON"),
676 _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
677 }
678 }
679
680 pub fn from_str_name(name: &str) -> std::option::Option<Self> {
682 match name {
683 "TYPE_UNKNOWN" => std::option::Option::Some(Self::TYPE_UNKNOWN),
684 "PROPER" => std::option::Option::Some(Self::PROPER),
685 "COMMON" => std::option::Option::Some(Self::COMMON),
686 _ => std::option::Option::None,
687 }
688 }
689 }
690
691 impl std::convert::From<i32> for Type {
692 fn from(value: i32) -> Self {
693 Self::new(value)
694 }
695 }
696
697 impl std::default::Default for Type {
698 fn default() -> Self {
699 Self::new(0)
700 }
701 }
702}
703
704#[serde_with::serde_as]
706#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
707#[serde(default, rename_all = "camelCase")]
708#[non_exhaustive]
709pub struct TextSpan {
710 #[serde(skip_serializing_if = "std::string::String::is_empty")]
712 pub content: std::string::String,
713
714 pub begin_offset: i32,
721
722 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
723 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
724}
725
726impl TextSpan {
727 pub fn new() -> Self {
728 std::default::Default::default()
729 }
730
731 pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
733 self.content = v.into();
734 self
735 }
736
737 pub fn set_begin_offset<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
739 self.begin_offset = v.into();
740 self
741 }
742}
743
744impl wkt::message::Message for TextSpan {
745 fn typename() -> &'static str {
746 "type.googleapis.com/google.cloud.language.v2.TextSpan"
747 }
748}
749
750#[serde_with::serde_as]
752#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
753#[serde(default, rename_all = "camelCase")]
754#[non_exhaustive]
755pub struct ClassificationCategory {
756 #[serde(skip_serializing_if = "std::string::String::is_empty")]
758 pub name: std::string::String,
759
760 pub confidence: f32,
763
764 pub severity: f32,
768
769 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
770 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
771}
772
773impl ClassificationCategory {
774 pub fn new() -> Self {
775 std::default::Default::default()
776 }
777
778 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
780 self.name = v.into();
781 self
782 }
783
784 pub fn set_confidence<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
786 self.confidence = v.into();
787 self
788 }
789
790 pub fn set_severity<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
792 self.severity = v.into();
793 self
794 }
795}
796
797impl wkt::message::Message for ClassificationCategory {
798 fn typename() -> &'static str {
799 "type.googleapis.com/google.cloud.language.v2.ClassificationCategory"
800 }
801}
802
803#[serde_with::serde_as]
805#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
806#[serde(default, rename_all = "camelCase")]
807#[non_exhaustive]
808pub struct AnalyzeSentimentRequest {
809 #[serde(skip_serializing_if = "std::option::Option::is_none")]
811 pub document: std::option::Option<crate::model::Document>,
812
813 pub encoding_type: crate::model::EncodingType,
815
816 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
817 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
818}
819
820impl AnalyzeSentimentRequest {
821 pub fn new() -> Self {
822 std::default::Default::default()
823 }
824
825 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
827 mut self,
828 v: T,
829 ) -> Self {
830 self.document = v.into();
831 self
832 }
833
834 pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
836 mut self,
837 v: T,
838 ) -> Self {
839 self.encoding_type = v.into();
840 self
841 }
842}
843
844impl wkt::message::Message for AnalyzeSentimentRequest {
845 fn typename() -> &'static str {
846 "type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentRequest"
847 }
848}
849
850#[serde_with::serde_as]
852#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
853#[serde(default, rename_all = "camelCase")]
854#[non_exhaustive]
855pub struct AnalyzeSentimentResponse {
856 #[serde(skip_serializing_if = "std::option::Option::is_none")]
858 pub document_sentiment: std::option::Option<crate::model::Sentiment>,
859
860 #[serde(skip_serializing_if = "std::string::String::is_empty")]
864 pub language_code: std::string::String,
865
866 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
868 pub sentences: std::vec::Vec<crate::model::Sentence>,
869
870 pub language_supported: bool,
874
875 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
876 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
877}
878
879impl AnalyzeSentimentResponse {
880 pub fn new() -> Self {
881 std::default::Default::default()
882 }
883
884 pub fn set_document_sentiment<
886 T: std::convert::Into<std::option::Option<crate::model::Sentiment>>,
887 >(
888 mut self,
889 v: T,
890 ) -> Self {
891 self.document_sentiment = v.into();
892 self
893 }
894
895 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
897 self.language_code = v.into();
898 self
899 }
900
901 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
903 self.language_supported = v.into();
904 self
905 }
906
907 pub fn set_sentences<T, V>(mut self, v: T) -> Self
909 where
910 T: std::iter::IntoIterator<Item = V>,
911 V: std::convert::Into<crate::model::Sentence>,
912 {
913 use std::iter::Iterator;
914 self.sentences = v.into_iter().map(|i| i.into()).collect();
915 self
916 }
917}
918
919impl wkt::message::Message for AnalyzeSentimentResponse {
920 fn typename() -> &'static str {
921 "type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentResponse"
922 }
923}
924
925#[serde_with::serde_as]
927#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
928#[serde(default, rename_all = "camelCase")]
929#[non_exhaustive]
930pub struct AnalyzeEntitiesRequest {
931 #[serde(skip_serializing_if = "std::option::Option::is_none")]
933 pub document: std::option::Option<crate::model::Document>,
934
935 pub encoding_type: crate::model::EncodingType,
937
938 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
939 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
940}
941
942impl AnalyzeEntitiesRequest {
943 pub fn new() -> Self {
944 std::default::Default::default()
945 }
946
947 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
949 mut self,
950 v: T,
951 ) -> Self {
952 self.document = v.into();
953 self
954 }
955
956 pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
958 mut self,
959 v: T,
960 ) -> Self {
961 self.encoding_type = v.into();
962 self
963 }
964}
965
966impl wkt::message::Message for AnalyzeEntitiesRequest {
967 fn typename() -> &'static str {
968 "type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesRequest"
969 }
970}
971
972#[serde_with::serde_as]
974#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
975#[serde(default, rename_all = "camelCase")]
976#[non_exhaustive]
977pub struct AnalyzeEntitiesResponse {
978 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
980 pub entities: std::vec::Vec<crate::model::Entity>,
981
982 #[serde(skip_serializing_if = "std::string::String::is_empty")]
986 pub language_code: std::string::String,
987
988 pub language_supported: bool,
992
993 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
994 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
995}
996
997impl AnalyzeEntitiesResponse {
998 pub fn new() -> Self {
999 std::default::Default::default()
1000 }
1001
1002 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1004 self.language_code = v.into();
1005 self
1006 }
1007
1008 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1010 self.language_supported = v.into();
1011 self
1012 }
1013
1014 pub fn set_entities<T, V>(mut self, v: T) -> Self
1016 where
1017 T: std::iter::IntoIterator<Item = V>,
1018 V: std::convert::Into<crate::model::Entity>,
1019 {
1020 use std::iter::Iterator;
1021 self.entities = v.into_iter().map(|i| i.into()).collect();
1022 self
1023 }
1024}
1025
1026impl wkt::message::Message for AnalyzeEntitiesResponse {
1027 fn typename() -> &'static str {
1028 "type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesResponse"
1029 }
1030}
1031
1032#[serde_with::serde_as]
1034#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1035#[serde(default, rename_all = "camelCase")]
1036#[non_exhaustive]
1037pub struct ClassifyTextRequest {
1038 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1040 pub document: std::option::Option<crate::model::Document>,
1041
1042 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1043 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1044}
1045
1046impl ClassifyTextRequest {
1047 pub fn new() -> Self {
1048 std::default::Default::default()
1049 }
1050
1051 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
1053 mut self,
1054 v: T,
1055 ) -> Self {
1056 self.document = v.into();
1057 self
1058 }
1059}
1060
1061impl wkt::message::Message for ClassifyTextRequest {
1062 fn typename() -> &'static str {
1063 "type.googleapis.com/google.cloud.language.v2.ClassifyTextRequest"
1064 }
1065}
1066
1067#[serde_with::serde_as]
1069#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1070#[serde(default, rename_all = "camelCase")]
1071#[non_exhaustive]
1072pub struct ClassifyTextResponse {
1073 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1075 pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
1076
1077 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1081 pub language_code: std::string::String,
1082
1083 pub language_supported: bool,
1087
1088 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1089 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1090}
1091
1092impl ClassifyTextResponse {
1093 pub fn new() -> Self {
1094 std::default::Default::default()
1095 }
1096
1097 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1099 self.language_code = v.into();
1100 self
1101 }
1102
1103 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1105 self.language_supported = v.into();
1106 self
1107 }
1108
1109 pub fn set_categories<T, V>(mut self, v: T) -> Self
1111 where
1112 T: std::iter::IntoIterator<Item = V>,
1113 V: std::convert::Into<crate::model::ClassificationCategory>,
1114 {
1115 use std::iter::Iterator;
1116 self.categories = v.into_iter().map(|i| i.into()).collect();
1117 self
1118 }
1119}
1120
1121impl wkt::message::Message for ClassifyTextResponse {
1122 fn typename() -> &'static str {
1123 "type.googleapis.com/google.cloud.language.v2.ClassifyTextResponse"
1124 }
1125}
1126
1127#[serde_with::serde_as]
1129#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1130#[serde(default, rename_all = "camelCase")]
1131#[non_exhaustive]
1132pub struct ModerateTextRequest {
1133 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1135 pub document: std::option::Option<crate::model::Document>,
1136
1137 pub model_version: crate::model::moderate_text_request::ModelVersion,
1139
1140 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1141 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1142}
1143
1144impl ModerateTextRequest {
1145 pub fn new() -> Self {
1146 std::default::Default::default()
1147 }
1148
1149 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
1151 mut self,
1152 v: T,
1153 ) -> Self {
1154 self.document = v.into();
1155 self
1156 }
1157
1158 pub fn set_model_version<
1160 T: std::convert::Into<crate::model::moderate_text_request::ModelVersion>,
1161 >(
1162 mut self,
1163 v: T,
1164 ) -> Self {
1165 self.model_version = v.into();
1166 self
1167 }
1168}
1169
1170impl wkt::message::Message for ModerateTextRequest {
1171 fn typename() -> &'static str {
1172 "type.googleapis.com/google.cloud.language.v2.ModerateTextRequest"
1173 }
1174}
1175
1176pub mod moderate_text_request {
1178 #[allow(unused_imports)]
1179 use super::*;
1180
1181 #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
1183 pub struct ModelVersion(i32);
1184
1185 impl ModelVersion {
1186 pub const MODEL_VERSION_UNSPECIFIED: ModelVersion = ModelVersion::new(0);
1188
1189 pub const MODEL_VERSION_1: ModelVersion = ModelVersion::new(1);
1193
1194 pub const MODEL_VERSION_2: ModelVersion = ModelVersion::new(2);
1198
1199 pub(crate) const fn new(value: i32) -> Self {
1201 Self(value)
1202 }
1203
1204 pub fn value(&self) -> i32 {
1206 self.0
1207 }
1208
1209 pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
1211 match self.0 {
1212 0 => std::borrow::Cow::Borrowed("MODEL_VERSION_UNSPECIFIED"),
1213 1 => std::borrow::Cow::Borrowed("MODEL_VERSION_1"),
1214 2 => std::borrow::Cow::Borrowed("MODEL_VERSION_2"),
1215 _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
1216 }
1217 }
1218
1219 pub fn from_str_name(name: &str) -> std::option::Option<Self> {
1221 match name {
1222 "MODEL_VERSION_UNSPECIFIED" => {
1223 std::option::Option::Some(Self::MODEL_VERSION_UNSPECIFIED)
1224 }
1225 "MODEL_VERSION_1" => std::option::Option::Some(Self::MODEL_VERSION_1),
1226 "MODEL_VERSION_2" => std::option::Option::Some(Self::MODEL_VERSION_2),
1227 _ => std::option::Option::None,
1228 }
1229 }
1230 }
1231
1232 impl std::convert::From<i32> for ModelVersion {
1233 fn from(value: i32) -> Self {
1234 Self::new(value)
1235 }
1236 }
1237
1238 impl std::default::Default for ModelVersion {
1239 fn default() -> Self {
1240 Self::new(0)
1241 }
1242 }
1243}
1244
1245#[serde_with::serde_as]
1247#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1248#[serde(default, rename_all = "camelCase")]
1249#[non_exhaustive]
1250pub struct ModerateTextResponse {
1251 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1253 pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
1254
1255 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1259 pub language_code: std::string::String,
1260
1261 pub language_supported: bool,
1265
1266 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1267 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1268}
1269
1270impl ModerateTextResponse {
1271 pub fn new() -> Self {
1272 std::default::Default::default()
1273 }
1274
1275 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1277 self.language_code = v.into();
1278 self
1279 }
1280
1281 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1283 self.language_supported = v.into();
1284 self
1285 }
1286
1287 pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
1289 where
1290 T: std::iter::IntoIterator<Item = V>,
1291 V: std::convert::Into<crate::model::ClassificationCategory>,
1292 {
1293 use std::iter::Iterator;
1294 self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
1295 self
1296 }
1297}
1298
1299impl wkt::message::Message for ModerateTextResponse {
1300 fn typename() -> &'static str {
1301 "type.googleapis.com/google.cloud.language.v2.ModerateTextResponse"
1302 }
1303}
1304
1305#[serde_with::serde_as]
1308#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1309#[serde(default, rename_all = "camelCase")]
1310#[non_exhaustive]
1311pub struct AnnotateTextRequest {
1312 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1314 pub document: std::option::Option<crate::model::Document>,
1315
1316 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1318 pub features: std::option::Option<crate::model::annotate_text_request::Features>,
1319
1320 pub encoding_type: crate::model::EncodingType,
1322
1323 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1324 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1325}
1326
1327impl AnnotateTextRequest {
1328 pub fn new() -> Self {
1329 std::default::Default::default()
1330 }
1331
1332 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
1334 mut self,
1335 v: T,
1336 ) -> Self {
1337 self.document = v.into();
1338 self
1339 }
1340
1341 pub fn set_features<
1343 T: std::convert::Into<std::option::Option<crate::model::annotate_text_request::Features>>,
1344 >(
1345 mut self,
1346 v: T,
1347 ) -> Self {
1348 self.features = v.into();
1349 self
1350 }
1351
1352 pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
1354 mut self,
1355 v: T,
1356 ) -> Self {
1357 self.encoding_type = v.into();
1358 self
1359 }
1360}
1361
1362impl wkt::message::Message for AnnotateTextRequest {
1363 fn typename() -> &'static str {
1364 "type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest"
1365 }
1366}
1367
1368pub mod annotate_text_request {
1370 #[allow(unused_imports)]
1371 use super::*;
1372
1373 #[serde_with::serde_as]
1376 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1377 #[serde(default, rename_all = "camelCase")]
1378 #[non_exhaustive]
1379 pub struct Features {
1380 pub extract_entities: bool,
1382
1383 pub extract_document_sentiment: bool,
1385
1386 pub classify_text: bool,
1388
1389 pub moderate_text: bool,
1391
1392 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1393 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1394 }
1395
1396 impl Features {
1397 pub fn new() -> Self {
1398 std::default::Default::default()
1399 }
1400
1401 pub fn set_extract_entities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1403 self.extract_entities = v.into();
1404 self
1405 }
1406
1407 pub fn set_extract_document_sentiment<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1409 self.extract_document_sentiment = v.into();
1410 self
1411 }
1412
1413 pub fn set_classify_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1415 self.classify_text = v.into();
1416 self
1417 }
1418
1419 pub fn set_moderate_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1421 self.moderate_text = v.into();
1422 self
1423 }
1424 }
1425
1426 impl wkt::message::Message for Features {
1427 fn typename() -> &'static str {
1428 "type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest.Features"
1429 }
1430 }
1431}
1432
1433#[serde_with::serde_as]
1435#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1436#[serde(default, rename_all = "camelCase")]
1437#[non_exhaustive]
1438pub struct AnnotateTextResponse {
1439 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1444 pub sentences: std::vec::Vec<crate::model::Sentence>,
1445
1446 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1454 pub entities: std::vec::Vec<crate::model::Entity>,
1455
1456 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1461 pub document_sentiment: std::option::Option<crate::model::Sentiment>,
1462
1463 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1467 pub language_code: std::string::String,
1468
1469 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1471 pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
1472
1473 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1475 pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
1476
1477 pub language_supported: bool,
1481
1482 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1483 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1484}
1485
1486impl AnnotateTextResponse {
1487 pub fn new() -> Self {
1488 std::default::Default::default()
1489 }
1490
1491 pub fn set_document_sentiment<
1493 T: std::convert::Into<std::option::Option<crate::model::Sentiment>>,
1494 >(
1495 mut self,
1496 v: T,
1497 ) -> Self {
1498 self.document_sentiment = v.into();
1499 self
1500 }
1501
1502 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1504 self.language_code = v.into();
1505 self
1506 }
1507
1508 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1510 self.language_supported = v.into();
1511 self
1512 }
1513
1514 pub fn set_sentences<T, V>(mut self, v: T) -> Self
1516 where
1517 T: std::iter::IntoIterator<Item = V>,
1518 V: std::convert::Into<crate::model::Sentence>,
1519 {
1520 use std::iter::Iterator;
1521 self.sentences = v.into_iter().map(|i| i.into()).collect();
1522 self
1523 }
1524
1525 pub fn set_entities<T, V>(mut self, v: T) -> Self
1527 where
1528 T: std::iter::IntoIterator<Item = V>,
1529 V: std::convert::Into<crate::model::Entity>,
1530 {
1531 use std::iter::Iterator;
1532 self.entities = v.into_iter().map(|i| i.into()).collect();
1533 self
1534 }
1535
1536 pub fn set_categories<T, V>(mut self, v: T) -> Self
1538 where
1539 T: std::iter::IntoIterator<Item = V>,
1540 V: std::convert::Into<crate::model::ClassificationCategory>,
1541 {
1542 use std::iter::Iterator;
1543 self.categories = v.into_iter().map(|i| i.into()).collect();
1544 self
1545 }
1546
1547 pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
1549 where
1550 T: std::iter::IntoIterator<Item = V>,
1551 V: std::convert::Into<crate::model::ClassificationCategory>,
1552 {
1553 use std::iter::Iterator;
1554 self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
1555 self
1556 }
1557}
1558
1559impl wkt::message::Message for AnnotateTextResponse {
1560 fn typename() -> &'static str {
1561 "type.googleapis.com/google.cloud.language.v2.AnnotateTextResponse"
1562 }
1563}
1564
1565#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
1571pub struct EncodingType(i32);
1572
1573impl EncodingType {
1574 pub const NONE: EncodingType = EncodingType::new(0);
1577
1578 pub const UTF8: EncodingType = EncodingType::new(1);
1582
1583 pub const UTF16: EncodingType = EncodingType::new(2);
1587
1588 pub const UTF32: EncodingType = EncodingType::new(3);
1592
1593 pub(crate) const fn new(value: i32) -> Self {
1595 Self(value)
1596 }
1597
1598 pub fn value(&self) -> i32 {
1600 self.0
1601 }
1602
1603 pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
1605 match self.0 {
1606 0 => std::borrow::Cow::Borrowed("NONE"),
1607 1 => std::borrow::Cow::Borrowed("UTF8"),
1608 2 => std::borrow::Cow::Borrowed("UTF16"),
1609 3 => std::borrow::Cow::Borrowed("UTF32"),
1610 _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
1611 }
1612 }
1613
1614 pub fn from_str_name(name: &str) -> std::option::Option<Self> {
1616 match name {
1617 "NONE" => std::option::Option::Some(Self::NONE),
1618 "UTF8" => std::option::Option::Some(Self::UTF8),
1619 "UTF16" => std::option::Option::Some(Self::UTF16),
1620 "UTF32" => std::option::Option::Some(Self::UTF32),
1621 _ => std::option::Option::None,
1622 }
1623 }
1624}
1625
1626impl std::convert::From<i32> for EncodingType {
1627 fn from(value: i32) -> Self {
1628 Self::new(value)
1629 }
1630}
1631
1632impl std::default::Default for EncodingType {
1633 fn default() -> Self {
1634 Self::new(0)
1635 }
1636}