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 18 19import ( 20 "context" 21 "fmt" 22 "math" 23 "net/url" 24 "time" 25 26 "cloud.google.com/go/longrunning" 27 lroauto "cloud.google.com/go/longrunning/autogen" 28 gax "github.com/googleapis/gax-go/v2" 29 "google.golang.org/api/iterator" 30 "google.golang.org/api/option" 31 "google.golang.org/api/option/internaloption" 32 gtransport "google.golang.org/api/transport/grpc" 33 privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1beta1" 34 longrunningpb "google.golang.org/genproto/googleapis/longrunning" 35 "google.golang.org/grpc" 36 "google.golang.org/grpc/codes" 37 "google.golang.org/grpc/metadata" 38 "google.golang.org/protobuf/proto" 39) 40 41var newCertificateAuthorityClientHook clientHook 42 43// CertificateAuthorityCallOptions contains the retry settings for each method of CertificateAuthorityClient. 44type CertificateAuthorityCallOptions struct { 45 CreateCertificate []gax.CallOption 46 GetCertificate []gax.CallOption 47 ListCertificates []gax.CallOption 48 RevokeCertificate []gax.CallOption 49 UpdateCertificate []gax.CallOption 50 ActivateCertificateAuthority []gax.CallOption 51 CreateCertificateAuthority []gax.CallOption 52 DisableCertificateAuthority []gax.CallOption 53 EnableCertificateAuthority []gax.CallOption 54 FetchCertificateAuthorityCsr []gax.CallOption 55 GetCertificateAuthority []gax.CallOption 56 ListCertificateAuthorities []gax.CallOption 57 RestoreCertificateAuthority []gax.CallOption 58 ScheduleDeleteCertificateAuthority []gax.CallOption 59 UpdateCertificateAuthority []gax.CallOption 60 GetCertificateRevocationList []gax.CallOption 61 ListCertificateRevocationLists []gax.CallOption 62 UpdateCertificateRevocationList []gax.CallOption 63 GetReusableConfig []gax.CallOption 64 ListReusableConfigs []gax.CallOption 65} 66 67func defaultCertificateAuthorityGRPCClientOptions() []option.ClientOption { 68 return []option.ClientOption{ 69 internaloption.WithDefaultEndpoint("privateca.googleapis.com:443"), 70 internaloption.WithDefaultMTLSEndpoint("privateca.mtls.googleapis.com:443"), 71 internaloption.WithDefaultAudience("https://privateca.googleapis.com/"), 72 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 73 internaloption.EnableJwtWithScope(), 74 option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), 75 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 76 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 77 } 78} 79 80func defaultCertificateAuthorityCallOptions() *CertificateAuthorityCallOptions { 81 return &CertificateAuthorityCallOptions{ 82 CreateCertificate: []gax.CallOption{ 83 gax.WithRetry(func() gax.Retryer { 84 return gax.OnCodes([]codes.Code{ 85 codes.Unknown, 86 codes.Unavailable, 87 codes.DeadlineExceeded, 88 }, gax.Backoff{ 89 Initial: 100 * time.Millisecond, 90 Max: 60000 * time.Millisecond, 91 Multiplier: 1.30, 92 }) 93 }), 94 }, 95 GetCertificate: []gax.CallOption{ 96 gax.WithRetry(func() gax.Retryer { 97 return gax.OnCodes([]codes.Code{ 98 codes.Unknown, 99 codes.Unavailable, 100 codes.DeadlineExceeded, 101 }, gax.Backoff{ 102 Initial: 100 * time.Millisecond, 103 Max: 60000 * time.Millisecond, 104 Multiplier: 1.30, 105 }) 106 }), 107 }, 108 ListCertificates: []gax.CallOption{ 109 gax.WithRetry(func() gax.Retryer { 110 return gax.OnCodes([]codes.Code{ 111 codes.Unknown, 112 codes.Unavailable, 113 codes.DeadlineExceeded, 114 }, gax.Backoff{ 115 Initial: 100 * time.Millisecond, 116 Max: 60000 * time.Millisecond, 117 Multiplier: 1.30, 118 }) 119 }), 120 }, 121 RevokeCertificate: []gax.CallOption{ 122 gax.WithRetry(func() gax.Retryer { 123 return gax.OnCodes([]codes.Code{ 124 codes.Unknown, 125 codes.Unavailable, 126 codes.DeadlineExceeded, 127 }, gax.Backoff{ 128 Initial: 100 * time.Millisecond, 129 Max: 60000 * time.Millisecond, 130 Multiplier: 1.30, 131 }) 132 }), 133 }, 134 UpdateCertificate: []gax.CallOption{ 135 gax.WithRetry(func() gax.Retryer { 136 return gax.OnCodes([]codes.Code{ 137 codes.Unknown, 138 codes.Unavailable, 139 codes.DeadlineExceeded, 140 }, gax.Backoff{ 141 Initial: 100 * time.Millisecond, 142 Max: 60000 * time.Millisecond, 143 Multiplier: 1.30, 144 }) 145 }), 146 }, 147 ActivateCertificateAuthority: []gax.CallOption{ 148 gax.WithRetry(func() gax.Retryer { 149 return gax.OnCodes([]codes.Code{ 150 codes.Unknown, 151 codes.Unavailable, 152 codes.DeadlineExceeded, 153 }, gax.Backoff{ 154 Initial: 100 * time.Millisecond, 155 Max: 60000 * time.Millisecond, 156 Multiplier: 1.30, 157 }) 158 }), 159 }, 160 CreateCertificateAuthority: []gax.CallOption{ 161 gax.WithRetry(func() gax.Retryer { 162 return gax.OnCodes([]codes.Code{ 163 codes.Unknown, 164 codes.Unavailable, 165 codes.DeadlineExceeded, 166 }, gax.Backoff{ 167 Initial: 100 * time.Millisecond, 168 Max: 60000 * time.Millisecond, 169 Multiplier: 1.30, 170 }) 171 }), 172 }, 173 DisableCertificateAuthority: []gax.CallOption{ 174 gax.WithRetry(func() gax.Retryer { 175 return gax.OnCodes([]codes.Code{ 176 codes.Unknown, 177 codes.Unavailable, 178 codes.DeadlineExceeded, 179 }, gax.Backoff{ 180 Initial: 100 * time.Millisecond, 181 Max: 60000 * time.Millisecond, 182 Multiplier: 1.30, 183 }) 184 }), 185 }, 186 EnableCertificateAuthority: []gax.CallOption{ 187 gax.WithRetry(func() gax.Retryer { 188 return gax.OnCodes([]codes.Code{ 189 codes.Unknown, 190 codes.Unavailable, 191 codes.DeadlineExceeded, 192 }, gax.Backoff{ 193 Initial: 100 * time.Millisecond, 194 Max: 60000 * time.Millisecond, 195 Multiplier: 1.30, 196 }) 197 }), 198 }, 199 FetchCertificateAuthorityCsr: []gax.CallOption{ 200 gax.WithRetry(func() gax.Retryer { 201 return gax.OnCodes([]codes.Code{ 202 codes.Unknown, 203 codes.Unavailable, 204 codes.DeadlineExceeded, 205 }, gax.Backoff{ 206 Initial: 100 * time.Millisecond, 207 Max: 60000 * time.Millisecond, 208 Multiplier: 1.30, 209 }) 210 }), 211 }, 212 GetCertificateAuthority: []gax.CallOption{ 213 gax.WithRetry(func() gax.Retryer { 214 return gax.OnCodes([]codes.Code{ 215 codes.Unknown, 216 codes.Unavailable, 217 codes.DeadlineExceeded, 218 }, gax.Backoff{ 219 Initial: 100 * time.Millisecond, 220 Max: 60000 * time.Millisecond, 221 Multiplier: 1.30, 222 }) 223 }), 224 }, 225 ListCertificateAuthorities: []gax.CallOption{ 226 gax.WithRetry(func() gax.Retryer { 227 return gax.OnCodes([]codes.Code{ 228 codes.Unknown, 229 codes.Unavailable, 230 codes.DeadlineExceeded, 231 }, gax.Backoff{ 232 Initial: 100 * time.Millisecond, 233 Max: 60000 * time.Millisecond, 234 Multiplier: 1.30, 235 }) 236 }), 237 }, 238 RestoreCertificateAuthority: []gax.CallOption{ 239 gax.WithRetry(func() gax.Retryer { 240 return gax.OnCodes([]codes.Code{ 241 codes.Unknown, 242 codes.Unavailable, 243 codes.DeadlineExceeded, 244 }, gax.Backoff{ 245 Initial: 100 * time.Millisecond, 246 Max: 60000 * time.Millisecond, 247 Multiplier: 1.30, 248 }) 249 }), 250 }, 251 ScheduleDeleteCertificateAuthority: []gax.CallOption{ 252 gax.WithRetry(func() gax.Retryer { 253 return gax.OnCodes([]codes.Code{ 254 codes.Unknown, 255 codes.Unavailable, 256 codes.DeadlineExceeded, 257 }, gax.Backoff{ 258 Initial: 100 * time.Millisecond, 259 Max: 60000 * time.Millisecond, 260 Multiplier: 1.30, 261 }) 262 }), 263 }, 264 UpdateCertificateAuthority: []gax.CallOption{ 265 gax.WithRetry(func() gax.Retryer { 266 return gax.OnCodes([]codes.Code{ 267 codes.Unknown, 268 codes.Unavailable, 269 codes.DeadlineExceeded, 270 }, gax.Backoff{ 271 Initial: 100 * time.Millisecond, 272 Max: 60000 * time.Millisecond, 273 Multiplier: 1.30, 274 }) 275 }), 276 }, 277 GetCertificateRevocationList: []gax.CallOption{ 278 gax.WithRetry(func() gax.Retryer { 279 return gax.OnCodes([]codes.Code{ 280 codes.Unknown, 281 codes.Unavailable, 282 codes.DeadlineExceeded, 283 }, gax.Backoff{ 284 Initial: 100 * time.Millisecond, 285 Max: 60000 * time.Millisecond, 286 Multiplier: 1.30, 287 }) 288 }), 289 }, 290 ListCertificateRevocationLists: []gax.CallOption{ 291 gax.WithRetry(func() gax.Retryer { 292 return gax.OnCodes([]codes.Code{ 293 codes.Unknown, 294 codes.Unavailable, 295 codes.DeadlineExceeded, 296 }, gax.Backoff{ 297 Initial: 100 * time.Millisecond, 298 Max: 60000 * time.Millisecond, 299 Multiplier: 1.30, 300 }) 301 }), 302 }, 303 UpdateCertificateRevocationList: []gax.CallOption{ 304 gax.WithRetry(func() gax.Retryer { 305 return gax.OnCodes([]codes.Code{ 306 codes.Unknown, 307 codes.Unavailable, 308 codes.DeadlineExceeded, 309 }, gax.Backoff{ 310 Initial: 100 * time.Millisecond, 311 Max: 60000 * time.Millisecond, 312 Multiplier: 1.30, 313 }) 314 }), 315 }, 316 GetReusableConfig: []gax.CallOption{ 317 gax.WithRetry(func() gax.Retryer { 318 return gax.OnCodes([]codes.Code{ 319 codes.Unknown, 320 codes.Unavailable, 321 codes.DeadlineExceeded, 322 }, gax.Backoff{ 323 Initial: 100 * time.Millisecond, 324 Max: 60000 * time.Millisecond, 325 Multiplier: 1.30, 326 }) 327 }), 328 }, 329 ListReusableConfigs: []gax.CallOption{ 330 gax.WithRetry(func() gax.Retryer { 331 return gax.OnCodes([]codes.Code{ 332 codes.Unknown, 333 codes.Unavailable, 334 codes.DeadlineExceeded, 335 }, gax.Backoff{ 336 Initial: 100 * time.Millisecond, 337 Max: 60000 * time.Millisecond, 338 Multiplier: 1.30, 339 }) 340 }), 341 }, 342 } 343} 344 345// internalCertificateAuthorityClient is an interface that defines the methods availaible from Certificate Authority API. 346type internalCertificateAuthorityClient interface { 347 Close() error 348 setGoogleClientInfo(...string) 349 Connection() *grpc.ClientConn 350 CreateCertificate(context.Context, *privatecapb.CreateCertificateRequest, ...gax.CallOption) (*privatecapb.Certificate, error) 351 GetCertificate(context.Context, *privatecapb.GetCertificateRequest, ...gax.CallOption) (*privatecapb.Certificate, error) 352 ListCertificates(context.Context, *privatecapb.ListCertificatesRequest, ...gax.CallOption) *CertificateIterator 353 RevokeCertificate(context.Context, *privatecapb.RevokeCertificateRequest, ...gax.CallOption) (*privatecapb.Certificate, error) 354 UpdateCertificate(context.Context, *privatecapb.UpdateCertificateRequest, ...gax.CallOption) (*privatecapb.Certificate, error) 355 ActivateCertificateAuthority(context.Context, *privatecapb.ActivateCertificateAuthorityRequest, ...gax.CallOption) (*ActivateCertificateAuthorityOperation, error) 356 ActivateCertificateAuthorityOperation(name string) *ActivateCertificateAuthorityOperation 357 CreateCertificateAuthority(context.Context, *privatecapb.CreateCertificateAuthorityRequest, ...gax.CallOption) (*CreateCertificateAuthorityOperation, error) 358 CreateCertificateAuthorityOperation(name string) *CreateCertificateAuthorityOperation 359 DisableCertificateAuthority(context.Context, *privatecapb.DisableCertificateAuthorityRequest, ...gax.CallOption) (*DisableCertificateAuthorityOperation, error) 360 DisableCertificateAuthorityOperation(name string) *DisableCertificateAuthorityOperation 361 EnableCertificateAuthority(context.Context, *privatecapb.EnableCertificateAuthorityRequest, ...gax.CallOption) (*EnableCertificateAuthorityOperation, error) 362 EnableCertificateAuthorityOperation(name string) *EnableCertificateAuthorityOperation 363 FetchCertificateAuthorityCsr(context.Context, *privatecapb.FetchCertificateAuthorityCsrRequest, ...gax.CallOption) (*privatecapb.FetchCertificateAuthorityCsrResponse, error) 364 GetCertificateAuthority(context.Context, *privatecapb.GetCertificateAuthorityRequest, ...gax.CallOption) (*privatecapb.CertificateAuthority, error) 365 ListCertificateAuthorities(context.Context, *privatecapb.ListCertificateAuthoritiesRequest, ...gax.CallOption) *CertificateAuthorityIterator 366 RestoreCertificateAuthority(context.Context, *privatecapb.RestoreCertificateAuthorityRequest, ...gax.CallOption) (*RestoreCertificateAuthorityOperation, error) 367 RestoreCertificateAuthorityOperation(name string) *RestoreCertificateAuthorityOperation 368 ScheduleDeleteCertificateAuthority(context.Context, *privatecapb.ScheduleDeleteCertificateAuthorityRequest, ...gax.CallOption) (*ScheduleDeleteCertificateAuthorityOperation, error) 369 ScheduleDeleteCertificateAuthorityOperation(name string) *ScheduleDeleteCertificateAuthorityOperation 370 UpdateCertificateAuthority(context.Context, *privatecapb.UpdateCertificateAuthorityRequest, ...gax.CallOption) (*UpdateCertificateAuthorityOperation, error) 371 UpdateCertificateAuthorityOperation(name string) *UpdateCertificateAuthorityOperation 372 GetCertificateRevocationList(context.Context, *privatecapb.GetCertificateRevocationListRequest, ...gax.CallOption) (*privatecapb.CertificateRevocationList, error) 373 ListCertificateRevocationLists(context.Context, *privatecapb.ListCertificateRevocationListsRequest, ...gax.CallOption) *CertificateRevocationListIterator 374 UpdateCertificateRevocationList(context.Context, *privatecapb.UpdateCertificateRevocationListRequest, ...gax.CallOption) (*UpdateCertificateRevocationListOperation, error) 375 UpdateCertificateRevocationListOperation(name string) *UpdateCertificateRevocationListOperation 376 GetReusableConfig(context.Context, *privatecapb.GetReusableConfigRequest, ...gax.CallOption) (*privatecapb.ReusableConfig, error) 377 ListReusableConfigs(context.Context, *privatecapb.ListReusableConfigsRequest, ...gax.CallOption) *ReusableConfigIterator 378} 379 380// CertificateAuthorityClient is a client for interacting with Certificate Authority API. 381// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 382// 383// [Certificate Authority Service][google.cloud.security.privateca.v1beta1.CertificateAuthorityService] manages private 384// certificate authorities and issued certificates. 385type CertificateAuthorityClient struct { 386 // The internal transport-dependent client. 387 internalClient internalCertificateAuthorityClient 388 389 // The call options for this service. 390 CallOptions *CertificateAuthorityCallOptions 391 392 // LROClient is used internally to handle long-running operations. 393 // It is exposed so that its CallOptions can be modified if required. 394 // Users should not Close this client. 395 LROClient *lroauto.OperationsClient 396} 397 398// Wrapper methods routed to the internal client. 399 400// Close closes the connection to the API service. The user should invoke this when 401// the client is no longer required. 402func (c *CertificateAuthorityClient) Close() error { 403 return c.internalClient.Close() 404} 405 406// setGoogleClientInfo sets the name and version of the application in 407// the `x-goog-api-client` header passed on each request. Intended for 408// use by Google-written clients. 409func (c *CertificateAuthorityClient) setGoogleClientInfo(keyval ...string) { 410 c.internalClient.setGoogleClientInfo(keyval...) 411} 412 413// Connection returns a connection to the API service. 414// 415// Deprecated. 416func (c *CertificateAuthorityClient) Connection() *grpc.ClientConn { 417 return c.internalClient.Connection() 418} 419 420// CreateCertificate create a new Certificate in a given Project, Location from a particular 421// CertificateAuthority. 422func (c *CertificateAuthorityClient) CreateCertificate(ctx context.Context, req *privatecapb.CreateCertificateRequest, opts ...gax.CallOption) (*privatecapb.Certificate, error) { 423 return c.internalClient.CreateCertificate(ctx, req, opts...) 424} 425 426// GetCertificate returns a Certificate. 427func (c *CertificateAuthorityClient) GetCertificate(ctx context.Context, req *privatecapb.GetCertificateRequest, opts ...gax.CallOption) (*privatecapb.Certificate, error) { 428 return c.internalClient.GetCertificate(ctx, req, opts...) 429} 430 431// ListCertificates lists Certificates. 432func (c *CertificateAuthorityClient) ListCertificates(ctx context.Context, req *privatecapb.ListCertificatesRequest, opts ...gax.CallOption) *CertificateIterator { 433 return c.internalClient.ListCertificates(ctx, req, opts...) 434} 435 436// RevokeCertificate revoke a Certificate. 437func (c *CertificateAuthorityClient) RevokeCertificate(ctx context.Context, req *privatecapb.RevokeCertificateRequest, opts ...gax.CallOption) (*privatecapb.Certificate, error) { 438 return c.internalClient.RevokeCertificate(ctx, req, opts...) 439} 440 441// UpdateCertificate update a Certificate. Currently, the only field you can update is the 442// labels field. 443func (c *CertificateAuthorityClient) UpdateCertificate(ctx context.Context, req *privatecapb.UpdateCertificateRequest, opts ...gax.CallOption) (*privatecapb.Certificate, error) { 444 return c.internalClient.UpdateCertificate(ctx, req, opts...) 445} 446 447// ActivateCertificateAuthority activate a CertificateAuthority that is in state 448// PENDING_ACTIVATION and is 449// of type SUBORDINATE. After the 450// parent Certificate Authority signs a certificate signing request from 451// FetchCertificateAuthorityCsr, this method can complete the activation 452// process. 453func (c *CertificateAuthorityClient) ActivateCertificateAuthority(ctx context.Context, req *privatecapb.ActivateCertificateAuthorityRequest, opts ...gax.CallOption) (*ActivateCertificateAuthorityOperation, error) { 454 return c.internalClient.ActivateCertificateAuthority(ctx, req, opts...) 455} 456 457// ActivateCertificateAuthorityOperation returns a new ActivateCertificateAuthorityOperation from a given name. 458// The name must be that of a previously created ActivateCertificateAuthorityOperation, possibly from a different process. 459func (c *CertificateAuthorityClient) ActivateCertificateAuthorityOperation(name string) *ActivateCertificateAuthorityOperation { 460 return c.internalClient.ActivateCertificateAuthorityOperation(name) 461} 462 463// CreateCertificateAuthority create a new CertificateAuthority in a given Project and Location. 464func (c *CertificateAuthorityClient) CreateCertificateAuthority(ctx context.Context, req *privatecapb.CreateCertificateAuthorityRequest, opts ...gax.CallOption) (*CreateCertificateAuthorityOperation, error) { 465 return c.internalClient.CreateCertificateAuthority(ctx, req, opts...) 466} 467 468// CreateCertificateAuthorityOperation returns a new CreateCertificateAuthorityOperation from a given name. 469// The name must be that of a previously created CreateCertificateAuthorityOperation, possibly from a different process. 470func (c *CertificateAuthorityClient) CreateCertificateAuthorityOperation(name string) *CreateCertificateAuthorityOperation { 471 return c.internalClient.CreateCertificateAuthorityOperation(name) 472} 473 474// DisableCertificateAuthority disable a CertificateAuthority. 475func (c *CertificateAuthorityClient) DisableCertificateAuthority(ctx context.Context, req *privatecapb.DisableCertificateAuthorityRequest, opts ...gax.CallOption) (*DisableCertificateAuthorityOperation, error) { 476 return c.internalClient.DisableCertificateAuthority(ctx, req, opts...) 477} 478 479// DisableCertificateAuthorityOperation returns a new DisableCertificateAuthorityOperation from a given name. 480// The name must be that of a previously created DisableCertificateAuthorityOperation, possibly from a different process. 481func (c *CertificateAuthorityClient) DisableCertificateAuthorityOperation(name string) *DisableCertificateAuthorityOperation { 482 return c.internalClient.DisableCertificateAuthorityOperation(name) 483} 484 485// EnableCertificateAuthority enable a CertificateAuthority. 486func (c *CertificateAuthorityClient) EnableCertificateAuthority(ctx context.Context, req *privatecapb.EnableCertificateAuthorityRequest, opts ...gax.CallOption) (*EnableCertificateAuthorityOperation, error) { 487 return c.internalClient.EnableCertificateAuthority(ctx, req, opts...) 488} 489 490// EnableCertificateAuthorityOperation returns a new EnableCertificateAuthorityOperation from a given name. 491// The name must be that of a previously created EnableCertificateAuthorityOperation, possibly from a different process. 492func (c *CertificateAuthorityClient) EnableCertificateAuthorityOperation(name string) *EnableCertificateAuthorityOperation { 493 return c.internalClient.EnableCertificateAuthorityOperation(name) 494} 495 496// FetchCertificateAuthorityCsr fetch a certificate signing request (CSR) from a CertificateAuthority 497// that is in state 498// PENDING_ACTIVATION and is 499// of type SUBORDINATE. The CSR must 500// then be signed by the desired parent Certificate Authority, which could be 501// another CertificateAuthority resource, or could be an on-prem 502// certificate authority. See also ActivateCertificateAuthority. 503func (c *CertificateAuthorityClient) FetchCertificateAuthorityCsr(ctx context.Context, req *privatecapb.FetchCertificateAuthorityCsrRequest, opts ...gax.CallOption) (*privatecapb.FetchCertificateAuthorityCsrResponse, error) { 504 return c.internalClient.FetchCertificateAuthorityCsr(ctx, req, opts...) 505} 506 507// GetCertificateAuthority returns a CertificateAuthority. 508func (c *CertificateAuthorityClient) GetCertificateAuthority(ctx context.Context, req *privatecapb.GetCertificateAuthorityRequest, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 509 return c.internalClient.GetCertificateAuthority(ctx, req, opts...) 510} 511 512// ListCertificateAuthorities lists CertificateAuthorities. 513func (c *CertificateAuthorityClient) ListCertificateAuthorities(ctx context.Context, req *privatecapb.ListCertificateAuthoritiesRequest, opts ...gax.CallOption) *CertificateAuthorityIterator { 514 return c.internalClient.ListCertificateAuthorities(ctx, req, opts...) 515} 516 517// RestoreCertificateAuthority restore a CertificateAuthority that is scheduled for deletion. 518func (c *CertificateAuthorityClient) RestoreCertificateAuthority(ctx context.Context, req *privatecapb.RestoreCertificateAuthorityRequest, opts ...gax.CallOption) (*RestoreCertificateAuthorityOperation, error) { 519 return c.internalClient.RestoreCertificateAuthority(ctx, req, opts...) 520} 521 522// RestoreCertificateAuthorityOperation returns a new RestoreCertificateAuthorityOperation from a given name. 523// The name must be that of a previously created RestoreCertificateAuthorityOperation, possibly from a different process. 524func (c *CertificateAuthorityClient) RestoreCertificateAuthorityOperation(name string) *RestoreCertificateAuthorityOperation { 525 return c.internalClient.RestoreCertificateAuthorityOperation(name) 526} 527 528// ScheduleDeleteCertificateAuthority schedule a CertificateAuthority for deletion. 529func (c *CertificateAuthorityClient) ScheduleDeleteCertificateAuthority(ctx context.Context, req *privatecapb.ScheduleDeleteCertificateAuthorityRequest, opts ...gax.CallOption) (*ScheduleDeleteCertificateAuthorityOperation, error) { 530 return c.internalClient.ScheduleDeleteCertificateAuthority(ctx, req, opts...) 531} 532 533// ScheduleDeleteCertificateAuthorityOperation returns a new ScheduleDeleteCertificateAuthorityOperation from a given name. 534// The name must be that of a previously created ScheduleDeleteCertificateAuthorityOperation, possibly from a different process. 535func (c *CertificateAuthorityClient) ScheduleDeleteCertificateAuthorityOperation(name string) *ScheduleDeleteCertificateAuthorityOperation { 536 return c.internalClient.ScheduleDeleteCertificateAuthorityOperation(name) 537} 538 539// UpdateCertificateAuthority update a CertificateAuthority. 540func (c *CertificateAuthorityClient) UpdateCertificateAuthority(ctx context.Context, req *privatecapb.UpdateCertificateAuthorityRequest, opts ...gax.CallOption) (*UpdateCertificateAuthorityOperation, error) { 541 return c.internalClient.UpdateCertificateAuthority(ctx, req, opts...) 542} 543 544// UpdateCertificateAuthorityOperation returns a new UpdateCertificateAuthorityOperation from a given name. 545// The name must be that of a previously created UpdateCertificateAuthorityOperation, possibly from a different process. 546func (c *CertificateAuthorityClient) UpdateCertificateAuthorityOperation(name string) *UpdateCertificateAuthorityOperation { 547 return c.internalClient.UpdateCertificateAuthorityOperation(name) 548} 549 550// GetCertificateRevocationList returns a CertificateRevocationList. 551func (c *CertificateAuthorityClient) GetCertificateRevocationList(ctx context.Context, req *privatecapb.GetCertificateRevocationListRequest, opts ...gax.CallOption) (*privatecapb.CertificateRevocationList, error) { 552 return c.internalClient.GetCertificateRevocationList(ctx, req, opts...) 553} 554 555// ListCertificateRevocationLists lists CertificateRevocationLists. 556func (c *CertificateAuthorityClient) ListCertificateRevocationLists(ctx context.Context, req *privatecapb.ListCertificateRevocationListsRequest, opts ...gax.CallOption) *CertificateRevocationListIterator { 557 return c.internalClient.ListCertificateRevocationLists(ctx, req, opts...) 558} 559 560// UpdateCertificateRevocationList update a CertificateRevocationList. 561func (c *CertificateAuthorityClient) UpdateCertificateRevocationList(ctx context.Context, req *privatecapb.UpdateCertificateRevocationListRequest, opts ...gax.CallOption) (*UpdateCertificateRevocationListOperation, error) { 562 return c.internalClient.UpdateCertificateRevocationList(ctx, req, opts...) 563} 564 565// UpdateCertificateRevocationListOperation returns a new UpdateCertificateRevocationListOperation from a given name. 566// The name must be that of a previously created UpdateCertificateRevocationListOperation, possibly from a different process. 567func (c *CertificateAuthorityClient) UpdateCertificateRevocationListOperation(name string) *UpdateCertificateRevocationListOperation { 568 return c.internalClient.UpdateCertificateRevocationListOperation(name) 569} 570 571// GetReusableConfig returns a ReusableConfig. 572func (c *CertificateAuthorityClient) GetReusableConfig(ctx context.Context, req *privatecapb.GetReusableConfigRequest, opts ...gax.CallOption) (*privatecapb.ReusableConfig, error) { 573 return c.internalClient.GetReusableConfig(ctx, req, opts...) 574} 575 576// ListReusableConfigs lists ReusableConfigs. 577func (c *CertificateAuthorityClient) ListReusableConfigs(ctx context.Context, req *privatecapb.ListReusableConfigsRequest, opts ...gax.CallOption) *ReusableConfigIterator { 578 return c.internalClient.ListReusableConfigs(ctx, req, opts...) 579} 580 581// certificateAuthorityGRPCClient is a client for interacting with Certificate Authority API over gRPC transport. 582// 583// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 584type certificateAuthorityGRPCClient struct { 585 // Connection pool of gRPC connections to the service. 586 connPool gtransport.ConnPool 587 588 // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE 589 disableDeadlines bool 590 591 // Points back to the CallOptions field of the containing CertificateAuthorityClient 592 CallOptions **CertificateAuthorityCallOptions 593 594 // The gRPC API client. 595 certificateAuthorityClient privatecapb.CertificateAuthorityServiceClient 596 597 // LROClient is used internally to handle long-running operations. 598 // It is exposed so that its CallOptions can be modified if required. 599 // Users should not Close this client. 600 LROClient **lroauto.OperationsClient 601 602 // The x-goog-* metadata to be sent with each request. 603 xGoogMetadata metadata.MD 604} 605 606// NewCertificateAuthorityClient creates a new certificate authority service client based on gRPC. 607// The returned client must be Closed when it is done being used to clean up its underlying connections. 608// 609// [Certificate Authority Service][google.cloud.security.privateca.v1beta1.CertificateAuthorityService] manages private 610// certificate authorities and issued certificates. 611func NewCertificateAuthorityClient(ctx context.Context, opts ...option.ClientOption) (*CertificateAuthorityClient, error) { 612 clientOpts := defaultCertificateAuthorityGRPCClientOptions() 613 if newCertificateAuthorityClientHook != nil { 614 hookOpts, err := newCertificateAuthorityClientHook(ctx, clientHookParams{}) 615 if err != nil { 616 return nil, err 617 } 618 clientOpts = append(clientOpts, hookOpts...) 619 } 620 621 disableDeadlines, err := checkDisableDeadlines() 622 if err != nil { 623 return nil, err 624 } 625 626 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 627 if err != nil { 628 return nil, err 629 } 630 client := CertificateAuthorityClient{CallOptions: defaultCertificateAuthorityCallOptions()} 631 632 c := &certificateAuthorityGRPCClient{ 633 connPool: connPool, 634 disableDeadlines: disableDeadlines, 635 certificateAuthorityClient: privatecapb.NewCertificateAuthorityServiceClient(connPool), 636 CallOptions: &client.CallOptions, 637 } 638 c.setGoogleClientInfo() 639 640 client.internalClient = c 641 642 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) 643 if err != nil { 644 // This error "should not happen", since we are just reusing old connection pool 645 // and never actually need to dial. 646 // If this does happen, we could leak connp. However, we cannot close conn: 647 // If the user invoked the constructor with option.WithGRPCConn, 648 // we would close a connection that's still in use. 649 // TODO: investigate error conditions. 650 return nil, err 651 } 652 c.LROClient = &client.LROClient 653 return &client, nil 654} 655 656// Connection returns a connection to the API service. 657// 658// Deprecated. 659func (c *certificateAuthorityGRPCClient) Connection() *grpc.ClientConn { 660 return c.connPool.Conn() 661} 662 663// setGoogleClientInfo sets the name and version of the application in 664// the `x-goog-api-client` header passed on each request. Intended for 665// use by Google-written clients. 666func (c *certificateAuthorityGRPCClient) setGoogleClientInfo(keyval ...string) { 667 kv := append([]string{"gl-go", versionGo()}, keyval...) 668 kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) 669 c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) 670} 671 672// Close closes the connection to the API service. The user should invoke this when 673// the client is no longer required. 674func (c *certificateAuthorityGRPCClient) Close() error { 675 return c.connPool.Close() 676} 677 678func (c *certificateAuthorityGRPCClient) CreateCertificate(ctx context.Context, req *privatecapb.CreateCertificateRequest, opts ...gax.CallOption) (*privatecapb.Certificate, error) { 679 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 680 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 681 defer cancel() 682 ctx = cctx 683 } 684 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 685 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 686 opts = append((*c.CallOptions).CreateCertificate[0:len((*c.CallOptions).CreateCertificate):len((*c.CallOptions).CreateCertificate)], opts...) 687 var resp *privatecapb.Certificate 688 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 689 var err error 690 resp, err = c.certificateAuthorityClient.CreateCertificate(ctx, req, settings.GRPC...) 691 return err 692 }, opts...) 693 if err != nil { 694 return nil, err 695 } 696 return resp, nil 697} 698 699func (c *certificateAuthorityGRPCClient) GetCertificate(ctx context.Context, req *privatecapb.GetCertificateRequest, opts ...gax.CallOption) (*privatecapb.Certificate, error) { 700 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 701 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 702 defer cancel() 703 ctx = cctx 704 } 705 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 706 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 707 opts = append((*c.CallOptions).GetCertificate[0:len((*c.CallOptions).GetCertificate):len((*c.CallOptions).GetCertificate)], opts...) 708 var resp *privatecapb.Certificate 709 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 710 var err error 711 resp, err = c.certificateAuthorityClient.GetCertificate(ctx, req, settings.GRPC...) 712 return err 713 }, opts...) 714 if err != nil { 715 return nil, err 716 } 717 return resp, nil 718} 719 720func (c *certificateAuthorityGRPCClient) ListCertificates(ctx context.Context, req *privatecapb.ListCertificatesRequest, opts ...gax.CallOption) *CertificateIterator { 721 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 722 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 723 opts = append((*c.CallOptions).ListCertificates[0:len((*c.CallOptions).ListCertificates):len((*c.CallOptions).ListCertificates)], opts...) 724 it := &CertificateIterator{} 725 req = proto.Clone(req).(*privatecapb.ListCertificatesRequest) 726 it.InternalFetch = func(pageSize int, pageToken string) ([]*privatecapb.Certificate, string, error) { 727 resp := &privatecapb.ListCertificatesResponse{} 728 if pageToken != "" { 729 req.PageToken = pageToken 730 } 731 if pageSize > math.MaxInt32 { 732 req.PageSize = math.MaxInt32 733 } else if pageSize != 0 { 734 req.PageSize = int32(pageSize) 735 } 736 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 737 var err error 738 resp, err = c.certificateAuthorityClient.ListCertificates(ctx, req, settings.GRPC...) 739 return err 740 }, opts...) 741 if err != nil { 742 return nil, "", err 743 } 744 745 it.Response = resp 746 return resp.GetCertificates(), resp.GetNextPageToken(), nil 747 } 748 fetch := func(pageSize int, pageToken string) (string, error) { 749 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 750 if err != nil { 751 return "", err 752 } 753 it.items = append(it.items, items...) 754 return nextPageToken, nil 755 } 756 757 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 758 it.pageInfo.MaxSize = int(req.GetPageSize()) 759 it.pageInfo.Token = req.GetPageToken() 760 761 return it 762} 763 764func (c *certificateAuthorityGRPCClient) RevokeCertificate(ctx context.Context, req *privatecapb.RevokeCertificateRequest, opts ...gax.CallOption) (*privatecapb.Certificate, error) { 765 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 766 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 767 defer cancel() 768 ctx = cctx 769 } 770 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 771 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 772 opts = append((*c.CallOptions).RevokeCertificate[0:len((*c.CallOptions).RevokeCertificate):len((*c.CallOptions).RevokeCertificate)], opts...) 773 var resp *privatecapb.Certificate 774 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 775 var err error 776 resp, err = c.certificateAuthorityClient.RevokeCertificate(ctx, req, settings.GRPC...) 777 return err 778 }, opts...) 779 if err != nil { 780 return nil, err 781 } 782 return resp, nil 783} 784 785func (c *certificateAuthorityGRPCClient) UpdateCertificate(ctx context.Context, req *privatecapb.UpdateCertificateRequest, opts ...gax.CallOption) (*privatecapb.Certificate, error) { 786 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 787 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 788 defer cancel() 789 ctx = cctx 790 } 791 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "certificate.name", url.QueryEscape(req.GetCertificate().GetName()))) 792 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 793 opts = append((*c.CallOptions).UpdateCertificate[0:len((*c.CallOptions).UpdateCertificate):len((*c.CallOptions).UpdateCertificate)], opts...) 794 var resp *privatecapb.Certificate 795 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 796 var err error 797 resp, err = c.certificateAuthorityClient.UpdateCertificate(ctx, req, settings.GRPC...) 798 return err 799 }, opts...) 800 if err != nil { 801 return nil, err 802 } 803 return resp, nil 804} 805 806func (c *certificateAuthorityGRPCClient) ActivateCertificateAuthority(ctx context.Context, req *privatecapb.ActivateCertificateAuthorityRequest, opts ...gax.CallOption) (*ActivateCertificateAuthorityOperation, error) { 807 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 808 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 809 defer cancel() 810 ctx = cctx 811 } 812 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 813 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 814 opts = append((*c.CallOptions).ActivateCertificateAuthority[0:len((*c.CallOptions).ActivateCertificateAuthority):len((*c.CallOptions).ActivateCertificateAuthority)], opts...) 815 var resp *longrunningpb.Operation 816 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 817 var err error 818 resp, err = c.certificateAuthorityClient.ActivateCertificateAuthority(ctx, req, settings.GRPC...) 819 return err 820 }, opts...) 821 if err != nil { 822 return nil, err 823 } 824 return &ActivateCertificateAuthorityOperation{ 825 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 826 }, nil 827} 828 829func (c *certificateAuthorityGRPCClient) CreateCertificateAuthority(ctx context.Context, req *privatecapb.CreateCertificateAuthorityRequest, opts ...gax.CallOption) (*CreateCertificateAuthorityOperation, error) { 830 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 831 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 832 defer cancel() 833 ctx = cctx 834 } 835 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 836 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 837 opts = append((*c.CallOptions).CreateCertificateAuthority[0:len((*c.CallOptions).CreateCertificateAuthority):len((*c.CallOptions).CreateCertificateAuthority)], opts...) 838 var resp *longrunningpb.Operation 839 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 840 var err error 841 resp, err = c.certificateAuthorityClient.CreateCertificateAuthority(ctx, req, settings.GRPC...) 842 return err 843 }, opts...) 844 if err != nil { 845 return nil, err 846 } 847 return &CreateCertificateAuthorityOperation{ 848 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 849 }, nil 850} 851 852func (c *certificateAuthorityGRPCClient) DisableCertificateAuthority(ctx context.Context, req *privatecapb.DisableCertificateAuthorityRequest, opts ...gax.CallOption) (*DisableCertificateAuthorityOperation, error) { 853 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 854 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 855 defer cancel() 856 ctx = cctx 857 } 858 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 859 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 860 opts = append((*c.CallOptions).DisableCertificateAuthority[0:len((*c.CallOptions).DisableCertificateAuthority):len((*c.CallOptions).DisableCertificateAuthority)], opts...) 861 var resp *longrunningpb.Operation 862 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 863 var err error 864 resp, err = c.certificateAuthorityClient.DisableCertificateAuthority(ctx, req, settings.GRPC...) 865 return err 866 }, opts...) 867 if err != nil { 868 return nil, err 869 } 870 return &DisableCertificateAuthorityOperation{ 871 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 872 }, nil 873} 874 875func (c *certificateAuthorityGRPCClient) EnableCertificateAuthority(ctx context.Context, req *privatecapb.EnableCertificateAuthorityRequest, opts ...gax.CallOption) (*EnableCertificateAuthorityOperation, error) { 876 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 877 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 878 defer cancel() 879 ctx = cctx 880 } 881 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 882 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 883 opts = append((*c.CallOptions).EnableCertificateAuthority[0:len((*c.CallOptions).EnableCertificateAuthority):len((*c.CallOptions).EnableCertificateAuthority)], opts...) 884 var resp *longrunningpb.Operation 885 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 886 var err error 887 resp, err = c.certificateAuthorityClient.EnableCertificateAuthority(ctx, req, settings.GRPC...) 888 return err 889 }, opts...) 890 if err != nil { 891 return nil, err 892 } 893 return &EnableCertificateAuthorityOperation{ 894 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 895 }, nil 896} 897 898func (c *certificateAuthorityGRPCClient) FetchCertificateAuthorityCsr(ctx context.Context, req *privatecapb.FetchCertificateAuthorityCsrRequest, opts ...gax.CallOption) (*privatecapb.FetchCertificateAuthorityCsrResponse, error) { 899 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 900 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 901 defer cancel() 902 ctx = cctx 903 } 904 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 905 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 906 opts = append((*c.CallOptions).FetchCertificateAuthorityCsr[0:len((*c.CallOptions).FetchCertificateAuthorityCsr):len((*c.CallOptions).FetchCertificateAuthorityCsr)], opts...) 907 var resp *privatecapb.FetchCertificateAuthorityCsrResponse 908 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 909 var err error 910 resp, err = c.certificateAuthorityClient.FetchCertificateAuthorityCsr(ctx, req, settings.GRPC...) 911 return err 912 }, opts...) 913 if err != nil { 914 return nil, err 915 } 916 return resp, nil 917} 918 919func (c *certificateAuthorityGRPCClient) GetCertificateAuthority(ctx context.Context, req *privatecapb.GetCertificateAuthorityRequest, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 920 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 921 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 922 defer cancel() 923 ctx = cctx 924 } 925 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 926 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 927 opts = append((*c.CallOptions).GetCertificateAuthority[0:len((*c.CallOptions).GetCertificateAuthority):len((*c.CallOptions).GetCertificateAuthority)], opts...) 928 var resp *privatecapb.CertificateAuthority 929 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 930 var err error 931 resp, err = c.certificateAuthorityClient.GetCertificateAuthority(ctx, req, settings.GRPC...) 932 return err 933 }, opts...) 934 if err != nil { 935 return nil, err 936 } 937 return resp, nil 938} 939 940func (c *certificateAuthorityGRPCClient) ListCertificateAuthorities(ctx context.Context, req *privatecapb.ListCertificateAuthoritiesRequest, opts ...gax.CallOption) *CertificateAuthorityIterator { 941 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 942 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 943 opts = append((*c.CallOptions).ListCertificateAuthorities[0:len((*c.CallOptions).ListCertificateAuthorities):len((*c.CallOptions).ListCertificateAuthorities)], opts...) 944 it := &CertificateAuthorityIterator{} 945 req = proto.Clone(req).(*privatecapb.ListCertificateAuthoritiesRequest) 946 it.InternalFetch = func(pageSize int, pageToken string) ([]*privatecapb.CertificateAuthority, string, error) { 947 resp := &privatecapb.ListCertificateAuthoritiesResponse{} 948 if pageToken != "" { 949 req.PageToken = pageToken 950 } 951 if pageSize > math.MaxInt32 { 952 req.PageSize = math.MaxInt32 953 } else if pageSize != 0 { 954 req.PageSize = int32(pageSize) 955 } 956 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 957 var err error 958 resp, err = c.certificateAuthorityClient.ListCertificateAuthorities(ctx, req, settings.GRPC...) 959 return err 960 }, opts...) 961 if err != nil { 962 return nil, "", err 963 } 964 965 it.Response = resp 966 return resp.GetCertificateAuthorities(), resp.GetNextPageToken(), nil 967 } 968 fetch := func(pageSize int, pageToken string) (string, error) { 969 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 970 if err != nil { 971 return "", err 972 } 973 it.items = append(it.items, items...) 974 return nextPageToken, nil 975 } 976 977 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 978 it.pageInfo.MaxSize = int(req.GetPageSize()) 979 it.pageInfo.Token = req.GetPageToken() 980 981 return it 982} 983 984func (c *certificateAuthorityGRPCClient) RestoreCertificateAuthority(ctx context.Context, req *privatecapb.RestoreCertificateAuthorityRequest, opts ...gax.CallOption) (*RestoreCertificateAuthorityOperation, error) { 985 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 986 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 987 defer cancel() 988 ctx = cctx 989 } 990 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 991 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 992 opts = append((*c.CallOptions).RestoreCertificateAuthority[0:len((*c.CallOptions).RestoreCertificateAuthority):len((*c.CallOptions).RestoreCertificateAuthority)], opts...) 993 var resp *longrunningpb.Operation 994 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 995 var err error 996 resp, err = c.certificateAuthorityClient.RestoreCertificateAuthority(ctx, req, settings.GRPC...) 997 return err 998 }, opts...) 999 if err != nil { 1000 return nil, err 1001 } 1002 return &RestoreCertificateAuthorityOperation{ 1003 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1004 }, nil 1005} 1006 1007func (c *certificateAuthorityGRPCClient) ScheduleDeleteCertificateAuthority(ctx context.Context, req *privatecapb.ScheduleDeleteCertificateAuthorityRequest, opts ...gax.CallOption) (*ScheduleDeleteCertificateAuthorityOperation, error) { 1008 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1009 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1010 defer cancel() 1011 ctx = cctx 1012 } 1013 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1014 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1015 opts = append((*c.CallOptions).ScheduleDeleteCertificateAuthority[0:len((*c.CallOptions).ScheduleDeleteCertificateAuthority):len((*c.CallOptions).ScheduleDeleteCertificateAuthority)], opts...) 1016 var resp *longrunningpb.Operation 1017 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1018 var err error 1019 resp, err = c.certificateAuthorityClient.ScheduleDeleteCertificateAuthority(ctx, req, settings.GRPC...) 1020 return err 1021 }, opts...) 1022 if err != nil { 1023 return nil, err 1024 } 1025 return &ScheduleDeleteCertificateAuthorityOperation{ 1026 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1027 }, nil 1028} 1029 1030func (c *certificateAuthorityGRPCClient) UpdateCertificateAuthority(ctx context.Context, req *privatecapb.UpdateCertificateAuthorityRequest, opts ...gax.CallOption) (*UpdateCertificateAuthorityOperation, error) { 1031 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1032 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1033 defer cancel() 1034 ctx = cctx 1035 } 1036 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "certificate_authority.name", url.QueryEscape(req.GetCertificateAuthority().GetName()))) 1037 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1038 opts = append((*c.CallOptions).UpdateCertificateAuthority[0:len((*c.CallOptions).UpdateCertificateAuthority):len((*c.CallOptions).UpdateCertificateAuthority)], opts...) 1039 var resp *longrunningpb.Operation 1040 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1041 var err error 1042 resp, err = c.certificateAuthorityClient.UpdateCertificateAuthority(ctx, req, settings.GRPC...) 1043 return err 1044 }, opts...) 1045 if err != nil { 1046 return nil, err 1047 } 1048 return &UpdateCertificateAuthorityOperation{ 1049 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1050 }, nil 1051} 1052 1053func (c *certificateAuthorityGRPCClient) GetCertificateRevocationList(ctx context.Context, req *privatecapb.GetCertificateRevocationListRequest, opts ...gax.CallOption) (*privatecapb.CertificateRevocationList, error) { 1054 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1055 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1056 defer cancel() 1057 ctx = cctx 1058 } 1059 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1060 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1061 opts = append((*c.CallOptions).GetCertificateRevocationList[0:len((*c.CallOptions).GetCertificateRevocationList):len((*c.CallOptions).GetCertificateRevocationList)], opts...) 1062 var resp *privatecapb.CertificateRevocationList 1063 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1064 var err error 1065 resp, err = c.certificateAuthorityClient.GetCertificateRevocationList(ctx, req, settings.GRPC...) 1066 return err 1067 }, opts...) 1068 if err != nil { 1069 return nil, err 1070 } 1071 return resp, nil 1072} 1073 1074func (c *certificateAuthorityGRPCClient) ListCertificateRevocationLists(ctx context.Context, req *privatecapb.ListCertificateRevocationListsRequest, opts ...gax.CallOption) *CertificateRevocationListIterator { 1075 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1076 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1077 opts = append((*c.CallOptions).ListCertificateRevocationLists[0:len((*c.CallOptions).ListCertificateRevocationLists):len((*c.CallOptions).ListCertificateRevocationLists)], opts...) 1078 it := &CertificateRevocationListIterator{} 1079 req = proto.Clone(req).(*privatecapb.ListCertificateRevocationListsRequest) 1080 it.InternalFetch = func(pageSize int, pageToken string) ([]*privatecapb.CertificateRevocationList, string, error) { 1081 resp := &privatecapb.ListCertificateRevocationListsResponse{} 1082 if pageToken != "" { 1083 req.PageToken = pageToken 1084 } 1085 if pageSize > math.MaxInt32 { 1086 req.PageSize = math.MaxInt32 1087 } else if pageSize != 0 { 1088 req.PageSize = int32(pageSize) 1089 } 1090 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1091 var err error 1092 resp, err = c.certificateAuthorityClient.ListCertificateRevocationLists(ctx, req, settings.GRPC...) 1093 return err 1094 }, opts...) 1095 if err != nil { 1096 return nil, "", err 1097 } 1098 1099 it.Response = resp 1100 return resp.GetCertificateRevocationLists(), resp.GetNextPageToken(), nil 1101 } 1102 fetch := func(pageSize int, pageToken string) (string, error) { 1103 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1104 if err != nil { 1105 return "", err 1106 } 1107 it.items = append(it.items, items...) 1108 return nextPageToken, nil 1109 } 1110 1111 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1112 it.pageInfo.MaxSize = int(req.GetPageSize()) 1113 it.pageInfo.Token = req.GetPageToken() 1114 1115 return it 1116} 1117 1118func (c *certificateAuthorityGRPCClient) UpdateCertificateRevocationList(ctx context.Context, req *privatecapb.UpdateCertificateRevocationListRequest, opts ...gax.CallOption) (*UpdateCertificateRevocationListOperation, error) { 1119 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1120 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1121 defer cancel() 1122 ctx = cctx 1123 } 1124 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "certificate_revocation_list.name", url.QueryEscape(req.GetCertificateRevocationList().GetName()))) 1125 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1126 opts = append((*c.CallOptions).UpdateCertificateRevocationList[0:len((*c.CallOptions).UpdateCertificateRevocationList):len((*c.CallOptions).UpdateCertificateRevocationList)], opts...) 1127 var resp *longrunningpb.Operation 1128 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1129 var err error 1130 resp, err = c.certificateAuthorityClient.UpdateCertificateRevocationList(ctx, req, settings.GRPC...) 1131 return err 1132 }, opts...) 1133 if err != nil { 1134 return nil, err 1135 } 1136 return &UpdateCertificateRevocationListOperation{ 1137 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1138 }, nil 1139} 1140 1141func (c *certificateAuthorityGRPCClient) GetReusableConfig(ctx context.Context, req *privatecapb.GetReusableConfigRequest, opts ...gax.CallOption) (*privatecapb.ReusableConfig, error) { 1142 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1143 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1144 defer cancel() 1145 ctx = cctx 1146 } 1147 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1148 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1149 opts = append((*c.CallOptions).GetReusableConfig[0:len((*c.CallOptions).GetReusableConfig):len((*c.CallOptions).GetReusableConfig)], opts...) 1150 var resp *privatecapb.ReusableConfig 1151 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1152 var err error 1153 resp, err = c.certificateAuthorityClient.GetReusableConfig(ctx, req, settings.GRPC...) 1154 return err 1155 }, opts...) 1156 if err != nil { 1157 return nil, err 1158 } 1159 return resp, nil 1160} 1161 1162func (c *certificateAuthorityGRPCClient) ListReusableConfigs(ctx context.Context, req *privatecapb.ListReusableConfigsRequest, opts ...gax.CallOption) *ReusableConfigIterator { 1163 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1164 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1165 opts = append((*c.CallOptions).ListReusableConfigs[0:len((*c.CallOptions).ListReusableConfigs):len((*c.CallOptions).ListReusableConfigs)], opts...) 1166 it := &ReusableConfigIterator{} 1167 req = proto.Clone(req).(*privatecapb.ListReusableConfigsRequest) 1168 it.InternalFetch = func(pageSize int, pageToken string) ([]*privatecapb.ReusableConfig, string, error) { 1169 resp := &privatecapb.ListReusableConfigsResponse{} 1170 if pageToken != "" { 1171 req.PageToken = pageToken 1172 } 1173 if pageSize > math.MaxInt32 { 1174 req.PageSize = math.MaxInt32 1175 } else if pageSize != 0 { 1176 req.PageSize = int32(pageSize) 1177 } 1178 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1179 var err error 1180 resp, err = c.certificateAuthorityClient.ListReusableConfigs(ctx, req, settings.GRPC...) 1181 return err 1182 }, opts...) 1183 if err != nil { 1184 return nil, "", err 1185 } 1186 1187 it.Response = resp 1188 return resp.GetReusableConfigs(), resp.GetNextPageToken(), nil 1189 } 1190 fetch := func(pageSize int, pageToken string) (string, error) { 1191 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1192 if err != nil { 1193 return "", err 1194 } 1195 it.items = append(it.items, items...) 1196 return nextPageToken, nil 1197 } 1198 1199 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1200 it.pageInfo.MaxSize = int(req.GetPageSize()) 1201 it.pageInfo.Token = req.GetPageToken() 1202 1203 return it 1204} 1205 1206// ActivateCertificateAuthorityOperation manages a long-running operation from ActivateCertificateAuthority. 1207type ActivateCertificateAuthorityOperation struct { 1208 lro *longrunning.Operation 1209} 1210 1211// ActivateCertificateAuthorityOperation returns a new ActivateCertificateAuthorityOperation from a given name. 1212// The name must be that of a previously created ActivateCertificateAuthorityOperation, possibly from a different process. 1213func (c *certificateAuthorityGRPCClient) ActivateCertificateAuthorityOperation(name string) *ActivateCertificateAuthorityOperation { 1214 return &ActivateCertificateAuthorityOperation{ 1215 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1216 } 1217} 1218 1219// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1220// 1221// See documentation of Poll for error-handling information. 1222func (op *ActivateCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1223 var resp privatecapb.CertificateAuthority 1224 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1225 return nil, err 1226 } 1227 return &resp, nil 1228} 1229 1230// Poll fetches the latest state of the long-running operation. 1231// 1232// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1233// 1234// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1235// the operation has completed with failure, the error is returned and op.Done will return true. 1236// If Poll succeeds and the operation has completed successfully, 1237// op.Done will return true, and the response of the operation is returned. 1238// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1239func (op *ActivateCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1240 var resp privatecapb.CertificateAuthority 1241 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1242 return nil, err 1243 } 1244 if !op.Done() { 1245 return nil, nil 1246 } 1247 return &resp, nil 1248} 1249 1250// Metadata returns metadata associated with the long-running operation. 1251// Metadata itself does not contact the server, but Poll does. 1252// To get the latest metadata, call this method after a successful call to Poll. 1253// If the metadata is not available, the returned metadata and error are both nil. 1254func (op *ActivateCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { 1255 var meta privatecapb.OperationMetadata 1256 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1257 return nil, nil 1258 } else if err != nil { 1259 return nil, err 1260 } 1261 return &meta, nil 1262} 1263 1264// Done reports whether the long-running operation has completed. 1265func (op *ActivateCertificateAuthorityOperation) Done() bool { 1266 return op.lro.Done() 1267} 1268 1269// Name returns the name of the long-running operation. 1270// The name is assigned by the server and is unique within the service from which the operation is created. 1271func (op *ActivateCertificateAuthorityOperation) Name() string { 1272 return op.lro.Name() 1273} 1274 1275// CreateCertificateAuthorityOperation manages a long-running operation from CreateCertificateAuthority. 1276type CreateCertificateAuthorityOperation struct { 1277 lro *longrunning.Operation 1278} 1279 1280// CreateCertificateAuthorityOperation returns a new CreateCertificateAuthorityOperation from a given name. 1281// The name must be that of a previously created CreateCertificateAuthorityOperation, possibly from a different process. 1282func (c *certificateAuthorityGRPCClient) CreateCertificateAuthorityOperation(name string) *CreateCertificateAuthorityOperation { 1283 return &CreateCertificateAuthorityOperation{ 1284 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1285 } 1286} 1287 1288// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1289// 1290// See documentation of Poll for error-handling information. 1291func (op *CreateCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1292 var resp privatecapb.CertificateAuthority 1293 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1294 return nil, err 1295 } 1296 return &resp, nil 1297} 1298 1299// Poll fetches the latest state of the long-running operation. 1300// 1301// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1302// 1303// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1304// the operation has completed with failure, the error is returned and op.Done will return true. 1305// If Poll succeeds and the operation has completed successfully, 1306// op.Done will return true, and the response of the operation is returned. 1307// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1308func (op *CreateCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1309 var resp privatecapb.CertificateAuthority 1310 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1311 return nil, err 1312 } 1313 if !op.Done() { 1314 return nil, nil 1315 } 1316 return &resp, nil 1317} 1318 1319// Metadata returns metadata associated with the long-running operation. 1320// Metadata itself does not contact the server, but Poll does. 1321// To get the latest metadata, call this method after a successful call to Poll. 1322// If the metadata is not available, the returned metadata and error are both nil. 1323func (op *CreateCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { 1324 var meta privatecapb.OperationMetadata 1325 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1326 return nil, nil 1327 } else if err != nil { 1328 return nil, err 1329 } 1330 return &meta, nil 1331} 1332 1333// Done reports whether the long-running operation has completed. 1334func (op *CreateCertificateAuthorityOperation) Done() bool { 1335 return op.lro.Done() 1336} 1337 1338// Name returns the name of the long-running operation. 1339// The name is assigned by the server and is unique within the service from which the operation is created. 1340func (op *CreateCertificateAuthorityOperation) Name() string { 1341 return op.lro.Name() 1342} 1343 1344// DisableCertificateAuthorityOperation manages a long-running operation from DisableCertificateAuthority. 1345type DisableCertificateAuthorityOperation struct { 1346 lro *longrunning.Operation 1347} 1348 1349// DisableCertificateAuthorityOperation returns a new DisableCertificateAuthorityOperation from a given name. 1350// The name must be that of a previously created DisableCertificateAuthorityOperation, possibly from a different process. 1351func (c *certificateAuthorityGRPCClient) DisableCertificateAuthorityOperation(name string) *DisableCertificateAuthorityOperation { 1352 return &DisableCertificateAuthorityOperation{ 1353 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1354 } 1355} 1356 1357// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1358// 1359// See documentation of Poll for error-handling information. 1360func (op *DisableCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1361 var resp privatecapb.CertificateAuthority 1362 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1363 return nil, err 1364 } 1365 return &resp, nil 1366} 1367 1368// Poll fetches the latest state of the long-running operation. 1369// 1370// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1371// 1372// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1373// the operation has completed with failure, the error is returned and op.Done will return true. 1374// If Poll succeeds and the operation has completed successfully, 1375// op.Done will return true, and the response of the operation is returned. 1376// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1377func (op *DisableCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1378 var resp privatecapb.CertificateAuthority 1379 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1380 return nil, err 1381 } 1382 if !op.Done() { 1383 return nil, nil 1384 } 1385 return &resp, nil 1386} 1387 1388// Metadata returns metadata associated with the long-running operation. 1389// Metadata itself does not contact the server, but Poll does. 1390// To get the latest metadata, call this method after a successful call to Poll. 1391// If the metadata is not available, the returned metadata and error are both nil. 1392func (op *DisableCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { 1393 var meta privatecapb.OperationMetadata 1394 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1395 return nil, nil 1396 } else if err != nil { 1397 return nil, err 1398 } 1399 return &meta, nil 1400} 1401 1402// Done reports whether the long-running operation has completed. 1403func (op *DisableCertificateAuthorityOperation) Done() bool { 1404 return op.lro.Done() 1405} 1406 1407// Name returns the name of the long-running operation. 1408// The name is assigned by the server and is unique within the service from which the operation is created. 1409func (op *DisableCertificateAuthorityOperation) Name() string { 1410 return op.lro.Name() 1411} 1412 1413// EnableCertificateAuthorityOperation manages a long-running operation from EnableCertificateAuthority. 1414type EnableCertificateAuthorityOperation struct { 1415 lro *longrunning.Operation 1416} 1417 1418// EnableCertificateAuthorityOperation returns a new EnableCertificateAuthorityOperation from a given name. 1419// The name must be that of a previously created EnableCertificateAuthorityOperation, possibly from a different process. 1420func (c *certificateAuthorityGRPCClient) EnableCertificateAuthorityOperation(name string) *EnableCertificateAuthorityOperation { 1421 return &EnableCertificateAuthorityOperation{ 1422 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1423 } 1424} 1425 1426// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1427// 1428// See documentation of Poll for error-handling information. 1429func (op *EnableCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1430 var resp privatecapb.CertificateAuthority 1431 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1432 return nil, err 1433 } 1434 return &resp, nil 1435} 1436 1437// Poll fetches the latest state of the long-running operation. 1438// 1439// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1440// 1441// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1442// the operation has completed with failure, the error is returned and op.Done will return true. 1443// If Poll succeeds and the operation has completed successfully, 1444// op.Done will return true, and the response of the operation is returned. 1445// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1446func (op *EnableCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1447 var resp privatecapb.CertificateAuthority 1448 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1449 return nil, err 1450 } 1451 if !op.Done() { 1452 return nil, nil 1453 } 1454 return &resp, nil 1455} 1456 1457// Metadata returns metadata associated with the long-running operation. 1458// Metadata itself does not contact the server, but Poll does. 1459// To get the latest metadata, call this method after a successful call to Poll. 1460// If the metadata is not available, the returned metadata and error are both nil. 1461func (op *EnableCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { 1462 var meta privatecapb.OperationMetadata 1463 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1464 return nil, nil 1465 } else if err != nil { 1466 return nil, err 1467 } 1468 return &meta, nil 1469} 1470 1471// Done reports whether the long-running operation has completed. 1472func (op *EnableCertificateAuthorityOperation) Done() bool { 1473 return op.lro.Done() 1474} 1475 1476// Name returns the name of the long-running operation. 1477// The name is assigned by the server and is unique within the service from which the operation is created. 1478func (op *EnableCertificateAuthorityOperation) Name() string { 1479 return op.lro.Name() 1480} 1481 1482// RestoreCertificateAuthorityOperation manages a long-running operation from RestoreCertificateAuthority. 1483type RestoreCertificateAuthorityOperation struct { 1484 lro *longrunning.Operation 1485} 1486 1487// RestoreCertificateAuthorityOperation returns a new RestoreCertificateAuthorityOperation from a given name. 1488// The name must be that of a previously created RestoreCertificateAuthorityOperation, possibly from a different process. 1489func (c *certificateAuthorityGRPCClient) RestoreCertificateAuthorityOperation(name string) *RestoreCertificateAuthorityOperation { 1490 return &RestoreCertificateAuthorityOperation{ 1491 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1492 } 1493} 1494 1495// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1496// 1497// See documentation of Poll for error-handling information. 1498func (op *RestoreCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1499 var resp privatecapb.CertificateAuthority 1500 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1501 return nil, err 1502 } 1503 return &resp, nil 1504} 1505 1506// Poll fetches the latest state of the long-running operation. 1507// 1508// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1509// 1510// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1511// the operation has completed with failure, the error is returned and op.Done will return true. 1512// If Poll succeeds and the operation has completed successfully, 1513// op.Done will return true, and the response of the operation is returned. 1514// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1515func (op *RestoreCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1516 var resp privatecapb.CertificateAuthority 1517 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1518 return nil, err 1519 } 1520 if !op.Done() { 1521 return nil, nil 1522 } 1523 return &resp, nil 1524} 1525 1526// Metadata returns metadata associated with the long-running operation. 1527// Metadata itself does not contact the server, but Poll does. 1528// To get the latest metadata, call this method after a successful call to Poll. 1529// If the metadata is not available, the returned metadata and error are both nil. 1530func (op *RestoreCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { 1531 var meta privatecapb.OperationMetadata 1532 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1533 return nil, nil 1534 } else if err != nil { 1535 return nil, err 1536 } 1537 return &meta, nil 1538} 1539 1540// Done reports whether the long-running operation has completed. 1541func (op *RestoreCertificateAuthorityOperation) Done() bool { 1542 return op.lro.Done() 1543} 1544 1545// Name returns the name of the long-running operation. 1546// The name is assigned by the server and is unique within the service from which the operation is created. 1547func (op *RestoreCertificateAuthorityOperation) Name() string { 1548 return op.lro.Name() 1549} 1550 1551// ScheduleDeleteCertificateAuthorityOperation manages a long-running operation from ScheduleDeleteCertificateAuthority. 1552type ScheduleDeleteCertificateAuthorityOperation struct { 1553 lro *longrunning.Operation 1554} 1555 1556// ScheduleDeleteCertificateAuthorityOperation returns a new ScheduleDeleteCertificateAuthorityOperation from a given name. 1557// The name must be that of a previously created ScheduleDeleteCertificateAuthorityOperation, possibly from a different process. 1558func (c *certificateAuthorityGRPCClient) ScheduleDeleteCertificateAuthorityOperation(name string) *ScheduleDeleteCertificateAuthorityOperation { 1559 return &ScheduleDeleteCertificateAuthorityOperation{ 1560 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1561 } 1562} 1563 1564// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1565// 1566// See documentation of Poll for error-handling information. 1567func (op *ScheduleDeleteCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1568 var resp privatecapb.CertificateAuthority 1569 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1570 return nil, err 1571 } 1572 return &resp, nil 1573} 1574 1575// Poll fetches the latest state of the long-running operation. 1576// 1577// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1578// 1579// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1580// the operation has completed with failure, the error is returned and op.Done will return true. 1581// If Poll succeeds and the operation has completed successfully, 1582// op.Done will return true, and the response of the operation is returned. 1583// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1584func (op *ScheduleDeleteCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1585 var resp privatecapb.CertificateAuthority 1586 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1587 return nil, err 1588 } 1589 if !op.Done() { 1590 return nil, nil 1591 } 1592 return &resp, nil 1593} 1594 1595// Metadata returns metadata associated with the long-running operation. 1596// Metadata itself does not contact the server, but Poll does. 1597// To get the latest metadata, call this method after a successful call to Poll. 1598// If the metadata is not available, the returned metadata and error are both nil. 1599func (op *ScheduleDeleteCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { 1600 var meta privatecapb.OperationMetadata 1601 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1602 return nil, nil 1603 } else if err != nil { 1604 return nil, err 1605 } 1606 return &meta, nil 1607} 1608 1609// Done reports whether the long-running operation has completed. 1610func (op *ScheduleDeleteCertificateAuthorityOperation) Done() bool { 1611 return op.lro.Done() 1612} 1613 1614// Name returns the name of the long-running operation. 1615// The name is assigned by the server and is unique within the service from which the operation is created. 1616func (op *ScheduleDeleteCertificateAuthorityOperation) Name() string { 1617 return op.lro.Name() 1618} 1619 1620// UpdateCertificateAuthorityOperation manages a long-running operation from UpdateCertificateAuthority. 1621type UpdateCertificateAuthorityOperation struct { 1622 lro *longrunning.Operation 1623} 1624 1625// UpdateCertificateAuthorityOperation returns a new UpdateCertificateAuthorityOperation from a given name. 1626// The name must be that of a previously created UpdateCertificateAuthorityOperation, possibly from a different process. 1627func (c *certificateAuthorityGRPCClient) UpdateCertificateAuthorityOperation(name string) *UpdateCertificateAuthorityOperation { 1628 return &UpdateCertificateAuthorityOperation{ 1629 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1630 } 1631} 1632 1633// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1634// 1635// See documentation of Poll for error-handling information. 1636func (op *UpdateCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1637 var resp privatecapb.CertificateAuthority 1638 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1639 return nil, err 1640 } 1641 return &resp, nil 1642} 1643 1644// Poll fetches the latest state of the long-running operation. 1645// 1646// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1647// 1648// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1649// the operation has completed with failure, the error is returned and op.Done will return true. 1650// If Poll succeeds and the operation has completed successfully, 1651// op.Done will return true, and the response of the operation is returned. 1652// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1653func (op *UpdateCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { 1654 var resp privatecapb.CertificateAuthority 1655 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1656 return nil, err 1657 } 1658 if !op.Done() { 1659 return nil, nil 1660 } 1661 return &resp, nil 1662} 1663 1664// Metadata returns metadata associated with the long-running operation. 1665// Metadata itself does not contact the server, but Poll does. 1666// To get the latest metadata, call this method after a successful call to Poll. 1667// If the metadata is not available, the returned metadata and error are both nil. 1668func (op *UpdateCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { 1669 var meta privatecapb.OperationMetadata 1670 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1671 return nil, nil 1672 } else if err != nil { 1673 return nil, err 1674 } 1675 return &meta, nil 1676} 1677 1678// Done reports whether the long-running operation has completed. 1679func (op *UpdateCertificateAuthorityOperation) Done() bool { 1680 return op.lro.Done() 1681} 1682 1683// Name returns the name of the long-running operation. 1684// The name is assigned by the server and is unique within the service from which the operation is created. 1685func (op *UpdateCertificateAuthorityOperation) Name() string { 1686 return op.lro.Name() 1687} 1688 1689// UpdateCertificateRevocationListOperation manages a long-running operation from UpdateCertificateRevocationList. 1690type UpdateCertificateRevocationListOperation struct { 1691 lro *longrunning.Operation 1692} 1693 1694// UpdateCertificateRevocationListOperation returns a new UpdateCertificateRevocationListOperation from a given name. 1695// The name must be that of a previously created UpdateCertificateRevocationListOperation, possibly from a different process. 1696func (c *certificateAuthorityGRPCClient) UpdateCertificateRevocationListOperation(name string) *UpdateCertificateRevocationListOperation { 1697 return &UpdateCertificateRevocationListOperation{ 1698 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1699 } 1700} 1701 1702// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1703// 1704// See documentation of Poll for error-handling information. 1705func (op *UpdateCertificateRevocationListOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateRevocationList, error) { 1706 var resp privatecapb.CertificateRevocationList 1707 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1708 return nil, err 1709 } 1710 return &resp, nil 1711} 1712 1713// Poll fetches the latest state of the long-running operation. 1714// 1715// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1716// 1717// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1718// the operation has completed with failure, the error is returned and op.Done will return true. 1719// If Poll succeeds and the operation has completed successfully, 1720// op.Done will return true, and the response of the operation is returned. 1721// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1722func (op *UpdateCertificateRevocationListOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateRevocationList, error) { 1723 var resp privatecapb.CertificateRevocationList 1724 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1725 return nil, err 1726 } 1727 if !op.Done() { 1728 return nil, nil 1729 } 1730 return &resp, nil 1731} 1732 1733// Metadata returns metadata associated with the long-running operation. 1734// Metadata itself does not contact the server, but Poll does. 1735// To get the latest metadata, call this method after a successful call to Poll. 1736// If the metadata is not available, the returned metadata and error are both nil. 1737func (op *UpdateCertificateRevocationListOperation) Metadata() (*privatecapb.OperationMetadata, error) { 1738 var meta privatecapb.OperationMetadata 1739 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1740 return nil, nil 1741 } else if err != nil { 1742 return nil, err 1743 } 1744 return &meta, nil 1745} 1746 1747// Done reports whether the long-running operation has completed. 1748func (op *UpdateCertificateRevocationListOperation) Done() bool { 1749 return op.lro.Done() 1750} 1751 1752// Name returns the name of the long-running operation. 1753// The name is assigned by the server and is unique within the service from which the operation is created. 1754func (op *UpdateCertificateRevocationListOperation) Name() string { 1755 return op.lro.Name() 1756} 1757 1758// CertificateAuthorityIterator manages a stream of *privatecapb.CertificateAuthority. 1759type CertificateAuthorityIterator struct { 1760 items []*privatecapb.CertificateAuthority 1761 pageInfo *iterator.PageInfo 1762 nextFunc func() error 1763 1764 // Response is the raw response for the current page. 1765 // It must be cast to the RPC response type. 1766 // Calling Next() or InternalFetch() updates this value. 1767 Response interface{} 1768 1769 // InternalFetch is for use by the Google Cloud Libraries only. 1770 // It is not part of the stable interface of this package. 1771 // 1772 // InternalFetch returns results from a single call to the underlying RPC. 1773 // The number of results is no greater than pageSize. 1774 // If there are no more results, nextPageToken is empty and err is nil. 1775 InternalFetch func(pageSize int, pageToken string) (results []*privatecapb.CertificateAuthority, nextPageToken string, err error) 1776} 1777 1778// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1779func (it *CertificateAuthorityIterator) PageInfo() *iterator.PageInfo { 1780 return it.pageInfo 1781} 1782 1783// Next returns the next result. Its second return value is iterator.Done if there are no more 1784// results. Once Next returns Done, all subsequent calls will return Done. 1785func (it *CertificateAuthorityIterator) Next() (*privatecapb.CertificateAuthority, error) { 1786 var item *privatecapb.CertificateAuthority 1787 if err := it.nextFunc(); err != nil { 1788 return item, err 1789 } 1790 item = it.items[0] 1791 it.items = it.items[1:] 1792 return item, nil 1793} 1794 1795func (it *CertificateAuthorityIterator) bufLen() int { 1796 return len(it.items) 1797} 1798 1799func (it *CertificateAuthorityIterator) takeBuf() interface{} { 1800 b := it.items 1801 it.items = nil 1802 return b 1803} 1804 1805// CertificateIterator manages a stream of *privatecapb.Certificate. 1806type CertificateIterator struct { 1807 items []*privatecapb.Certificate 1808 pageInfo *iterator.PageInfo 1809 nextFunc func() error 1810 1811 // Response is the raw response for the current page. 1812 // It must be cast to the RPC response type. 1813 // Calling Next() or InternalFetch() updates this value. 1814 Response interface{} 1815 1816 // InternalFetch is for use by the Google Cloud Libraries only. 1817 // It is not part of the stable interface of this package. 1818 // 1819 // InternalFetch returns results from a single call to the underlying RPC. 1820 // The number of results is no greater than pageSize. 1821 // If there are no more results, nextPageToken is empty and err is nil. 1822 InternalFetch func(pageSize int, pageToken string) (results []*privatecapb.Certificate, nextPageToken string, err error) 1823} 1824 1825// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1826func (it *CertificateIterator) PageInfo() *iterator.PageInfo { 1827 return it.pageInfo 1828} 1829 1830// Next returns the next result. Its second return value is iterator.Done if there are no more 1831// results. Once Next returns Done, all subsequent calls will return Done. 1832func (it *CertificateIterator) Next() (*privatecapb.Certificate, error) { 1833 var item *privatecapb.Certificate 1834 if err := it.nextFunc(); err != nil { 1835 return item, err 1836 } 1837 item = it.items[0] 1838 it.items = it.items[1:] 1839 return item, nil 1840} 1841 1842func (it *CertificateIterator) bufLen() int { 1843 return len(it.items) 1844} 1845 1846func (it *CertificateIterator) takeBuf() interface{} { 1847 b := it.items 1848 it.items = nil 1849 return b 1850} 1851 1852// CertificateRevocationListIterator manages a stream of *privatecapb.CertificateRevocationList. 1853type CertificateRevocationListIterator struct { 1854 items []*privatecapb.CertificateRevocationList 1855 pageInfo *iterator.PageInfo 1856 nextFunc func() error 1857 1858 // Response is the raw response for the current page. 1859 // It must be cast to the RPC response type. 1860 // Calling Next() or InternalFetch() updates this value. 1861 Response interface{} 1862 1863 // InternalFetch is for use by the Google Cloud Libraries only. 1864 // It is not part of the stable interface of this package. 1865 // 1866 // InternalFetch returns results from a single call to the underlying RPC. 1867 // The number of results is no greater than pageSize. 1868 // If there are no more results, nextPageToken is empty and err is nil. 1869 InternalFetch func(pageSize int, pageToken string) (results []*privatecapb.CertificateRevocationList, nextPageToken string, err error) 1870} 1871 1872// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1873func (it *CertificateRevocationListIterator) PageInfo() *iterator.PageInfo { 1874 return it.pageInfo 1875} 1876 1877// Next returns the next result. Its second return value is iterator.Done if there are no more 1878// results. Once Next returns Done, all subsequent calls will return Done. 1879func (it *CertificateRevocationListIterator) Next() (*privatecapb.CertificateRevocationList, error) { 1880 var item *privatecapb.CertificateRevocationList 1881 if err := it.nextFunc(); err != nil { 1882 return item, err 1883 } 1884 item = it.items[0] 1885 it.items = it.items[1:] 1886 return item, nil 1887} 1888 1889func (it *CertificateRevocationListIterator) bufLen() int { 1890 return len(it.items) 1891} 1892 1893func (it *CertificateRevocationListIterator) takeBuf() interface{} { 1894 b := it.items 1895 it.items = nil 1896 return b 1897} 1898 1899// ReusableConfigIterator manages a stream of *privatecapb.ReusableConfig. 1900type ReusableConfigIterator struct { 1901 items []*privatecapb.ReusableConfig 1902 pageInfo *iterator.PageInfo 1903 nextFunc func() error 1904 1905 // Response is the raw response for the current page. 1906 // It must be cast to the RPC response type. 1907 // Calling Next() or InternalFetch() updates this value. 1908 Response interface{} 1909 1910 // InternalFetch is for use by the Google Cloud Libraries only. 1911 // It is not part of the stable interface of this package. 1912 // 1913 // InternalFetch returns results from a single call to the underlying RPC. 1914 // The number of results is no greater than pageSize. 1915 // If there are no more results, nextPageToken is empty and err is nil. 1916 InternalFetch func(pageSize int, pageToken string) (results []*privatecapb.ReusableConfig, nextPageToken string, err error) 1917} 1918 1919// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1920func (it *ReusableConfigIterator) PageInfo() *iterator.PageInfo { 1921 return it.pageInfo 1922} 1923 1924// Next returns the next result. Its second return value is iterator.Done if there are no more 1925// results. Once Next returns Done, all subsequent calls will return Done. 1926func (it *ReusableConfigIterator) Next() (*privatecapb.ReusableConfig, error) { 1927 var item *privatecapb.ReusableConfig 1928 if err := it.nextFunc(); err != nil { 1929 return item, err 1930 } 1931 item = it.items[0] 1932 it.items = it.items[1:] 1933 return item, nil 1934} 1935 1936func (it *ReusableConfigIterator) bufLen() int { 1937 return len(it.items) 1938} 1939 1940func (it *ReusableConfigIterator) takeBuf() interface{} { 1941 b := it.items 1942 it.items = nil 1943 return b 1944} 1945