google_cloud_translation_v3/client.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#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19/// Implements a client for the Cloud Translation API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_translation_v3::client::TranslationService;
24/// use google_cloud_gax::paginator::ItemPaginator as _;
25/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
26/// let client = TranslationService::builder().build().await?;
27/// let parent = "parent_value";
28/// let mut list = client.list_glossaries()
29/// .set_parent(parent)
30/// .by_item();
31/// while let Some(item) = list.next().await.transpose()? {
32/// println!("{:?}", item);
33/// }
34/// # Ok(()) }
35/// ```
36///
37/// # Service Description
38///
39/// Provides natural language translation operations.
40///
41/// # Configuration
42///
43/// To configure `TranslationService` use the `with_*` methods in the type returned
44/// by [builder()][TranslationService::builder]. The default configuration should
45/// work for most applications. Common configuration changes include
46///
47/// * [with_endpoint()]: by default this client uses the global default endpoint
48/// (`https://translate.googleapis.com`). Applications using regional
49/// endpoints or running in restricted networks (e.g. a network configured
50// with [Private Google Access with VPC Service Controls]) may want to
51/// override this default.
52/// * [with_credentials()]: by default this client uses
53/// [Application Default Credentials]. Applications using custom
54/// authentication may need to override this default.
55///
56/// [with_endpoint()]: super::builder::translation_service::ClientBuilder::with_endpoint
57/// [with_credentials()]: super::builder::translation_service::ClientBuilder::with_credentials
58/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
59/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
60///
61/// # Pooling and Cloning
62///
63/// `TranslationService` holds a connection pool internally, it is advised to
64/// create one and reuse it. You do not need to wrap `TranslationService` in
65/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
66/// already uses an `Arc` internally.
67#[derive(Clone, Debug)]
68pub struct TranslationService {
69 inner: std::sync::Arc<dyn super::stub::dynamic::TranslationService>,
70}
71
72impl TranslationService {
73 /// Returns a builder for [TranslationService].
74 ///
75 /// ```
76 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
77 /// # use google_cloud_translation_v3::client::TranslationService;
78 /// let client = TranslationService::builder().build().await?;
79 /// # Ok(()) }
80 /// ```
81 pub fn builder() -> super::builder::translation_service::ClientBuilder {
82 crate::new_client_builder(super::builder::translation_service::client::Factory)
83 }
84
85 /// Creates a new client from the provided stub.
86 ///
87 /// The most common case for calling this function is in tests mocking the
88 /// client's behavior.
89 pub fn from_stub<T>(stub: T) -> Self
90 where
91 T: super::stub::TranslationService + 'static,
92 {
93 Self {
94 inner: std::sync::Arc::new(stub),
95 }
96 }
97
98 pub(crate) async fn new(
99 config: gaxi::options::ClientConfig,
100 ) -> crate::ClientBuilderResult<Self> {
101 let inner = Self::build_inner(config).await?;
102 Ok(Self { inner })
103 }
104
105 async fn build_inner(
106 conf: gaxi::options::ClientConfig,
107 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::TranslationService>>
108 {
109 if gaxi::options::tracing_enabled(&conf) {
110 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
111 }
112 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
113 }
114
115 async fn build_transport(
116 conf: gaxi::options::ClientConfig,
117 ) -> crate::ClientBuilderResult<impl super::stub::TranslationService> {
118 super::transport::TranslationService::new(conf).await
119 }
120
121 async fn build_with_tracing(
122 conf: gaxi::options::ClientConfig,
123 ) -> crate::ClientBuilderResult<impl super::stub::TranslationService> {
124 Self::build_transport(conf)
125 .await
126 .map(super::tracing::TranslationService::new)
127 }
128
129 /// Translates input text and returns translated text.
130 ///
131 /// # Example
132 /// ```
133 /// # use google_cloud_translation_v3::client::TranslationService;
134 /// use google_cloud_translation_v3::Result;
135 /// async fn sample(
136 /// client: &TranslationService
137 /// ) -> Result<()> {
138 /// let response = client.translate_text()
139 /// /* set fields */
140 /// .send().await?;
141 /// println!("response {:?}", response);
142 /// Ok(())
143 /// }
144 /// ```
145 pub fn translate_text(&self) -> super::builder::translation_service::TranslateText {
146 super::builder::translation_service::TranslateText::new(self.inner.clone())
147 }
148
149 /// Romanize input text written in non-Latin scripts to Latin text.
150 ///
151 /// # Example
152 /// ```
153 /// # use google_cloud_translation_v3::client::TranslationService;
154 /// use google_cloud_translation_v3::Result;
155 /// async fn sample(
156 /// client: &TranslationService
157 /// ) -> Result<()> {
158 /// let response = client.romanize_text()
159 /// /* set fields */
160 /// .send().await?;
161 /// println!("response {:?}", response);
162 /// Ok(())
163 /// }
164 /// ```
165 pub fn romanize_text(&self) -> super::builder::translation_service::RomanizeText {
166 super::builder::translation_service::RomanizeText::new(self.inner.clone())
167 }
168
169 /// Detects the language of text within a request.
170 ///
171 /// # Example
172 /// ```
173 /// # use google_cloud_translation_v3::client::TranslationService;
174 /// use google_cloud_translation_v3::Result;
175 /// async fn sample(
176 /// client: &TranslationService
177 /// ) -> Result<()> {
178 /// let response = client.detect_language()
179 /// /* set fields */
180 /// .send().await?;
181 /// println!("response {:?}", response);
182 /// Ok(())
183 /// }
184 /// ```
185 pub fn detect_language(&self) -> super::builder::translation_service::DetectLanguage {
186 super::builder::translation_service::DetectLanguage::new(self.inner.clone())
187 }
188
189 /// Returns a list of supported languages for translation.
190 ///
191 /// # Example
192 /// ```
193 /// # use google_cloud_translation_v3::client::TranslationService;
194 /// use google_cloud_translation_v3::Result;
195 /// async fn sample(
196 /// client: &TranslationService
197 /// ) -> Result<()> {
198 /// let response = client.get_supported_languages()
199 /// /* set fields */
200 /// .send().await?;
201 /// println!("response {:?}", response);
202 /// Ok(())
203 /// }
204 /// ```
205 pub fn get_supported_languages(
206 &self,
207 ) -> super::builder::translation_service::GetSupportedLanguages {
208 super::builder::translation_service::GetSupportedLanguages::new(self.inner.clone())
209 }
210
211 /// Translates documents in synchronous mode.
212 ///
213 /// # Example
214 /// ```
215 /// # use google_cloud_translation_v3::client::TranslationService;
216 /// use google_cloud_translation_v3::Result;
217 /// async fn sample(
218 /// client: &TranslationService
219 /// ) -> Result<()> {
220 /// let response = client.translate_document()
221 /// /* set fields */
222 /// .send().await?;
223 /// println!("response {:?}", response);
224 /// Ok(())
225 /// }
226 /// ```
227 pub fn translate_document(&self) -> super::builder::translation_service::TranslateDocument {
228 super::builder::translation_service::TranslateDocument::new(self.inner.clone())
229 }
230
231 /// Translates a large volume of text in asynchronous batch mode.
232 /// This function provides real-time output as the inputs are being processed.
233 /// If caller cancels a request, the partial results (for an input file, it's
234 /// all or nothing) may still be available on the specified output location.
235 ///
236 /// This call returns immediately and you can
237 /// use google.longrunning.Operation.name to poll the status of the call.
238 ///
239 /// # Long running operations
240 ///
241 /// This method is used to start, and/or poll a [long-running Operation].
242 /// The [Working with long-running operations] chapter in the [user guide]
243 /// covers these operations in detail.
244 ///
245 /// [long-running operation]: https://google.aip.dev/151
246 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
247 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
248 ///
249 /// # Example
250 /// ```
251 /// # use google_cloud_translation_v3::client::TranslationService;
252 /// use google_cloud_lro::Poller;
253 /// use google_cloud_translation_v3::Result;
254 /// async fn sample(
255 /// client: &TranslationService
256 /// ) -> Result<()> {
257 /// let response = client.batch_translate_text()
258 /// /* set fields */
259 /// .poller().until_done().await?;
260 /// println!("response {:?}", response);
261 /// Ok(())
262 /// }
263 /// ```
264 pub fn batch_translate_text(&self) -> super::builder::translation_service::BatchTranslateText {
265 super::builder::translation_service::BatchTranslateText::new(self.inner.clone())
266 }
267
268 /// Translates a large volume of document in asynchronous batch mode.
269 /// This function provides real-time output as the inputs are being processed.
270 /// If caller cancels a request, the partial results (for an input file, it's
271 /// all or nothing) may still be available on the specified output location.
272 ///
273 /// This call returns immediately and you can use
274 /// google.longrunning.Operation.name to poll the status of the call.
275 ///
276 /// # Long running operations
277 ///
278 /// This method is used to start, and/or poll a [long-running Operation].
279 /// The [Working with long-running operations] chapter in the [user guide]
280 /// covers these operations in detail.
281 ///
282 /// [long-running operation]: https://google.aip.dev/151
283 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
284 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
285 ///
286 /// # Example
287 /// ```
288 /// # use google_cloud_translation_v3::client::TranslationService;
289 /// use google_cloud_lro::Poller;
290 /// use google_cloud_translation_v3::Result;
291 /// async fn sample(
292 /// client: &TranslationService
293 /// ) -> Result<()> {
294 /// let response = client.batch_translate_document()
295 /// /* set fields */
296 /// .poller().until_done().await?;
297 /// println!("response {:?}", response);
298 /// Ok(())
299 /// }
300 /// ```
301 pub fn batch_translate_document(
302 &self,
303 ) -> super::builder::translation_service::BatchTranslateDocument {
304 super::builder::translation_service::BatchTranslateDocument::new(self.inner.clone())
305 }
306
307 /// Creates a glossary and returns the long-running operation. Returns
308 /// NOT_FOUND, if the project doesn't exist.
309 ///
310 /// # Long running operations
311 ///
312 /// This method is used to start, and/or poll a [long-running Operation].
313 /// The [Working with long-running operations] chapter in the [user guide]
314 /// covers these operations in detail.
315 ///
316 /// [long-running operation]: https://google.aip.dev/151
317 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
318 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
319 ///
320 /// # Example
321 /// ```
322 /// # use google_cloud_translation_v3::client::TranslationService;
323 /// use google_cloud_lro::Poller;
324 /// use google_cloud_translation_v3::model::Glossary;
325 /// use google_cloud_translation_v3::Result;
326 /// async fn sample(
327 /// client: &TranslationService, parent: &str
328 /// ) -> Result<()> {
329 /// let response = client.create_glossary()
330 /// .set_parent(parent)
331 /// .set_glossary(
332 /// Glossary::new()/* set fields */
333 /// )
334 /// .poller().until_done().await?;
335 /// println!("response {:?}", response);
336 /// Ok(())
337 /// }
338 /// ```
339 pub fn create_glossary(&self) -> super::builder::translation_service::CreateGlossary {
340 super::builder::translation_service::CreateGlossary::new(self.inner.clone())
341 }
342
343 /// Updates a glossary. A LRO is used since the update can be async if the
344 /// glossary's entry file is updated.
345 ///
346 /// # Long running operations
347 ///
348 /// This method is used to start, and/or poll a [long-running Operation].
349 /// The [Working with long-running operations] chapter in the [user guide]
350 /// covers these operations in detail.
351 ///
352 /// [long-running operation]: https://google.aip.dev/151
353 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
354 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
355 ///
356 /// # Example
357 /// ```
358 /// # use google_cloud_translation_v3::client::TranslationService;
359 /// use google_cloud_lro::Poller;
360 /// # extern crate wkt as google_cloud_wkt;
361 /// use google_cloud_wkt::FieldMask;
362 /// use google_cloud_translation_v3::model::Glossary;
363 /// use google_cloud_translation_v3::Result;
364 /// async fn sample(
365 /// client: &TranslationService, name: &str
366 /// ) -> Result<()> {
367 /// let response = client.update_glossary()
368 /// .set_glossary(
369 /// Glossary::new().set_name(name)/* set fields */
370 /// )
371 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
372 /// .poller().until_done().await?;
373 /// println!("response {:?}", response);
374 /// Ok(())
375 /// }
376 /// ```
377 pub fn update_glossary(&self) -> super::builder::translation_service::UpdateGlossary {
378 super::builder::translation_service::UpdateGlossary::new(self.inner.clone())
379 }
380
381 /// Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't
382 /// exist.
383 ///
384 /// # Example
385 /// ```
386 /// # use google_cloud_translation_v3::client::TranslationService;
387 /// use google_cloud_gax::paginator::ItemPaginator as _;
388 /// use google_cloud_translation_v3::Result;
389 /// async fn sample(
390 /// client: &TranslationService, parent: &str
391 /// ) -> Result<()> {
392 /// let mut list = client.list_glossaries()
393 /// .set_parent(parent)
394 /// .by_item();
395 /// while let Some(item) = list.next().await.transpose()? {
396 /// println!("{:?}", item);
397 /// }
398 /// Ok(())
399 /// }
400 /// ```
401 pub fn list_glossaries(&self) -> super::builder::translation_service::ListGlossaries {
402 super::builder::translation_service::ListGlossaries::new(self.inner.clone())
403 }
404
405 /// Gets a glossary. Returns NOT_FOUND, if the glossary doesn't
406 /// exist.
407 ///
408 /// # Example
409 /// ```
410 /// # use google_cloud_translation_v3::client::TranslationService;
411 /// use google_cloud_translation_v3::Result;
412 /// async fn sample(
413 /// client: &TranslationService, name: &str
414 /// ) -> Result<()> {
415 /// let response = client.get_glossary()
416 /// .set_name(name)
417 /// .send().await?;
418 /// println!("response {:?}", response);
419 /// Ok(())
420 /// }
421 /// ```
422 pub fn get_glossary(&self) -> super::builder::translation_service::GetGlossary {
423 super::builder::translation_service::GetGlossary::new(self.inner.clone())
424 }
425
426 /// Deletes a glossary, or cancels glossary construction
427 /// if the glossary isn't created yet.
428 /// Returns NOT_FOUND, if the glossary doesn't exist.
429 ///
430 /// # Long running operations
431 ///
432 /// This method is used to start, and/or poll a [long-running Operation].
433 /// The [Working with long-running operations] chapter in the [user guide]
434 /// covers these operations in detail.
435 ///
436 /// [long-running operation]: https://google.aip.dev/151
437 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
438 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
439 ///
440 /// # Example
441 /// ```
442 /// # use google_cloud_translation_v3::client::TranslationService;
443 /// use google_cloud_lro::Poller;
444 /// use google_cloud_translation_v3::Result;
445 /// async fn sample(
446 /// client: &TranslationService, name: &str
447 /// ) -> Result<()> {
448 /// let response = client.delete_glossary()
449 /// .set_name(name)
450 /// .poller().until_done().await?;
451 /// println!("response {:?}", response);
452 /// Ok(())
453 /// }
454 /// ```
455 pub fn delete_glossary(&self) -> super::builder::translation_service::DeleteGlossary {
456 super::builder::translation_service::DeleteGlossary::new(self.inner.clone())
457 }
458
459 /// Gets a single glossary entry by the given id.
460 ///
461 /// # Example
462 /// ```
463 /// # use google_cloud_translation_v3::client::TranslationService;
464 /// use google_cloud_translation_v3::Result;
465 /// async fn sample(
466 /// client: &TranslationService, name: &str
467 /// ) -> Result<()> {
468 /// let response = client.get_glossary_entry()
469 /// .set_name(name)
470 /// .send().await?;
471 /// println!("response {:?}", response);
472 /// Ok(())
473 /// }
474 /// ```
475 pub fn get_glossary_entry(&self) -> super::builder::translation_service::GetGlossaryEntry {
476 super::builder::translation_service::GetGlossaryEntry::new(self.inner.clone())
477 }
478
479 /// List the entries for the glossary.
480 ///
481 /// # Example
482 /// ```
483 /// # use google_cloud_translation_v3::client::TranslationService;
484 /// use google_cloud_gax::paginator::ItemPaginator as _;
485 /// use google_cloud_translation_v3::Result;
486 /// async fn sample(
487 /// client: &TranslationService, parent: &str
488 /// ) -> Result<()> {
489 /// let mut list = client.list_glossary_entries()
490 /// .set_parent(parent)
491 /// .by_item();
492 /// while let Some(item) = list.next().await.transpose()? {
493 /// println!("{:?}", item);
494 /// }
495 /// Ok(())
496 /// }
497 /// ```
498 pub fn list_glossary_entries(
499 &self,
500 ) -> super::builder::translation_service::ListGlossaryEntries {
501 super::builder::translation_service::ListGlossaryEntries::new(self.inner.clone())
502 }
503
504 /// Creates a glossary entry.
505 ///
506 /// # Example
507 /// ```
508 /// # use google_cloud_translation_v3::client::TranslationService;
509 /// use google_cloud_translation_v3::model::GlossaryEntry;
510 /// use google_cloud_translation_v3::Result;
511 /// async fn sample(
512 /// client: &TranslationService, parent: &str
513 /// ) -> Result<()> {
514 /// let response = client.create_glossary_entry()
515 /// .set_parent(parent)
516 /// .set_glossary_entry(
517 /// GlossaryEntry::new()/* set fields */
518 /// )
519 /// .send().await?;
520 /// println!("response {:?}", response);
521 /// Ok(())
522 /// }
523 /// ```
524 pub fn create_glossary_entry(
525 &self,
526 ) -> super::builder::translation_service::CreateGlossaryEntry {
527 super::builder::translation_service::CreateGlossaryEntry::new(self.inner.clone())
528 }
529
530 /// Updates a glossary entry.
531 ///
532 /// # Example
533 /// ```
534 /// # use google_cloud_translation_v3::client::TranslationService;
535 /// use google_cloud_translation_v3::model::GlossaryEntry;
536 /// use google_cloud_translation_v3::Result;
537 /// async fn sample(
538 /// client: &TranslationService, name: &str
539 /// ) -> Result<()> {
540 /// let response = client.update_glossary_entry()
541 /// .set_glossary_entry(
542 /// GlossaryEntry::new().set_name(name)/* set fields */
543 /// )
544 /// .send().await?;
545 /// println!("response {:?}", response);
546 /// Ok(())
547 /// }
548 /// ```
549 pub fn update_glossary_entry(
550 &self,
551 ) -> super::builder::translation_service::UpdateGlossaryEntry {
552 super::builder::translation_service::UpdateGlossaryEntry::new(self.inner.clone())
553 }
554
555 /// Deletes a single entry from the glossary
556 ///
557 /// # Example
558 /// ```
559 /// # use google_cloud_translation_v3::client::TranslationService;
560 /// use google_cloud_translation_v3::Result;
561 /// async fn sample(
562 /// client: &TranslationService, name: &str
563 /// ) -> Result<()> {
564 /// client.delete_glossary_entry()
565 /// .set_name(name)
566 /// .send().await?;
567 /// Ok(())
568 /// }
569 /// ```
570 pub fn delete_glossary_entry(
571 &self,
572 ) -> super::builder::translation_service::DeleteGlossaryEntry {
573 super::builder::translation_service::DeleteGlossaryEntry::new(self.inner.clone())
574 }
575
576 /// Creates a Dataset.
577 ///
578 /// # Long running operations
579 ///
580 /// This method is used to start, and/or poll a [long-running Operation].
581 /// The [Working with long-running operations] chapter in the [user guide]
582 /// covers these operations in detail.
583 ///
584 /// [long-running operation]: https://google.aip.dev/151
585 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
586 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
587 ///
588 /// # Example
589 /// ```
590 /// # use google_cloud_translation_v3::client::TranslationService;
591 /// use google_cloud_lro::Poller;
592 /// use google_cloud_translation_v3::model::Dataset;
593 /// use google_cloud_translation_v3::Result;
594 /// async fn sample(
595 /// client: &TranslationService, parent: &str
596 /// ) -> Result<()> {
597 /// let response = client.create_dataset()
598 /// .set_parent(parent)
599 /// .set_dataset(
600 /// Dataset::new()/* set fields */
601 /// )
602 /// .poller().until_done().await?;
603 /// println!("response {:?}", response);
604 /// Ok(())
605 /// }
606 /// ```
607 pub fn create_dataset(&self) -> super::builder::translation_service::CreateDataset {
608 super::builder::translation_service::CreateDataset::new(self.inner.clone())
609 }
610
611 /// Gets a Dataset.
612 ///
613 /// # Example
614 /// ```
615 /// # use google_cloud_translation_v3::client::TranslationService;
616 /// use google_cloud_translation_v3::Result;
617 /// async fn sample(
618 /// client: &TranslationService, name: &str
619 /// ) -> Result<()> {
620 /// let response = client.get_dataset()
621 /// .set_name(name)
622 /// .send().await?;
623 /// println!("response {:?}", response);
624 /// Ok(())
625 /// }
626 /// ```
627 pub fn get_dataset(&self) -> super::builder::translation_service::GetDataset {
628 super::builder::translation_service::GetDataset::new(self.inner.clone())
629 }
630
631 /// Lists datasets.
632 ///
633 /// # Example
634 /// ```
635 /// # use google_cloud_translation_v3::client::TranslationService;
636 /// use google_cloud_gax::paginator::ItemPaginator as _;
637 /// use google_cloud_translation_v3::Result;
638 /// async fn sample(
639 /// client: &TranslationService, parent: &str
640 /// ) -> Result<()> {
641 /// let mut list = client.list_datasets()
642 /// .set_parent(parent)
643 /// .by_item();
644 /// while let Some(item) = list.next().await.transpose()? {
645 /// println!("{:?}", item);
646 /// }
647 /// Ok(())
648 /// }
649 /// ```
650 pub fn list_datasets(&self) -> super::builder::translation_service::ListDatasets {
651 super::builder::translation_service::ListDatasets::new(self.inner.clone())
652 }
653
654 /// Deletes a dataset and all of its contents.
655 ///
656 /// # Long running operations
657 ///
658 /// This method is used to start, and/or poll a [long-running Operation].
659 /// The [Working with long-running operations] chapter in the [user guide]
660 /// covers these operations in detail.
661 ///
662 /// [long-running operation]: https://google.aip.dev/151
663 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
664 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
665 ///
666 /// # Example
667 /// ```
668 /// # use google_cloud_translation_v3::client::TranslationService;
669 /// use google_cloud_lro::Poller;
670 /// use google_cloud_translation_v3::Result;
671 /// async fn sample(
672 /// client: &TranslationService, name: &str
673 /// ) -> Result<()> {
674 /// client.delete_dataset()
675 /// .set_name(name)
676 /// .poller().until_done().await?;
677 /// Ok(())
678 /// }
679 /// ```
680 pub fn delete_dataset(&self) -> super::builder::translation_service::DeleteDataset {
681 super::builder::translation_service::DeleteDataset::new(self.inner.clone())
682 }
683
684 /// Creates an Adaptive MT dataset.
685 ///
686 /// # Example
687 /// ```
688 /// # use google_cloud_translation_v3::client::TranslationService;
689 /// use google_cloud_translation_v3::model::AdaptiveMtDataset;
690 /// use google_cloud_translation_v3::Result;
691 /// async fn sample(
692 /// client: &TranslationService, parent: &str
693 /// ) -> Result<()> {
694 /// let response = client.create_adaptive_mt_dataset()
695 /// .set_parent(parent)
696 /// .set_adaptive_mt_dataset(
697 /// AdaptiveMtDataset::new()/* set fields */
698 /// )
699 /// .send().await?;
700 /// println!("response {:?}", response);
701 /// Ok(())
702 /// }
703 /// ```
704 pub fn create_adaptive_mt_dataset(
705 &self,
706 ) -> super::builder::translation_service::CreateAdaptiveMtDataset {
707 super::builder::translation_service::CreateAdaptiveMtDataset::new(self.inner.clone())
708 }
709
710 /// Deletes an Adaptive MT dataset, including all its entries and associated
711 /// metadata.
712 ///
713 /// # Example
714 /// ```
715 /// # use google_cloud_translation_v3::client::TranslationService;
716 /// use google_cloud_translation_v3::Result;
717 /// async fn sample(
718 /// client: &TranslationService, name: &str
719 /// ) -> Result<()> {
720 /// client.delete_adaptive_mt_dataset()
721 /// .set_name(name)
722 /// .send().await?;
723 /// Ok(())
724 /// }
725 /// ```
726 pub fn delete_adaptive_mt_dataset(
727 &self,
728 ) -> super::builder::translation_service::DeleteAdaptiveMtDataset {
729 super::builder::translation_service::DeleteAdaptiveMtDataset::new(self.inner.clone())
730 }
731
732 /// Gets the Adaptive MT dataset.
733 ///
734 /// # Example
735 /// ```
736 /// # use google_cloud_translation_v3::client::TranslationService;
737 /// use google_cloud_translation_v3::Result;
738 /// async fn sample(
739 /// client: &TranslationService, name: &str
740 /// ) -> Result<()> {
741 /// let response = client.get_adaptive_mt_dataset()
742 /// .set_name(name)
743 /// .send().await?;
744 /// println!("response {:?}", response);
745 /// Ok(())
746 /// }
747 /// ```
748 pub fn get_adaptive_mt_dataset(
749 &self,
750 ) -> super::builder::translation_service::GetAdaptiveMtDataset {
751 super::builder::translation_service::GetAdaptiveMtDataset::new(self.inner.clone())
752 }
753
754 /// Lists all Adaptive MT datasets for which the caller has read permission.
755 ///
756 /// # Example
757 /// ```
758 /// # use google_cloud_translation_v3::client::TranslationService;
759 /// use google_cloud_gax::paginator::ItemPaginator as _;
760 /// use google_cloud_translation_v3::Result;
761 /// async fn sample(
762 /// client: &TranslationService, parent: &str
763 /// ) -> Result<()> {
764 /// let mut list = client.list_adaptive_mt_datasets()
765 /// .set_parent(parent)
766 /// .by_item();
767 /// while let Some(item) = list.next().await.transpose()? {
768 /// println!("{:?}", item);
769 /// }
770 /// Ok(())
771 /// }
772 /// ```
773 pub fn list_adaptive_mt_datasets(
774 &self,
775 ) -> super::builder::translation_service::ListAdaptiveMtDatasets {
776 super::builder::translation_service::ListAdaptiveMtDatasets::new(self.inner.clone())
777 }
778
779 /// Translate text using Adaptive MT.
780 ///
781 /// # Example
782 /// ```
783 /// # use google_cloud_translation_v3::client::TranslationService;
784 /// use google_cloud_translation_v3::Result;
785 /// async fn sample(
786 /// client: &TranslationService
787 /// ) -> Result<()> {
788 /// let response = client.adaptive_mt_translate()
789 /// /* set fields */
790 /// .send().await?;
791 /// println!("response {:?}", response);
792 /// Ok(())
793 /// }
794 /// ```
795 pub fn adaptive_mt_translate(
796 &self,
797 ) -> super::builder::translation_service::AdaptiveMtTranslate {
798 super::builder::translation_service::AdaptiveMtTranslate::new(self.inner.clone())
799 }
800
801 /// Gets and AdaptiveMtFile
802 ///
803 /// # Example
804 /// ```
805 /// # use google_cloud_translation_v3::client::TranslationService;
806 /// use google_cloud_translation_v3::Result;
807 /// async fn sample(
808 /// client: &TranslationService, name: &str
809 /// ) -> Result<()> {
810 /// let response = client.get_adaptive_mt_file()
811 /// .set_name(name)
812 /// .send().await?;
813 /// println!("response {:?}", response);
814 /// Ok(())
815 /// }
816 /// ```
817 pub fn get_adaptive_mt_file(&self) -> super::builder::translation_service::GetAdaptiveMtFile {
818 super::builder::translation_service::GetAdaptiveMtFile::new(self.inner.clone())
819 }
820
821 /// Deletes an AdaptiveMtFile along with its sentences.
822 ///
823 /// # Example
824 /// ```
825 /// # use google_cloud_translation_v3::client::TranslationService;
826 /// use google_cloud_translation_v3::Result;
827 /// async fn sample(
828 /// client: &TranslationService, name: &str
829 /// ) -> Result<()> {
830 /// client.delete_adaptive_mt_file()
831 /// .set_name(name)
832 /// .send().await?;
833 /// Ok(())
834 /// }
835 /// ```
836 pub fn delete_adaptive_mt_file(
837 &self,
838 ) -> super::builder::translation_service::DeleteAdaptiveMtFile {
839 super::builder::translation_service::DeleteAdaptiveMtFile::new(self.inner.clone())
840 }
841
842 /// Imports an AdaptiveMtFile and adds all of its sentences into the
843 /// AdaptiveMtDataset.
844 ///
845 /// # Example
846 /// ```
847 /// # use google_cloud_translation_v3::client::TranslationService;
848 /// use google_cloud_translation_v3::Result;
849 /// async fn sample(
850 /// client: &TranslationService
851 /// ) -> Result<()> {
852 /// let response = client.import_adaptive_mt_file()
853 /// /* set fields */
854 /// .send().await?;
855 /// println!("response {:?}", response);
856 /// Ok(())
857 /// }
858 /// ```
859 pub fn import_adaptive_mt_file(
860 &self,
861 ) -> super::builder::translation_service::ImportAdaptiveMtFile {
862 super::builder::translation_service::ImportAdaptiveMtFile::new(self.inner.clone())
863 }
864
865 /// Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.
866 ///
867 /// # Example
868 /// ```
869 /// # use google_cloud_translation_v3::client::TranslationService;
870 /// use google_cloud_gax::paginator::ItemPaginator as _;
871 /// use google_cloud_translation_v3::Result;
872 /// async fn sample(
873 /// client: &TranslationService, parent: &str
874 /// ) -> Result<()> {
875 /// let mut list = client.list_adaptive_mt_files()
876 /// .set_parent(parent)
877 /// .by_item();
878 /// while let Some(item) = list.next().await.transpose()? {
879 /// println!("{:?}", item);
880 /// }
881 /// Ok(())
882 /// }
883 /// ```
884 pub fn list_adaptive_mt_files(
885 &self,
886 ) -> super::builder::translation_service::ListAdaptiveMtFiles {
887 super::builder::translation_service::ListAdaptiveMtFiles::new(self.inner.clone())
888 }
889
890 /// Lists all AdaptiveMtSentences under a given file/dataset.
891 ///
892 /// # Example
893 /// ```
894 /// # use google_cloud_translation_v3::client::TranslationService;
895 /// use google_cloud_gax::paginator::ItemPaginator as _;
896 /// use google_cloud_translation_v3::Result;
897 /// async fn sample(
898 /// client: &TranslationService, parent: &str
899 /// ) -> Result<()> {
900 /// let mut list = client.list_adaptive_mt_sentences()
901 /// .set_parent(parent)
902 /// .by_item();
903 /// while let Some(item) = list.next().await.transpose()? {
904 /// println!("{:?}", item);
905 /// }
906 /// Ok(())
907 /// }
908 /// ```
909 pub fn list_adaptive_mt_sentences(
910 &self,
911 ) -> super::builder::translation_service::ListAdaptiveMtSentences {
912 super::builder::translation_service::ListAdaptiveMtSentences::new(self.inner.clone())
913 }
914
915 /// Import sentence pairs into translation Dataset.
916 ///
917 /// # Long running operations
918 ///
919 /// This method is used to start, and/or poll a [long-running Operation].
920 /// The [Working with long-running operations] chapter in the [user guide]
921 /// covers these operations in detail.
922 ///
923 /// [long-running operation]: https://google.aip.dev/151
924 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
925 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
926 ///
927 /// # Example
928 /// ```
929 /// # use google_cloud_translation_v3::client::TranslationService;
930 /// use google_cloud_lro::Poller;
931 /// use google_cloud_translation_v3::Result;
932 /// async fn sample(
933 /// client: &TranslationService
934 /// ) -> Result<()> {
935 /// client.import_data()
936 /// /* set fields */
937 /// .poller().until_done().await?;
938 /// Ok(())
939 /// }
940 /// ```
941 pub fn import_data(&self) -> super::builder::translation_service::ImportData {
942 super::builder::translation_service::ImportData::new(self.inner.clone())
943 }
944
945 /// Exports dataset's data to the provided output location.
946 ///
947 /// # Long running operations
948 ///
949 /// This method is used to start, and/or poll a [long-running Operation].
950 /// The [Working with long-running operations] chapter in the [user guide]
951 /// covers these operations in detail.
952 ///
953 /// [long-running operation]: https://google.aip.dev/151
954 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
955 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
956 ///
957 /// # Example
958 /// ```
959 /// # use google_cloud_translation_v3::client::TranslationService;
960 /// use google_cloud_lro::Poller;
961 /// use google_cloud_translation_v3::Result;
962 /// async fn sample(
963 /// client: &TranslationService
964 /// ) -> Result<()> {
965 /// client.export_data()
966 /// /* set fields */
967 /// .poller().until_done().await?;
968 /// Ok(())
969 /// }
970 /// ```
971 pub fn export_data(&self) -> super::builder::translation_service::ExportData {
972 super::builder::translation_service::ExportData::new(self.inner.clone())
973 }
974
975 /// Lists sentence pairs in the dataset.
976 ///
977 /// # Example
978 /// ```
979 /// # use google_cloud_translation_v3::client::TranslationService;
980 /// use google_cloud_gax::paginator::ItemPaginator as _;
981 /// use google_cloud_translation_v3::Result;
982 /// async fn sample(
983 /// client: &TranslationService, parent: &str
984 /// ) -> Result<()> {
985 /// let mut list = client.list_examples()
986 /// .set_parent(parent)
987 /// .by_item();
988 /// while let Some(item) = list.next().await.transpose()? {
989 /// println!("{:?}", item);
990 /// }
991 /// Ok(())
992 /// }
993 /// ```
994 pub fn list_examples(&self) -> super::builder::translation_service::ListExamples {
995 super::builder::translation_service::ListExamples::new(self.inner.clone())
996 }
997
998 /// Creates a Model.
999 ///
1000 /// # Long running operations
1001 ///
1002 /// This method is used to start, and/or poll a [long-running Operation].
1003 /// The [Working with long-running operations] chapter in the [user guide]
1004 /// covers these operations in detail.
1005 ///
1006 /// [long-running operation]: https://google.aip.dev/151
1007 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1008 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1009 ///
1010 /// # Example
1011 /// ```
1012 /// # use google_cloud_translation_v3::client::TranslationService;
1013 /// use google_cloud_lro::Poller;
1014 /// use google_cloud_translation_v3::model::Model;
1015 /// use google_cloud_translation_v3::Result;
1016 /// async fn sample(
1017 /// client: &TranslationService, parent: &str
1018 /// ) -> Result<()> {
1019 /// let response = client.create_model()
1020 /// .set_parent(parent)
1021 /// .set_model(
1022 /// Model::new()/* set fields */
1023 /// )
1024 /// .poller().until_done().await?;
1025 /// println!("response {:?}", response);
1026 /// Ok(())
1027 /// }
1028 /// ```
1029 pub fn create_model(&self) -> super::builder::translation_service::CreateModel {
1030 super::builder::translation_service::CreateModel::new(self.inner.clone())
1031 }
1032
1033 /// Lists models.
1034 ///
1035 /// # Example
1036 /// ```
1037 /// # use google_cloud_translation_v3::client::TranslationService;
1038 /// use google_cloud_gax::paginator::ItemPaginator as _;
1039 /// use google_cloud_translation_v3::Result;
1040 /// async fn sample(
1041 /// client: &TranslationService, parent: &str
1042 /// ) -> Result<()> {
1043 /// let mut list = client.list_models()
1044 /// .set_parent(parent)
1045 /// .by_item();
1046 /// while let Some(item) = list.next().await.transpose()? {
1047 /// println!("{:?}", item);
1048 /// }
1049 /// Ok(())
1050 /// }
1051 /// ```
1052 pub fn list_models(&self) -> super::builder::translation_service::ListModels {
1053 super::builder::translation_service::ListModels::new(self.inner.clone())
1054 }
1055
1056 /// Gets a model.
1057 ///
1058 /// # Example
1059 /// ```
1060 /// # use google_cloud_translation_v3::client::TranslationService;
1061 /// use google_cloud_translation_v3::Result;
1062 /// async fn sample(
1063 /// client: &TranslationService, name: &str
1064 /// ) -> Result<()> {
1065 /// let response = client.get_model()
1066 /// .set_name(name)
1067 /// .send().await?;
1068 /// println!("response {:?}", response);
1069 /// Ok(())
1070 /// }
1071 /// ```
1072 pub fn get_model(&self) -> super::builder::translation_service::GetModel {
1073 super::builder::translation_service::GetModel::new(self.inner.clone())
1074 }
1075
1076 /// Deletes a model.
1077 ///
1078 /// # Long running operations
1079 ///
1080 /// This method is used to start, and/or poll a [long-running Operation].
1081 /// The [Working with long-running operations] chapter in the [user guide]
1082 /// covers these operations in detail.
1083 ///
1084 /// [long-running operation]: https://google.aip.dev/151
1085 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1086 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1087 ///
1088 /// # Example
1089 /// ```
1090 /// # use google_cloud_translation_v3::client::TranslationService;
1091 /// use google_cloud_lro::Poller;
1092 /// use google_cloud_translation_v3::Result;
1093 /// async fn sample(
1094 /// client: &TranslationService, name: &str
1095 /// ) -> Result<()> {
1096 /// client.delete_model()
1097 /// .set_name(name)
1098 /// .poller().until_done().await?;
1099 /// Ok(())
1100 /// }
1101 /// ```
1102 pub fn delete_model(&self) -> super::builder::translation_service::DeleteModel {
1103 super::builder::translation_service::DeleteModel::new(self.inner.clone())
1104 }
1105
1106 /// Lists information about the supported locations for this service.
1107 ///
1108 /// # Example
1109 /// ```
1110 /// # use google_cloud_translation_v3::client::TranslationService;
1111 /// use google_cloud_gax::paginator::ItemPaginator as _;
1112 /// use google_cloud_translation_v3::Result;
1113 /// async fn sample(
1114 /// client: &TranslationService
1115 /// ) -> Result<()> {
1116 /// let mut list = client.list_locations()
1117 /// /* set fields */
1118 /// .by_item();
1119 /// while let Some(item) = list.next().await.transpose()? {
1120 /// println!("{:?}", item);
1121 /// }
1122 /// Ok(())
1123 /// }
1124 /// ```
1125 pub fn list_locations(&self) -> super::builder::translation_service::ListLocations {
1126 super::builder::translation_service::ListLocations::new(self.inner.clone())
1127 }
1128
1129 /// Gets information about a location.
1130 ///
1131 /// # Example
1132 /// ```
1133 /// # use google_cloud_translation_v3::client::TranslationService;
1134 /// use google_cloud_translation_v3::Result;
1135 /// async fn sample(
1136 /// client: &TranslationService
1137 /// ) -> Result<()> {
1138 /// let response = client.get_location()
1139 /// /* set fields */
1140 /// .send().await?;
1141 /// println!("response {:?}", response);
1142 /// Ok(())
1143 /// }
1144 /// ```
1145 pub fn get_location(&self) -> super::builder::translation_service::GetLocation {
1146 super::builder::translation_service::GetLocation::new(self.inner.clone())
1147 }
1148
1149 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1150 ///
1151 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1152 ///
1153 /// # Example
1154 /// ```
1155 /// # use google_cloud_translation_v3::client::TranslationService;
1156 /// use google_cloud_gax::paginator::ItemPaginator as _;
1157 /// use google_cloud_translation_v3::Result;
1158 /// async fn sample(
1159 /// client: &TranslationService
1160 /// ) -> Result<()> {
1161 /// let mut list = client.list_operations()
1162 /// /* set fields */
1163 /// .by_item();
1164 /// while let Some(item) = list.next().await.transpose()? {
1165 /// println!("{:?}", item);
1166 /// }
1167 /// Ok(())
1168 /// }
1169 /// ```
1170 pub fn list_operations(&self) -> super::builder::translation_service::ListOperations {
1171 super::builder::translation_service::ListOperations::new(self.inner.clone())
1172 }
1173
1174 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1175 ///
1176 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1177 ///
1178 /// # Example
1179 /// ```
1180 /// # use google_cloud_translation_v3::client::TranslationService;
1181 /// use google_cloud_translation_v3::Result;
1182 /// async fn sample(
1183 /// client: &TranslationService
1184 /// ) -> Result<()> {
1185 /// let response = client.get_operation()
1186 /// /* set fields */
1187 /// .send().await?;
1188 /// println!("response {:?}", response);
1189 /// Ok(())
1190 /// }
1191 /// ```
1192 pub fn get_operation(&self) -> super::builder::translation_service::GetOperation {
1193 super::builder::translation_service::GetOperation::new(self.inner.clone())
1194 }
1195
1196 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1197 ///
1198 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1199 ///
1200 /// # Example
1201 /// ```
1202 /// # use google_cloud_translation_v3::client::TranslationService;
1203 /// use google_cloud_translation_v3::Result;
1204 /// async fn sample(
1205 /// client: &TranslationService
1206 /// ) -> Result<()> {
1207 /// client.delete_operation()
1208 /// /* set fields */
1209 /// .send().await?;
1210 /// Ok(())
1211 /// }
1212 /// ```
1213 pub fn delete_operation(&self) -> super::builder::translation_service::DeleteOperation {
1214 super::builder::translation_service::DeleteOperation::new(self.inner.clone())
1215 }
1216
1217 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1218 ///
1219 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1220 ///
1221 /// # Example
1222 /// ```
1223 /// # use google_cloud_translation_v3::client::TranslationService;
1224 /// use google_cloud_translation_v3::Result;
1225 /// async fn sample(
1226 /// client: &TranslationService
1227 /// ) -> Result<()> {
1228 /// client.cancel_operation()
1229 /// /* set fields */
1230 /// .send().await?;
1231 /// Ok(())
1232 /// }
1233 /// ```
1234 pub fn cancel_operation(&self) -> super::builder::translation_service::CancelOperation {
1235 super::builder::translation_service::CancelOperation::new(self.inner.clone())
1236 }
1237
1238 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1239 ///
1240 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1241 ///
1242 /// # Example
1243 /// ```
1244 /// # use google_cloud_translation_v3::client::TranslationService;
1245 /// use google_cloud_translation_v3::Result;
1246 /// async fn sample(
1247 /// client: &TranslationService
1248 /// ) -> Result<()> {
1249 /// let response = client.wait_operation()
1250 /// /* set fields */
1251 /// .send().await?;
1252 /// println!("response {:?}", response);
1253 /// Ok(())
1254 /// }
1255 /// ```
1256 pub fn wait_operation(&self) -> super::builder::translation_service::WaitOperation {
1257 super::builder::translation_service::WaitOperation::new(self.inner.clone())
1258 }
1259}