cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/example_store_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 ExampleNewExampleStoreClient() { 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.NewExampleStoreClient(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 ExampleNewExampleStoreRESTClient() { 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.NewExampleStoreRESTClient(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 ExampleExampleStoreClient_CreateExampleStore() { 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.NewExampleStoreClient(ctx) 72 if err != nil { 73 // TODO: Handle error. 74 } 75 defer c.Close() 76 77 req := &aiplatformpb.CreateExampleStoreRequest{ 78 // TODO: Fill request struct fields. 79 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#CreateExampleStoreRequest. 80 } 81 op, err := c.CreateExampleStore(ctx, req) 82 if err != nil { 83 // TODO: Handle error. 84 } 85 86 resp, err := op.Wait(ctx) 87 if err != nil { 88 // TODO: Handle error. 89 } 90 // TODO: Use resp. 91 _ = resp 92 } 93 94 func ExampleExampleStoreClient_DeleteExampleStore() { 95 ctx := context.Background() 96 // This snippet has been automatically generated and should be regarded as a code template only. 97 // It will require modifications to work: 98 // - It may require correct/in-range values for request initialization. 99 // - It may require specifying regional endpoints when creating the service client as shown in: 100 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 101 c, err := aiplatform.NewExampleStoreClient(ctx) 102 if err != nil { 103 // TODO: Handle error. 104 } 105 defer c.Close() 106 107 req := &aiplatformpb.DeleteExampleStoreRequest{ 108 // TODO: Fill request struct fields. 109 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#DeleteExampleStoreRequest. 110 } 111 op, err := c.DeleteExampleStore(ctx, req) 112 if err != nil { 113 // TODO: Handle error. 114 } 115 116 err = op.Wait(ctx) 117 if err != nil { 118 // TODO: Handle error. 119 } 120 } 121 122 func ExampleExampleStoreClient_FetchExamples() { 123 ctx := context.Background() 124 // This snippet has been automatically generated and should be regarded as a code template only. 125 // It will require modifications to work: 126 // - It may require correct/in-range values for request initialization. 127 // - It may require specifying regional endpoints when creating the service client as shown in: 128 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 129 c, err := aiplatform.NewExampleStoreClient(ctx) 130 if err != nil { 131 // TODO: Handle error. 132 } 133 defer c.Close() 134 135 req := &aiplatformpb.FetchExamplesRequest{ 136 // TODO: Fill request struct fields. 137 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#FetchExamplesRequest. 138 } 139 it := c.FetchExamples(ctx, req) 140 for { 141 resp, err := it.Next() 142 if err == iterator.Done { 143 break 144 } 145 if err != nil { 146 // TODO: Handle error. 147 } 148 // TODO: Use resp. 149 _ = resp 150 151 // If you need to access the underlying RPC response, 152 // you can do so by casting the `Response` as below. 153 // Otherwise, remove this line. Only populated after 154 // first call to Next(). Not safe for concurrent access. 155 _ = it.Response.(*aiplatformpb.FetchExamplesResponse) 156 } 157 } 158 159 func ExampleExampleStoreClient_GetExampleStore() { 160 ctx := context.Background() 161 // This snippet has been automatically generated and should be regarded as a code template only. 162 // It will require modifications to work: 163 // - It may require correct/in-range values for request initialization. 164 // - It may require specifying regional endpoints when creating the service client as shown in: 165 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 166 c, err := aiplatform.NewExampleStoreClient(ctx) 167 if err != nil { 168 // TODO: Handle error. 169 } 170 defer c.Close() 171 172 req := &aiplatformpb.GetExampleStoreRequest{ 173 // TODO: Fill request struct fields. 174 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#GetExampleStoreRequest. 175 } 176 resp, err := c.GetExampleStore(ctx, req) 177 if err != nil { 178 // TODO: Handle error. 179 } 180 // TODO: Use resp. 181 _ = resp 182 } 183 184 func ExampleExampleStoreClient_ListExampleStores() { 185 ctx := context.Background() 186 // This snippet has been automatically generated and should be regarded as a code template only. 187 // It will require modifications to work: 188 // - It may require correct/in-range values for request initialization. 189 // - It may require specifying regional endpoints when creating the service client as shown in: 190 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 191 c, err := aiplatform.NewExampleStoreClient(ctx) 192 if err != nil { 193 // TODO: Handle error. 194 } 195 defer c.Close() 196 197 req := &aiplatformpb.ListExampleStoresRequest{ 198 // TODO: Fill request struct fields. 199 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#ListExampleStoresRequest. 200 } 201 it := c.ListExampleStores(ctx, req) 202 for { 203 resp, err := it.Next() 204 if err == iterator.Done { 205 break 206 } 207 if err != nil { 208 // TODO: Handle error. 209 } 210 // TODO: Use resp. 211 _ = resp 212 213 // If you need to access the underlying RPC response, 214 // you can do so by casting the `Response` as below. 215 // Otherwise, remove this line. Only populated after 216 // first call to Next(). Not safe for concurrent access. 217 _ = it.Response.(*aiplatformpb.ListExampleStoresResponse) 218 } 219 } 220 221 func ExampleExampleStoreClient_RemoveExamples() { 222 ctx := context.Background() 223 // This snippet has been automatically generated and should be regarded as a code template only. 224 // It will require modifications to work: 225 // - It may require correct/in-range values for request initialization. 226 // - It may require specifying regional endpoints when creating the service client as shown in: 227 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 228 c, err := aiplatform.NewExampleStoreClient(ctx) 229 if err != nil { 230 // TODO: Handle error. 231 } 232 defer c.Close() 233 234 req := &aiplatformpb.RemoveExamplesRequest{ 235 // TODO: Fill request struct fields. 236 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#RemoveExamplesRequest. 237 } 238 resp, err := c.RemoveExamples(ctx, req) 239 if err != nil { 240 // TODO: Handle error. 241 } 242 // TODO: Use resp. 243 _ = resp 244 } 245 246 func ExampleExampleStoreClient_SearchExamples() { 247 ctx := context.Background() 248 // This snippet has been automatically generated and should be regarded as a code template only. 249 // It will require modifications to work: 250 // - It may require correct/in-range values for request initialization. 251 // - It may require specifying regional endpoints when creating the service client as shown in: 252 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 253 c, err := aiplatform.NewExampleStoreClient(ctx) 254 if err != nil { 255 // TODO: Handle error. 256 } 257 defer c.Close() 258 259 req := &aiplatformpb.SearchExamplesRequest{ 260 // TODO: Fill request struct fields. 261 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#SearchExamplesRequest. 262 } 263 resp, err := c.SearchExamples(ctx, req) 264 if err != nil { 265 // TODO: Handle error. 266 } 267 // TODO: Use resp. 268 _ = resp 269 } 270 271 func ExampleExampleStoreClient_UpdateExampleStore() { 272 ctx := context.Background() 273 // This snippet has been automatically generated and should be regarded as a code template only. 274 // It will require modifications to work: 275 // - It may require correct/in-range values for request initialization. 276 // - It may require specifying regional endpoints when creating the service client as shown in: 277 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 278 c, err := aiplatform.NewExampleStoreClient(ctx) 279 if err != nil { 280 // TODO: Handle error. 281 } 282 defer c.Close() 283 284 req := &aiplatformpb.UpdateExampleStoreRequest{ 285 // TODO: Fill request struct fields. 286 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#UpdateExampleStoreRequest. 287 } 288 op, err := c.UpdateExampleStore(ctx, req) 289 if err != nil { 290 // TODO: Handle error. 291 } 292 293 resp, err := op.Wait(ctx) 294 if err != nil { 295 // TODO: Handle error. 296 } 297 // TODO: Use resp. 298 _ = resp 299 } 300 301 func ExampleExampleStoreClient_UpsertExamples() { 302 ctx := context.Background() 303 // This snippet has been automatically generated and should be regarded as a code template only. 304 // It will require modifications to work: 305 // - It may require correct/in-range values for request initialization. 306 // - It may require specifying regional endpoints when creating the service client as shown in: 307 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 308 c, err := aiplatform.NewExampleStoreClient(ctx) 309 if err != nil { 310 // TODO: Handle error. 311 } 312 defer c.Close() 313 314 req := &aiplatformpb.UpsertExamplesRequest{ 315 // TODO: Fill request struct fields. 316 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#UpsertExamplesRequest. 317 } 318 resp, err := c.UpsertExamples(ctx, req) 319 if err != nil { 320 // TODO: Handle error. 321 } 322 // TODO: Use resp. 323 _ = resp 324 } 325 326 func ExampleExampleStoreClient_GetLocation() { 327 ctx := context.Background() 328 // This snippet has been automatically generated and should be regarded as a code template only. 329 // It will require modifications to work: 330 // - It may require correct/in-range values for request initialization. 331 // - It may require specifying regional endpoints when creating the service client as shown in: 332 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 333 c, err := aiplatform.NewExampleStoreClient(ctx) 334 if err != nil { 335 // TODO: Handle error. 336 } 337 defer c.Close() 338 339 req := &locationpb.GetLocationRequest{ 340 // TODO: Fill request struct fields. 341 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. 342 } 343 resp, err := c.GetLocation(ctx, req) 344 if err != nil { 345 // TODO: Handle error. 346 } 347 // TODO: Use resp. 348 _ = resp 349 } 350 351 func ExampleExampleStoreClient_ListLocations() { 352 ctx := context.Background() 353 // This snippet has been automatically generated and should be regarded as a code template only. 354 // It will require modifications to work: 355 // - It may require correct/in-range values for request initialization. 356 // - It may require specifying regional endpoints when creating the service client as shown in: 357 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 358 c, err := aiplatform.NewExampleStoreClient(ctx) 359 if err != nil { 360 // TODO: Handle error. 361 } 362 defer c.Close() 363 364 req := &locationpb.ListLocationsRequest{ 365 // TODO: Fill request struct fields. 366 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. 367 } 368 it := c.ListLocations(ctx, req) 369 for { 370 resp, err := it.Next() 371 if err == iterator.Done { 372 break 373 } 374 if err != nil { 375 // TODO: Handle error. 376 } 377 // TODO: Use resp. 378 _ = resp 379 380 // If you need to access the underlying RPC response, 381 // you can do so by casting the `Response` as below. 382 // Otherwise, remove this line. Only populated after 383 // first call to Next(). Not safe for concurrent access. 384 _ = it.Response.(*locationpb.ListLocationsResponse) 385 } 386 } 387 388 func ExampleExampleStoreClient_GetIamPolicy() { 389 ctx := context.Background() 390 // This snippet has been automatically generated and should be regarded as a code template only. 391 // It will require modifications to work: 392 // - It may require correct/in-range values for request initialization. 393 // - It may require specifying regional endpoints when creating the service client as shown in: 394 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 395 c, err := aiplatform.NewExampleStoreClient(ctx) 396 if err != nil { 397 // TODO: Handle error. 398 } 399 defer c.Close() 400 401 req := &iampb.GetIamPolicyRequest{ 402 // TODO: Fill request struct fields. 403 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest. 404 } 405 resp, err := c.GetIamPolicy(ctx, req) 406 if err != nil { 407 // TODO: Handle error. 408 } 409 // TODO: Use resp. 410 _ = resp 411 } 412 413 func ExampleExampleStoreClient_SetIamPolicy() { 414 ctx := context.Background() 415 // This snippet has been automatically generated and should be regarded as a code template only. 416 // It will require modifications to work: 417 // - It may require correct/in-range values for request initialization. 418 // - It may require specifying regional endpoints when creating the service client as shown in: 419 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 420 c, err := aiplatform.NewExampleStoreClient(ctx) 421 if err != nil { 422 // TODO: Handle error. 423 } 424 defer c.Close() 425 426 req := &iampb.SetIamPolicyRequest{ 427 // TODO: Fill request struct fields. 428 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest. 429 } 430 resp, err := c.SetIamPolicy(ctx, req) 431 if err != nil { 432 // TODO: Handle error. 433 } 434 // TODO: Use resp. 435 _ = resp 436 } 437 438 func ExampleExampleStoreClient_TestIamPermissions() { 439 ctx := context.Background() 440 // This snippet has been automatically generated and should be regarded as a code template only. 441 // It will require modifications to work: 442 // - It may require correct/in-range values for request initialization. 443 // - It may require specifying regional endpoints when creating the service client as shown in: 444 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 445 c, err := aiplatform.NewExampleStoreClient(ctx) 446 if err != nil { 447 // TODO: Handle error. 448 } 449 defer c.Close() 450 451 req := &iampb.TestIamPermissionsRequest{ 452 // TODO: Fill request struct fields. 453 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest. 454 } 455 resp, err := c.TestIamPermissions(ctx, req) 456 if err != nil { 457 // TODO: Handle error. 458 } 459 // TODO: Use resp. 460 _ = resp 461 } 462 463 func ExampleExampleStoreClient_CancelOperation() { 464 ctx := context.Background() 465 // This snippet has been automatically generated and should be regarded as a code template only. 466 // It will require modifications to work: 467 // - It may require correct/in-range values for request initialization. 468 // - It may require specifying regional endpoints when creating the service client as shown in: 469 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 470 c, err := aiplatform.NewExampleStoreClient(ctx) 471 if err != nil { 472 // TODO: Handle error. 473 } 474 defer c.Close() 475 476 req := &longrunningpb.CancelOperationRequest{ 477 // TODO: Fill request struct fields. 478 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest. 479 } 480 err = c.CancelOperation(ctx, req) 481 if err != nil { 482 // TODO: Handle error. 483 } 484 } 485 486 func ExampleExampleStoreClient_DeleteOperation() { 487 ctx := context.Background() 488 // This snippet has been automatically generated and should be regarded as a code template only. 489 // It will require modifications to work: 490 // - It may require correct/in-range values for request initialization. 491 // - It may require specifying regional endpoints when creating the service client as shown in: 492 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 493 c, err := aiplatform.NewExampleStoreClient(ctx) 494 if err != nil { 495 // TODO: Handle error. 496 } 497 defer c.Close() 498 499 req := &longrunningpb.DeleteOperationRequest{ 500 // TODO: Fill request struct fields. 501 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest. 502 } 503 err = c.DeleteOperation(ctx, req) 504 if err != nil { 505 // TODO: Handle error. 506 } 507 } 508 509 func ExampleExampleStoreClient_GetOperation() { 510 ctx := context.Background() 511 // This snippet has been automatically generated and should be regarded as a code template only. 512 // It will require modifications to work: 513 // - It may require correct/in-range values for request initialization. 514 // - It may require specifying regional endpoints when creating the service client as shown in: 515 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 516 c, err := aiplatform.NewExampleStoreClient(ctx) 517 if err != nil { 518 // TODO: Handle error. 519 } 520 defer c.Close() 521 522 req := &longrunningpb.GetOperationRequest{ 523 // TODO: Fill request struct fields. 524 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. 525 } 526 resp, err := c.GetOperation(ctx, req) 527 if err != nil { 528 // TODO: Handle error. 529 } 530 // TODO: Use resp. 531 _ = resp 532 } 533 534 func ExampleExampleStoreClient_ListOperations() { 535 ctx := context.Background() 536 // This snippet has been automatically generated and should be regarded as a code template only. 537 // It will require modifications to work: 538 // - It may require correct/in-range values for request initialization. 539 // - It may require specifying regional endpoints when creating the service client as shown in: 540 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 541 c, err := aiplatform.NewExampleStoreClient(ctx) 542 if err != nil { 543 // TODO: Handle error. 544 } 545 defer c.Close() 546 547 req := &longrunningpb.ListOperationsRequest{ 548 // TODO: Fill request struct fields. 549 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. 550 } 551 it := c.ListOperations(ctx, req) 552 for { 553 resp, err := it.Next() 554 if err == iterator.Done { 555 break 556 } 557 if err != nil { 558 // TODO: Handle error. 559 } 560 // TODO: Use resp. 561 _ = resp 562 563 // If you need to access the underlying RPC response, 564 // you can do so by casting the `Response` as below. 565 // Otherwise, remove this line. Only populated after 566 // first call to Next(). Not safe for concurrent access. 567 _ = it.Response.(*longrunningpb.ListOperationsResponse) 568 } 569 } 570 571 func ExampleExampleStoreClient_WaitOperation() { 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 := aiplatform.NewExampleStoreClient(ctx) 579 if err != nil { 580 // TODO: Handle error. 581 } 582 defer c.Close() 583 584 req := &longrunningpb.WaitOperationRequest{ 585 // TODO: Fill request struct fields. 586 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#WaitOperationRequest. 587 } 588 resp, err := c.WaitOperation(ctx, req) 589 if err != nil { 590 // TODO: Handle error. 591 } 592 // TODO: Use resp. 593 _ = resp 594 }