// 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 protoc-gen-go_gapic. DO NOT EDIT. package translate_test import ( "context" longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" translate "cloud.google.com/go/translate/apiv3" translatepb "cloud.google.com/go/translate/apiv3/translatepb" "google.golang.org/api/iterator" locationpb "google.golang.org/genproto/googleapis/cloud/location" ) func ExampleNewTranslationClient() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c } func ExampleNewTranslationRESTClient() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c } func ExampleTranslationClient_AdaptiveMtTranslate() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.AdaptiveMtTranslateRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#AdaptiveMtTranslateRequest. } resp, err := c.AdaptiveMtTranslate(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_BatchTranslateDocument() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.BatchTranslateDocumentRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#BatchTranslateDocumentRequest. } op, err := c.BatchTranslateDocument(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_BatchTranslateText() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.BatchTranslateTextRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#BatchTranslateTextRequest. } op, err := c.BatchTranslateText(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_CreateAdaptiveMtDataset() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.CreateAdaptiveMtDatasetRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#CreateAdaptiveMtDatasetRequest. } resp, err := c.CreateAdaptiveMtDataset(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_CreateDataset() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.CreateDatasetRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#CreateDatasetRequest. } op, err := c.CreateDataset(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_CreateGlossary() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.CreateGlossaryRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#CreateGlossaryRequest. } op, err := c.CreateGlossary(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_CreateGlossaryEntry() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.CreateGlossaryEntryRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#CreateGlossaryEntryRequest. } resp, err := c.CreateGlossaryEntry(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_CreateModel() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.CreateModelRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#CreateModelRequest. } op, err := c.CreateModel(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_DeleteAdaptiveMtDataset() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.DeleteAdaptiveMtDatasetRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DeleteAdaptiveMtDatasetRequest. } err = c.DeleteAdaptiveMtDataset(ctx, req) if err != nil { // TODO: Handle error. } } func ExampleTranslationClient_DeleteAdaptiveMtFile() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.DeleteAdaptiveMtFileRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DeleteAdaptiveMtFileRequest. } err = c.DeleteAdaptiveMtFile(ctx, req) if err != nil { // TODO: Handle error. } } func ExampleTranslationClient_DeleteDataset() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.DeleteDatasetRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DeleteDatasetRequest. } op, err := c.DeleteDataset(ctx, req) if err != nil { // TODO: Handle error. } err = op.Wait(ctx) if err != nil { // TODO: Handle error. } } func ExampleTranslationClient_DeleteGlossary() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.DeleteGlossaryRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DeleteGlossaryRequest. } op, err := c.DeleteGlossary(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_DeleteGlossaryEntry() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.DeleteGlossaryEntryRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DeleteGlossaryEntryRequest. } err = c.DeleteGlossaryEntry(ctx, req) if err != nil { // TODO: Handle error. } } func ExampleTranslationClient_DeleteModel() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.DeleteModelRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DeleteModelRequest. } op, err := c.DeleteModel(ctx, req) if err != nil { // TODO: Handle error. } err = op.Wait(ctx) if err != nil { // TODO: Handle error. } } func ExampleTranslationClient_DetectLanguage() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.DetectLanguageRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DetectLanguageRequest. } resp, err := c.DetectLanguage(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_ExportData() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.ExportDataRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ExportDataRequest. } op, err := c.ExportData(ctx, req) if err != nil { // TODO: Handle error. } err = op.Wait(ctx) if err != nil { // TODO: Handle error. } } func ExampleTranslationClient_GetAdaptiveMtDataset() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.GetAdaptiveMtDatasetRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetAdaptiveMtDatasetRequest. } resp, err := c.GetAdaptiveMtDataset(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_GetAdaptiveMtFile() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.GetAdaptiveMtFileRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetAdaptiveMtFileRequest. } resp, err := c.GetAdaptiveMtFile(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_GetDataset() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.GetDatasetRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetDatasetRequest. } resp, err := c.GetDataset(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_GetGlossary() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.GetGlossaryRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetGlossaryRequest. } resp, err := c.GetGlossary(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_GetGlossaryEntry() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.GetGlossaryEntryRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetGlossaryEntryRequest. } resp, err := c.GetGlossaryEntry(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_GetModel() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.GetModelRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetModelRequest. } resp, err := c.GetModel(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_GetSupportedLanguages() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.GetSupportedLanguagesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetSupportedLanguagesRequest. } resp, err := c.GetSupportedLanguages(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_ImportAdaptiveMtFile() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.ImportAdaptiveMtFileRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ImportAdaptiveMtFileRequest. } resp, err := c.ImportAdaptiveMtFile(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_ImportData() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.ImportDataRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ImportDataRequest. } op, err := c.ImportData(ctx, req) if err != nil { // TODO: Handle error. } err = op.Wait(ctx) if err != nil { // TODO: Handle error. } } func ExampleTranslationClient_ListAdaptiveMtDatasets() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.ListAdaptiveMtDatasetsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListAdaptiveMtDatasetsRequest. } it := c.ListAdaptiveMtDatasets(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*translatepb.ListAdaptiveMtDatasetsResponse) } } func ExampleTranslationClient_ListAdaptiveMtFiles() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.ListAdaptiveMtFilesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListAdaptiveMtFilesRequest. } it := c.ListAdaptiveMtFiles(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*translatepb.ListAdaptiveMtFilesResponse) } } func ExampleTranslationClient_ListAdaptiveMtSentences() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.ListAdaptiveMtSentencesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListAdaptiveMtSentencesRequest. } it := c.ListAdaptiveMtSentences(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*translatepb.ListAdaptiveMtSentencesResponse) } } func ExampleTranslationClient_ListDatasets() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.ListDatasetsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListDatasetsRequest. } it := c.ListDatasets(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*translatepb.ListDatasetsResponse) } } func ExampleTranslationClient_ListExamples() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.ListExamplesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListExamplesRequest. } it := c.ListExamples(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*translatepb.ListExamplesResponse) } } func ExampleTranslationClient_ListGlossaries() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.ListGlossariesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListGlossariesRequest. } it := c.ListGlossaries(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*translatepb.ListGlossariesResponse) } } func ExampleTranslationClient_ListGlossaryEntries() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.ListGlossaryEntriesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListGlossaryEntriesRequest. } it := c.ListGlossaryEntries(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*translatepb.ListGlossaryEntriesResponse) } } func ExampleTranslationClient_ListModels() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.ListModelsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListModelsRequest. } it := c.ListModels(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*translatepb.ListModelsResponse) } } func ExampleTranslationClient_RomanizeText() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.RomanizeTextRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#RomanizeTextRequest. } resp, err := c.RomanizeText(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_TranslateDocument() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.TranslateDocumentRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#TranslateDocumentRequest. } resp, err := c.TranslateDocument(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_TranslateText() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.TranslateTextRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#TranslateTextRequest. } resp, err := c.TranslateText(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_UpdateGlossary() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.UpdateGlossaryRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#UpdateGlossaryRequest. } op, err := c.UpdateGlossary(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_UpdateGlossaryEntry() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &translatepb.UpdateGlossaryEntryRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#UpdateGlossaryEntryRequest. } resp, err := c.UpdateGlossaryEntry(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_GetLocation() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &locationpb.GetLocationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. } resp, err := c.GetLocation(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_ListLocations() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &locationpb.ListLocationsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. } it := c.ListLocations(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*locationpb.ListLocationsResponse) } } func ExampleTranslationClient_CancelOperation() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.CancelOperationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest. } err = c.CancelOperation(ctx, req) if err != nil { // TODO: Handle error. } } func ExampleTranslationClient_DeleteOperation() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.DeleteOperationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest. } err = c.DeleteOperation(ctx, req) if err != nil { // TODO: Handle error. } } func ExampleTranslationClient_GetOperation() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.GetOperationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. } resp, err := c.GetOperation(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleTranslationClient_ListOperations() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.ListOperationsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. } it := c.ListOperations(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*longrunningpb.ListOperationsResponse) } } func ExampleTranslationClient_WaitOperation() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.WaitOperationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#WaitOperationRequest. } resp, err := c.WaitOperation(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }