1 // Copyright 2024 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 kms_test 18 19 import ( 20 "context" 21 22 iampb "cloud.google.com/go/iam/apiv1/iampb" 23 kms "cloud.google.com/go/kms/apiv1" 24 kmspb "cloud.google.com/go/kms/apiv1/kmspb" 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 ExampleNewKeyManagementClient() { 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 := kms.NewKeyManagementClient(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 ExampleNewKeyManagementRESTClient() { 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 := kms.NewKeyManagementRESTClient(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 ExampleKeyManagementClient_AsymmetricDecrypt() { 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 := kms.NewKeyManagementClient(ctx) 72 if err != nil { 73 // TODO: Handle error. 74 } 75 defer c.Close() 76 77 req := &kmspb.AsymmetricDecryptRequest{ 78 // TODO: Fill request struct fields. 79 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#AsymmetricDecryptRequest. 80 } 81 resp, err := c.AsymmetricDecrypt(ctx, req) 82 if err != nil { 83 // TODO: Handle error. 84 } 85 // TODO: Use resp. 86 _ = resp 87 } 88 89 func ExampleKeyManagementClient_AsymmetricSign() { 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 := kms.NewKeyManagementClient(ctx) 97 if err != nil { 98 // TODO: Handle error. 99 } 100 defer c.Close() 101 102 req := &kmspb.AsymmetricSignRequest{ 103 // TODO: Fill request struct fields. 104 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#AsymmetricSignRequest. 105 } 106 resp, err := c.AsymmetricSign(ctx, req) 107 if err != nil { 108 // TODO: Handle error. 109 } 110 // TODO: Use resp. 111 _ = resp 112 } 113 114 func ExampleKeyManagementClient_CreateCryptoKey() { 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 := kms.NewKeyManagementClient(ctx) 122 if err != nil { 123 // TODO: Handle error. 124 } 125 defer c.Close() 126 127 req := &kmspb.CreateCryptoKeyRequest{ 128 // TODO: Fill request struct fields. 129 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#CreateCryptoKeyRequest. 130 } 131 resp, err := c.CreateCryptoKey(ctx, req) 132 if err != nil { 133 // TODO: Handle error. 134 } 135 // TODO: Use resp. 136 _ = resp 137 } 138 139 func ExampleKeyManagementClient_CreateCryptoKeyVersion() { 140 ctx := context.Background() 141 // This snippet has been automatically generated and should be regarded as a code template only. 142 // It will require modifications to work: 143 // - It may require correct/in-range values for request initialization. 144 // - It may require specifying regional endpoints when creating the service client as shown in: 145 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 146 c, err := kms.NewKeyManagementClient(ctx) 147 if err != nil { 148 // TODO: Handle error. 149 } 150 defer c.Close() 151 152 req := &kmspb.CreateCryptoKeyVersionRequest{ 153 // TODO: Fill request struct fields. 154 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#CreateCryptoKeyVersionRequest. 155 } 156 resp, err := c.CreateCryptoKeyVersion(ctx, req) 157 if err != nil { 158 // TODO: Handle error. 159 } 160 // TODO: Use resp. 161 _ = resp 162 } 163 164 func ExampleKeyManagementClient_CreateImportJob() { 165 ctx := context.Background() 166 // This snippet has been automatically generated and should be regarded as a code template only. 167 // It will require modifications to work: 168 // - It may require correct/in-range values for request initialization. 169 // - It may require specifying regional endpoints when creating the service client as shown in: 170 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 171 c, err := kms.NewKeyManagementClient(ctx) 172 if err != nil { 173 // TODO: Handle error. 174 } 175 defer c.Close() 176 177 req := &kmspb.CreateImportJobRequest{ 178 // TODO: Fill request struct fields. 179 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#CreateImportJobRequest. 180 } 181 resp, err := c.CreateImportJob(ctx, req) 182 if err != nil { 183 // TODO: Handle error. 184 } 185 // TODO: Use resp. 186 _ = resp 187 } 188 189 func ExampleKeyManagementClient_CreateKeyRing() { 190 ctx := context.Background() 191 // This snippet has been automatically generated and should be regarded as a code template only. 192 // It will require modifications to work: 193 // - It may require correct/in-range values for request initialization. 194 // - It may require specifying regional endpoints when creating the service client as shown in: 195 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 196 c, err := kms.NewKeyManagementClient(ctx) 197 if err != nil { 198 // TODO: Handle error. 199 } 200 defer c.Close() 201 202 req := &kmspb.CreateKeyRingRequest{ 203 // TODO: Fill request struct fields. 204 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#CreateKeyRingRequest. 205 } 206 resp, err := c.CreateKeyRing(ctx, req) 207 if err != nil { 208 // TODO: Handle error. 209 } 210 // TODO: Use resp. 211 _ = resp 212 } 213 214 func ExampleKeyManagementClient_Decrypt() { 215 ctx := context.Background() 216 // This snippet has been automatically generated and should be regarded as a code template only. 217 // It will require modifications to work: 218 // - It may require correct/in-range values for request initialization. 219 // - It may require specifying regional endpoints when creating the service client as shown in: 220 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 221 c, err := kms.NewKeyManagementClient(ctx) 222 if err != nil { 223 // TODO: Handle error. 224 } 225 defer c.Close() 226 227 req := &kmspb.DecryptRequest{ 228 // TODO: Fill request struct fields. 229 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#DecryptRequest. 230 } 231 resp, err := c.Decrypt(ctx, req) 232 if err != nil { 233 // TODO: Handle error. 234 } 235 // TODO: Use resp. 236 _ = resp 237 } 238 239 func ExampleKeyManagementClient_DestroyCryptoKeyVersion() { 240 ctx := context.Background() 241 // This snippet has been automatically generated and should be regarded as a code template only. 242 // It will require modifications to work: 243 // - It may require correct/in-range values for request initialization. 244 // - It may require specifying regional endpoints when creating the service client as shown in: 245 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 246 c, err := kms.NewKeyManagementClient(ctx) 247 if err != nil { 248 // TODO: Handle error. 249 } 250 defer c.Close() 251 252 req := &kmspb.DestroyCryptoKeyVersionRequest{ 253 // TODO: Fill request struct fields. 254 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#DestroyCryptoKeyVersionRequest. 255 } 256 resp, err := c.DestroyCryptoKeyVersion(ctx, req) 257 if err != nil { 258 // TODO: Handle error. 259 } 260 // TODO: Use resp. 261 _ = resp 262 } 263 264 func ExampleKeyManagementClient_Encrypt() { 265 ctx := context.Background() 266 // This snippet has been automatically generated and should be regarded as a code template only. 267 // It will require modifications to work: 268 // - It may require correct/in-range values for request initialization. 269 // - It may require specifying regional endpoints when creating the service client as shown in: 270 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 271 c, err := kms.NewKeyManagementClient(ctx) 272 if err != nil { 273 // TODO: Handle error. 274 } 275 defer c.Close() 276 277 req := &kmspb.EncryptRequest{ 278 // TODO: Fill request struct fields. 279 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#EncryptRequest. 280 } 281 resp, err := c.Encrypt(ctx, req) 282 if err != nil { 283 // TODO: Handle error. 284 } 285 // TODO: Use resp. 286 _ = resp 287 } 288 289 func ExampleKeyManagementClient_GenerateRandomBytes() { 290 ctx := context.Background() 291 // This snippet has been automatically generated and should be regarded as a code template only. 292 // It will require modifications to work: 293 // - It may require correct/in-range values for request initialization. 294 // - It may require specifying regional endpoints when creating the service client as shown in: 295 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 296 c, err := kms.NewKeyManagementClient(ctx) 297 if err != nil { 298 // TODO: Handle error. 299 } 300 defer c.Close() 301 302 req := &kmspb.GenerateRandomBytesRequest{ 303 // TODO: Fill request struct fields. 304 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#GenerateRandomBytesRequest. 305 } 306 resp, err := c.GenerateRandomBytes(ctx, req) 307 if err != nil { 308 // TODO: Handle error. 309 } 310 // TODO: Use resp. 311 _ = resp 312 } 313 314 func ExampleKeyManagementClient_GetCryptoKey() { 315 ctx := context.Background() 316 // This snippet has been automatically generated and should be regarded as a code template only. 317 // It will require modifications to work: 318 // - It may require correct/in-range values for request initialization. 319 // - It may require specifying regional endpoints when creating the service client as shown in: 320 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 321 c, err := kms.NewKeyManagementClient(ctx) 322 if err != nil { 323 // TODO: Handle error. 324 } 325 defer c.Close() 326 327 req := &kmspb.GetCryptoKeyRequest{ 328 // TODO: Fill request struct fields. 329 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#GetCryptoKeyRequest. 330 } 331 resp, err := c.GetCryptoKey(ctx, req) 332 if err != nil { 333 // TODO: Handle error. 334 } 335 // TODO: Use resp. 336 _ = resp 337 } 338 339 func ExampleKeyManagementClient_GetCryptoKeyVersion() { 340 ctx := context.Background() 341 // This snippet has been automatically generated and should be regarded as a code template only. 342 // It will require modifications to work: 343 // - It may require correct/in-range values for request initialization. 344 // - It may require specifying regional endpoints when creating the service client as shown in: 345 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 346 c, err := kms.NewKeyManagementClient(ctx) 347 if err != nil { 348 // TODO: Handle error. 349 } 350 defer c.Close() 351 352 req := &kmspb.GetCryptoKeyVersionRequest{ 353 // TODO: Fill request struct fields. 354 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#GetCryptoKeyVersionRequest. 355 } 356 resp, err := c.GetCryptoKeyVersion(ctx, req) 357 if err != nil { 358 // TODO: Handle error. 359 } 360 // TODO: Use resp. 361 _ = resp 362 } 363 364 func ExampleKeyManagementClient_GetImportJob() { 365 ctx := context.Background() 366 // This snippet has been automatically generated and should be regarded as a code template only. 367 // It will require modifications to work: 368 // - It may require correct/in-range values for request initialization. 369 // - It may require specifying regional endpoints when creating the service client as shown in: 370 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 371 c, err := kms.NewKeyManagementClient(ctx) 372 if err != nil { 373 // TODO: Handle error. 374 } 375 defer c.Close() 376 377 req := &kmspb.GetImportJobRequest{ 378 // TODO: Fill request struct fields. 379 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#GetImportJobRequest. 380 } 381 resp, err := c.GetImportJob(ctx, req) 382 if err != nil { 383 // TODO: Handle error. 384 } 385 // TODO: Use resp. 386 _ = resp 387 } 388 389 func ExampleKeyManagementClient_GetKeyRing() { 390 ctx := context.Background() 391 // This snippet has been automatically generated and should be regarded as a code template only. 392 // It will require modifications to work: 393 // - It may require correct/in-range values for request initialization. 394 // - It may require specifying regional endpoints when creating the service client as shown in: 395 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 396 c, err := kms.NewKeyManagementClient(ctx) 397 if err != nil { 398 // TODO: Handle error. 399 } 400 defer c.Close() 401 402 req := &kmspb.GetKeyRingRequest{ 403 // TODO: Fill request struct fields. 404 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#GetKeyRingRequest. 405 } 406 resp, err := c.GetKeyRing(ctx, req) 407 if err != nil { 408 // TODO: Handle error. 409 } 410 // TODO: Use resp. 411 _ = resp 412 } 413 414 func ExampleKeyManagementClient_GetPublicKey() { 415 ctx := context.Background() 416 // This snippet has been automatically generated and should be regarded as a code template only. 417 // It will require modifications to work: 418 // - It may require correct/in-range values for request initialization. 419 // - It may require specifying regional endpoints when creating the service client as shown in: 420 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 421 c, err := kms.NewKeyManagementClient(ctx) 422 if err != nil { 423 // TODO: Handle error. 424 } 425 defer c.Close() 426 427 req := &kmspb.GetPublicKeyRequest{ 428 // TODO: Fill request struct fields. 429 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#GetPublicKeyRequest. 430 } 431 resp, err := c.GetPublicKey(ctx, req) 432 if err != nil { 433 // TODO: Handle error. 434 } 435 // TODO: Use resp. 436 _ = resp 437 } 438 439 func ExampleKeyManagementClient_ImportCryptoKeyVersion() { 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 := kms.NewKeyManagementClient(ctx) 447 if err != nil { 448 // TODO: Handle error. 449 } 450 defer c.Close() 451 452 req := &kmspb.ImportCryptoKeyVersionRequest{ 453 // TODO: Fill request struct fields. 454 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#ImportCryptoKeyVersionRequest. 455 } 456 resp, err := c.ImportCryptoKeyVersion(ctx, req) 457 if err != nil { 458 // TODO: Handle error. 459 } 460 // TODO: Use resp. 461 _ = resp 462 } 463 464 func ExampleKeyManagementClient_ListCryptoKeyVersions() { 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 := kms.NewKeyManagementClient(ctx) 472 if err != nil { 473 // TODO: Handle error. 474 } 475 defer c.Close() 476 477 req := &kmspb.ListCryptoKeyVersionsRequest{ 478 // TODO: Fill request struct fields. 479 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#ListCryptoKeyVersionsRequest. 480 } 481 it := c.ListCryptoKeyVersions(ctx, req) 482 for { 483 resp, err := it.Next() 484 if err == iterator.Done { 485 break 486 } 487 if err != nil { 488 // TODO: Handle error. 489 } 490 // TODO: Use resp. 491 _ = resp 492 493 // If you need to access the underlying RPC response, 494 // you can do so by casting the `Response` as below. 495 // Otherwise, remove this line. Only populated after 496 // first call to Next(). Not safe for concurrent access. 497 _ = it.Response.(*kmspb.ListCryptoKeyVersionsResponse) 498 } 499 } 500 501 func ExampleKeyManagementClient_ListCryptoKeys() { 502 ctx := context.Background() 503 // This snippet has been automatically generated and should be regarded as a code template only. 504 // It will require modifications to work: 505 // - It may require correct/in-range values for request initialization. 506 // - It may require specifying regional endpoints when creating the service client as shown in: 507 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 508 c, err := kms.NewKeyManagementClient(ctx) 509 if err != nil { 510 // TODO: Handle error. 511 } 512 defer c.Close() 513 514 req := &kmspb.ListCryptoKeysRequest{ 515 // TODO: Fill request struct fields. 516 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#ListCryptoKeysRequest. 517 } 518 it := c.ListCryptoKeys(ctx, req) 519 for { 520 resp, err := it.Next() 521 if err == iterator.Done { 522 break 523 } 524 if err != nil { 525 // TODO: Handle error. 526 } 527 // TODO: Use resp. 528 _ = resp 529 530 // If you need to access the underlying RPC response, 531 // you can do so by casting the `Response` as below. 532 // Otherwise, remove this line. Only populated after 533 // first call to Next(). Not safe for concurrent access. 534 _ = it.Response.(*kmspb.ListCryptoKeysResponse) 535 } 536 } 537 538 func ExampleKeyManagementClient_ListImportJobs() { 539 ctx := context.Background() 540 // This snippet has been automatically generated and should be regarded as a code template only. 541 // It will require modifications to work: 542 // - It may require correct/in-range values for request initialization. 543 // - It may require specifying regional endpoints when creating the service client as shown in: 544 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 545 c, err := kms.NewKeyManagementClient(ctx) 546 if err != nil { 547 // TODO: Handle error. 548 } 549 defer c.Close() 550 551 req := &kmspb.ListImportJobsRequest{ 552 // TODO: Fill request struct fields. 553 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#ListImportJobsRequest. 554 } 555 it := c.ListImportJobs(ctx, req) 556 for { 557 resp, err := it.Next() 558 if err == iterator.Done { 559 break 560 } 561 if err != nil { 562 // TODO: Handle error. 563 } 564 // TODO: Use resp. 565 _ = resp 566 567 // If you need to access the underlying RPC response, 568 // you can do so by casting the `Response` as below. 569 // Otherwise, remove this line. Only populated after 570 // first call to Next(). Not safe for concurrent access. 571 _ = it.Response.(*kmspb.ListImportJobsResponse) 572 } 573 } 574 575 func ExampleKeyManagementClient_ListKeyRings() { 576 ctx := context.Background() 577 // This snippet has been automatically generated and should be regarded as a code template only. 578 // It will require modifications to work: 579 // - It may require correct/in-range values for request initialization. 580 // - It may require specifying regional endpoints when creating the service client as shown in: 581 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 582 c, err := kms.NewKeyManagementClient(ctx) 583 if err != nil { 584 // TODO: Handle error. 585 } 586 defer c.Close() 587 588 req := &kmspb.ListKeyRingsRequest{ 589 // TODO: Fill request struct fields. 590 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#ListKeyRingsRequest. 591 } 592 it := c.ListKeyRings(ctx, req) 593 for { 594 resp, err := it.Next() 595 if err == iterator.Done { 596 break 597 } 598 if err != nil { 599 // TODO: Handle error. 600 } 601 // TODO: Use resp. 602 _ = resp 603 604 // If you need to access the underlying RPC response, 605 // you can do so by casting the `Response` as below. 606 // Otherwise, remove this line. Only populated after 607 // first call to Next(). Not safe for concurrent access. 608 _ = it.Response.(*kmspb.ListKeyRingsResponse) 609 } 610 } 611 612 func ExampleKeyManagementClient_MacSign() { 613 ctx := context.Background() 614 // This snippet has been automatically generated and should be regarded as a code template only. 615 // It will require modifications to work: 616 // - It may require correct/in-range values for request initialization. 617 // - It may require specifying regional endpoints when creating the service client as shown in: 618 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 619 c, err := kms.NewKeyManagementClient(ctx) 620 if err != nil { 621 // TODO: Handle error. 622 } 623 defer c.Close() 624 625 req := &kmspb.MacSignRequest{ 626 // TODO: Fill request struct fields. 627 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#MacSignRequest. 628 } 629 resp, err := c.MacSign(ctx, req) 630 if err != nil { 631 // TODO: Handle error. 632 } 633 // TODO: Use resp. 634 _ = resp 635 } 636 637 func ExampleKeyManagementClient_MacVerify() { 638 ctx := context.Background() 639 // This snippet has been automatically generated and should be regarded as a code template only. 640 // It will require modifications to work: 641 // - It may require correct/in-range values for request initialization. 642 // - It may require specifying regional endpoints when creating the service client as shown in: 643 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 644 c, err := kms.NewKeyManagementClient(ctx) 645 if err != nil { 646 // TODO: Handle error. 647 } 648 defer c.Close() 649 650 req := &kmspb.MacVerifyRequest{ 651 // TODO: Fill request struct fields. 652 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#MacVerifyRequest. 653 } 654 resp, err := c.MacVerify(ctx, req) 655 if err != nil { 656 // TODO: Handle error. 657 } 658 // TODO: Use resp. 659 _ = resp 660 } 661 662 func ExampleKeyManagementClient_RawDecrypt() { 663 ctx := context.Background() 664 // This snippet has been automatically generated and should be regarded as a code template only. 665 // It will require modifications to work: 666 // - It may require correct/in-range values for request initialization. 667 // - It may require specifying regional endpoints when creating the service client as shown in: 668 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 669 c, err := kms.NewKeyManagementClient(ctx) 670 if err != nil { 671 // TODO: Handle error. 672 } 673 defer c.Close() 674 675 req := &kmspb.RawDecryptRequest{ 676 // TODO: Fill request struct fields. 677 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#RawDecryptRequest. 678 } 679 resp, err := c.RawDecrypt(ctx, req) 680 if err != nil { 681 // TODO: Handle error. 682 } 683 // TODO: Use resp. 684 _ = resp 685 } 686 687 func ExampleKeyManagementClient_RawEncrypt() { 688 ctx := context.Background() 689 // This snippet has been automatically generated and should be regarded as a code template only. 690 // It will require modifications to work: 691 // - It may require correct/in-range values for request initialization. 692 // - It may require specifying regional endpoints when creating the service client as shown in: 693 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 694 c, err := kms.NewKeyManagementClient(ctx) 695 if err != nil { 696 // TODO: Handle error. 697 } 698 defer c.Close() 699 700 req := &kmspb.RawEncryptRequest{ 701 // TODO: Fill request struct fields. 702 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#RawEncryptRequest. 703 } 704 resp, err := c.RawEncrypt(ctx, req) 705 if err != nil { 706 // TODO: Handle error. 707 } 708 // TODO: Use resp. 709 _ = resp 710 } 711 712 func ExampleKeyManagementClient_RestoreCryptoKeyVersion() { 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 := kms.NewKeyManagementClient(ctx) 720 if err != nil { 721 // TODO: Handle error. 722 } 723 defer c.Close() 724 725 req := &kmspb.RestoreCryptoKeyVersionRequest{ 726 // TODO: Fill request struct fields. 727 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#RestoreCryptoKeyVersionRequest. 728 } 729 resp, err := c.RestoreCryptoKeyVersion(ctx, req) 730 if err != nil { 731 // TODO: Handle error. 732 } 733 // TODO: Use resp. 734 _ = resp 735 } 736 737 func ExampleKeyManagementClient_UpdateCryptoKey() { 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 := kms.NewKeyManagementClient(ctx) 745 if err != nil { 746 // TODO: Handle error. 747 } 748 defer c.Close() 749 750 req := &kmspb.UpdateCryptoKeyRequest{ 751 // TODO: Fill request struct fields. 752 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#UpdateCryptoKeyRequest. 753 } 754 resp, err := c.UpdateCryptoKey(ctx, req) 755 if err != nil { 756 // TODO: Handle error. 757 } 758 // TODO: Use resp. 759 _ = resp 760 } 761 762 func ExampleKeyManagementClient_UpdateCryptoKeyPrimaryVersion() { 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 := kms.NewKeyManagementClient(ctx) 770 if err != nil { 771 // TODO: Handle error. 772 } 773 defer c.Close() 774 775 req := &kmspb.UpdateCryptoKeyPrimaryVersionRequest{ 776 // TODO: Fill request struct fields. 777 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#UpdateCryptoKeyPrimaryVersionRequest. 778 } 779 resp, err := c.UpdateCryptoKeyPrimaryVersion(ctx, req) 780 if err != nil { 781 // TODO: Handle error. 782 } 783 // TODO: Use resp. 784 _ = resp 785 } 786 787 func ExampleKeyManagementClient_UpdateCryptoKeyVersion() { 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 := kms.NewKeyManagementClient(ctx) 795 if err != nil { 796 // TODO: Handle error. 797 } 798 defer c.Close() 799 800 req := &kmspb.UpdateCryptoKeyVersionRequest{ 801 // TODO: Fill request struct fields. 802 // See https://pkg.go.dev/cloud.google.com/go/kms/apiv1/kmspb#UpdateCryptoKeyVersionRequest. 803 } 804 resp, err := c.UpdateCryptoKeyVersion(ctx, req) 805 if err != nil { 806 // TODO: Handle error. 807 } 808 // TODO: Use resp. 809 _ = resp 810 } 811 812 func ExampleKeyManagementClient_GetLocation() { 813 ctx := context.Background() 814 // This snippet has been automatically generated and should be regarded as a code template only. 815 // It will require modifications to work: 816 // - It may require correct/in-range values for request initialization. 817 // - It may require specifying regional endpoints when creating the service client as shown in: 818 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 819 c, err := kms.NewKeyManagementClient(ctx) 820 if err != nil { 821 // TODO: Handle error. 822 } 823 defer c.Close() 824 825 req := &locationpb.GetLocationRequest{ 826 // TODO: Fill request struct fields. 827 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. 828 } 829 resp, err := c.GetLocation(ctx, req) 830 if err != nil { 831 // TODO: Handle error. 832 } 833 // TODO: Use resp. 834 _ = resp 835 } 836 837 func ExampleKeyManagementClient_ListLocations() { 838 ctx := context.Background() 839 // This snippet has been automatically generated and should be regarded as a code template only. 840 // It will require modifications to work: 841 // - It may require correct/in-range values for request initialization. 842 // - It may require specifying regional endpoints when creating the service client as shown in: 843 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 844 c, err := kms.NewKeyManagementClient(ctx) 845 if err != nil { 846 // TODO: Handle error. 847 } 848 defer c.Close() 849 850 req := &locationpb.ListLocationsRequest{ 851 // TODO: Fill request struct fields. 852 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. 853 } 854 it := c.ListLocations(ctx, req) 855 for { 856 resp, err := it.Next() 857 if err == iterator.Done { 858 break 859 } 860 if err != nil { 861 // TODO: Handle error. 862 } 863 // TODO: Use resp. 864 _ = resp 865 866 // If you need to access the underlying RPC response, 867 // you can do so by casting the `Response` as below. 868 // Otherwise, remove this line. Only populated after 869 // first call to Next(). Not safe for concurrent access. 870 _ = it.Response.(*locationpb.ListLocationsResponse) 871 } 872 } 873 874 func ExampleKeyManagementClient_GetIamPolicy() { 875 ctx := context.Background() 876 // This snippet has been automatically generated and should be regarded as a code template only. 877 // It will require modifications to work: 878 // - It may require correct/in-range values for request initialization. 879 // - It may require specifying regional endpoints when creating the service client as shown in: 880 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 881 c, err := kms.NewKeyManagementClient(ctx) 882 if err != nil { 883 // TODO: Handle error. 884 } 885 defer c.Close() 886 887 req := &iampb.GetIamPolicyRequest{ 888 // TODO: Fill request struct fields. 889 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest. 890 } 891 resp, err := c.GetIamPolicy(ctx, req) 892 if err != nil { 893 // TODO: Handle error. 894 } 895 // TODO: Use resp. 896 _ = resp 897 } 898 899 func ExampleKeyManagementClient_SetIamPolicy() { 900 ctx := context.Background() 901 // This snippet has been automatically generated and should be regarded as a code template only. 902 // It will require modifications to work: 903 // - It may require correct/in-range values for request initialization. 904 // - It may require specifying regional endpoints when creating the service client as shown in: 905 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 906 c, err := kms.NewKeyManagementClient(ctx) 907 if err != nil { 908 // TODO: Handle error. 909 } 910 defer c.Close() 911 912 req := &iampb.SetIamPolicyRequest{ 913 // TODO: Fill request struct fields. 914 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest. 915 } 916 resp, err := c.SetIamPolicy(ctx, req) 917 if err != nil { 918 // TODO: Handle error. 919 } 920 // TODO: Use resp. 921 _ = resp 922 } 923 924 func ExampleKeyManagementClient_TestIamPermissions() { 925 ctx := context.Background() 926 // This snippet has been automatically generated and should be regarded as a code template only. 927 // It will require modifications to work: 928 // - It may require correct/in-range values for request initialization. 929 // - It may require specifying regional endpoints when creating the service client as shown in: 930 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 931 c, err := kms.NewKeyManagementClient(ctx) 932 if err != nil { 933 // TODO: Handle error. 934 } 935 defer c.Close() 936 937 req := &iampb.TestIamPermissionsRequest{ 938 // TODO: Fill request struct fields. 939 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest. 940 } 941 resp, err := c.TestIamPermissions(ctx, req) 942 if err != nil { 943 // TODO: Handle error. 944 } 945 // TODO: Use resp. 946 _ = resp 947 } 948 949 func ExampleKeyManagementClient_GetOperation() { 950 ctx := context.Background() 951 // This snippet has been automatically generated and should be regarded as a code template only. 952 // It will require modifications to work: 953 // - It may require correct/in-range values for request initialization. 954 // - It may require specifying regional endpoints when creating the service client as shown in: 955 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 956 c, err := kms.NewKeyManagementClient(ctx) 957 if err != nil { 958 // TODO: Handle error. 959 } 960 defer c.Close() 961 962 req := &longrunningpb.GetOperationRequest{ 963 // TODO: Fill request struct fields. 964 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. 965 } 966 resp, err := c.GetOperation(ctx, req) 967 if err != nil { 968 // TODO: Handle error. 969 } 970 // TODO: Use resp. 971 _ = resp 972 } 973