1// Copyright 2021 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 17package privateca_test 18 19import ( 20 "context" 21 22 privateca "cloud.google.com/go/security/privateca/apiv1" 23 "google.golang.org/api/iterator" 24 privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" 25) 26 27func ExampleNewCertificateAuthorityClient() { 28 ctx := context.Background() 29 c, err := privateca.NewCertificateAuthorityClient(ctx) 30 if err != nil { 31 // TODO: Handle error. 32 } 33 defer c.Close() 34 35 // TODO: Use client. 36 _ = c 37} 38 39func ExampleCertificateAuthorityClient_CreateCertificate() { 40 ctx := context.Background() 41 c, err := privateca.NewCertificateAuthorityClient(ctx) 42 if err != nil { 43 // TODO: Handle error. 44 } 45 defer c.Close() 46 47 req := &privatecapb.CreateCertificateRequest{ 48 // TODO: Fill request struct fields. 49 } 50 resp, err := c.CreateCertificate(ctx, req) 51 if err != nil { 52 // TODO: Handle error. 53 } 54 // TODO: Use resp. 55 _ = resp 56} 57 58func ExampleCertificateAuthorityClient_GetCertificate() { 59 ctx := context.Background() 60 c, err := privateca.NewCertificateAuthorityClient(ctx) 61 if err != nil { 62 // TODO: Handle error. 63 } 64 defer c.Close() 65 66 req := &privatecapb.GetCertificateRequest{ 67 // TODO: Fill request struct fields. 68 } 69 resp, err := c.GetCertificate(ctx, req) 70 if err != nil { 71 // TODO: Handle error. 72 } 73 // TODO: Use resp. 74 _ = resp 75} 76 77func ExampleCertificateAuthorityClient_ListCertificates() { 78 ctx := context.Background() 79 c, err := privateca.NewCertificateAuthorityClient(ctx) 80 if err != nil { 81 // TODO: Handle error. 82 } 83 defer c.Close() 84 85 req := &privatecapb.ListCertificatesRequest{ 86 // TODO: Fill request struct fields. 87 } 88 it := c.ListCertificates(ctx, req) 89 for { 90 resp, err := it.Next() 91 if err == iterator.Done { 92 break 93 } 94 if err != nil { 95 // TODO: Handle error. 96 } 97 // TODO: Use resp. 98 _ = resp 99 } 100} 101 102func ExampleCertificateAuthorityClient_RevokeCertificate() { 103 ctx := context.Background() 104 c, err := privateca.NewCertificateAuthorityClient(ctx) 105 if err != nil { 106 // TODO: Handle error. 107 } 108 defer c.Close() 109 110 req := &privatecapb.RevokeCertificateRequest{ 111 // TODO: Fill request struct fields. 112 } 113 resp, err := c.RevokeCertificate(ctx, req) 114 if err != nil { 115 // TODO: Handle error. 116 } 117 // TODO: Use resp. 118 _ = resp 119} 120 121func ExampleCertificateAuthorityClient_UpdateCertificate() { 122 ctx := context.Background() 123 c, err := privateca.NewCertificateAuthorityClient(ctx) 124 if err != nil { 125 // TODO: Handle error. 126 } 127 defer c.Close() 128 129 req := &privatecapb.UpdateCertificateRequest{ 130 // TODO: Fill request struct fields. 131 } 132 resp, err := c.UpdateCertificate(ctx, req) 133 if err != nil { 134 // TODO: Handle error. 135 } 136 // TODO: Use resp. 137 _ = resp 138} 139 140func ExampleCertificateAuthorityClient_ActivateCertificateAuthority() { 141 ctx := context.Background() 142 c, err := privateca.NewCertificateAuthorityClient(ctx) 143 if err != nil { 144 // TODO: Handle error. 145 } 146 defer c.Close() 147 148 req := &privatecapb.ActivateCertificateAuthorityRequest{ 149 // TODO: Fill request struct fields. 150 } 151 op, err := c.ActivateCertificateAuthority(ctx, req) 152 if err != nil { 153 // TODO: Handle error. 154 } 155 156 resp, err := op.Wait(ctx) 157 if err != nil { 158 // TODO: Handle error. 159 } 160 // TODO: Use resp. 161 _ = resp 162} 163 164func ExampleCertificateAuthorityClient_CreateCertificateAuthority() { 165 ctx := context.Background() 166 c, err := privateca.NewCertificateAuthorityClient(ctx) 167 if err != nil { 168 // TODO: Handle error. 169 } 170 defer c.Close() 171 172 req := &privatecapb.CreateCertificateAuthorityRequest{ 173 // TODO: Fill request struct fields. 174 } 175 op, err := c.CreateCertificateAuthority(ctx, req) 176 if err != nil { 177 // TODO: Handle error. 178 } 179 180 resp, err := op.Wait(ctx) 181 if err != nil { 182 // TODO: Handle error. 183 } 184 // TODO: Use resp. 185 _ = resp 186} 187 188func ExampleCertificateAuthorityClient_DisableCertificateAuthority() { 189 ctx := context.Background() 190 c, err := privateca.NewCertificateAuthorityClient(ctx) 191 if err != nil { 192 // TODO: Handle error. 193 } 194 defer c.Close() 195 196 req := &privatecapb.DisableCertificateAuthorityRequest{ 197 // TODO: Fill request struct fields. 198 } 199 op, err := c.DisableCertificateAuthority(ctx, req) 200 if err != nil { 201 // TODO: Handle error. 202 } 203 204 resp, err := op.Wait(ctx) 205 if err != nil { 206 // TODO: Handle error. 207 } 208 // TODO: Use resp. 209 _ = resp 210} 211 212func ExampleCertificateAuthorityClient_EnableCertificateAuthority() { 213 ctx := context.Background() 214 c, err := privateca.NewCertificateAuthorityClient(ctx) 215 if err != nil { 216 // TODO: Handle error. 217 } 218 defer c.Close() 219 220 req := &privatecapb.EnableCertificateAuthorityRequest{ 221 // TODO: Fill request struct fields. 222 } 223 op, err := c.EnableCertificateAuthority(ctx, req) 224 if err != nil { 225 // TODO: Handle error. 226 } 227 228 resp, err := op.Wait(ctx) 229 if err != nil { 230 // TODO: Handle error. 231 } 232 // TODO: Use resp. 233 _ = resp 234} 235 236func ExampleCertificateAuthorityClient_FetchCertificateAuthorityCsr() { 237 ctx := context.Background() 238 c, err := privateca.NewCertificateAuthorityClient(ctx) 239 if err != nil { 240 // TODO: Handle error. 241 } 242 defer c.Close() 243 244 req := &privatecapb.FetchCertificateAuthorityCsrRequest{ 245 // TODO: Fill request struct fields. 246 } 247 resp, err := c.FetchCertificateAuthorityCsr(ctx, req) 248 if err != nil { 249 // TODO: Handle error. 250 } 251 // TODO: Use resp. 252 _ = resp 253} 254 255func ExampleCertificateAuthorityClient_GetCertificateAuthority() { 256 ctx := context.Background() 257 c, err := privateca.NewCertificateAuthorityClient(ctx) 258 if err != nil { 259 // TODO: Handle error. 260 } 261 defer c.Close() 262 263 req := &privatecapb.GetCertificateAuthorityRequest{ 264 // TODO: Fill request struct fields. 265 } 266 resp, err := c.GetCertificateAuthority(ctx, req) 267 if err != nil { 268 // TODO: Handle error. 269 } 270 // TODO: Use resp. 271 _ = resp 272} 273 274func ExampleCertificateAuthorityClient_ListCertificateAuthorities() { 275 ctx := context.Background() 276 c, err := privateca.NewCertificateAuthorityClient(ctx) 277 if err != nil { 278 // TODO: Handle error. 279 } 280 defer c.Close() 281 282 req := &privatecapb.ListCertificateAuthoritiesRequest{ 283 // TODO: Fill request struct fields. 284 } 285 it := c.ListCertificateAuthorities(ctx, req) 286 for { 287 resp, err := it.Next() 288 if err == iterator.Done { 289 break 290 } 291 if err != nil { 292 // TODO: Handle error. 293 } 294 // TODO: Use resp. 295 _ = resp 296 } 297} 298 299func ExampleCertificateAuthorityClient_UndeleteCertificateAuthority() { 300 ctx := context.Background() 301 c, err := privateca.NewCertificateAuthorityClient(ctx) 302 if err != nil { 303 // TODO: Handle error. 304 } 305 defer c.Close() 306 307 req := &privatecapb.UndeleteCertificateAuthorityRequest{ 308 // TODO: Fill request struct fields. 309 } 310 op, err := c.UndeleteCertificateAuthority(ctx, req) 311 if err != nil { 312 // TODO: Handle error. 313 } 314 315 resp, err := op.Wait(ctx) 316 if err != nil { 317 // TODO: Handle error. 318 } 319 // TODO: Use resp. 320 _ = resp 321} 322 323func ExampleCertificateAuthorityClient_DeleteCertificateAuthority() { 324 ctx := context.Background() 325 c, err := privateca.NewCertificateAuthorityClient(ctx) 326 if err != nil { 327 // TODO: Handle error. 328 } 329 defer c.Close() 330 331 req := &privatecapb.DeleteCertificateAuthorityRequest{ 332 // TODO: Fill request struct fields. 333 } 334 op, err := c.DeleteCertificateAuthority(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 347func ExampleCertificateAuthorityClient_UpdateCertificateAuthority() { 348 ctx := context.Background() 349 c, err := privateca.NewCertificateAuthorityClient(ctx) 350 if err != nil { 351 // TODO: Handle error. 352 } 353 defer c.Close() 354 355 req := &privatecapb.UpdateCertificateAuthorityRequest{ 356 // TODO: Fill request struct fields. 357 } 358 op, err := c.UpdateCertificateAuthority(ctx, req) 359 if err != nil { 360 // TODO: Handle error. 361 } 362 363 resp, err := op.Wait(ctx) 364 if err != nil { 365 // TODO: Handle error. 366 } 367 // TODO: Use resp. 368 _ = resp 369} 370 371func ExampleCertificateAuthorityClient_CreateCaPool() { 372 ctx := context.Background() 373 c, err := privateca.NewCertificateAuthorityClient(ctx) 374 if err != nil { 375 // TODO: Handle error. 376 } 377 defer c.Close() 378 379 req := &privatecapb.CreateCaPoolRequest{ 380 // TODO: Fill request struct fields. 381 } 382 op, err := c.CreateCaPool(ctx, req) 383 if err != nil { 384 // TODO: Handle error. 385 } 386 387 resp, err := op.Wait(ctx) 388 if err != nil { 389 // TODO: Handle error. 390 } 391 // TODO: Use resp. 392 _ = resp 393} 394 395func ExampleCertificateAuthorityClient_UpdateCaPool() { 396 ctx := context.Background() 397 c, err := privateca.NewCertificateAuthorityClient(ctx) 398 if err != nil { 399 // TODO: Handle error. 400 } 401 defer c.Close() 402 403 req := &privatecapb.UpdateCaPoolRequest{ 404 // TODO: Fill request struct fields. 405 } 406 op, err := c.UpdateCaPool(ctx, req) 407 if err != nil { 408 // TODO: Handle error. 409 } 410 411 resp, err := op.Wait(ctx) 412 if err != nil { 413 // TODO: Handle error. 414 } 415 // TODO: Use resp. 416 _ = resp 417} 418 419func ExampleCertificateAuthorityClient_GetCaPool() { 420 ctx := context.Background() 421 c, err := privateca.NewCertificateAuthorityClient(ctx) 422 if err != nil { 423 // TODO: Handle error. 424 } 425 defer c.Close() 426 427 req := &privatecapb.GetCaPoolRequest{ 428 // TODO: Fill request struct fields. 429 } 430 resp, err := c.GetCaPool(ctx, req) 431 if err != nil { 432 // TODO: Handle error. 433 } 434 // TODO: Use resp. 435 _ = resp 436} 437 438func ExampleCertificateAuthorityClient_ListCaPools() { 439 ctx := context.Background() 440 c, err := privateca.NewCertificateAuthorityClient(ctx) 441 if err != nil { 442 // TODO: Handle error. 443 } 444 defer c.Close() 445 446 req := &privatecapb.ListCaPoolsRequest{ 447 // TODO: Fill request struct fields. 448 } 449 it := c.ListCaPools(ctx, req) 450 for { 451 resp, err := it.Next() 452 if err == iterator.Done { 453 break 454 } 455 if err != nil { 456 // TODO: Handle error. 457 } 458 // TODO: Use resp. 459 _ = resp 460 } 461} 462 463func ExampleCertificateAuthorityClient_DeleteCaPool() { 464 ctx := context.Background() 465 c, err := privateca.NewCertificateAuthorityClient(ctx) 466 if err != nil { 467 // TODO: Handle error. 468 } 469 defer c.Close() 470 471 req := &privatecapb.DeleteCaPoolRequest{ 472 // TODO: Fill request struct fields. 473 } 474 op, err := c.DeleteCaPool(ctx, req) 475 if err != nil { 476 // TODO: Handle error. 477 } 478 479 err = op.Wait(ctx) 480 if err != nil { 481 // TODO: Handle error. 482 } 483} 484 485func ExampleCertificateAuthorityClient_FetchCaCerts() { 486 ctx := context.Background() 487 c, err := privateca.NewCertificateAuthorityClient(ctx) 488 if err != nil { 489 // TODO: Handle error. 490 } 491 defer c.Close() 492 493 req := &privatecapb.FetchCaCertsRequest{ 494 // TODO: Fill request struct fields. 495 } 496 resp, err := c.FetchCaCerts(ctx, req) 497 if err != nil { 498 // TODO: Handle error. 499 } 500 // TODO: Use resp. 501 _ = resp 502} 503 504func ExampleCertificateAuthorityClient_GetCertificateRevocationList() { 505 ctx := context.Background() 506 c, err := privateca.NewCertificateAuthorityClient(ctx) 507 if err != nil { 508 // TODO: Handle error. 509 } 510 defer c.Close() 511 512 req := &privatecapb.GetCertificateRevocationListRequest{ 513 // TODO: Fill request struct fields. 514 } 515 resp, err := c.GetCertificateRevocationList(ctx, req) 516 if err != nil { 517 // TODO: Handle error. 518 } 519 // TODO: Use resp. 520 _ = resp 521} 522 523func ExampleCertificateAuthorityClient_ListCertificateRevocationLists() { 524 ctx := context.Background() 525 c, err := privateca.NewCertificateAuthorityClient(ctx) 526 if err != nil { 527 // TODO: Handle error. 528 } 529 defer c.Close() 530 531 req := &privatecapb.ListCertificateRevocationListsRequest{ 532 // TODO: Fill request struct fields. 533 } 534 it := c.ListCertificateRevocationLists(ctx, req) 535 for { 536 resp, err := it.Next() 537 if err == iterator.Done { 538 break 539 } 540 if err != nil { 541 // TODO: Handle error. 542 } 543 // TODO: Use resp. 544 _ = resp 545 } 546} 547 548func ExampleCertificateAuthorityClient_UpdateCertificateRevocationList() { 549 ctx := context.Background() 550 c, err := privateca.NewCertificateAuthorityClient(ctx) 551 if err != nil { 552 // TODO: Handle error. 553 } 554 defer c.Close() 555 556 req := &privatecapb.UpdateCertificateRevocationListRequest{ 557 // TODO: Fill request struct fields. 558 } 559 op, err := c.UpdateCertificateRevocationList(ctx, req) 560 if err != nil { 561 // TODO: Handle error. 562 } 563 564 resp, err := op.Wait(ctx) 565 if err != nil { 566 // TODO: Handle error. 567 } 568 // TODO: Use resp. 569 _ = resp 570} 571 572func ExampleCertificateAuthorityClient_CreateCertificateTemplate() { 573 ctx := context.Background() 574 c, err := privateca.NewCertificateAuthorityClient(ctx) 575 if err != nil { 576 // TODO: Handle error. 577 } 578 defer c.Close() 579 580 req := &privatecapb.CreateCertificateTemplateRequest{ 581 // TODO: Fill request struct fields. 582 } 583 op, err := c.CreateCertificateTemplate(ctx, req) 584 if err != nil { 585 // TODO: Handle error. 586 } 587 588 resp, err := op.Wait(ctx) 589 if err != nil { 590 // TODO: Handle error. 591 } 592 // TODO: Use resp. 593 _ = resp 594} 595 596func ExampleCertificateAuthorityClient_DeleteCertificateTemplate() { 597 ctx := context.Background() 598 c, err := privateca.NewCertificateAuthorityClient(ctx) 599 if err != nil { 600 // TODO: Handle error. 601 } 602 defer c.Close() 603 604 req := &privatecapb.DeleteCertificateTemplateRequest{ 605 // TODO: Fill request struct fields. 606 } 607 op, err := c.DeleteCertificateTemplate(ctx, req) 608 if err != nil { 609 // TODO: Handle error. 610 } 611 612 err = op.Wait(ctx) 613 if err != nil { 614 // TODO: Handle error. 615 } 616} 617 618func ExampleCertificateAuthorityClient_GetCertificateTemplate() { 619 ctx := context.Background() 620 c, err := privateca.NewCertificateAuthorityClient(ctx) 621 if err != nil { 622 // TODO: Handle error. 623 } 624 defer c.Close() 625 626 req := &privatecapb.GetCertificateTemplateRequest{ 627 // TODO: Fill request struct fields. 628 } 629 resp, err := c.GetCertificateTemplate(ctx, req) 630 if err != nil { 631 // TODO: Handle error. 632 } 633 // TODO: Use resp. 634 _ = resp 635} 636 637func ExampleCertificateAuthorityClient_ListCertificateTemplates() { 638 ctx := context.Background() 639 c, err := privateca.NewCertificateAuthorityClient(ctx) 640 if err != nil { 641 // TODO: Handle error. 642 } 643 defer c.Close() 644 645 req := &privatecapb.ListCertificateTemplatesRequest{ 646 // TODO: Fill request struct fields. 647 } 648 it := c.ListCertificateTemplates(ctx, req) 649 for { 650 resp, err := it.Next() 651 if err == iterator.Done { 652 break 653 } 654 if err != nil { 655 // TODO: Handle error. 656 } 657 // TODO: Use resp. 658 _ = resp 659 } 660} 661 662func ExampleCertificateAuthorityClient_UpdateCertificateTemplate() { 663 ctx := context.Background() 664 c, err := privateca.NewCertificateAuthorityClient(ctx) 665 if err != nil { 666 // TODO: Handle error. 667 } 668 defer c.Close() 669 670 req := &privatecapb.UpdateCertificateTemplateRequest{ 671 // TODO: Fill request struct fields. 672 } 673 op, err := c.UpdateCertificateTemplate(ctx, req) 674 if err != nil { 675 // TODO: Handle error. 676 } 677 678 resp, err := op.Wait(ctx) 679 if err != nil { 680 // TODO: Handle error. 681 } 682 // TODO: Use resp. 683 _ = resp 684} 685