gcp_sdk_language_v2/
builders.rs

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
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

pub mod language_service {
    use crate::Result;
    use std::sync::Arc;

    /// Common implementation for [crate::client::LanguageService] request builders.
    #[derive(Clone, Debug)]
    pub struct RequestBuilder<R: std::default::Default> {
        stub: Arc<dyn crate::stubs::dynamic::LanguageService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for a LanguageService::analyze_sentiment call.
    #[derive(Clone, Debug)]
    pub struct AnalyzeSentiment(RequestBuilder<crate::model::AnalyzeSentimentRequest>);

    impl AnalyzeSentiment {
        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::AnalyzeSentimentRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::AnalyzeSentimentResponse> {
            (*self.0.stub)
                .analyze_sentiment(self.0.request, self.0.options)
                .await
        }

        /// Sets the value of [document][crate::model::AnalyzeSentimentRequest::document].
        pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.document = v.into();
            self
        }

        /// Sets the value of [encoding_type][crate::model::AnalyzeSentimentRequest::encoding_type].
        pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
            self.0.request.encoding_type = v.into();
            self
        }
    }

    impl gax::options::RequestBuilder for AnalyzeSentiment {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for a LanguageService::analyze_entities call.
    #[derive(Clone, Debug)]
    pub struct AnalyzeEntities(RequestBuilder<crate::model::AnalyzeEntitiesRequest>);

    impl AnalyzeEntities {
        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::AnalyzeEntitiesRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::AnalyzeEntitiesResponse> {
            (*self.0.stub)
                .analyze_entities(self.0.request, self.0.options)
                .await
        }

        /// Sets the value of [document][crate::model::AnalyzeEntitiesRequest::document].
        pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.document = v.into();
            self
        }

        /// Sets the value of [encoding_type][crate::model::AnalyzeEntitiesRequest::encoding_type].
        pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
            self.0.request.encoding_type = v.into();
            self
        }
    }

    impl gax::options::RequestBuilder for AnalyzeEntities {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for a LanguageService::classify_text call.
    #[derive(Clone, Debug)]
    pub struct ClassifyText(RequestBuilder<crate::model::ClassifyTextRequest>);

    impl ClassifyText {
        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ClassifyTextRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ClassifyTextResponse> {
            (*self.0.stub)
                .classify_text(self.0.request, self.0.options)
                .await
        }

        /// Sets the value of [document][crate::model::ClassifyTextRequest::document].
        pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.document = v.into();
            self
        }
    }

    impl gax::options::RequestBuilder for ClassifyText {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for a LanguageService::moderate_text call.
    #[derive(Clone, Debug)]
    pub struct ModerateText(RequestBuilder<crate::model::ModerateTextRequest>);

    impl ModerateText {
        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ModerateTextRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ModerateTextResponse> {
            (*self.0.stub)
                .moderate_text(self.0.request, self.0.options)
                .await
        }

        /// Sets the value of [document][crate::model::ModerateTextRequest::document].
        pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.document = v.into();
            self
        }

        /// Sets the value of [model_version][crate::model::ModerateTextRequest::model_version].
        pub fn set_model_version<T: Into<crate::model::moderate_text_request::ModelVersion>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.model_version = v.into();
            self
        }
    }

    impl gax::options::RequestBuilder for ModerateText {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for a LanguageService::annotate_text call.
    #[derive(Clone, Debug)]
    pub struct AnnotateText(RequestBuilder<crate::model::AnnotateTextRequest>);

    impl AnnotateText {
        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::AnnotateTextRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::AnnotateTextResponse> {
            (*self.0.stub)
                .annotate_text(self.0.request, self.0.options)
                .await
        }

        /// Sets the value of [document][crate::model::AnnotateTextRequest::document].
        pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.document = v.into();
            self
        }

        /// Sets the value of [features][crate::model::AnnotateTextRequest::features].
        pub fn set_features<
            T: Into<std::option::Option<crate::model::annotate_text_request::Features>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.features = v.into();
            self
        }

        /// Sets the value of [encoding_type][crate::model::AnnotateTextRequest::encoding_type].
        pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
            self.0.request.encoding_type = v.into();
            self
        }
    }

    impl gax::options::RequestBuilder for AnnotateText {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}