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/apiv1beta1" 23 "google.golang.org/api/iterator" 24 privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1beta1" 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_RestoreCertificateAuthority() { 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.RestoreCertificateAuthorityRequest{ 308 // TODO: Fill request struct fields. 309 } 310 op, err := c.RestoreCertificateAuthority(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_ScheduleDeleteCertificateAuthority() { 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.ScheduleDeleteCertificateAuthorityRequest{ 332 // TODO: Fill request struct fields. 333 } 334 op, err := c.ScheduleDeleteCertificateAuthority(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_GetCertificateRevocationList() { 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.GetCertificateRevocationListRequest{ 380 // TODO: Fill request struct fields. 381 } 382 resp, err := c.GetCertificateRevocationList(ctx, req) 383 if err != nil { 384 // TODO: Handle error. 385 } 386 // TODO: Use resp. 387 _ = resp 388} 389 390func ExampleCertificateAuthorityClient_ListCertificateRevocationLists() { 391 ctx := context.Background() 392 c, err := privateca.NewCertificateAuthorityClient(ctx) 393 if err != nil { 394 // TODO: Handle error. 395 } 396 defer c.Close() 397 398 req := &privatecapb.ListCertificateRevocationListsRequest{ 399 // TODO: Fill request struct fields. 400 } 401 it := c.ListCertificateRevocationLists(ctx, req) 402 for { 403 resp, err := it.Next() 404 if err == iterator.Done { 405 break 406 } 407 if err != nil { 408 // TODO: Handle error. 409 } 410 // TODO: Use resp. 411 _ = resp 412 } 413} 414 415func ExampleCertificateAuthorityClient_UpdateCertificateRevocationList() { 416 ctx := context.Background() 417 c, err := privateca.NewCertificateAuthorityClient(ctx) 418 if err != nil { 419 // TODO: Handle error. 420 } 421 defer c.Close() 422 423 req := &privatecapb.UpdateCertificateRevocationListRequest{ 424 // TODO: Fill request struct fields. 425 } 426 op, err := c.UpdateCertificateRevocationList(ctx, req) 427 if err != nil { 428 // TODO: Handle error. 429 } 430 431 resp, err := op.Wait(ctx) 432 if err != nil { 433 // TODO: Handle error. 434 } 435 // TODO: Use resp. 436 _ = resp 437} 438 439func ExampleCertificateAuthorityClient_GetReusableConfig() { 440 ctx := context.Background() 441 c, err := privateca.NewCertificateAuthorityClient(ctx) 442 if err != nil { 443 // TODO: Handle error. 444 } 445 defer c.Close() 446 447 req := &privatecapb.GetReusableConfigRequest{ 448 // TODO: Fill request struct fields. 449 } 450 resp, err := c.GetReusableConfig(ctx, req) 451 if err != nil { 452 // TODO: Handle error. 453 } 454 // TODO: Use resp. 455 _ = resp 456} 457 458func ExampleCertificateAuthorityClient_ListReusableConfigs() { 459 ctx := context.Background() 460 c, err := privateca.NewCertificateAuthorityClient(ctx) 461 if err != nil { 462 // TODO: Handle error. 463 } 464 defer c.Close() 465 466 req := &privatecapb.ListReusableConfigsRequest{ 467 // TODO: Fill request struct fields. 468 } 469 it := c.ListReusableConfigs(ctx, req) 470 for { 471 resp, err := it.Next() 472 if err == iterator.Done { 473 break 474 } 475 if err != nil { 476 // TODO: Handle error. 477 } 478 // TODO: Use resp. 479 _ = resp 480 } 481} 482