cloud.google.com/go/aiplatform@v1.106.0/apiv1/feature_registry_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/apiv1" 23 aiplatformpb "cloud.google.com/go/aiplatform/apiv1/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 ExampleNewFeatureRegistryClient() { 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.NewFeatureRegistryClient(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 ExampleFeatureRegistryClient_BatchCreateFeatures() { 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.NewFeatureRegistryClient(ctx) 55 if err != nil { 56 // TODO: Handle error. 57 } 58 defer c.Close() 59 60 req := &aiplatformpb.BatchCreateFeaturesRequest{ 61 // TODO: Fill request struct fields. 62 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#BatchCreateFeaturesRequest. 63 } 64 op, err := c.BatchCreateFeatures(ctx, req) 65 if err != nil { 66 // TODO: Handle error. 67 } 68 69 resp, err := op.Wait(ctx) 70 if err != nil { 71 // TODO: Handle error. 72 } 73 // TODO: Use resp. 74 _ = resp 75 } 76 77 func ExampleFeatureRegistryClient_CreateFeature() { 78 ctx := context.Background() 79 // This snippet has been automatically generated and should be regarded as a code template only. 80 // It will require modifications to work: 81 // - It may require correct/in-range values for request initialization. 82 // - It may require specifying regional endpoints when creating the service client as shown in: 83 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 84 c, err := aiplatform.NewFeatureRegistryClient(ctx) 85 if err != nil { 86 // TODO: Handle error. 87 } 88 defer c.Close() 89 90 req := &aiplatformpb.CreateFeatureRequest{ 91 // TODO: Fill request struct fields. 92 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#CreateFeatureRequest. 93 } 94 op, err := c.CreateFeature(ctx, req) 95 if err != nil { 96 // TODO: Handle error. 97 } 98 99 resp, err := op.Wait(ctx) 100 if err != nil { 101 // TODO: Handle error. 102 } 103 // TODO: Use resp. 104 _ = resp 105 } 106 107 func ExampleFeatureRegistryClient_CreateFeatureGroup() { 108 ctx := context.Background() 109 // This snippet has been automatically generated and should be regarded as a code template only. 110 // It will require modifications to work: 111 // - It may require correct/in-range values for request initialization. 112 // - It may require specifying regional endpoints when creating the service client as shown in: 113 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 114 c, err := aiplatform.NewFeatureRegistryClient(ctx) 115 if err != nil { 116 // TODO: Handle error. 117 } 118 defer c.Close() 119 120 req := &aiplatformpb.CreateFeatureGroupRequest{ 121 // TODO: Fill request struct fields. 122 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#CreateFeatureGroupRequest. 123 } 124 op, err := c.CreateFeatureGroup(ctx, req) 125 if err != nil { 126 // TODO: Handle error. 127 } 128 129 resp, err := op.Wait(ctx) 130 if err != nil { 131 // TODO: Handle error. 132 } 133 // TODO: Use resp. 134 _ = resp 135 } 136 137 func ExampleFeatureRegistryClient_DeleteFeature() { 138 ctx := context.Background() 139 // This snippet has been automatically generated and should be regarded as a code template only. 140 // It will require modifications to work: 141 // - It may require correct/in-range values for request initialization. 142 // - It may require specifying regional endpoints when creating the service client as shown in: 143 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 144 c, err := aiplatform.NewFeatureRegistryClient(ctx) 145 if err != nil { 146 // TODO: Handle error. 147 } 148 defer c.Close() 149 150 req := &aiplatformpb.DeleteFeatureRequest{ 151 // TODO: Fill request struct fields. 152 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#DeleteFeatureRequest. 153 } 154 op, err := c.DeleteFeature(ctx, req) 155 if err != nil { 156 // TODO: Handle error. 157 } 158 159 err = op.Wait(ctx) 160 if err != nil { 161 // TODO: Handle error. 162 } 163 } 164 165 func ExampleFeatureRegistryClient_DeleteFeatureGroup() { 166 ctx := context.Background() 167 // This snippet has been automatically generated and should be regarded as a code template only. 168 // It will require modifications to work: 169 // - It may require correct/in-range values for request initialization. 170 // - It may require specifying regional endpoints when creating the service client as shown in: 171 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 172 c, err := aiplatform.NewFeatureRegistryClient(ctx) 173 if err != nil { 174 // TODO: Handle error. 175 } 176 defer c.Close() 177 178 req := &aiplatformpb.DeleteFeatureGroupRequest{ 179 // TODO: Fill request struct fields. 180 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#DeleteFeatureGroupRequest. 181 } 182 op, err := c.DeleteFeatureGroup(ctx, req) 183 if err != nil { 184 // TODO: Handle error. 185 } 186 187 err = op.Wait(ctx) 188 if err != nil { 189 // TODO: Handle error. 190 } 191 } 192 193 func ExampleFeatureRegistryClient_GetFeature() { 194 ctx := context.Background() 195 // This snippet has been automatically generated and should be regarded as a code template only. 196 // It will require modifications to work: 197 // - It may require correct/in-range values for request initialization. 198 // - It may require specifying regional endpoints when creating the service client as shown in: 199 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 200 c, err := aiplatform.NewFeatureRegistryClient(ctx) 201 if err != nil { 202 // TODO: Handle error. 203 } 204 defer c.Close() 205 206 req := &aiplatformpb.GetFeatureRequest{ 207 // TODO: Fill request struct fields. 208 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#GetFeatureRequest. 209 } 210 resp, err := c.GetFeature(ctx, req) 211 if err != nil { 212 // TODO: Handle error. 213 } 214 // TODO: Use resp. 215 _ = resp 216 } 217 218 func ExampleFeatureRegistryClient_GetFeatureGroup() { 219 ctx := context.Background() 220 // This snippet has been automatically generated and should be regarded as a code template only. 221 // It will require modifications to work: 222 // - It may require correct/in-range values for request initialization. 223 // - It may require specifying regional endpoints when creating the service client as shown in: 224 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 225 c, err := aiplatform.NewFeatureRegistryClient(ctx) 226 if err != nil { 227 // TODO: Handle error. 228 } 229 defer c.Close() 230 231 req := &aiplatformpb.GetFeatureGroupRequest{ 232 // TODO: Fill request struct fields. 233 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#GetFeatureGroupRequest. 234 } 235 resp, err := c.GetFeatureGroup(ctx, req) 236 if err != nil { 237 // TODO: Handle error. 238 } 239 // TODO: Use resp. 240 _ = resp 241 } 242 243 func ExampleFeatureRegistryClient_ListFeatureGroups() { 244 ctx := context.Background() 245 // This snippet has been automatically generated and should be regarded as a code template only. 246 // It will require modifications to work: 247 // - It may require correct/in-range values for request initialization. 248 // - It may require specifying regional endpoints when creating the service client as shown in: 249 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 250 c, err := aiplatform.NewFeatureRegistryClient(ctx) 251 if err != nil { 252 // TODO: Handle error. 253 } 254 defer c.Close() 255 256 req := &aiplatformpb.ListFeatureGroupsRequest{ 257 // TODO: Fill request struct fields. 258 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#ListFeatureGroupsRequest. 259 } 260 it := c.ListFeatureGroups(ctx, req) 261 for { 262 resp, err := it.Next() 263 if err == iterator.Done { 264 break 265 } 266 if err != nil { 267 // TODO: Handle error. 268 } 269 // TODO: Use resp. 270 _ = resp 271 272 // If you need to access the underlying RPC response, 273 // you can do so by casting the `Response` as below. 274 // Otherwise, remove this line. Only populated after 275 // first call to Next(). Not safe for concurrent access. 276 _ = it.Response.(*aiplatformpb.ListFeatureGroupsResponse) 277 } 278 } 279 280 func ExampleFeatureRegistryClient_ListFeatures() { 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.NewFeatureRegistryClient(ctx) 288 if err != nil { 289 // TODO: Handle error. 290 } 291 defer c.Close() 292 293 req := &aiplatformpb.ListFeaturesRequest{ 294 // TODO: Fill request struct fields. 295 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#ListFeaturesRequest. 296 } 297 it := c.ListFeatures(ctx, req) 298 for { 299 resp, err := it.Next() 300 if err == iterator.Done { 301 break 302 } 303 if err != nil { 304 // TODO: Handle error. 305 } 306 // TODO: Use resp. 307 _ = resp 308 309 // If you need to access the underlying RPC response, 310 // you can do so by casting the `Response` as below. 311 // Otherwise, remove this line. Only populated after 312 // first call to Next(). Not safe for concurrent access. 313 _ = it.Response.(*aiplatformpb.ListFeaturesResponse) 314 } 315 } 316 317 func ExampleFeatureRegistryClient_UpdateFeature() { 318 ctx := context.Background() 319 // This snippet has been automatically generated and should be regarded as a code template only. 320 // It will require modifications to work: 321 // - It may require correct/in-range values for request initialization. 322 // - It may require specifying regional endpoints when creating the service client as shown in: 323 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 324 c, err := aiplatform.NewFeatureRegistryClient(ctx) 325 if err != nil { 326 // TODO: Handle error. 327 } 328 defer c.Close() 329 330 req := &aiplatformpb.UpdateFeatureRequest{ 331 // TODO: Fill request struct fields. 332 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#UpdateFeatureRequest. 333 } 334 op, err := c.UpdateFeature(ctx, req) 335 if err != nil { 336 // TODO: Handle error. 337 } 338 339 resp, err := op.Wait(ctx) 340 if err != nil { 341 // TODO: Handle error. 342 } 343 // TODO: Use resp. 344 _ = resp 345 } 346 347 func ExampleFeatureRegistryClient_UpdateFeatureGroup() { 348 ctx := context.Background() 349 // This snippet has been automatically generated and should be regarded as a code template only. 350 // It will require modifications to work: 351 // - It may require correct/in-range values for request initialization. 352 // - It may require specifying regional endpoints when creating the service client as shown in: 353 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 354 c, err := aiplatform.NewFeatureRegistryClient(ctx) 355 if err != nil { 356 // TODO: Handle error. 357 } 358 defer c.Close() 359 360 req := &aiplatformpb.UpdateFeatureGroupRequest{ 361 // TODO: Fill request struct fields. 362 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#UpdateFeatureGroupRequest. 363 } 364 op, err := c.UpdateFeatureGroup(ctx, req) 365 if err != nil { 366 // TODO: Handle error. 367 } 368 369 resp, err := op.Wait(ctx) 370 if err != nil { 371 // TODO: Handle error. 372 } 373 // TODO: Use resp. 374 _ = resp 375 } 376 377 func ExampleFeatureRegistryClient_GetLocation() { 378 ctx := context.Background() 379 // This snippet has been automatically generated and should be regarded as a code template only. 380 // It will require modifications to work: 381 // - It may require correct/in-range values for request initialization. 382 // - It may require specifying regional endpoints when creating the service client as shown in: 383 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 384 c, err := aiplatform.NewFeatureRegistryClient(ctx) 385 if err != nil { 386 // TODO: Handle error. 387 } 388 defer c.Close() 389 390 req := &locationpb.GetLocationRequest{ 391 // TODO: Fill request struct fields. 392 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. 393 } 394 resp, err := c.GetLocation(ctx, req) 395 if err != nil { 396 // TODO: Handle error. 397 } 398 // TODO: Use resp. 399 _ = resp 400 } 401 402 func ExampleFeatureRegistryClient_ListLocations() { 403 ctx := context.Background() 404 // This snippet has been automatically generated and should be regarded as a code template only. 405 // It will require modifications to work: 406 // - It may require correct/in-range values for request initialization. 407 // - It may require specifying regional endpoints when creating the service client as shown in: 408 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 409 c, err := aiplatform.NewFeatureRegistryClient(ctx) 410 if err != nil { 411 // TODO: Handle error. 412 } 413 defer c.Close() 414 415 req := &locationpb.ListLocationsRequest{ 416 // TODO: Fill request struct fields. 417 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. 418 } 419 it := c.ListLocations(ctx, req) 420 for { 421 resp, err := it.Next() 422 if err == iterator.Done { 423 break 424 } 425 if err != nil { 426 // TODO: Handle error. 427 } 428 // TODO: Use resp. 429 _ = resp 430 431 // If you need to access the underlying RPC response, 432 // you can do so by casting the `Response` as below. 433 // Otherwise, remove this line. Only populated after 434 // first call to Next(). Not safe for concurrent access. 435 _ = it.Response.(*locationpb.ListLocationsResponse) 436 } 437 } 438 439 func ExampleFeatureRegistryClient_GetIamPolicy() { 440 ctx := context.Background() 441 // This snippet has been automatically generated and should be regarded as a code template only. 442 // It will require modifications to work: 443 // - It may require correct/in-range values for request initialization. 444 // - It may require specifying regional endpoints when creating the service client as shown in: 445 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 446 c, err := aiplatform.NewFeatureRegistryClient(ctx) 447 if err != nil { 448 // TODO: Handle error. 449 } 450 defer c.Close() 451 452 req := &iampb.GetIamPolicyRequest{ 453 // TODO: Fill request struct fields. 454 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest. 455 } 456 resp, err := c.GetIamPolicy(ctx, req) 457 if err != nil { 458 // TODO: Handle error. 459 } 460 // TODO: Use resp. 461 _ = resp 462 } 463 464 func ExampleFeatureRegistryClient_SetIamPolicy() { 465 ctx := context.Background() 466 // This snippet has been automatically generated and should be regarded as a code template only. 467 // It will require modifications to work: 468 // - It may require correct/in-range values for request initialization. 469 // - It may require specifying regional endpoints when creating the service client as shown in: 470 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 471 c, err := aiplatform.NewFeatureRegistryClient(ctx) 472 if err != nil { 473 // TODO: Handle error. 474 } 475 defer c.Close() 476 477 req := &iampb.SetIamPolicyRequest{ 478 // TODO: Fill request struct fields. 479 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest. 480 } 481 resp, err := c.SetIamPolicy(ctx, req) 482 if err != nil { 483 // TODO: Handle error. 484 } 485 // TODO: Use resp. 486 _ = resp 487 } 488 489 func ExampleFeatureRegistryClient_TestIamPermissions() { 490 ctx := context.Background() 491 // This snippet has been automatically generated and should be regarded as a code template only. 492 // It will require modifications to work: 493 // - It may require correct/in-range values for request initialization. 494 // - It may require specifying regional endpoints when creating the service client as shown in: 495 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 496 c, err := aiplatform.NewFeatureRegistryClient(ctx) 497 if err != nil { 498 // TODO: Handle error. 499 } 500 defer c.Close() 501 502 req := &iampb.TestIamPermissionsRequest{ 503 // TODO: Fill request struct fields. 504 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest. 505 } 506 resp, err := c.TestIamPermissions(ctx, req) 507 if err != nil { 508 // TODO: Handle error. 509 } 510 // TODO: Use resp. 511 _ = resp 512 } 513 514 func ExampleFeatureRegistryClient_CancelOperation() { 515 ctx := context.Background() 516 // This snippet has been automatically generated and should be regarded as a code template only. 517 // It will require modifications to work: 518 // - It may require correct/in-range values for request initialization. 519 // - It may require specifying regional endpoints when creating the service client as shown in: 520 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 521 c, err := aiplatform.NewFeatureRegistryClient(ctx) 522 if err != nil { 523 // TODO: Handle error. 524 } 525 defer c.Close() 526 527 req := &longrunningpb.CancelOperationRequest{ 528 // TODO: Fill request struct fields. 529 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest. 530 } 531 err = c.CancelOperation(ctx, req) 532 if err != nil { 533 // TODO: Handle error. 534 } 535 } 536 537 func ExampleFeatureRegistryClient_DeleteOperation() { 538 ctx := context.Background() 539 // This snippet has been automatically generated and should be regarded as a code template only. 540 // It will require modifications to work: 541 // - It may require correct/in-range values for request initialization. 542 // - It may require specifying regional endpoints when creating the service client as shown in: 543 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 544 c, err := aiplatform.NewFeatureRegistryClient(ctx) 545 if err != nil { 546 // TODO: Handle error. 547 } 548 defer c.Close() 549 550 req := &longrunningpb.DeleteOperationRequest{ 551 // TODO: Fill request struct fields. 552 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest. 553 } 554 err = c.DeleteOperation(ctx, req) 555 if err != nil { 556 // TODO: Handle error. 557 } 558 } 559 560 func ExampleFeatureRegistryClient_GetOperation() { 561 ctx := context.Background() 562 // This snippet has been automatically generated and should be regarded as a code template only. 563 // It will require modifications to work: 564 // - It may require correct/in-range values for request initialization. 565 // - It may require specifying regional endpoints when creating the service client as shown in: 566 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 567 c, err := aiplatform.NewFeatureRegistryClient(ctx) 568 if err != nil { 569 // TODO: Handle error. 570 } 571 defer c.Close() 572 573 req := &longrunningpb.GetOperationRequest{ 574 // TODO: Fill request struct fields. 575 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. 576 } 577 resp, err := c.GetOperation(ctx, req) 578 if err != nil { 579 // TODO: Handle error. 580 } 581 // TODO: Use resp. 582 _ = resp 583 } 584 585 func ExampleFeatureRegistryClient_ListOperations() { 586 ctx := context.Background() 587 // This snippet has been automatically generated and should be regarded as a code template only. 588 // It will require modifications to work: 589 // - It may require correct/in-range values for request initialization. 590 // - It may require specifying regional endpoints when creating the service client as shown in: 591 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 592 c, err := aiplatform.NewFeatureRegistryClient(ctx) 593 if err != nil { 594 // TODO: Handle error. 595 } 596 defer c.Close() 597 598 req := &longrunningpb.ListOperationsRequest{ 599 // TODO: Fill request struct fields. 600 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. 601 } 602 it := c.ListOperations(ctx, req) 603 for { 604 resp, err := it.Next() 605 if err == iterator.Done { 606 break 607 } 608 if err != nil { 609 // TODO: Handle error. 610 } 611 // TODO: Use resp. 612 _ = resp 613 614 // If you need to access the underlying RPC response, 615 // you can do so by casting the `Response` as below. 616 // Otherwise, remove this line. Only populated after 617 // first call to Next(). Not safe for concurrent access. 618 _ = it.Response.(*longrunningpb.ListOperationsResponse) 619 } 620 } 621 622 func ExampleFeatureRegistryClient_WaitOperation() { 623 ctx := context.Background() 624 // This snippet has been automatically generated and should be regarded as a code template only. 625 // It will require modifications to work: 626 // - It may require correct/in-range values for request initialization. 627 // - It may require specifying regional endpoints when creating the service client as shown in: 628 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 629 c, err := aiplatform.NewFeatureRegistryClient(ctx) 630 if err != nil { 631 // TODO: Handle error. 632 } 633 defer c.Close() 634 635 req := &longrunningpb.WaitOperationRequest{ 636 // TODO: Fill request struct fields. 637 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#WaitOperationRequest. 638 } 639 resp, err := c.WaitOperation(ctx, req) 640 if err != nil { 641 // TODO: Handle error. 642 } 643 // TODO: Use resp. 644 _ = resp 645 }