google_cloud_language_v2/
builders.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17pub mod language_service {
18    use crate::Result;
19    use std::sync::Arc;
20
21    /// Common implementation for [crate::client::LanguageService] request builders.
22    #[derive(Clone, Debug)]
23    pub struct RequestBuilder<R: std::default::Default> {
24        stub: Arc<dyn crate::stubs::dynamic::LanguageService>,
25        request: R,
26        options: gax::options::RequestOptions,
27    }
28
29    impl<R> RequestBuilder<R>
30    where
31        R: std::default::Default,
32    {
33        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
34            Self {
35                stub,
36                request: R::default(),
37                options: gax::options::RequestOptions::default(),
38            }
39        }
40    }
41
42    /// The request builder for a LanguageService::analyze_sentiment call.
43    #[derive(Clone, Debug)]
44    pub struct AnalyzeSentiment(RequestBuilder<crate::model::AnalyzeSentimentRequest>);
45
46    impl AnalyzeSentiment {
47        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
48            Self(RequestBuilder::new(stub))
49        }
50
51        /// Sets the full request, replacing any prior values.
52        pub fn with_request<V: Into<crate::model::AnalyzeSentimentRequest>>(
53            mut self,
54            v: V,
55        ) -> Self {
56            self.0.request = v.into();
57            self
58        }
59
60        /// Sets all the options, replacing any prior values.
61        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
62            self.0.options = v.into();
63            self
64        }
65
66        /// Sends the request.
67        pub async fn send(self) -> Result<crate::model::AnalyzeSentimentResponse> {
68            (*self.0.stub)
69                .analyze_sentiment(self.0.request, self.0.options)
70                .await
71        }
72
73        /// Sets the value of [document][crate::model::AnalyzeSentimentRequest::document].
74        pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
75            mut self,
76            v: T,
77        ) -> Self {
78            self.0.request.document = v.into();
79            self
80        }
81
82        /// Sets the value of [encoding_type][crate::model::AnalyzeSentimentRequest::encoding_type].
83        pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
84            self.0.request.encoding_type = v.into();
85            self
86        }
87    }
88
89    impl gax::options::RequestBuilder for AnalyzeSentiment {
90        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
91            &mut self.0.options
92        }
93    }
94
95    /// The request builder for a LanguageService::analyze_entities call.
96    #[derive(Clone, Debug)]
97    pub struct AnalyzeEntities(RequestBuilder<crate::model::AnalyzeEntitiesRequest>);
98
99    impl AnalyzeEntities {
100        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
101            Self(RequestBuilder::new(stub))
102        }
103
104        /// Sets the full request, replacing any prior values.
105        pub fn with_request<V: Into<crate::model::AnalyzeEntitiesRequest>>(mut self, v: V) -> Self {
106            self.0.request = v.into();
107            self
108        }
109
110        /// Sets all the options, replacing any prior values.
111        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
112            self.0.options = v.into();
113            self
114        }
115
116        /// Sends the request.
117        pub async fn send(self) -> Result<crate::model::AnalyzeEntitiesResponse> {
118            (*self.0.stub)
119                .analyze_entities(self.0.request, self.0.options)
120                .await
121        }
122
123        /// Sets the value of [document][crate::model::AnalyzeEntitiesRequest::document].
124        pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
125            mut self,
126            v: T,
127        ) -> Self {
128            self.0.request.document = v.into();
129            self
130        }
131
132        /// Sets the value of [encoding_type][crate::model::AnalyzeEntitiesRequest::encoding_type].
133        pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
134            self.0.request.encoding_type = v.into();
135            self
136        }
137    }
138
139    impl gax::options::RequestBuilder for AnalyzeEntities {
140        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
141            &mut self.0.options
142        }
143    }
144
145    /// The request builder for a LanguageService::classify_text call.
146    #[derive(Clone, Debug)]
147    pub struct ClassifyText(RequestBuilder<crate::model::ClassifyTextRequest>);
148
149    impl ClassifyText {
150        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
151            Self(RequestBuilder::new(stub))
152        }
153
154        /// Sets the full request, replacing any prior values.
155        pub fn with_request<V: Into<crate::model::ClassifyTextRequest>>(mut self, v: V) -> Self {
156            self.0.request = v.into();
157            self
158        }
159
160        /// Sets all the options, replacing any prior values.
161        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
162            self.0.options = v.into();
163            self
164        }
165
166        /// Sends the request.
167        pub async fn send(self) -> Result<crate::model::ClassifyTextResponse> {
168            (*self.0.stub)
169                .classify_text(self.0.request, self.0.options)
170                .await
171        }
172
173        /// Sets the value of [document][crate::model::ClassifyTextRequest::document].
174        pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
175            mut self,
176            v: T,
177        ) -> Self {
178            self.0.request.document = v.into();
179            self
180        }
181    }
182
183    impl gax::options::RequestBuilder for ClassifyText {
184        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
185            &mut self.0.options
186        }
187    }
188
189    /// The request builder for a LanguageService::moderate_text call.
190    #[derive(Clone, Debug)]
191    pub struct ModerateText(RequestBuilder<crate::model::ModerateTextRequest>);
192
193    impl ModerateText {
194        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
195            Self(RequestBuilder::new(stub))
196        }
197
198        /// Sets the full request, replacing any prior values.
199        pub fn with_request<V: Into<crate::model::ModerateTextRequest>>(mut self, v: V) -> Self {
200            self.0.request = v.into();
201            self
202        }
203
204        /// Sets all the options, replacing any prior values.
205        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
206            self.0.options = v.into();
207            self
208        }
209
210        /// Sends the request.
211        pub async fn send(self) -> Result<crate::model::ModerateTextResponse> {
212            (*self.0.stub)
213                .moderate_text(self.0.request, self.0.options)
214                .await
215        }
216
217        /// Sets the value of [document][crate::model::ModerateTextRequest::document].
218        pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
219            mut self,
220            v: T,
221        ) -> Self {
222            self.0.request.document = v.into();
223            self
224        }
225
226        /// Sets the value of [model_version][crate::model::ModerateTextRequest::model_version].
227        pub fn set_model_version<T: Into<crate::model::moderate_text_request::ModelVersion>>(
228            mut self,
229            v: T,
230        ) -> Self {
231            self.0.request.model_version = v.into();
232            self
233        }
234    }
235
236    impl gax::options::RequestBuilder for ModerateText {
237        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
238            &mut self.0.options
239        }
240    }
241
242    /// The request builder for a LanguageService::annotate_text call.
243    #[derive(Clone, Debug)]
244    pub struct AnnotateText(RequestBuilder<crate::model::AnnotateTextRequest>);
245
246    impl AnnotateText {
247        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
248            Self(RequestBuilder::new(stub))
249        }
250
251        /// Sets the full request, replacing any prior values.
252        pub fn with_request<V: Into<crate::model::AnnotateTextRequest>>(mut self, v: V) -> Self {
253            self.0.request = v.into();
254            self
255        }
256
257        /// Sets all the options, replacing any prior values.
258        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
259            self.0.options = v.into();
260            self
261        }
262
263        /// Sends the request.
264        pub async fn send(self) -> Result<crate::model::AnnotateTextResponse> {
265            (*self.0.stub)
266                .annotate_text(self.0.request, self.0.options)
267                .await
268        }
269
270        /// Sets the value of [document][crate::model::AnnotateTextRequest::document].
271        pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
272            mut self,
273            v: T,
274        ) -> Self {
275            self.0.request.document = v.into();
276            self
277        }
278
279        /// Sets the value of [features][crate::model::AnnotateTextRequest::features].
280        pub fn set_features<
281            T: Into<std::option::Option<crate::model::annotate_text_request::Features>>,
282        >(
283            mut self,
284            v: T,
285        ) -> Self {
286            self.0.request.features = v.into();
287            self
288        }
289
290        /// Sets the value of [encoding_type][crate::model::AnnotateTextRequest::encoding_type].
291        pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
292            self.0.request.encoding_type = v.into();
293            self
294        }
295    }
296
297    impl gax::options::RequestBuilder for AnnotateText {
298        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
299            &mut self.0.options
300        }
301    }
302}