| 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 protoc-gen-go_gapic. DO NOT EDIT. |
| 16 |
|
| 17 |
package translate_test |
| 18 |
|
| 19 |
import ( |
| 20 |
"context" |
| 21 |
|
| 22 |
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" |
| 23 |
translate "cloud.google.com/go/translate/apiv3" |
| 24 |
translatepb "cloud.google.com/go/translate/apiv3/translatepb" |
| 25 |
"google.golang.org/api/iterator" |
| 26 |
locationpb "google.golang.org/genproto/googleapis/cloud/location" |
| 27 |
) |
| 28 |
|
| 29 |
func ExampleNewTranslationClient() { |
| 30 |
ctx := context.Background() |
| 31 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 32 |
// It will require modifications to work: |
| 33 |
// - It may require correct/in-range values for request initialization. |
| 34 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 35 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 36 |
c, err := translate.NewTranslationClient(ctx) |
| 37 |
if err != nil { |
| 38 |
// TODO: Handle error. |
| 39 |
} |
| 40 |
defer c.Close() |
| 41 |
|
| 42 |
// TODO: Use client. |
| 43 |
_ = c |
| 44 |
} |
| 45 |
|
| 46 |
func ExampleNewTranslationRESTClient() { |
| 47 |
ctx := context.Background() |
| 48 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 49 |
// It will require modifications to work: |
| 50 |
// - It may require correct/in-range values for request initialization. |
| 51 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 52 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 53 |
c, err := translate.NewTranslationRESTClient(ctx) |
| 54 |
if err != nil { |
| 55 |
// TODO: Handle error. |
| 56 |
} |
| 57 |
defer c.Close() |
| 58 |
|
| 59 |
// TODO: Use client. |
| 60 |
_ = c |
| 61 |
} |
| 62 |
|
| 63 |
func ExampleTranslationClient_AdaptiveMtTranslate() { |
| 64 |
ctx := context.Background() |
| 65 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 66 |
// It will require modifications to work: |
| 67 |
// - It may require correct/in-range values for request initialization. |
| 68 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 69 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 70 |
c, err := translate.NewTranslationClient(ctx) |
| 71 |
if err != nil { |
| 72 |
// TODO: Handle error. |
| 73 |
} |
| 74 |
defer c.Close() |
| 75 |
|
| 76 |
req := &translatepb.AdaptiveMtTranslateRequest{ |
| 77 |
// TODO: Fill request struct fields. |
| 78 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#AdaptiveMtTranslateRequest. |
| 79 |
} |
| 80 |
resp, err := c.AdaptiveMtTranslate(ctx, req) |
| 81 |
if err != nil { |
| 82 |
// TODO: Handle error. |
| 83 |
} |
| 84 |
// TODO: Use resp. |
| 85 |
_ = resp |
| 86 |
} |
| 87 |
|
| 88 |
func ExampleTranslationClient_BatchTranslateDocument() { |
| 89 |
ctx := context.Background() |
| 90 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 91 |
// It will require modifications to work: |
| 92 |
// - It may require correct/in-range values for request initialization. |
| 93 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 94 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 95 |
c, err := translate.NewTranslationClient(ctx) |
| 96 |
if err != nil { |
| 97 |
// TODO: Handle error. |
| 98 |
} |
| 99 |
defer c.Close() |
| 100 |
|
| 101 |
req := &translatepb.BatchTranslateDocumentRequest{ |
| 102 |
// TODO: Fill request struct fields. |
| 103 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#BatchTranslateDocumentRequest. |
| 104 |
} |
| 105 |
op, err := c.BatchTranslateDocument(ctx, req) |
| 106 |
if err != nil { |
| 107 |
// TODO: Handle error. |
| 108 |
} |
| 109 |
|
| 110 |
resp, err := op.Wait(ctx) |
| 111 |
if err != nil { |
| 112 |
// TODO: Handle error. |
| 113 |
} |
| 114 |
// TODO: Use resp. |
| 115 |
_ = resp |
| 116 |
} |
| 117 |
|
| 118 |
func ExampleTranslationClient_BatchTranslateText() { |
| 119 |
ctx := context.Background() |
| 120 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 121 |
// It will require modifications to work: |
| 122 |
// - It may require correct/in-range values for request initialization. |
| 123 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 124 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 125 |
c, err := translate.NewTranslationClient(ctx) |
| 126 |
if err != nil { |
| 127 |
// TODO: Handle error. |
| 128 |
} |
| 129 |
defer c.Close() |
| 130 |
|
| 131 |
req := &translatepb.BatchTranslateTextRequest{ |
| 132 |
// TODO: Fill request struct fields. |
| 133 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#BatchTranslateTextRequest. |
| 134 |
} |
| 135 |
op, err := c.BatchTranslateText(ctx, req) |
| 136 |
if err != nil { |
| 137 |
// TODO: Handle error. |
| 138 |
} |
| 139 |
|
| 140 |
resp, err := op.Wait(ctx) |
| 141 |
if err != nil { |
| 142 |
// TODO: Handle error. |
| 143 |
} |
| 144 |
// TODO: Use resp. |
| 145 |
_ = resp |
| 146 |
} |
| 147 |
|
| 148 |
func ExampleTranslationClient_CreateAdaptiveMtDataset() { |
| 149 |
ctx := context.Background() |
| 150 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 151 |
// It will require modifications to work: |
| 152 |
// - It may require correct/in-range values for request initialization. |
| 153 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 154 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 155 |
c, err := translate.NewTranslationClient(ctx) |
| 156 |
if err != nil { |
| 157 |
// TODO: Handle error. |
| 158 |
} |
| 159 |
defer c.Close() |
| 160 |
|
| 161 |
req := &translatepb.CreateAdaptiveMtDatasetRequest{ |
| 162 |
// TODO: Fill request struct fields. |
| 163 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#CreateAdaptiveMtDatasetRequest. |
| 164 |
} |
| 165 |
resp, err := c.CreateAdaptiveMtDataset(ctx, req) |
| 166 |
if err != nil { |
| 167 |
// TODO: Handle error. |
| 168 |
} |
| 169 |
// TODO: Use resp. |
| 170 |
_ = resp |
| 171 |
} |
| 172 |
|
| 173 |
func ExampleTranslationClient_CreateDataset() { |
| 174 |
ctx := context.Background() |
| 175 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 176 |
// It will require modifications to work: |
| 177 |
// - It may require correct/in-range values for request initialization. |
| 178 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 179 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 180 |
c, err := translate.NewTranslationClient(ctx) |
| 181 |
if err != nil { |
| 182 |
// TODO: Handle error. |
| 183 |
} |
| 184 |
defer c.Close() |
| 185 |
|
| 186 |
req := &translatepb.CreateDatasetRequest{ |
| 187 |
// TODO: Fill request struct fields. |
| 188 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#CreateDatasetRequest. |
| 189 |
} |
| 190 |
op, err := c.CreateDataset(ctx, req) |
| 191 |
if err != nil { |
| 192 |
// TODO: Handle error. |
| 193 |
} |
| 194 |
|
| 195 |
resp, err := op.Wait(ctx) |
| 196 |
if err != nil { |
| 197 |
// TODO: Handle error. |
| 198 |
} |
| 199 |
// TODO: Use resp. |
| 200 |
_ = resp |
| 201 |
} |
| 202 |
|
| 203 |
func ExampleTranslationClient_CreateGlossary() { |
| 204 |
ctx := context.Background() |
| 205 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 206 |
// It will require modifications to work: |
| 207 |
// - It may require correct/in-range values for request initialization. |
| 208 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 209 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 210 |
c, err := translate.NewTranslationClient(ctx) |
| 211 |
if err != nil { |
| 212 |
// TODO: Handle error. |
| 213 |
} |
| 214 |
defer c.Close() |
| 215 |
|
| 216 |
req := &translatepb.CreateGlossaryRequest{ |
| 217 |
// TODO: Fill request struct fields. |
| 218 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#CreateGlossaryRequest. |
| 219 |
} |
| 220 |
op, err := c.CreateGlossary(ctx, req) |
| 221 |
if err != nil { |
| 222 |
// TODO: Handle error. |
| 223 |
} |
| 224 |
|
| 225 |
resp, err := op.Wait(ctx) |
| 226 |
if err != nil { |
| 227 |
// TODO: Handle error. |
| 228 |
} |
| 229 |
// TODO: Use resp. |
| 230 |
_ = resp |
| 231 |
} |
| 232 |
|
| 233 |
func ExampleTranslationClient_CreateGlossaryEntry() { |
| 234 |
ctx := context.Background() |
| 235 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 236 |
// It will require modifications to work: |
| 237 |
// - It may require correct/in-range values for request initialization. |
| 238 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 239 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 240 |
c, err := translate.NewTranslationClient(ctx) |
| 241 |
if err != nil { |
| 242 |
// TODO: Handle error. |
| 243 |
} |
| 244 |
defer c.Close() |
| 245 |
|
| 246 |
req := &translatepb.CreateGlossaryEntryRequest{ |
| 247 |
// TODO: Fill request struct fields. |
| 248 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#CreateGlossaryEntryRequest. |
| 249 |
} |
| 250 |
resp, err := c.CreateGlossaryEntry(ctx, req) |
| 251 |
if err != nil { |
| 252 |
// TODO: Handle error. |
| 253 |
} |
| 254 |
// TODO: Use resp. |
| 255 |
_ = resp |
| 256 |
} |
| 257 |
|
| 258 |
func ExampleTranslationClient_CreateModel() { |
| 259 |
ctx := context.Background() |
| 260 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 261 |
// It will require modifications to work: |
| 262 |
// - It may require correct/in-range values for request initialization. |
| 263 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 264 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 265 |
c, err := translate.NewTranslationClient(ctx) |
| 266 |
if err != nil { |
| 267 |
// TODO: Handle error. |
| 268 |
} |
| 269 |
defer c.Close() |
| 270 |
|
| 271 |
req := &translatepb.CreateModelRequest{ |
| 272 |
// TODO: Fill request struct fields. |
| 273 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#CreateModelRequest. |
| 274 |
} |
| 275 |
op, err := c.CreateModel(ctx, req) |
| 276 |
if err != nil { |
| 277 |
// TODO: Handle error. |
| 278 |
} |
| 279 |
|
| 280 |
resp, err := op.Wait(ctx) |
| 281 |
if err != nil { |
| 282 |
// TODO: Handle error. |
| 283 |
} |
| 284 |
// TODO: Use resp. |
| 285 |
_ = resp |
| 286 |
} |
| 287 |
|
| 288 |
func ExampleTranslationClient_DeleteAdaptiveMtDataset() { |
| 289 |
ctx := context.Background() |
| 290 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 291 |
// It will require modifications to work: |
| 292 |
// - It may require correct/in-range values for request initialization. |
| 293 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 294 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 295 |
c, err := translate.NewTranslationClient(ctx) |
| 296 |
if err != nil { |
| 297 |
// TODO: Handle error. |
| 298 |
} |
| 299 |
defer c.Close() |
| 300 |
|
| 301 |
req := &translatepb.DeleteAdaptiveMtDatasetRequest{ |
| 302 |
// TODO: Fill request struct fields. |
| 303 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DeleteAdaptiveMtDatasetRequest. |
| 304 |
} |
| 305 |
err = c.DeleteAdaptiveMtDataset(ctx, req) |
| 306 |
if err != nil { |
| 307 |
// TODO: Handle error. |
| 308 |
} |
| 309 |
} |
| 310 |
|
| 311 |
func ExampleTranslationClient_DeleteAdaptiveMtFile() { |
| 312 |
ctx := context.Background() |
| 313 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 314 |
// It will require modifications to work: |
| 315 |
// - It may require correct/in-range values for request initialization. |
| 316 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 317 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 318 |
c, err := translate.NewTranslationClient(ctx) |
| 319 |
if err != nil { |
| 320 |
// TODO: Handle error. |
| 321 |
} |
| 322 |
defer c.Close() |
| 323 |
|
| 324 |
req := &translatepb.DeleteAdaptiveMtFileRequest{ |
| 325 |
// TODO: Fill request struct fields. |
| 326 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DeleteAdaptiveMtFileRequest. |
| 327 |
} |
| 328 |
err = c.DeleteAdaptiveMtFile(ctx, req) |
| 329 |
if err != nil { |
| 330 |
// TODO: Handle error. |
| 331 |
} |
| 332 |
} |
| 333 |
|
| 334 |
func ExampleTranslationClient_DeleteDataset() { |
| 335 |
ctx := context.Background() |
| 336 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 337 |
// It will require modifications to work: |
| 338 |
// - It may require correct/in-range values for request initialization. |
| 339 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 340 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 341 |
c, err := translate.NewTranslationClient(ctx) |
| 342 |
if err != nil { |
| 343 |
// TODO: Handle error. |
| 344 |
} |
| 345 |
defer c.Close() |
| 346 |
|
| 347 |
req := &translatepb.DeleteDatasetRequest{ |
| 348 |
// TODO: Fill request struct fields. |
| 349 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DeleteDatasetRequest. |
| 350 |
} |
| 351 |
op, err := c.DeleteDataset(ctx, req) |
| 352 |
if err != nil { |
| 353 |
// TODO: Handle error. |
| 354 |
} |
| 355 |
|
| 356 |
err = op.Wait(ctx) |
| 357 |
if err != nil { |
| 358 |
// TODO: Handle error. |
| 359 |
} |
| 360 |
} |
| 361 |
|
| 362 |
func ExampleTranslationClient_DeleteGlossary() { |
| 363 |
ctx := context.Background() |
| 364 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 365 |
// It will require modifications to work: |
| 366 |
// - It may require correct/in-range values for request initialization. |
| 367 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 368 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 369 |
c, err := translate.NewTranslationClient(ctx) |
| 370 |
if err != nil { |
| 371 |
// TODO: Handle error. |
| 372 |
} |
| 373 |
defer c.Close() |
| 374 |
|
| 375 |
req := &translatepb.DeleteGlossaryRequest{ |
| 376 |
// TODO: Fill request struct fields. |
| 377 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DeleteGlossaryRequest. |
| 378 |
} |
| 379 |
op, err := c.DeleteGlossary(ctx, req) |
| 380 |
if err != nil { |
| 381 |
// TODO: Handle error. |
| 382 |
} |
| 383 |
|
| 384 |
resp, err := op.Wait(ctx) |
| 385 |
if err != nil { |
| 386 |
// TODO: Handle error. |
| 387 |
} |
| 388 |
// TODO: Use resp. |
| 389 |
_ = resp |
| 390 |
} |
| 391 |
|
| 392 |
func ExampleTranslationClient_DeleteGlossaryEntry() { |
| 393 |
ctx := context.Background() |
| 394 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 395 |
// It will require modifications to work: |
| 396 |
// - It may require correct/in-range values for request initialization. |
| 397 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 398 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 399 |
c, err := translate.NewTranslationClient(ctx) |
| 400 |
if err != nil { |
| 401 |
// TODO: Handle error. |
| 402 |
} |
| 403 |
defer c.Close() |
| 404 |
|
| 405 |
req := &translatepb.DeleteGlossaryEntryRequest{ |
| 406 |
// TODO: Fill request struct fields. |
| 407 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DeleteGlossaryEntryRequest. |
| 408 |
} |
| 409 |
err = c.DeleteGlossaryEntry(ctx, req) |
| 410 |
if err != nil { |
| 411 |
// TODO: Handle error. |
| 412 |
} |
| 413 |
} |
| 414 |
|
| 415 |
func ExampleTranslationClient_DeleteModel() { |
| 416 |
ctx := context.Background() |
| 417 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 418 |
// It will require modifications to work: |
| 419 |
// - It may require correct/in-range values for request initialization. |
| 420 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 421 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 422 |
c, err := translate.NewTranslationClient(ctx) |
| 423 |
if err != nil { |
| 424 |
// TODO: Handle error. |
| 425 |
} |
| 426 |
defer c.Close() |
| 427 |
|
| 428 |
req := &translatepb.DeleteModelRequest{ |
| 429 |
// TODO: Fill request struct fields. |
| 430 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DeleteModelRequest. |
| 431 |
} |
| 432 |
op, err := c.DeleteModel(ctx, req) |
| 433 |
if err != nil { |
| 434 |
// TODO: Handle error. |
| 435 |
} |
| 436 |
|
| 437 |
err = op.Wait(ctx) |
| 438 |
if err != nil { |
| 439 |
// TODO: Handle error. |
| 440 |
} |
| 441 |
} |
| 442 |
|
| 443 |
func ExampleTranslationClient_DetectLanguage() { |
| 444 |
ctx := context.Background() |
| 445 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 446 |
// It will require modifications to work: |
| 447 |
// - It may require correct/in-range values for request initialization. |
| 448 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 449 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 450 |
c, err := translate.NewTranslationClient(ctx) |
| 451 |
if err != nil { |
| 452 |
// TODO: Handle error. |
| 453 |
} |
| 454 |
defer c.Close() |
| 455 |
|
| 456 |
req := &translatepb.DetectLanguageRequest{ |
| 457 |
// TODO: Fill request struct fields. |
| 458 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#DetectLanguageRequest. |
| 459 |
} |
| 460 |
resp, err := c.DetectLanguage(ctx, req) |
| 461 |
if err != nil { |
| 462 |
// TODO: Handle error. |
| 463 |
} |
| 464 |
// TODO: Use resp. |
| 465 |
_ = resp |
| 466 |
} |
| 467 |
|
| 468 |
func ExampleTranslationClient_ExportData() { |
| 469 |
ctx := context.Background() |
| 470 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 471 |
// It will require modifications to work: |
| 472 |
// - It may require correct/in-range values for request initialization. |
| 473 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 474 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 475 |
c, err := translate.NewTranslationClient(ctx) |
| 476 |
if err != nil { |
| 477 |
// TODO: Handle error. |
| 478 |
} |
| 479 |
defer c.Close() |
| 480 |
|
| 481 |
req := &translatepb.ExportDataRequest{ |
| 482 |
// TODO: Fill request struct fields. |
| 483 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ExportDataRequest. |
| 484 |
} |
| 485 |
op, err := c.ExportData(ctx, req) |
| 486 |
if err != nil { |
| 487 |
// TODO: Handle error. |
| 488 |
} |
| 489 |
|
| 490 |
err = op.Wait(ctx) |
| 491 |
if err != nil { |
| 492 |
// TODO: Handle error. |
| 493 |
} |
| 494 |
} |
| 495 |
|
| 496 |
func ExampleTranslationClient_GetAdaptiveMtDataset() { |
| 497 |
ctx := context.Background() |
| 498 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 499 |
// It will require modifications to work: |
| 500 |
// - It may require correct/in-range values for request initialization. |
| 501 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 502 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 503 |
c, err := translate.NewTranslationClient(ctx) |
| 504 |
if err != nil { |
| 505 |
// TODO: Handle error. |
| 506 |
} |
| 507 |
defer c.Close() |
| 508 |
|
| 509 |
req := &translatepb.GetAdaptiveMtDatasetRequest{ |
| 510 |
// TODO: Fill request struct fields. |
| 511 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetAdaptiveMtDatasetRequest. |
| 512 |
} |
| 513 |
resp, err := c.GetAdaptiveMtDataset(ctx, req) |
| 514 |
if err != nil { |
| 515 |
// TODO: Handle error. |
| 516 |
} |
| 517 |
// TODO: Use resp. |
| 518 |
_ = resp |
| 519 |
} |
| 520 |
|
| 521 |
func ExampleTranslationClient_GetAdaptiveMtFile() { |
| 522 |
ctx := context.Background() |
| 523 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 524 |
// It will require modifications to work: |
| 525 |
// - It may require correct/in-range values for request initialization. |
| 526 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 527 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 528 |
c, err := translate.NewTranslationClient(ctx) |
| 529 |
if err != nil { |
| 530 |
// TODO: Handle error. |
| 531 |
} |
| 532 |
defer c.Close() |
| 533 |
|
| 534 |
req := &translatepb.GetAdaptiveMtFileRequest{ |
| 535 |
// TODO: Fill request struct fields. |
| 536 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetAdaptiveMtFileRequest. |
| 537 |
} |
| 538 |
resp, err := c.GetAdaptiveMtFile(ctx, req) |
| 539 |
if err != nil { |
| 540 |
// TODO: Handle error. |
| 541 |
} |
| 542 |
// TODO: Use resp. |
| 543 |
_ = resp |
| 544 |
} |
| 545 |
|
| 546 |
func ExampleTranslationClient_GetDataset() { |
| 547 |
ctx := context.Background() |
| 548 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 549 |
// It will require modifications to work: |
| 550 |
// - It may require correct/in-range values for request initialization. |
| 551 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 552 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 553 |
c, err := translate.NewTranslationClient(ctx) |
| 554 |
if err != nil { |
| 555 |
// TODO: Handle error. |
| 556 |
} |
| 557 |
defer c.Close() |
| 558 |
|
| 559 |
req := &translatepb.GetDatasetRequest{ |
| 560 |
// TODO: Fill request struct fields. |
| 561 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetDatasetRequest. |
| 562 |
} |
| 563 |
resp, err := c.GetDataset(ctx, req) |
| 564 |
if err != nil { |
| 565 |
// TODO: Handle error. |
| 566 |
} |
| 567 |
// TODO: Use resp. |
| 568 |
_ = resp |
| 569 |
} |
| 570 |
|
| 571 |
func ExampleTranslationClient_GetGlossary() { |
| 572 |
ctx := context.Background() |
| 573 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 574 |
// It will require modifications to work: |
| 575 |
// - It may require correct/in-range values for request initialization. |
| 576 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 577 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 578 |
c, err := translate.NewTranslationClient(ctx) |
| 579 |
if err != nil { |
| 580 |
// TODO: Handle error. |
| 581 |
} |
| 582 |
defer c.Close() |
| 583 |
|
| 584 |
req := &translatepb.GetGlossaryRequest{ |
| 585 |
// TODO: Fill request struct fields. |
| 586 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetGlossaryRequest. |
| 587 |
} |
| 588 |
resp, err := c.GetGlossary(ctx, req) |
| 589 |
if err != nil { |
| 590 |
// TODO: Handle error. |
| 591 |
} |
| 592 |
// TODO: Use resp. |
| 593 |
_ = resp |
| 594 |
} |
| 595 |
|
| 596 |
func ExampleTranslationClient_GetGlossaryEntry() { |
| 597 |
ctx := context.Background() |
| 598 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 599 |
// It will require modifications to work: |
| 600 |
// - It may require correct/in-range values for request initialization. |
| 601 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 602 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 603 |
c, err := translate.NewTranslationClient(ctx) |
| 604 |
if err != nil { |
| 605 |
// TODO: Handle error. |
| 606 |
} |
| 607 |
defer c.Close() |
| 608 |
|
| 609 |
req := &translatepb.GetGlossaryEntryRequest{ |
| 610 |
// TODO: Fill request struct fields. |
| 611 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetGlossaryEntryRequest. |
| 612 |
} |
| 613 |
resp, err := c.GetGlossaryEntry(ctx, req) |
| 614 |
if err != nil { |
| 615 |
// TODO: Handle error. |
| 616 |
} |
| 617 |
// TODO: Use resp. |
| 618 |
_ = resp |
| 619 |
} |
| 620 |
|
| 621 |
func ExampleTranslationClient_GetModel() { |
| 622 |
ctx := context.Background() |
| 623 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 624 |
// It will require modifications to work: |
| 625 |
// - It may require correct/in-range values for request initialization. |
| 626 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 627 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 628 |
c, err := translate.NewTranslationClient(ctx) |
| 629 |
if err != nil { |
| 630 |
// TODO: Handle error. |
| 631 |
} |
| 632 |
defer c.Close() |
| 633 |
|
| 634 |
req := &translatepb.GetModelRequest{ |
| 635 |
// TODO: Fill request struct fields. |
| 636 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetModelRequest. |
| 637 |
} |
| 638 |
resp, err := c.GetModel(ctx, req) |
| 639 |
if err != nil { |
| 640 |
// TODO: Handle error. |
| 641 |
} |
| 642 |
// TODO: Use resp. |
| 643 |
_ = resp |
| 644 |
} |
| 645 |
|
| 646 |
func ExampleTranslationClient_GetSupportedLanguages() { |
| 647 |
ctx := context.Background() |
| 648 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 649 |
// It will require modifications to work: |
| 650 |
// - It may require correct/in-range values for request initialization. |
| 651 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 652 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 653 |
c, err := translate.NewTranslationClient(ctx) |
| 654 |
if err != nil { |
| 655 |
// TODO: Handle error. |
| 656 |
} |
| 657 |
defer c.Close() |
| 658 |
|
| 659 |
req := &translatepb.GetSupportedLanguagesRequest{ |
| 660 |
// TODO: Fill request struct fields. |
| 661 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#GetSupportedLanguagesRequest. |
| 662 |
} |
| 663 |
resp, err := c.GetSupportedLanguages(ctx, req) |
| 664 |
if err != nil { |
| 665 |
// TODO: Handle error. |
| 666 |
} |
| 667 |
// TODO: Use resp. |
| 668 |
_ = resp |
| 669 |
} |
| 670 |
|
| 671 |
func ExampleTranslationClient_ImportAdaptiveMtFile() { |
| 672 |
ctx := context.Background() |
| 673 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 674 |
// It will require modifications to work: |
| 675 |
// - It may require correct/in-range values for request initialization. |
| 676 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 677 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 678 |
c, err := translate.NewTranslationClient(ctx) |
| 679 |
if err != nil { |
| 680 |
// TODO: Handle error. |
| 681 |
} |
| 682 |
defer c.Close() |
| 683 |
|
| 684 |
req := &translatepb.ImportAdaptiveMtFileRequest{ |
| 685 |
// TODO: Fill request struct fields. |
| 686 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ImportAdaptiveMtFileRequest. |
| 687 |
} |
| 688 |
resp, err := c.ImportAdaptiveMtFile(ctx, req) |
| 689 |
if err != nil { |
| 690 |
// TODO: Handle error. |
| 691 |
} |
| 692 |
// TODO: Use resp. |
| 693 |
_ = resp |
| 694 |
} |
| 695 |
|
| 696 |
func ExampleTranslationClient_ImportData() { |
| 697 |
ctx := context.Background() |
| 698 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 699 |
// It will require modifications to work: |
| 700 |
// - It may require correct/in-range values for request initialization. |
| 701 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 702 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 703 |
c, err := translate.NewTranslationClient(ctx) |
| 704 |
if err != nil { |
| 705 |
// TODO: Handle error. |
| 706 |
} |
| 707 |
defer c.Close() |
| 708 |
|
| 709 |
req := &translatepb.ImportDataRequest{ |
| 710 |
// TODO: Fill request struct fields. |
| 711 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ImportDataRequest. |
| 712 |
} |
| 713 |
op, err := c.ImportData(ctx, req) |
| 714 |
if err != nil { |
| 715 |
// TODO: Handle error. |
| 716 |
} |
| 717 |
|
| 718 |
err = op.Wait(ctx) |
| 719 |
if err != nil { |
| 720 |
// TODO: Handle error. |
| 721 |
} |
| 722 |
} |
| 723 |
|
| 724 |
func ExampleTranslationClient_ListAdaptiveMtDatasets() { |
| 725 |
ctx := context.Background() |
| 726 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 727 |
// It will require modifications to work: |
| 728 |
// - It may require correct/in-range values for request initialization. |
| 729 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 730 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 731 |
c, err := translate.NewTranslationClient(ctx) |
| 732 |
if err != nil { |
| 733 |
// TODO: Handle error. |
| 734 |
} |
| 735 |
defer c.Close() |
| 736 |
|
| 737 |
req := &translatepb.ListAdaptiveMtDatasetsRequest{ |
| 738 |
// TODO: Fill request struct fields. |
| 739 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListAdaptiveMtDatasetsRequest. |
| 740 |
} |
| 741 |
it := c.ListAdaptiveMtDatasets(ctx, req) |
| 742 |
for { |
| 743 |
resp, err := it.Next() |
| 744 |
if err == iterator.Done { |
| 745 |
break |
| 746 |
} |
| 747 |
if err != nil { |
| 748 |
// TODO: Handle error. |
| 749 |
} |
| 750 |
// TODO: Use resp. |
| 751 |
_ = resp |
| 752 |
|
| 753 |
// If you need to access the underlying RPC response, |
| 754 |
// you can do so by casting the `Response` as below. |
| 755 |
// Otherwise, remove this line. Only populated after |
| 756 |
// first call to Next(). Not safe for concurrent access. |
| 757 |
_ = it.Response.(*translatepb.ListAdaptiveMtDatasetsResponse) |
| 758 |
} |
| 759 |
} |
| 760 |
|
| 761 |
func ExampleTranslationClient_ListAdaptiveMtFiles() { |
| 762 |
ctx := context.Background() |
| 763 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 764 |
// It will require modifications to work: |
| 765 |
// - It may require correct/in-range values for request initialization. |
| 766 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 767 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 768 |
c, err := translate.NewTranslationClient(ctx) |
| 769 |
if err != nil { |
| 770 |
// TODO: Handle error. |
| 771 |
} |
| 772 |
defer c.Close() |
| 773 |
|
| 774 |
req := &translatepb.ListAdaptiveMtFilesRequest{ |
| 775 |
// TODO: Fill request struct fields. |
| 776 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListAdaptiveMtFilesRequest. |
| 777 |
} |
| 778 |
it := c.ListAdaptiveMtFiles(ctx, req) |
| 779 |
for { |
| 780 |
resp, err := it.Next() |
| 781 |
if err == iterator.Done { |
| 782 |
break |
| 783 |
} |
| 784 |
if err != nil { |
| 785 |
// TODO: Handle error. |
| 786 |
} |
| 787 |
// TODO: Use resp. |
| 788 |
_ = resp |
| 789 |
|
| 790 |
// If you need to access the underlying RPC response, |
| 791 |
// you can do so by casting the `Response` as below. |
| 792 |
// Otherwise, remove this line. Only populated after |
| 793 |
// first call to Next(). Not safe for concurrent access. |
| 794 |
_ = it.Response.(*translatepb.ListAdaptiveMtFilesResponse) |
| 795 |
} |
| 796 |
} |
| 797 |
|
| 798 |
func ExampleTranslationClient_ListAdaptiveMtSentences() { |
| 799 |
ctx := context.Background() |
| 800 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 801 |
// It will require modifications to work: |
| 802 |
// - It may require correct/in-range values for request initialization. |
| 803 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 804 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 805 |
c, err := translate.NewTranslationClient(ctx) |
| 806 |
if err != nil { |
| 807 |
// TODO: Handle error. |
| 808 |
} |
| 809 |
defer c.Close() |
| 810 |
|
| 811 |
req := &translatepb.ListAdaptiveMtSentencesRequest{ |
| 812 |
// TODO: Fill request struct fields. |
| 813 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListAdaptiveMtSentencesRequest. |
| 814 |
} |
| 815 |
it := c.ListAdaptiveMtSentences(ctx, req) |
| 816 |
for { |
| 817 |
resp, err := it.Next() |
| 818 |
if err == iterator.Done { |
| 819 |
break |
| 820 |
} |
| 821 |
if err != nil { |
| 822 |
// TODO: Handle error. |
| 823 |
} |
| 824 |
// TODO: Use resp. |
| 825 |
_ = resp |
| 826 |
|
| 827 |
// If you need to access the underlying RPC response, |
| 828 |
// you can do so by casting the `Response` as below. |
| 829 |
// Otherwise, remove this line. Only populated after |
| 830 |
// first call to Next(). Not safe for concurrent access. |
| 831 |
_ = it.Response.(*translatepb.ListAdaptiveMtSentencesResponse) |
| 832 |
} |
| 833 |
} |
| 834 |
|
| 835 |
func ExampleTranslationClient_ListDatasets() { |
| 836 |
ctx := context.Background() |
| 837 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 838 |
// It will require modifications to work: |
| 839 |
// - It may require correct/in-range values for request initialization. |
| 840 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 841 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 842 |
c, err := translate.NewTranslationClient(ctx) |
| 843 |
if err != nil { |
| 844 |
// TODO: Handle error. |
| 845 |
} |
| 846 |
defer c.Close() |
| 847 |
|
| 848 |
req := &translatepb.ListDatasetsRequest{ |
| 849 |
// TODO: Fill request struct fields. |
| 850 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListDatasetsRequest. |
| 851 |
} |
| 852 |
it := c.ListDatasets(ctx, req) |
| 853 |
for { |
| 854 |
resp, err := it.Next() |
| 855 |
if err == iterator.Done { |
| 856 |
break |
| 857 |
} |
| 858 |
if err != nil { |
| 859 |
// TODO: Handle error. |
| 860 |
} |
| 861 |
// TODO: Use resp. |
| 862 |
_ = resp |
| 863 |
|
| 864 |
// If you need to access the underlying RPC response, |
| 865 |
// you can do so by casting the `Response` as below. |
| 866 |
// Otherwise, remove this line. Only populated after |
| 867 |
// first call to Next(). Not safe for concurrent access. |
| 868 |
_ = it.Response.(*translatepb.ListDatasetsResponse) |
| 869 |
} |
| 870 |
} |
| 871 |
|
| 872 |
func ExampleTranslationClient_ListExamples() { |
| 873 |
ctx := context.Background() |
| 874 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 875 |
// It will require modifications to work: |
| 876 |
// - It may require correct/in-range values for request initialization. |
| 877 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 878 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 879 |
c, err := translate.NewTranslationClient(ctx) |
| 880 |
if err != nil { |
| 881 |
// TODO: Handle error. |
| 882 |
} |
| 883 |
defer c.Close() |
| 884 |
|
| 885 |
req := &translatepb.ListExamplesRequest{ |
| 886 |
// TODO: Fill request struct fields. |
| 887 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListExamplesRequest. |
| 888 |
} |
| 889 |
it := c.ListExamples(ctx, req) |
| 890 |
for { |
| 891 |
resp, err := it.Next() |
| 892 |
if err == iterator.Done { |
| 893 |
break |
| 894 |
} |
| 895 |
if err != nil { |
| 896 |
// TODO: Handle error. |
| 897 |
} |
| 898 |
// TODO: Use resp. |
| 899 |
_ = resp |
| 900 |
|
| 901 |
// If you need to access the underlying RPC response, |
| 902 |
// you can do so by casting the `Response` as below. |
| 903 |
// Otherwise, remove this line. Only populated after |
| 904 |
// first call to Next(). Not safe for concurrent access. |
| 905 |
_ = it.Response.(*translatepb.ListExamplesResponse) |
| 906 |
} |
| 907 |
} |
| 908 |
|
| 909 |
func ExampleTranslationClient_ListGlossaries() { |
| 910 |
ctx := context.Background() |
| 911 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 912 |
// It will require modifications to work: |
| 913 |
// - It may require correct/in-range values for request initialization. |
| 914 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 915 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 916 |
c, err := translate.NewTranslationClient(ctx) |
| 917 |
if err != nil { |
| 918 |
// TODO: Handle error. |
| 919 |
} |
| 920 |
defer c.Close() |
| 921 |
|
| 922 |
req := &translatepb.ListGlossariesRequest{ |
| 923 |
// TODO: Fill request struct fields. |
| 924 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListGlossariesRequest. |
| 925 |
} |
| 926 |
it := c.ListGlossaries(ctx, req) |
| 927 |
for { |
| 928 |
resp, err := it.Next() |
| 929 |
if err == iterator.Done { |
| 930 |
break |
| 931 |
} |
| 932 |
if err != nil { |
| 933 |
// TODO: Handle error. |
| 934 |
} |
| 935 |
// TODO: Use resp. |
| 936 |
_ = resp |
| 937 |
|
| 938 |
// If you need to access the underlying RPC response, |
| 939 |
// you can do so by casting the `Response` as below. |
| 940 |
// Otherwise, remove this line. Only populated after |
| 941 |
// first call to Next(). Not safe for concurrent access. |
| 942 |
_ = it.Response.(*translatepb.ListGlossariesResponse) |
| 943 |
} |
| 944 |
} |
| 945 |
|
| 946 |
func ExampleTranslationClient_ListGlossaryEntries() { |
| 947 |
ctx := context.Background() |
| 948 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 949 |
// It will require modifications to work: |
| 950 |
// - It may require correct/in-range values for request initialization. |
| 951 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 952 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 953 |
c, err := translate.NewTranslationClient(ctx) |
| 954 |
if err != nil { |
| 955 |
// TODO: Handle error. |
| 956 |
} |
| 957 |
defer c.Close() |
| 958 |
|
| 959 |
req := &translatepb.ListGlossaryEntriesRequest{ |
| 960 |
// TODO: Fill request struct fields. |
| 961 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListGlossaryEntriesRequest. |
| 962 |
} |
| 963 |
it := c.ListGlossaryEntries(ctx, req) |
| 964 |
for { |
| 965 |
resp, err := it.Next() |
| 966 |
if err == iterator.Done { |
| 967 |
break |
| 968 |
} |
| 969 |
if err != nil { |
| 970 |
// TODO: Handle error. |
| 971 |
} |
| 972 |
// TODO: Use resp. |
| 973 |
_ = resp |
| 974 |
|
| 975 |
// If you need to access the underlying RPC response, |
| 976 |
// you can do so by casting the `Response` as below. |
| 977 |
// Otherwise, remove this line. Only populated after |
| 978 |
// first call to Next(). Not safe for concurrent access. |
| 979 |
_ = it.Response.(*translatepb.ListGlossaryEntriesResponse) |
| 980 |
} |
| 981 |
} |
| 982 |
|
| 983 |
func ExampleTranslationClient_ListModels() { |
| 984 |
ctx := context.Background() |
| 985 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 986 |
// It will require modifications to work: |
| 987 |
// - It may require correct/in-range values for request initialization. |
| 988 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 989 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 990 |
c, err := translate.NewTranslationClient(ctx) |
| 991 |
if err != nil { |
| 992 |
// TODO: Handle error. |
| 993 |
} |
| 994 |
defer c.Close() |
| 995 |
|
| 996 |
req := &translatepb.ListModelsRequest{ |
| 997 |
// TODO: Fill request struct fields. |
| 998 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#ListModelsRequest. |
| 999 |
} |
| 1000 |
it := c.ListModels(ctx, req) |
| 1001 |
for { |
| 1002 |
resp, err := it.Next() |
| 1003 |
if err == iterator.Done { |
| 1004 |
break |
| 1005 |
} |
| 1006 |
if err != nil { |
| 1007 |
// TODO: Handle error. |
| 1008 |
} |
| 1009 |
// TODO: Use resp. |
| 1010 |
_ = resp |
| 1011 |
|
| 1012 |
// If you need to access the underlying RPC response, |
| 1013 |
// you can do so by casting the `Response` as below. |
| 1014 |
// Otherwise, remove this line. Only populated after |
| 1015 |
// first call to Next(). Not safe for concurrent access. |
| 1016 |
_ = it.Response.(*translatepb.ListModelsResponse) |
| 1017 |
} |
| 1018 |
} |
| 1019 |
|
| 1020 |
func ExampleTranslationClient_RomanizeText() { |
| 1021 |
ctx := context.Background() |
| 1022 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 1023 |
// It will require modifications to work: |
| 1024 |
// - It may require correct/in-range values for request initialization. |
| 1025 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 1026 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 1027 |
c, err := translate.NewTranslationClient(ctx) |
| 1028 |
if err != nil { |
| 1029 |
// TODO: Handle error. |
| 1030 |
} |
| 1031 |
defer c.Close() |
| 1032 |
|
| 1033 |
req := &translatepb.RomanizeTextRequest{ |
| 1034 |
// TODO: Fill request struct fields. |
| 1035 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#RomanizeTextRequest. |
| 1036 |
} |
| 1037 |
resp, err := c.RomanizeText(ctx, req) |
| 1038 |
if err != nil { |
| 1039 |
// TODO: Handle error. |
| 1040 |
} |
| 1041 |
// TODO: Use resp. |
| 1042 |
_ = resp |
| 1043 |
} |
| 1044 |
|
| 1045 |
func ExampleTranslationClient_TranslateDocument() { |
| 1046 |
ctx := context.Background() |
| 1047 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 1048 |
// It will require modifications to work: |
| 1049 |
// - It may require correct/in-range values for request initialization. |
| 1050 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 1051 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 1052 |
c, err := translate.NewTranslationClient(ctx) |
| 1053 |
if err != nil { |
| 1054 |
// TODO: Handle error. |
| 1055 |
} |
| 1056 |
defer c.Close() |
| 1057 |
|
| 1058 |
req := &translatepb.TranslateDocumentRequest{ |
| 1059 |
// TODO: Fill request struct fields. |
| 1060 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#TranslateDocumentRequest. |
| 1061 |
} |
| 1062 |
resp, err := c.TranslateDocument(ctx, req) |
| 1063 |
if err != nil { |
| 1064 |
// TODO: Handle error. |
| 1065 |
} |
| 1066 |
// TODO: Use resp. |
| 1067 |
_ = resp |
| 1068 |
} |
| 1069 |
|
| 1070 |
func ExampleTranslationClient_TranslateText() { |
| 1071 |
ctx := context.Background() |
| 1072 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 1073 |
// It will require modifications to work: |
| 1074 |
// - It may require correct/in-range values for request initialization. |
| 1075 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 1076 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 1077 |
c, err := translate.NewTranslationClient(ctx) |
| 1078 |
if err != nil { |
| 1079 |
// TODO: Handle error. |
| 1080 |
} |
| 1081 |
defer c.Close() |
| 1082 |
|
| 1083 |
req := &translatepb.TranslateTextRequest{ |
| 1084 |
// TODO: Fill request struct fields. |
| 1085 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#TranslateTextRequest. |
| 1086 |
} |
| 1087 |
resp, err := c.TranslateText(ctx, req) |
| 1088 |
if err != nil { |
| 1089 |
// TODO: Handle error. |
| 1090 |
} |
| 1091 |
// TODO: Use resp. |
| 1092 |
_ = resp |
| 1093 |
} |
| 1094 |
|
| 1095 |
func ExampleTranslationClient_UpdateGlossary() { |
| 1096 |
ctx := context.Background() |
| 1097 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 1098 |
// It will require modifications to work: |
| 1099 |
// - It may require correct/in-range values for request initialization. |
| 1100 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 1101 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 1102 |
c, err := translate.NewTranslationClient(ctx) |
| 1103 |
if err != nil { |
| 1104 |
// TODO: Handle error. |
| 1105 |
} |
| 1106 |
defer c.Close() |
| 1107 |
|
| 1108 |
req := &translatepb.UpdateGlossaryRequest{ |
| 1109 |
// TODO: Fill request struct fields. |
| 1110 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#UpdateGlossaryRequest. |
| 1111 |
} |
| 1112 |
op, err := c.UpdateGlossary(ctx, req) |
| 1113 |
if err != nil { |
| 1114 |
// TODO: Handle error. |
| 1115 |
} |
| 1116 |
|
| 1117 |
resp, err := op.Wait(ctx) |
| 1118 |
if err != nil { |
| 1119 |
// TODO: Handle error. |
| 1120 |
} |
| 1121 |
// TODO: Use resp. |
| 1122 |
_ = resp |
| 1123 |
} |
| 1124 |
|
| 1125 |
func ExampleTranslationClient_UpdateGlossaryEntry() { |
| 1126 |
ctx := context.Background() |
| 1127 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 1128 |
// It will require modifications to work: |
| 1129 |
// - It may require correct/in-range values for request initialization. |
| 1130 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 1131 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 1132 |
c, err := translate.NewTranslationClient(ctx) |
| 1133 |
if err != nil { |
| 1134 |
// TODO: Handle error. |
| 1135 |
} |
| 1136 |
defer c.Close() |
| 1137 |
|
| 1138 |
req := &translatepb.UpdateGlossaryEntryRequest{ |
| 1139 |
// TODO: Fill request struct fields. |
| 1140 |
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#UpdateGlossaryEntryRequest. |
| 1141 |
} |
| 1142 |
resp, err := c.UpdateGlossaryEntry(ctx, req) |
| 1143 |
if err != nil { |
| 1144 |
// TODO: Handle error. |
| 1145 |
} |
| 1146 |
// TODO: Use resp. |
| 1147 |
_ = resp |
| 1148 |
} |
| 1149 |
|
| 1150 |
func ExampleTranslationClient_GetLocation() { |
| 1151 |
ctx := context.Background() |
| 1152 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 1153 |
// It will require modifications to work: |
| 1154 |
// - It may require correct/in-range values for request initialization. |
| 1155 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 1156 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 1157 |
c, err := translate.NewTranslationClient(ctx) |
| 1158 |
if err != nil { |
| 1159 |
// TODO: Handle error. |
| 1160 |
} |
| 1161 |
defer c.Close() |
| 1162 |
|
| 1163 |
req := &locationpb.GetLocationRequest{ |
| 1164 |
// TODO: Fill request struct fields. |
| 1165 |
// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. |
| 1166 |
} |
| 1167 |
resp, err := c.GetLocation(ctx, req) |
| 1168 |
if err != nil { |
| 1169 |
// TODO: Handle error. |
| 1170 |
} |
| 1171 |
// TODO: Use resp. |
| 1172 |
_ = resp |
| 1173 |
} |
| 1174 |
|
| 1175 |
func ExampleTranslationClient_ListLocations() { |
| 1176 |
ctx := context.Background() |
| 1177 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 1178 |
// It will require modifications to work: |
| 1179 |
// - It may require correct/in-range values for request initialization. |
| 1180 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 1181 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 1182 |
c, err := translate.NewTranslationClient(ctx) |
| 1183 |
if err != nil { |
| 1184 |
// TODO: Handle error. |
| 1185 |
} |
| 1186 |
defer c.Close() |
| 1187 |
|
| 1188 |
req := &locationpb.ListLocationsRequest{ |
| 1189 |
// TODO: Fill request struct fields. |
| 1190 |
// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. |
| 1191 |
} |
| 1192 |
it := c.ListLocations(ctx, req) |
| 1193 |
for { |
| 1194 |
resp, err := it.Next() |
| 1195 |
if err == iterator.Done { |
| 1196 |
break |
| 1197 |
} |
| 1198 |
if err != nil { |
| 1199 |
// TODO: Handle error. |
| 1200 |
} |
| 1201 |
// TODO: Use resp. |
| 1202 |
_ = resp |
| 1203 |
|
| 1204 |
// If you need to access the underlying RPC response, |
| 1205 |
// you can do so by casting the `Response` as below. |
| 1206 |
// Otherwise, remove this line. Only populated after |
| 1207 |
// first call to Next(). Not safe for concurrent access. |
| 1208 |
_ = it.Response.(*locationpb.ListLocationsResponse) |
| 1209 |
} |
| 1210 |
} |
| 1211 |
|
| 1212 |
func ExampleTranslationClient_CancelOperation() { |
| 1213 |
ctx := context.Background() |
| 1214 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 1215 |
// It will require modifications to work: |
| 1216 |
// - It may require correct/in-range values for request initialization. |
| 1217 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 1218 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 1219 |
c, err := translate.NewTranslationClient(ctx) |
| 1220 |
if err != nil { |
| 1221 |
// TODO: Handle error. |
| 1222 |
} |
| 1223 |
defer c.Close() |
| 1224 |
|
| 1225 |
req := &longrunningpb.CancelOperationRequest{ |
| 1226 |
// TODO: Fill request struct fields. |
| 1227 |
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest. |
| 1228 |
} |
| 1229 |
err = c.CancelOperation(ctx, req) |
| 1230 |
if err != nil { |
| 1231 |
// TODO: Handle error. |
| 1232 |
} |
| 1233 |
} |
| 1234 |
|
| 1235 |
func ExampleTranslationClient_DeleteOperation() { |
| 1236 |
ctx := context.Background() |
| 1237 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 1238 |
// It will require modifications to work: |
| 1239 |
// - It may require correct/in-range values for request initialization. |
| 1240 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 1241 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 1242 |
c, err := translate.NewTranslationClient(ctx) |
| 1243 |
if err != nil { |
| 1244 |
// TODO: Handle error. |
| 1245 |
} |
| 1246 |
defer c.Close() |
| 1247 |
|
| 1248 |
req := &longrunningpb.DeleteOperationRequest{ |
| 1249 |
// TODO: Fill request struct fields. |
| 1250 |
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest. |
| 1251 |
} |
| 1252 |
err = c.DeleteOperation(ctx, req) |
| 1253 |
if err != nil { |
| 1254 |
// TODO: Handle error. |
| 1255 |
} |
| 1256 |
} |
| 1257 |
|
| 1258 |
func ExampleTranslationClient_GetOperation() { |
| 1259 |
ctx := context.Background() |
| 1260 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 1261 |
// It will require modifications to work: |
| 1262 |
// - It may require correct/in-range values for request initialization. |
| 1263 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 1264 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 1265 |
c, err := translate.NewTranslationClient(ctx) |
| 1266 |
if err != nil { |
| 1267 |
// TODO: Handle error. |
| 1268 |
} |
| 1269 |
defer c.Close() |
| 1270 |
|
| 1271 |
req := &longrunningpb.GetOperationRequest{ |
| 1272 |
// TODO: Fill request struct fields. |
| 1273 |
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. |
| 1274 |
} |
| 1275 |
resp, err := c.GetOperation(ctx, req) |
| 1276 |
if err != nil { |
| 1277 |
// TODO: Handle error. |
| 1278 |
} |
| 1279 |
// TODO: Use resp. |
| 1280 |
_ = resp |
| 1281 |
} |
| 1282 |
|
| 1283 |
func ExampleTranslationClient_ListOperations() { |
| 1284 |
ctx := context.Background() |
| 1285 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 1286 |
// It will require modifications to work: |
| 1287 |
// - It may require correct/in-range values for request initialization. |
| 1288 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 1289 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 1290 |
c, err := translate.NewTranslationClient(ctx) |
| 1291 |
if err != nil { |
| 1292 |
// TODO: Handle error. |
| 1293 |
} |
| 1294 |
defer c.Close() |
| 1295 |
|
| 1296 |
req := &longrunningpb.ListOperationsRequest{ |
| 1297 |
// TODO: Fill request struct fields. |
| 1298 |
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. |
| 1299 |
} |
| 1300 |
it := c.ListOperations(ctx, req) |
| 1301 |
for { |
| 1302 |
resp, err := it.Next() |
| 1303 |
if err == iterator.Done { |
| 1304 |
break |
| 1305 |
} |
| 1306 |
if err != nil { |
| 1307 |
// TODO: Handle error. |
| 1308 |
} |
| 1309 |
// TODO: Use resp. |
| 1310 |
_ = resp |
| 1311 |
|
| 1312 |
// If you need to access the underlying RPC response, |
| 1313 |
// you can do so by casting the `Response` as below. |
| 1314 |
// Otherwise, remove this line. Only populated after |
| 1315 |
// first call to Next(). Not safe for concurrent access. |
| 1316 |
_ = it.Response.(*longrunningpb.ListOperationsResponse) |
| 1317 |
} |
| 1318 |
} |
| 1319 |
|
| 1320 |
func ExampleTranslationClient_WaitOperation() { |
| 1321 |
ctx := context.Background() |
| 1322 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 1323 |
// It will require modifications to work: |
| 1324 |
// - It may require correct/in-range values for request initialization. |
| 1325 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 1326 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 1327 |
c, err := translate.NewTranslationClient(ctx) |
| 1328 |
if err != nil { |
| 1329 |
// TODO: Handle error. |
| 1330 |
} |
| 1331 |
defer c.Close() |
| 1332 |
|
| 1333 |
req := &longrunningpb.WaitOperationRequest{ |
| 1334 |
// TODO: Fill request struct fields. |
| 1335 |
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#WaitOperationRequest. |
| 1336 |
} |
| 1337 |
resp, err := c.WaitOperation(ctx, req) |
| 1338 |
if err != nil { |
| 1339 |
// TODO: Handle error. |
| 1340 |
} |
| 1341 |
// TODO: Use resp. |
| 1342 |
_ = resp |
| 1343 |
} |