cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/model_client_example_test.go (about) 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 aiplatform_test 18 19 import ( 20 "context" 21 22 aiplatform "cloud.google.com/go/aiplatform/apiv1beta1" 23 aiplatformpb "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb" 24 iampb "cloud.google.com/go/iam/apiv1/iampb" 25 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" 26 "google.golang.org/api/iterator" 27 locationpb "google.golang.org/genproto/googleapis/cloud/location" 28 ) 29 30 func ExampleNewModelClient() { 31 ctx := context.Background() 32 // This snippet has been automatically generated and should be regarded as a code template only. 33 // It will require modifications to work: 34 // - It may require correct/in-range values for request initialization. 35 // - It may require specifying regional endpoints when creating the service client as shown in: 36 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 37 c, err := aiplatform.NewModelClient(ctx) 38 if err != nil { 39 // TODO: Handle error. 40 } 41 defer c.Close() 42 43 // TODO: Use client. 44 _ = c 45 } 46 47 func ExampleNewModelRESTClient() { 48 ctx := context.Background() 49 // This snippet has been automatically generated and should be regarded as a code template only. 50 // It will require modifications to work: 51 // - It may require correct/in-range values for request initialization. 52 // - It may require specifying regional endpoints when creating the service client as shown in: 53 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 54 c, err := aiplatform.NewModelRESTClient(ctx) 55 if err != nil { 56 // TODO: Handle error. 57 } 58 defer c.Close() 59 60 // TODO: Use client. 61 _ = c 62 } 63 64 func ExampleModelClient_BatchImportEvaluatedAnnotations() { 65 ctx := context.Background() 66 // This snippet has been automatically generated and should be regarded as a code template only. 67 // It will require modifications to work: 68 // - It may require correct/in-range values for request initialization. 69 // - It may require specifying regional endpoints when creating the service client as shown in: 70 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 71 c, err := aiplatform.NewModelClient(ctx) 72 if err != nil { 73 // TODO: Handle error. 74 } 75 defer c.Close() 76 77 req := &aiplatformpb.BatchImportEvaluatedAnnotationsRequest{ 78 // TODO: Fill request struct fields. 79 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#BatchImportEvaluatedAnnotationsRequest. 80 } 81 resp, err := c.BatchImportEvaluatedAnnotations(ctx, req) 82 if err != nil { 83 // TODO: Handle error. 84 } 85 // TODO: Use resp. 86 _ = resp 87 } 88 89 func ExampleModelClient_BatchImportModelEvaluationSlices() { 90 ctx := context.Background() 91 // This snippet has been automatically generated and should be regarded as a code template only. 92 // It will require modifications to work: 93 // - It may require correct/in-range values for request initialization. 94 // - It may require specifying regional endpoints when creating the service client as shown in: 95 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 96 c, err := aiplatform.NewModelClient(ctx) 97 if err != nil { 98 // TODO: Handle error. 99 } 100 defer c.Close() 101 102 req := &aiplatformpb.BatchImportModelEvaluationSlicesRequest{ 103 // TODO: Fill request struct fields. 104 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#BatchImportModelEvaluationSlicesRequest. 105 } 106 resp, err := c.BatchImportModelEvaluationSlices(ctx, req) 107 if err != nil { 108 // TODO: Handle error. 109 } 110 // TODO: Use resp. 111 _ = resp 112 } 113 114 func ExampleModelClient_CopyModel() { 115 ctx := context.Background() 116 // This snippet has been automatically generated and should be regarded as a code template only. 117 // It will require modifications to work: 118 // - It may require correct/in-range values for request initialization. 119 // - It may require specifying regional endpoints when creating the service client as shown in: 120 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 121 c, err := aiplatform.NewModelClient(ctx) 122 if err != nil { 123 // TODO: Handle error. 124 } 125 defer c.Close() 126 127 req := &aiplatformpb.CopyModelRequest{ 128 // TODO: Fill request struct fields. 129 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#CopyModelRequest. 130 } 131 op, err := c.CopyModel(ctx, req) 132 if err != nil { 133 // TODO: Handle error. 134 } 135 136 resp, err := op.Wait(ctx) 137 if err != nil { 138 // TODO: Handle error. 139 } 140 // TODO: Use resp. 141 _ = resp 142 } 143 144 func ExampleModelClient_DeleteModel() { 145 ctx := context.Background() 146 // This snippet has been automatically generated and should be regarded as a code template only. 147 // It will require modifications to work: 148 // - It may require correct/in-range values for request initialization. 149 // - It may require specifying regional endpoints when creating the service client as shown in: 150 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 151 c, err := aiplatform.NewModelClient(ctx) 152 if err != nil { 153 // TODO: Handle error. 154 } 155 defer c.Close() 156 157 req := &aiplatformpb.DeleteModelRequest{ 158 // TODO: Fill request struct fields. 159 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#DeleteModelRequest. 160 } 161 op, err := c.DeleteModel(ctx, req) 162 if err != nil { 163 // TODO: Handle error. 164 } 165 166 err = op.Wait(ctx) 167 if err != nil { 168 // TODO: Handle error. 169 } 170 } 171 172 func ExampleModelClient_DeleteModelVersion() { 173 ctx := context.Background() 174 // This snippet has been automatically generated and should be regarded as a code template only. 175 // It will require modifications to work: 176 // - It may require correct/in-range values for request initialization. 177 // - It may require specifying regional endpoints when creating the service client as shown in: 178 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 179 c, err := aiplatform.NewModelClient(ctx) 180 if err != nil { 181 // TODO: Handle error. 182 } 183 defer c.Close() 184 185 req := &aiplatformpb.DeleteModelVersionRequest{ 186 // TODO: Fill request struct fields. 187 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#DeleteModelVersionRequest. 188 } 189 op, err := c.DeleteModelVersion(ctx, req) 190 if err != nil { 191 // TODO: Handle error. 192 } 193 194 err = op.Wait(ctx) 195 if err != nil { 196 // TODO: Handle error. 197 } 198 } 199 200 func ExampleModelClient_ExportModel() { 201 ctx := context.Background() 202 // This snippet has been automatically generated and should be regarded as a code template only. 203 // It will require modifications to work: 204 // - It may require correct/in-range values for request initialization. 205 // - It may require specifying regional endpoints when creating the service client as shown in: 206 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 207 c, err := aiplatform.NewModelClient(ctx) 208 if err != nil { 209 // TODO: Handle error. 210 } 211 defer c.Close() 212 213 req := &aiplatformpb.ExportModelRequest{ 214 // TODO: Fill request struct fields. 215 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#ExportModelRequest. 216 } 217 op, err := c.ExportModel(ctx, req) 218 if err != nil { 219 // TODO: Handle error. 220 } 221 222 resp, err := op.Wait(ctx) 223 if err != nil { 224 // TODO: Handle error. 225 } 226 // TODO: Use resp. 227 _ = resp 228 } 229 230 func ExampleModelClient_GetModel() { 231 ctx := context.Background() 232 // This snippet has been automatically generated and should be regarded as a code template only. 233 // It will require modifications to work: 234 // - It may require correct/in-range values for request initialization. 235 // - It may require specifying regional endpoints when creating the service client as shown in: 236 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 237 c, err := aiplatform.NewModelClient(ctx) 238 if err != nil { 239 // TODO: Handle error. 240 } 241 defer c.Close() 242 243 req := &aiplatformpb.GetModelRequest{ 244 // TODO: Fill request struct fields. 245 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#GetModelRequest. 246 } 247 resp, err := c.GetModel(ctx, req) 248 if err != nil { 249 // TODO: Handle error. 250 } 251 // TODO: Use resp. 252 _ = resp 253 } 254 255 func ExampleModelClient_GetModelEvaluation() { 256 ctx := context.Background() 257 // This snippet has been automatically generated and should be regarded as a code template only. 258 // It will require modifications to work: 259 // - It may require correct/in-range values for request initialization. 260 // - It may require specifying regional endpoints when creating the service client as shown in: 261 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 262 c, err := aiplatform.NewModelClient(ctx) 263 if err != nil { 264 // TODO: Handle error. 265 } 266 defer c.Close() 267 268 req := &aiplatformpb.GetModelEvaluationRequest{ 269 // TODO: Fill request struct fields. 270 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#GetModelEvaluationRequest. 271 } 272 resp, err := c.GetModelEvaluation(ctx, req) 273 if err != nil { 274 // TODO: Handle error. 275 } 276 // TODO: Use resp. 277 _ = resp 278 } 279 280 func ExampleModelClient_GetModelEvaluationSlice() { 281 ctx := context.Background() 282 // This snippet has been automatically generated and should be regarded as a code template only. 283 // It will require modifications to work: 284 // - It may require correct/in-range values for request initialization. 285 // - It may require specifying regional endpoints when creating the service client as shown in: 286 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 287 c, err := aiplatform.NewModelClient(ctx) 288 if err != nil { 289 // TODO: Handle error. 290 } 291 defer c.Close() 292 293 req := &aiplatformpb.GetModelEvaluationSliceRequest{ 294 // TODO: Fill request struct fields. 295 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#GetModelEvaluationSliceRequest. 296 } 297 resp, err := c.GetModelEvaluationSlice(ctx, req) 298 if err != nil { 299 // TODO: Handle error. 300 } 301 // TODO: Use resp. 302 _ = resp 303 } 304 305 func ExampleModelClient_ImportModelEvaluation() { 306 ctx := context.Background() 307 // This snippet has been automatically generated and should be regarded as a code template only. 308 // It will require modifications to work: 309 // - It may require correct/in-range values for request initialization. 310 // - It may require specifying regional endpoints when creating the service client as shown in: 311 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 312 c, err := aiplatform.NewModelClient(ctx) 313 if err != nil { 314 // TODO: Handle error. 315 } 316 defer c.Close() 317 318 req := &aiplatformpb.ImportModelEvaluationRequest{ 319 // TODO: Fill request struct fields. 320 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#ImportModelEvaluationRequest. 321 } 322 resp, err := c.ImportModelEvaluation(ctx, req) 323 if err != nil { 324 // TODO: Handle error. 325 } 326 // TODO: Use resp. 327 _ = resp 328 } 329 330 func ExampleModelClient_ListModelEvaluationSlices() { 331 ctx := context.Background() 332 // This snippet has been automatically generated and should be regarded as a code template only. 333 // It will require modifications to work: 334 // - It may require correct/in-range values for request initialization. 335 // - It may require specifying regional endpoints when creating the service client as shown in: 336 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 337 c, err := aiplatform.NewModelClient(ctx) 338 if err != nil { 339 // TODO: Handle error. 340 } 341 defer c.Close() 342 343 req := &aiplatformpb.ListModelEvaluationSlicesRequest{ 344 // TODO: Fill request struct fields. 345 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#ListModelEvaluationSlicesRequest. 346 } 347 it := c.ListModelEvaluationSlices(ctx, req) 348 for { 349 resp, err := it.Next() 350 if err == iterator.Done { 351 break 352 } 353 if err != nil { 354 // TODO: Handle error. 355 } 356 // TODO: Use resp. 357 _ = resp 358 359 // If you need to access the underlying RPC response, 360 // you can do so by casting the `Response` as below. 361 // Otherwise, remove this line. Only populated after 362 // first call to Next(). Not safe for concurrent access. 363 _ = it.Response.(*aiplatformpb.ListModelEvaluationSlicesResponse) 364 } 365 } 366 367 func ExampleModelClient_ListModelEvaluations() { 368 ctx := context.Background() 369 // This snippet has been automatically generated and should be regarded as a code template only. 370 // It will require modifications to work: 371 // - It may require correct/in-range values for request initialization. 372 // - It may require specifying regional endpoints when creating the service client as shown in: 373 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 374 c, err := aiplatform.NewModelClient(ctx) 375 if err != nil { 376 // TODO: Handle error. 377 } 378 defer c.Close() 379 380 req := &aiplatformpb.ListModelEvaluationsRequest{ 381 // TODO: Fill request struct fields. 382 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#ListModelEvaluationsRequest. 383 } 384 it := c.ListModelEvaluations(ctx, req) 385 for { 386 resp, err := it.Next() 387 if err == iterator.Done { 388 break 389 } 390 if err != nil { 391 // TODO: Handle error. 392 } 393 // TODO: Use resp. 394 _ = resp 395 396 // If you need to access the underlying RPC response, 397 // you can do so by casting the `Response` as below. 398 // Otherwise, remove this line. Only populated after 399 // first call to Next(). Not safe for concurrent access. 400 _ = it.Response.(*aiplatformpb.ListModelEvaluationsResponse) 401 } 402 } 403 404 func ExampleModelClient_ListModelVersionCheckpoints() { 405 ctx := context.Background() 406 // This snippet has been automatically generated and should be regarded as a code template only. 407 // It will require modifications to work: 408 // - It may require correct/in-range values for request initialization. 409 // - It may require specifying regional endpoints when creating the service client as shown in: 410 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 411 c, err := aiplatform.NewModelClient(ctx) 412 if err != nil { 413 // TODO: Handle error. 414 } 415 defer c.Close() 416 417 req := &aiplatformpb.ListModelVersionCheckpointsRequest{ 418 // TODO: Fill request struct fields. 419 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#ListModelVersionCheckpointsRequest. 420 } 421 it := c.ListModelVersionCheckpoints(ctx, req) 422 for { 423 resp, err := it.Next() 424 if err == iterator.Done { 425 break 426 } 427 if err != nil { 428 // TODO: Handle error. 429 } 430 // TODO: Use resp. 431 _ = resp 432 433 // If you need to access the underlying RPC response, 434 // you can do so by casting the `Response` as below. 435 // Otherwise, remove this line. Only populated after 436 // first call to Next(). Not safe for concurrent access. 437 _ = it.Response.(*aiplatformpb.ListModelVersionCheckpointsResponse) 438 } 439 } 440 441 func ExampleModelClient_ListModelVersions() { 442 ctx := context.Background() 443 // This snippet has been automatically generated and should be regarded as a code template only. 444 // It will require modifications to work: 445 // - It may require correct/in-range values for request initialization. 446 // - It may require specifying regional endpoints when creating the service client as shown in: 447 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 448 c, err := aiplatform.NewModelClient(ctx) 449 if err != nil { 450 // TODO: Handle error. 451 } 452 defer c.Close() 453 454 req := &aiplatformpb.ListModelVersionsRequest{ 455 // TODO: Fill request struct fields. 456 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#ListModelVersionsRequest. 457 } 458 it := c.ListModelVersions(ctx, req) 459 for { 460 resp, err := it.Next() 461 if err == iterator.Done { 462 break 463 } 464 if err != nil { 465 // TODO: Handle error. 466 } 467 // TODO: Use resp. 468 _ = resp 469 470 // If you need to access the underlying RPC response, 471 // you can do so by casting the `Response` as below. 472 // Otherwise, remove this line. Only populated after 473 // first call to Next(). Not safe for concurrent access. 474 _ = it.Response.(*aiplatformpb.ListModelVersionsResponse) 475 } 476 } 477 478 func ExampleModelClient_ListModels() { 479 ctx := context.Background() 480 // This snippet has been automatically generated and should be regarded as a code template only. 481 // It will require modifications to work: 482 // - It may require correct/in-range values for request initialization. 483 // - It may require specifying regional endpoints when creating the service client as shown in: 484 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 485 c, err := aiplatform.NewModelClient(ctx) 486 if err != nil { 487 // TODO: Handle error. 488 } 489 defer c.Close() 490 491 req := &aiplatformpb.ListModelsRequest{ 492 // TODO: Fill request struct fields. 493 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#ListModelsRequest. 494 } 495 it := c.ListModels(ctx, req) 496 for { 497 resp, err := it.Next() 498 if err == iterator.Done { 499 break 500 } 501 if err != nil { 502 // TODO: Handle error. 503 } 504 // TODO: Use resp. 505 _ = resp 506 507 // If you need to access the underlying RPC response, 508 // you can do so by casting the `Response` as below. 509 // Otherwise, remove this line. Only populated after 510 // first call to Next(). Not safe for concurrent access. 511 _ = it.Response.(*aiplatformpb.ListModelsResponse) 512 } 513 } 514 515 func ExampleModelClient_MergeVersionAliases() { 516 ctx := context.Background() 517 // This snippet has been automatically generated and should be regarded as a code template only. 518 // It will require modifications to work: 519 // - It may require correct/in-range values for request initialization. 520 // - It may require specifying regional endpoints when creating the service client as shown in: 521 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 522 c, err := aiplatform.NewModelClient(ctx) 523 if err != nil { 524 // TODO: Handle error. 525 } 526 defer c.Close() 527 528 req := &aiplatformpb.MergeVersionAliasesRequest{ 529 // TODO: Fill request struct fields. 530 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#MergeVersionAliasesRequest. 531 } 532 resp, err := c.MergeVersionAliases(ctx, req) 533 if err != nil { 534 // TODO: Handle error. 535 } 536 // TODO: Use resp. 537 _ = resp 538 } 539 540 func ExampleModelClient_RecommendSpec() { 541 ctx := context.Background() 542 // This snippet has been automatically generated and should be regarded as a code template only. 543 // It will require modifications to work: 544 // - It may require correct/in-range values for request initialization. 545 // - It may require specifying regional endpoints when creating the service client as shown in: 546 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 547 c, err := aiplatform.NewModelClient(ctx) 548 if err != nil { 549 // TODO: Handle error. 550 } 551 defer c.Close() 552 553 req := &aiplatformpb.RecommendSpecRequest{ 554 // TODO: Fill request struct fields. 555 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#RecommendSpecRequest. 556 } 557 resp, err := c.RecommendSpec(ctx, req) 558 if err != nil { 559 // TODO: Handle error. 560 } 561 // TODO: Use resp. 562 _ = resp 563 } 564 565 func ExampleModelClient_UpdateExplanationDataset() { 566 ctx := context.Background() 567 // This snippet has been automatically generated and should be regarded as a code template only. 568 // It will require modifications to work: 569 // - It may require correct/in-range values for request initialization. 570 // - It may require specifying regional endpoints when creating the service client as shown in: 571 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 572 c, err := aiplatform.NewModelClient(ctx) 573 if err != nil { 574 // TODO: Handle error. 575 } 576 defer c.Close() 577 578 req := &aiplatformpb.UpdateExplanationDatasetRequest{ 579 // TODO: Fill request struct fields. 580 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#UpdateExplanationDatasetRequest. 581 } 582 op, err := c.UpdateExplanationDataset(ctx, req) 583 if err != nil { 584 // TODO: Handle error. 585 } 586 587 resp, err := op.Wait(ctx) 588 if err != nil { 589 // TODO: Handle error. 590 } 591 // TODO: Use resp. 592 _ = resp 593 } 594 595 func ExampleModelClient_UpdateModel() { 596 ctx := context.Background() 597 // This snippet has been automatically generated and should be regarded as a code template only. 598 // It will require modifications to work: 599 // - It may require correct/in-range values for request initialization. 600 // - It may require specifying regional endpoints when creating the service client as shown in: 601 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 602 c, err := aiplatform.NewModelClient(ctx) 603 if err != nil { 604 // TODO: Handle error. 605 } 606 defer c.Close() 607 608 req := &aiplatformpb.UpdateModelRequest{ 609 // TODO: Fill request struct fields. 610 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#UpdateModelRequest. 611 } 612 resp, err := c.UpdateModel(ctx, req) 613 if err != nil { 614 // TODO: Handle error. 615 } 616 // TODO: Use resp. 617 _ = resp 618 } 619 620 func ExampleModelClient_UploadModel() { 621 ctx := context.Background() 622 // This snippet has been automatically generated and should be regarded as a code template only. 623 // It will require modifications to work: 624 // - It may require correct/in-range values for request initialization. 625 // - It may require specifying regional endpoints when creating the service client as shown in: 626 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 627 c, err := aiplatform.NewModelClient(ctx) 628 if err != nil { 629 // TODO: Handle error. 630 } 631 defer c.Close() 632 633 req := &aiplatformpb.UploadModelRequest{ 634 // TODO: Fill request struct fields. 635 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#UploadModelRequest. 636 } 637 op, err := c.UploadModel(ctx, req) 638 if err != nil { 639 // TODO: Handle error. 640 } 641 642 resp, err := op.Wait(ctx) 643 if err != nil { 644 // TODO: Handle error. 645 } 646 // TODO: Use resp. 647 _ = resp 648 } 649 650 func ExampleModelClient_GetLocation() { 651 ctx := context.Background() 652 // This snippet has been automatically generated and should be regarded as a code template only. 653 // It will require modifications to work: 654 // - It may require correct/in-range values for request initialization. 655 // - It may require specifying regional endpoints when creating the service client as shown in: 656 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 657 c, err := aiplatform.NewModelClient(ctx) 658 if err != nil { 659 // TODO: Handle error. 660 } 661 defer c.Close() 662 663 req := &locationpb.GetLocationRequest{ 664 // TODO: Fill request struct fields. 665 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. 666 } 667 resp, err := c.GetLocation(ctx, req) 668 if err != nil { 669 // TODO: Handle error. 670 } 671 // TODO: Use resp. 672 _ = resp 673 } 674 675 func ExampleModelClient_ListLocations() { 676 ctx := context.Background() 677 // This snippet has been automatically generated and should be regarded as a code template only. 678 // It will require modifications to work: 679 // - It may require correct/in-range values for request initialization. 680 // - It may require specifying regional endpoints when creating the service client as shown in: 681 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 682 c, err := aiplatform.NewModelClient(ctx) 683 if err != nil { 684 // TODO: Handle error. 685 } 686 defer c.Close() 687 688 req := &locationpb.ListLocationsRequest{ 689 // TODO: Fill request struct fields. 690 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. 691 } 692 it := c.ListLocations(ctx, req) 693 for { 694 resp, err := it.Next() 695 if err == iterator.Done { 696 break 697 } 698 if err != nil { 699 // TODO: Handle error. 700 } 701 // TODO: Use resp. 702 _ = resp 703 704 // If you need to access the underlying RPC response, 705 // you can do so by casting the `Response` as below. 706 // Otherwise, remove this line. Only populated after 707 // first call to Next(). Not safe for concurrent access. 708 _ = it.Response.(*locationpb.ListLocationsResponse) 709 } 710 } 711 712 func ExampleModelClient_GetIamPolicy() { 713 ctx := context.Background() 714 // This snippet has been automatically generated and should be regarded as a code template only. 715 // It will require modifications to work: 716 // - It may require correct/in-range values for request initialization. 717 // - It may require specifying regional endpoints when creating the service client as shown in: 718 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 719 c, err := aiplatform.NewModelClient(ctx) 720 if err != nil { 721 // TODO: Handle error. 722 } 723 defer c.Close() 724 725 req := &iampb.GetIamPolicyRequest{ 726 // TODO: Fill request struct fields. 727 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest. 728 } 729 resp, err := c.GetIamPolicy(ctx, req) 730 if err != nil { 731 // TODO: Handle error. 732 } 733 // TODO: Use resp. 734 _ = resp 735 } 736 737 func ExampleModelClient_SetIamPolicy() { 738 ctx := context.Background() 739 // This snippet has been automatically generated and should be regarded as a code template only. 740 // It will require modifications to work: 741 // - It may require correct/in-range values for request initialization. 742 // - It may require specifying regional endpoints when creating the service client as shown in: 743 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 744 c, err := aiplatform.NewModelClient(ctx) 745 if err != nil { 746 // TODO: Handle error. 747 } 748 defer c.Close() 749 750 req := &iampb.SetIamPolicyRequest{ 751 // TODO: Fill request struct fields. 752 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest. 753 } 754 resp, err := c.SetIamPolicy(ctx, req) 755 if err != nil { 756 // TODO: Handle error. 757 } 758 // TODO: Use resp. 759 _ = resp 760 } 761 762 func ExampleModelClient_TestIamPermissions() { 763 ctx := context.Background() 764 // This snippet has been automatically generated and should be regarded as a code template only. 765 // It will require modifications to work: 766 // - It may require correct/in-range values for request initialization. 767 // - It may require specifying regional endpoints when creating the service client as shown in: 768 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 769 c, err := aiplatform.NewModelClient(ctx) 770 if err != nil { 771 // TODO: Handle error. 772 } 773 defer c.Close() 774 775 req := &iampb.TestIamPermissionsRequest{ 776 // TODO: Fill request struct fields. 777 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest. 778 } 779 resp, err := c.TestIamPermissions(ctx, req) 780 if err != nil { 781 // TODO: Handle error. 782 } 783 // TODO: Use resp. 784 _ = resp 785 } 786 787 func ExampleModelClient_CancelOperation() { 788 ctx := context.Background() 789 // This snippet has been automatically generated and should be regarded as a code template only. 790 // It will require modifications to work: 791 // - It may require correct/in-range values for request initialization. 792 // - It may require specifying regional endpoints when creating the service client as shown in: 793 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 794 c, err := aiplatform.NewModelClient(ctx) 795 if err != nil { 796 // TODO: Handle error. 797 } 798 defer c.Close() 799 800 req := &longrunningpb.CancelOperationRequest{ 801 // TODO: Fill request struct fields. 802 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest. 803 } 804 err = c.CancelOperation(ctx, req) 805 if err != nil { 806 // TODO: Handle error. 807 } 808 } 809 810 func ExampleModelClient_DeleteOperation() { 811 ctx := context.Background() 812 // This snippet has been automatically generated and should be regarded as a code template only. 813 // It will require modifications to work: 814 // - It may require correct/in-range values for request initialization. 815 // - It may require specifying regional endpoints when creating the service client as shown in: 816 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 817 c, err := aiplatform.NewModelClient(ctx) 818 if err != nil { 819 // TODO: Handle error. 820 } 821 defer c.Close() 822 823 req := &longrunningpb.DeleteOperationRequest{ 824 // TODO: Fill request struct fields. 825 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest. 826 } 827 err = c.DeleteOperation(ctx, req) 828 if err != nil { 829 // TODO: Handle error. 830 } 831 } 832 833 func ExampleModelClient_GetOperation() { 834 ctx := context.Background() 835 // This snippet has been automatically generated and should be regarded as a code template only. 836 // It will require modifications to work: 837 // - It may require correct/in-range values for request initialization. 838 // - It may require specifying regional endpoints when creating the service client as shown in: 839 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 840 c, err := aiplatform.NewModelClient(ctx) 841 if err != nil { 842 // TODO: Handle error. 843 } 844 defer c.Close() 845 846 req := &longrunningpb.GetOperationRequest{ 847 // TODO: Fill request struct fields. 848 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. 849 } 850 resp, err := c.GetOperation(ctx, req) 851 if err != nil { 852 // TODO: Handle error. 853 } 854 // TODO: Use resp. 855 _ = resp 856 } 857 858 func ExampleModelClient_ListOperations() { 859 ctx := context.Background() 860 // This snippet has been automatically generated and should be regarded as a code template only. 861 // It will require modifications to work: 862 // - It may require correct/in-range values for request initialization. 863 // - It may require specifying regional endpoints when creating the service client as shown in: 864 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 865 c, err := aiplatform.NewModelClient(ctx) 866 if err != nil { 867 // TODO: Handle error. 868 } 869 defer c.Close() 870 871 req := &longrunningpb.ListOperationsRequest{ 872 // TODO: Fill request struct fields. 873 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. 874 } 875 it := c.ListOperations(ctx, req) 876 for { 877 resp, err := it.Next() 878 if err == iterator.Done { 879 break 880 } 881 if err != nil { 882 // TODO: Handle error. 883 } 884 // TODO: Use resp. 885 _ = resp 886 887 // If you need to access the underlying RPC response, 888 // you can do so by casting the `Response` as below. 889 // Otherwise, remove this line. Only populated after 890 // first call to Next(). Not safe for concurrent access. 891 _ = it.Response.(*longrunningpb.ListOperationsResponse) 892 } 893 } 894 895 func ExampleModelClient_WaitOperation() { 896 ctx := context.Background() 897 // This snippet has been automatically generated and should be regarded as a code template only. 898 // It will require modifications to work: 899 // - It may require correct/in-range values for request initialization. 900 // - It may require specifying regional endpoints when creating the service client as shown in: 901 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 902 c, err := aiplatform.NewModelClient(ctx) 903 if err != nil { 904 // TODO: Handle error. 905 } 906 defer c.Close() 907 908 req := &longrunningpb.WaitOperationRequest{ 909 // TODO: Fill request struct fields. 910 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#WaitOperationRequest. 911 } 912 resp, err := c.WaitOperation(ctx, req) 913 if err != nil { 914 // TODO: Handle error. 915 } 916 // TODO: Use resp. 917 _ = resp 918 }