From e4b7e5f53ab1aa1c4a7868a6955debcaf96e33b4 Mon Sep 17 00:00:00 2001 From: Cody Oss Date: Thu, 29 Apr 2021 09:22:36 -0600 Subject: [PATCH] feat(security/privateca): start generating apiv1 --- internal/.repo-metadata-full.json | 9 + internal/gapicgen/generator/config.go | 9 + .../apiv1/certificate_authority_client.go | 2527 +++++++++++++++++ ...rtificate_authority_client_example_test.go | 718 +++++ security/privateca/apiv1/doc.go | 119 + security/privateca/apiv1/gapic_metadata.json | 163 ++ 6 files changed, 3545 insertions(+) create mode 100644 security/privateca/apiv1/certificate_authority_client.go create mode 100644 security/privateca/apiv1/certificate_authority_client_example_test.go create mode 100644 security/privateca/apiv1/doc.go create mode 100644 security/privateca/apiv1/gapic_metadata.json diff --git a/internal/.repo-metadata-full.json b/internal/.repo-metadata-full.json index 563c95434c5..371363c9f22 100644 --- a/internal/.repo-metadata-full.json +++ b/internal/.repo-metadata-full.json @@ -980,6 +980,15 @@ "release_level": "beta", "library_type": "" }, + "cloud.google.com/go/security/privateca/apiv1": { + "distribution_name": "cloud.google.com/go/security/privateca/apiv1", + "description": "Certificate Authority API", + "language": "Go", + "client_library_type": "generated", + "docs_url": "https://pkg.go.dev/cloud.google.com/go/security/privateca/apiv1", + "release_level": "beta", + "library_type": "" + }, "cloud.google.com/go/security/privateca/apiv1beta1": { "distribution_name": "cloud.google.com/go/security/privateca/apiv1beta1", "description": "Certificate Authority API", diff --git a/internal/gapicgen/generator/config.go b/internal/gapicgen/generator/config.go index 5488d3a74e7..f0b9241541d 100644 --- a/internal/gapicgen/generator/config.go +++ b/internal/gapicgen/generator/config.go @@ -855,6 +855,15 @@ var microgenGapicConfigs = []*microgenConfig{ apiServiceConfigPath: "google/cloud/security/privateca/v1beta1/privateca_v1beta1.yaml", releaseLevel: "beta", }, + { + inputDirectoryPath: "google/cloud/security/privateca/v1", + pkg: "privateca", + importPath: "cloud.google.com/go/security/privateca/apiv1", + gRPCServiceConfigPath: "google/cloud/security/privateca/v1/privateca_grpc_service_config.json", + apiServiceConfigPath: "google/cloud/security/privateca/v1/privateca_v1.yaml", + // GA after 2021/05/29 + releaseLevel: "beta", + }, { inputDirectoryPath: "google/cloud/assuredworkloads/v1beta1", pkg: "assuredworkloads", diff --git a/security/privateca/apiv1/certificate_authority_client.go b/security/privateca/apiv1/certificate_authority_client.go new file mode 100644 index 00000000000..c8647e01272 --- /dev/null +++ b/security/privateca/apiv1/certificate_authority_client.go @@ -0,0 +1,2527 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package privateca + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + "cloud.google.com/go/longrunning" + lroauto "cloud.google.com/go/longrunning/autogen" + "github.com/golang/protobuf/proto" + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/iterator" + "google.golang.org/api/option" + "google.golang.org/api/option/internaloption" + gtransport "google.golang.org/api/transport/grpc" + privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" +) + +var newCertificateAuthorityClientHook clientHook + +// CertificateAuthorityCallOptions contains the retry settings for each method of CertificateAuthorityClient. +type CertificateAuthorityCallOptions struct { + CreateCertificate []gax.CallOption + GetCertificate []gax.CallOption + ListCertificates []gax.CallOption + RevokeCertificate []gax.CallOption + UpdateCertificate []gax.CallOption + ActivateCertificateAuthority []gax.CallOption + CreateCertificateAuthority []gax.CallOption + DisableCertificateAuthority []gax.CallOption + EnableCertificateAuthority []gax.CallOption + FetchCertificateAuthorityCsr []gax.CallOption + GetCertificateAuthority []gax.CallOption + ListCertificateAuthorities []gax.CallOption + UndeleteCertificateAuthority []gax.CallOption + DeleteCertificateAuthority []gax.CallOption + UpdateCertificateAuthority []gax.CallOption + CreateCaPool []gax.CallOption + UpdateCaPool []gax.CallOption + GetCaPool []gax.CallOption + ListCaPools []gax.CallOption + DeleteCaPool []gax.CallOption + FetchCaCerts []gax.CallOption + GetCertificateRevocationList []gax.CallOption + ListCertificateRevocationLists []gax.CallOption + UpdateCertificateRevocationList []gax.CallOption + CreateCertificateTemplate []gax.CallOption + DeleteCertificateTemplate []gax.CallOption + GetCertificateTemplate []gax.CallOption + ListCertificateTemplates []gax.CallOption + UpdateCertificateTemplate []gax.CallOption +} + +func defaultCertificateAuthorityClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("privateca.googleapis.com:443"), + internaloption.WithDefaultMTLSEndpoint("privateca.mtls.googleapis.com:443"), + internaloption.WithDefaultAudience("https://privateca.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultCertificateAuthorityCallOptions() *CertificateAuthorityCallOptions { + return &CertificateAuthorityCallOptions{ + CreateCertificate: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetCertificate: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + ListCertificates: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + RevokeCertificate: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + UpdateCertificate: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + ActivateCertificateAuthority: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + CreateCertificateAuthority: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + DisableCertificateAuthority: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + EnableCertificateAuthority: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + FetchCertificateAuthorityCsr: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetCertificateAuthority: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + ListCertificateAuthorities: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + UndeleteCertificateAuthority: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + DeleteCertificateAuthority: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + UpdateCertificateAuthority: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + CreateCaPool: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + UpdateCaPool: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetCaPool: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + ListCaPools: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + DeleteCaPool: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + FetchCaCerts: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetCertificateRevocationList: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + ListCertificateRevocationLists: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + UpdateCertificateRevocationList: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + CreateCertificateTemplate: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + DeleteCertificateTemplate: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetCertificateTemplate: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + ListCertificateTemplates: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + UpdateCertificateTemplate: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unknown, + codes.Unavailable, + codes.DeadlineExceeded, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + } +} + +// CertificateAuthorityClient is a client for interacting with Certificate Authority API. +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type CertificateAuthorityClient struct { + // Connection pool of gRPC connections to the service. + connPool gtransport.ConnPool + + // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE + disableDeadlines bool + + // The gRPC API client. + certificateAuthorityClient privatecapb.CertificateAuthorityServiceClient + + // LROClient is used internally to handle longrunning operations. + // It is exposed so that its CallOptions can be modified if required. + // Users should not Close this client. + LROClient *lroauto.OperationsClient + + // The call options for this service. + CallOptions *CertificateAuthorityCallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewCertificateAuthorityClient creates a new certificate authority service client. +// +// [Certificate Authority Service][google.cloud.security.privateca.v1.CertificateAuthorityService] manages private +// certificate authorities and issued certificates. +func NewCertificateAuthorityClient(ctx context.Context, opts ...option.ClientOption) (*CertificateAuthorityClient, error) { + clientOpts := defaultCertificateAuthorityClientOptions() + + if newCertificateAuthorityClientHook != nil { + hookOpts, err := newCertificateAuthorityClientHook(ctx, clientHookParams{}) + if err != nil { + return nil, err + } + clientOpts = append(clientOpts, hookOpts...) + } + + disableDeadlines, err := checkDisableDeadlines() + if err != nil { + return nil, err + } + + connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) + if err != nil { + return nil, err + } + c := &CertificateAuthorityClient{ + connPool: connPool, + disableDeadlines: disableDeadlines, + CallOptions: defaultCertificateAuthorityCallOptions(), + + certificateAuthorityClient: privatecapb.NewCertificateAuthorityServiceClient(connPool), + } + c.setGoogleClientInfo() + + c.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) + if err != nil { + // This error "should not happen", since we are just reusing old connection pool + // and never actually need to dial. + // If this does happen, we could leak connp. However, we cannot close conn: + // If the user invoked the constructor with option.WithGRPCConn, + // we would close a connection that's still in use. + // TODO: investigate error conditions. + return nil, err + } + return c, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *CertificateAuthorityClient) Connection() *grpc.ClientConn { + return c.connPool.Conn() +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *CertificateAuthorityClient) Close() error { + return c.connPool.Close() +} + +// setGoogleClientInfo sets the name and version of the application in +// the `x-goog-api-client` header passed on each request. Intended for +// use by Google-written clients. +func (c *CertificateAuthorityClient) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// CreateCertificate create a new Certificate in a given Project, Location from a particular +// CaPool. +func (c *CertificateAuthorityClient) CreateCertificate(ctx context.Context, req *privatecapb.CreateCertificateRequest, opts ...gax.CallOption) (*privatecapb.Certificate, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateCertificate[0:len(c.CallOptions.CreateCertificate):len(c.CallOptions.CreateCertificate)], opts...) + var resp *privatecapb.Certificate + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.CreateCertificate(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// GetCertificate returns a Certificate. +func (c *CertificateAuthorityClient) GetCertificate(ctx context.Context, req *privatecapb.GetCertificateRequest, opts ...gax.CallOption) (*privatecapb.Certificate, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetCertificate[0:len(c.CallOptions.GetCertificate):len(c.CallOptions.GetCertificate)], opts...) + var resp *privatecapb.Certificate + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.GetCertificate(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListCertificates lists Certificates. +func (c *CertificateAuthorityClient) ListCertificates(ctx context.Context, req *privatecapb.ListCertificatesRequest, opts ...gax.CallOption) *CertificateIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListCertificates[0:len(c.CallOptions.ListCertificates):len(c.CallOptions.ListCertificates)], opts...) + it := &CertificateIterator{} + req = proto.Clone(req).(*privatecapb.ListCertificatesRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*privatecapb.Certificate, string, error) { + var resp *privatecapb.ListCertificatesResponse + req.PageToken = pageToken + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.ListCertificates(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetCertificates(), resp.GetNextPageToken(), nil + } + fetch := func(pageSize int, pageToken string) (string, error) { + items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) + if err != nil { + return "", err + } + it.items = append(it.items, items...) + return nextPageToken, nil + } + it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) + it.pageInfo.MaxSize = int(req.GetPageSize()) + it.pageInfo.Token = req.GetPageToken() + return it +} + +// RevokeCertificate revoke a Certificate. +func (c *CertificateAuthorityClient) RevokeCertificate(ctx context.Context, req *privatecapb.RevokeCertificateRequest, opts ...gax.CallOption) (*privatecapb.Certificate, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.RevokeCertificate[0:len(c.CallOptions.RevokeCertificate):len(c.CallOptions.RevokeCertificate)], opts...) + var resp *privatecapb.Certificate + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.RevokeCertificate(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// UpdateCertificate update a Certificate. Currently, the only field you can update is the +// labels field. +func (c *CertificateAuthorityClient) UpdateCertificate(ctx context.Context, req *privatecapb.UpdateCertificateRequest, opts ...gax.CallOption) (*privatecapb.Certificate, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "certificate.name", url.QueryEscape(req.GetCertificate().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateCertificate[0:len(c.CallOptions.UpdateCertificate):len(c.CallOptions.UpdateCertificate)], opts...) + var resp *privatecapb.Certificate + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.UpdateCertificate(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ActivateCertificateAuthority activate a CertificateAuthority that is in state +// AWAITING_USER_ACTIVATION +// and is of type SUBORDINATE. After +// the parent Certificate Authority signs a certificate signing request from +// FetchCertificateAuthorityCsr, this method can complete the activation +// process. +func (c *CertificateAuthorityClient) ActivateCertificateAuthority(ctx context.Context, req *privatecapb.ActivateCertificateAuthorityRequest, opts ...gax.CallOption) (*ActivateCertificateAuthorityOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ActivateCertificateAuthority[0:len(c.CallOptions.ActivateCertificateAuthority):len(c.CallOptions.ActivateCertificateAuthority)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.ActivateCertificateAuthority(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &ActivateCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// CreateCertificateAuthority create a new CertificateAuthority in a given Project and Location. +func (c *CertificateAuthorityClient) CreateCertificateAuthority(ctx context.Context, req *privatecapb.CreateCertificateAuthorityRequest, opts ...gax.CallOption) (*CreateCertificateAuthorityOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateCertificateAuthority[0:len(c.CallOptions.CreateCertificateAuthority):len(c.CallOptions.CreateCertificateAuthority)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.CreateCertificateAuthority(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// DisableCertificateAuthority disable a CertificateAuthority. +func (c *CertificateAuthorityClient) DisableCertificateAuthority(ctx context.Context, req *privatecapb.DisableCertificateAuthorityRequest, opts ...gax.CallOption) (*DisableCertificateAuthorityOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DisableCertificateAuthority[0:len(c.CallOptions.DisableCertificateAuthority):len(c.CallOptions.DisableCertificateAuthority)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.DisableCertificateAuthority(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DisableCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// EnableCertificateAuthority enable a CertificateAuthority. +func (c *CertificateAuthorityClient) EnableCertificateAuthority(ctx context.Context, req *privatecapb.EnableCertificateAuthorityRequest, opts ...gax.CallOption) (*EnableCertificateAuthorityOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.EnableCertificateAuthority[0:len(c.CallOptions.EnableCertificateAuthority):len(c.CallOptions.EnableCertificateAuthority)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.EnableCertificateAuthority(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &EnableCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// FetchCertificateAuthorityCsr fetch a certificate signing request (CSR) from a CertificateAuthority +// that is in state +// AWAITING_USER_ACTIVATION +// and is of type SUBORDINATE. The +// CSR must then be signed by the desired parent Certificate Authority, which +// could be another CertificateAuthority resource, or could be an on-prem +// certificate authority. See also ActivateCertificateAuthority. +func (c *CertificateAuthorityClient) FetchCertificateAuthorityCsr(ctx context.Context, req *privatecapb.FetchCertificateAuthorityCsrRequest, opts ...gax.CallOption) (*privatecapb.FetchCertificateAuthorityCsrResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.FetchCertificateAuthorityCsr[0:len(c.CallOptions.FetchCertificateAuthorityCsr):len(c.CallOptions.FetchCertificateAuthorityCsr)], opts...) + var resp *privatecapb.FetchCertificateAuthorityCsrResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.FetchCertificateAuthorityCsr(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// GetCertificateAuthority returns a CertificateAuthority. +func (c *CertificateAuthorityClient) GetCertificateAuthority(ctx context.Context, req *privatecapb.GetCertificateAuthorityRequest, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetCertificateAuthority[0:len(c.CallOptions.GetCertificateAuthority):len(c.CallOptions.GetCertificateAuthority)], opts...) + var resp *privatecapb.CertificateAuthority + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.GetCertificateAuthority(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListCertificateAuthorities lists CertificateAuthorities. +func (c *CertificateAuthorityClient) ListCertificateAuthorities(ctx context.Context, req *privatecapb.ListCertificateAuthoritiesRequest, opts ...gax.CallOption) *CertificateAuthorityIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListCertificateAuthorities[0:len(c.CallOptions.ListCertificateAuthorities):len(c.CallOptions.ListCertificateAuthorities)], opts...) + it := &CertificateAuthorityIterator{} + req = proto.Clone(req).(*privatecapb.ListCertificateAuthoritiesRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*privatecapb.CertificateAuthority, string, error) { + var resp *privatecapb.ListCertificateAuthoritiesResponse + req.PageToken = pageToken + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.ListCertificateAuthorities(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetCertificateAuthorities(), resp.GetNextPageToken(), nil + } + fetch := func(pageSize int, pageToken string) (string, error) { + items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) + if err != nil { + return "", err + } + it.items = append(it.items, items...) + return nextPageToken, nil + } + it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) + it.pageInfo.MaxSize = int(req.GetPageSize()) + it.pageInfo.Token = req.GetPageToken() + return it +} + +// UndeleteCertificateAuthority undelete a CertificateAuthority that has been deleted. +func (c *CertificateAuthorityClient) UndeleteCertificateAuthority(ctx context.Context, req *privatecapb.UndeleteCertificateAuthorityRequest, opts ...gax.CallOption) (*UndeleteCertificateAuthorityOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UndeleteCertificateAuthority[0:len(c.CallOptions.UndeleteCertificateAuthority):len(c.CallOptions.UndeleteCertificateAuthority)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.UndeleteCertificateAuthority(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UndeleteCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// DeleteCertificateAuthority delete a CertificateAuthority. +func (c *CertificateAuthorityClient) DeleteCertificateAuthority(ctx context.Context, req *privatecapb.DeleteCertificateAuthorityRequest, opts ...gax.CallOption) (*DeleteCertificateAuthorityOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeleteCertificateAuthority[0:len(c.CallOptions.DeleteCertificateAuthority):len(c.CallOptions.DeleteCertificateAuthority)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.DeleteCertificateAuthority(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// UpdateCertificateAuthority update a CertificateAuthority. +func (c *CertificateAuthorityClient) UpdateCertificateAuthority(ctx context.Context, req *privatecapb.UpdateCertificateAuthorityRequest, opts ...gax.CallOption) (*UpdateCertificateAuthorityOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "certificate_authority.name", url.QueryEscape(req.GetCertificateAuthority().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateCertificateAuthority[0:len(c.CallOptions.UpdateCertificateAuthority):len(c.CallOptions.UpdateCertificateAuthority)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.UpdateCertificateAuthority(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UpdateCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// CreateCaPool create a CaPool. +func (c *CertificateAuthorityClient) CreateCaPool(ctx context.Context, req *privatecapb.CreateCaPoolRequest, opts ...gax.CallOption) (*CreateCaPoolOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateCaPool[0:len(c.CallOptions.CreateCaPool):len(c.CallOptions.CreateCaPool)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.CreateCaPool(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateCaPoolOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// UpdateCaPool update a CaPool. +func (c *CertificateAuthorityClient) UpdateCaPool(ctx context.Context, req *privatecapb.UpdateCaPoolRequest, opts ...gax.CallOption) (*UpdateCaPoolOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "ca_pool.name", url.QueryEscape(req.GetCaPool().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateCaPool[0:len(c.CallOptions.UpdateCaPool):len(c.CallOptions.UpdateCaPool)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.UpdateCaPool(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UpdateCaPoolOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// GetCaPool returns a CaPool. +func (c *CertificateAuthorityClient) GetCaPool(ctx context.Context, req *privatecapb.GetCaPoolRequest, opts ...gax.CallOption) (*privatecapb.CaPool, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetCaPool[0:len(c.CallOptions.GetCaPool):len(c.CallOptions.GetCaPool)], opts...) + var resp *privatecapb.CaPool + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.GetCaPool(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListCaPools lists CaPools. +func (c *CertificateAuthorityClient) ListCaPools(ctx context.Context, req *privatecapb.ListCaPoolsRequest, opts ...gax.CallOption) *CaPoolIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListCaPools[0:len(c.CallOptions.ListCaPools):len(c.CallOptions.ListCaPools)], opts...) + it := &CaPoolIterator{} + req = proto.Clone(req).(*privatecapb.ListCaPoolsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*privatecapb.CaPool, string, error) { + var resp *privatecapb.ListCaPoolsResponse + req.PageToken = pageToken + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.ListCaPools(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetCaPools(), resp.GetNextPageToken(), nil + } + fetch := func(pageSize int, pageToken string) (string, error) { + items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) + if err != nil { + return "", err + } + it.items = append(it.items, items...) + return nextPageToken, nil + } + it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) + it.pageInfo.MaxSize = int(req.GetPageSize()) + it.pageInfo.Token = req.GetPageToken() + return it +} + +// DeleteCaPool delete a CaPool. +func (c *CertificateAuthorityClient) DeleteCaPool(ctx context.Context, req *privatecapb.DeleteCaPoolRequest, opts ...gax.CallOption) (*DeleteCaPoolOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeleteCaPool[0:len(c.CallOptions.DeleteCaPool):len(c.CallOptions.DeleteCaPool)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.DeleteCaPool(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteCaPoolOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// FetchCaCerts fetchCaCerts returns the current trust anchor for the CaPool. This will +// include CA certificate chains for all ACTIVE CertificateAuthority +// resources in the CaPool. +func (c *CertificateAuthorityClient) FetchCaCerts(ctx context.Context, req *privatecapb.FetchCaCertsRequest, opts ...gax.CallOption) (*privatecapb.FetchCaCertsResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "ca_pool", url.QueryEscape(req.GetCaPool()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.FetchCaCerts[0:len(c.CallOptions.FetchCaCerts):len(c.CallOptions.FetchCaCerts)], opts...) + var resp *privatecapb.FetchCaCertsResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.FetchCaCerts(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// GetCertificateRevocationList returns a CertificateRevocationList. +func (c *CertificateAuthorityClient) GetCertificateRevocationList(ctx context.Context, req *privatecapb.GetCertificateRevocationListRequest, opts ...gax.CallOption) (*privatecapb.CertificateRevocationList, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetCertificateRevocationList[0:len(c.CallOptions.GetCertificateRevocationList):len(c.CallOptions.GetCertificateRevocationList)], opts...) + var resp *privatecapb.CertificateRevocationList + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.GetCertificateRevocationList(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListCertificateRevocationLists lists CertificateRevocationLists. +func (c *CertificateAuthorityClient) ListCertificateRevocationLists(ctx context.Context, req *privatecapb.ListCertificateRevocationListsRequest, opts ...gax.CallOption) *CertificateRevocationListIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListCertificateRevocationLists[0:len(c.CallOptions.ListCertificateRevocationLists):len(c.CallOptions.ListCertificateRevocationLists)], opts...) + it := &CertificateRevocationListIterator{} + req = proto.Clone(req).(*privatecapb.ListCertificateRevocationListsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*privatecapb.CertificateRevocationList, string, error) { + var resp *privatecapb.ListCertificateRevocationListsResponse + req.PageToken = pageToken + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.ListCertificateRevocationLists(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetCertificateRevocationLists(), resp.GetNextPageToken(), nil + } + fetch := func(pageSize int, pageToken string) (string, error) { + items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) + if err != nil { + return "", err + } + it.items = append(it.items, items...) + return nextPageToken, nil + } + it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) + it.pageInfo.MaxSize = int(req.GetPageSize()) + it.pageInfo.Token = req.GetPageToken() + return it +} + +// UpdateCertificateRevocationList update a CertificateRevocationList. +func (c *CertificateAuthorityClient) UpdateCertificateRevocationList(ctx context.Context, req *privatecapb.UpdateCertificateRevocationListRequest, opts ...gax.CallOption) (*UpdateCertificateRevocationListOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "certificate_revocation_list.name", url.QueryEscape(req.GetCertificateRevocationList().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateCertificateRevocationList[0:len(c.CallOptions.UpdateCertificateRevocationList):len(c.CallOptions.UpdateCertificateRevocationList)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.UpdateCertificateRevocationList(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UpdateCertificateRevocationListOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// CreateCertificateTemplate create a new CertificateTemplate in a given Project and Location. +func (c *CertificateAuthorityClient) CreateCertificateTemplate(ctx context.Context, req *privatecapb.CreateCertificateTemplateRequest, opts ...gax.CallOption) (*CreateCertificateTemplateOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateCertificateTemplate[0:len(c.CallOptions.CreateCertificateTemplate):len(c.CallOptions.CreateCertificateTemplate)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.CreateCertificateTemplate(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateCertificateTemplateOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// DeleteCertificateTemplate deleteCertificateTemplate deletes a CertificateTemplate. +func (c *CertificateAuthorityClient) DeleteCertificateTemplate(ctx context.Context, req *privatecapb.DeleteCertificateTemplateRequest, opts ...gax.CallOption) (*DeleteCertificateTemplateOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeleteCertificateTemplate[0:len(c.CallOptions.DeleteCertificateTemplate):len(c.CallOptions.DeleteCertificateTemplate)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.DeleteCertificateTemplate(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteCertificateTemplateOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// GetCertificateTemplate returns a CertificateTemplate. +func (c *CertificateAuthorityClient) GetCertificateTemplate(ctx context.Context, req *privatecapb.GetCertificateTemplateRequest, opts ...gax.CallOption) (*privatecapb.CertificateTemplate, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetCertificateTemplate[0:len(c.CallOptions.GetCertificateTemplate):len(c.CallOptions.GetCertificateTemplate)], opts...) + var resp *privatecapb.CertificateTemplate + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.GetCertificateTemplate(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListCertificateTemplates lists CertificateTemplates. +func (c *CertificateAuthorityClient) ListCertificateTemplates(ctx context.Context, req *privatecapb.ListCertificateTemplatesRequest, opts ...gax.CallOption) *CertificateTemplateIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListCertificateTemplates[0:len(c.CallOptions.ListCertificateTemplates):len(c.CallOptions.ListCertificateTemplates)], opts...) + it := &CertificateTemplateIterator{} + req = proto.Clone(req).(*privatecapb.ListCertificateTemplatesRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*privatecapb.CertificateTemplate, string, error) { + var resp *privatecapb.ListCertificateTemplatesResponse + req.PageToken = pageToken + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.ListCertificateTemplates(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetCertificateTemplates(), resp.GetNextPageToken(), nil + } + fetch := func(pageSize int, pageToken string) (string, error) { + items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) + if err != nil { + return "", err + } + it.items = append(it.items, items...) + return nextPageToken, nil + } + it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) + it.pageInfo.MaxSize = int(req.GetPageSize()) + it.pageInfo.Token = req.GetPageToken() + return it +} + +// UpdateCertificateTemplate update a CertificateTemplate. +func (c *CertificateAuthorityClient) UpdateCertificateTemplate(ctx context.Context, req *privatecapb.UpdateCertificateTemplateRequest, opts ...gax.CallOption) (*UpdateCertificateTemplateOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "certificate_template.name", url.QueryEscape(req.GetCertificateTemplate().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateCertificateTemplate[0:len(c.CallOptions.UpdateCertificateTemplate):len(c.CallOptions.UpdateCertificateTemplate)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.certificateAuthorityClient.UpdateCertificateTemplate(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UpdateCertificateTemplateOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// ActivateCertificateAuthorityOperation manages a long-running operation from ActivateCertificateAuthority. +type ActivateCertificateAuthorityOperation struct { + lro *longrunning.Operation +} + +// ActivateCertificateAuthorityOperation returns a new ActivateCertificateAuthorityOperation from a given name. +// The name must be that of a previously created ActivateCertificateAuthorityOperation, possibly from a different process. +func (c *CertificateAuthorityClient) ActivateCertificateAuthorityOperation(name string) *ActivateCertificateAuthorityOperation { + return &ActivateCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *ActivateCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *ActivateCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *ActivateCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *ActivateCertificateAuthorityOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *ActivateCertificateAuthorityOperation) Name() string { + return op.lro.Name() +} + +// CreateCaPoolOperation manages a long-running operation from CreateCaPool. +type CreateCaPoolOperation struct { + lro *longrunning.Operation +} + +// CreateCaPoolOperation returns a new CreateCaPoolOperation from a given name. +// The name must be that of a previously created CreateCaPoolOperation, possibly from a different process. +func (c *CertificateAuthorityClient) CreateCaPoolOperation(name string) *CreateCaPoolOperation { + return &CreateCaPoolOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *CreateCaPoolOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CaPool, error) { + var resp privatecapb.CaPool + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *CreateCaPoolOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CaPool, error) { + var resp privatecapb.CaPool + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *CreateCaPoolOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *CreateCaPoolOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *CreateCaPoolOperation) Name() string { + return op.lro.Name() +} + +// CreateCertificateAuthorityOperation manages a long-running operation from CreateCertificateAuthority. +type CreateCertificateAuthorityOperation struct { + lro *longrunning.Operation +} + +// CreateCertificateAuthorityOperation returns a new CreateCertificateAuthorityOperation from a given name. +// The name must be that of a previously created CreateCertificateAuthorityOperation, possibly from a different process. +func (c *CertificateAuthorityClient) CreateCertificateAuthorityOperation(name string) *CreateCertificateAuthorityOperation { + return &CreateCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *CreateCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *CreateCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *CreateCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *CreateCertificateAuthorityOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *CreateCertificateAuthorityOperation) Name() string { + return op.lro.Name() +} + +// CreateCertificateTemplateOperation manages a long-running operation from CreateCertificateTemplate. +type CreateCertificateTemplateOperation struct { + lro *longrunning.Operation +} + +// CreateCertificateTemplateOperation returns a new CreateCertificateTemplateOperation from a given name. +// The name must be that of a previously created CreateCertificateTemplateOperation, possibly from a different process. +func (c *CertificateAuthorityClient) CreateCertificateTemplateOperation(name string) *CreateCertificateTemplateOperation { + return &CreateCertificateTemplateOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *CreateCertificateTemplateOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateTemplate, error) { + var resp privatecapb.CertificateTemplate + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *CreateCertificateTemplateOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateTemplate, error) { + var resp privatecapb.CertificateTemplate + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *CreateCertificateTemplateOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *CreateCertificateTemplateOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *CreateCertificateTemplateOperation) Name() string { + return op.lro.Name() +} + +// DeleteCaPoolOperation manages a long-running operation from DeleteCaPool. +type DeleteCaPoolOperation struct { + lro *longrunning.Operation +} + +// DeleteCaPoolOperation returns a new DeleteCaPoolOperation from a given name. +// The name must be that of a previously created DeleteCaPoolOperation, possibly from a different process. +func (c *CertificateAuthorityClient) DeleteCaPoolOperation(name string) *DeleteCaPoolOperation { + return &DeleteCaPoolOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *DeleteCaPoolOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CaPool, error) { + var resp privatecapb.CaPool + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *DeleteCaPoolOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CaPool, error) { + var resp privatecapb.CaPool + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeleteCaPoolOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *DeleteCaPoolOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *DeleteCaPoolOperation) Name() string { + return op.lro.Name() +} + +// DeleteCertificateAuthorityOperation manages a long-running operation from DeleteCertificateAuthority. +type DeleteCertificateAuthorityOperation struct { + lro *longrunning.Operation +} + +// DeleteCertificateAuthorityOperation returns a new DeleteCertificateAuthorityOperation from a given name. +// The name must be that of a previously created DeleteCertificateAuthorityOperation, possibly from a different process. +func (c *CertificateAuthorityClient) DeleteCertificateAuthorityOperation(name string) *DeleteCertificateAuthorityOperation { + return &DeleteCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *DeleteCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *DeleteCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeleteCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *DeleteCertificateAuthorityOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *DeleteCertificateAuthorityOperation) Name() string { + return op.lro.Name() +} + +// DeleteCertificateTemplateOperation manages a long-running operation from DeleteCertificateTemplate. +type DeleteCertificateTemplateOperation struct { + lro *longrunning.Operation +} + +// DeleteCertificateTemplateOperation returns a new DeleteCertificateTemplateOperation from a given name. +// The name must be that of a previously created DeleteCertificateTemplateOperation, possibly from a different process. +func (c *CertificateAuthorityClient) DeleteCertificateTemplateOperation(name string) *DeleteCertificateTemplateOperation { + return &DeleteCertificateTemplateOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *DeleteCertificateTemplateOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *DeleteCertificateTemplateOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeleteCertificateTemplateOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *DeleteCertificateTemplateOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *DeleteCertificateTemplateOperation) Name() string { + return op.lro.Name() +} + +// DisableCertificateAuthorityOperation manages a long-running operation from DisableCertificateAuthority. +type DisableCertificateAuthorityOperation struct { + lro *longrunning.Operation +} + +// DisableCertificateAuthorityOperation returns a new DisableCertificateAuthorityOperation from a given name. +// The name must be that of a previously created DisableCertificateAuthorityOperation, possibly from a different process. +func (c *CertificateAuthorityClient) DisableCertificateAuthorityOperation(name string) *DisableCertificateAuthorityOperation { + return &DisableCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *DisableCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *DisableCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DisableCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *DisableCertificateAuthorityOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *DisableCertificateAuthorityOperation) Name() string { + return op.lro.Name() +} + +// EnableCertificateAuthorityOperation manages a long-running operation from EnableCertificateAuthority. +type EnableCertificateAuthorityOperation struct { + lro *longrunning.Operation +} + +// EnableCertificateAuthorityOperation returns a new EnableCertificateAuthorityOperation from a given name. +// The name must be that of a previously created EnableCertificateAuthorityOperation, possibly from a different process. +func (c *CertificateAuthorityClient) EnableCertificateAuthorityOperation(name string) *EnableCertificateAuthorityOperation { + return &EnableCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *EnableCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *EnableCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *EnableCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *EnableCertificateAuthorityOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *EnableCertificateAuthorityOperation) Name() string { + return op.lro.Name() +} + +// UndeleteCertificateAuthorityOperation manages a long-running operation from UndeleteCertificateAuthority. +type UndeleteCertificateAuthorityOperation struct { + lro *longrunning.Operation +} + +// UndeleteCertificateAuthorityOperation returns a new UndeleteCertificateAuthorityOperation from a given name. +// The name must be that of a previously created UndeleteCertificateAuthorityOperation, possibly from a different process. +func (c *CertificateAuthorityClient) UndeleteCertificateAuthorityOperation(name string) *UndeleteCertificateAuthorityOperation { + return &UndeleteCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *UndeleteCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *UndeleteCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *UndeleteCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *UndeleteCertificateAuthorityOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *UndeleteCertificateAuthorityOperation) Name() string { + return op.lro.Name() +} + +// UpdateCaPoolOperation manages a long-running operation from UpdateCaPool. +type UpdateCaPoolOperation struct { + lro *longrunning.Operation +} + +// UpdateCaPoolOperation returns a new UpdateCaPoolOperation from a given name. +// The name must be that of a previously created UpdateCaPoolOperation, possibly from a different process. +func (c *CertificateAuthorityClient) UpdateCaPoolOperation(name string) *UpdateCaPoolOperation { + return &UpdateCaPoolOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *UpdateCaPoolOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CaPool, error) { + var resp privatecapb.CaPool + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *UpdateCaPoolOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CaPool, error) { + var resp privatecapb.CaPool + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *UpdateCaPoolOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *UpdateCaPoolOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *UpdateCaPoolOperation) Name() string { + return op.lro.Name() +} + +// UpdateCertificateAuthorityOperation manages a long-running operation from UpdateCertificateAuthority. +type UpdateCertificateAuthorityOperation struct { + lro *longrunning.Operation +} + +// UpdateCertificateAuthorityOperation returns a new UpdateCertificateAuthorityOperation from a given name. +// The name must be that of a previously created UpdateCertificateAuthorityOperation, possibly from a different process. +func (c *CertificateAuthorityClient) UpdateCertificateAuthorityOperation(name string) *UpdateCertificateAuthorityOperation { + return &UpdateCertificateAuthorityOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *UpdateCertificateAuthorityOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *UpdateCertificateAuthorityOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { + var resp privatecapb.CertificateAuthority + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *UpdateCertificateAuthorityOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *UpdateCertificateAuthorityOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *UpdateCertificateAuthorityOperation) Name() string { + return op.lro.Name() +} + +// UpdateCertificateRevocationListOperation manages a long-running operation from UpdateCertificateRevocationList. +type UpdateCertificateRevocationListOperation struct { + lro *longrunning.Operation +} + +// UpdateCertificateRevocationListOperation returns a new UpdateCertificateRevocationListOperation from a given name. +// The name must be that of a previously created UpdateCertificateRevocationListOperation, possibly from a different process. +func (c *CertificateAuthorityClient) UpdateCertificateRevocationListOperation(name string) *UpdateCertificateRevocationListOperation { + return &UpdateCertificateRevocationListOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *UpdateCertificateRevocationListOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateRevocationList, error) { + var resp privatecapb.CertificateRevocationList + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *UpdateCertificateRevocationListOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateRevocationList, error) { + var resp privatecapb.CertificateRevocationList + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *UpdateCertificateRevocationListOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *UpdateCertificateRevocationListOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *UpdateCertificateRevocationListOperation) Name() string { + return op.lro.Name() +} + +// UpdateCertificateTemplateOperation manages a long-running operation from UpdateCertificateTemplate. +type UpdateCertificateTemplateOperation struct { + lro *longrunning.Operation +} + +// UpdateCertificateTemplateOperation returns a new UpdateCertificateTemplateOperation from a given name. +// The name must be that of a previously created UpdateCertificateTemplateOperation, possibly from a different process. +func (c *CertificateAuthorityClient) UpdateCertificateTemplateOperation(name string) *UpdateCertificateTemplateOperation { + return &UpdateCertificateTemplateOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *UpdateCertificateTemplateOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateTemplate, error) { + var resp privatecapb.CertificateTemplate + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *UpdateCertificateTemplateOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*privatecapb.CertificateTemplate, error) { + var resp privatecapb.CertificateTemplate + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *UpdateCertificateTemplateOperation) Metadata() (*privatecapb.OperationMetadata, error) { + var meta privatecapb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *UpdateCertificateTemplateOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *UpdateCertificateTemplateOperation) Name() string { + return op.lro.Name() +} + +// CaPoolIterator manages a stream of *privatecapb.CaPool. +type CaPoolIterator struct { + items []*privatecapb.CaPool + pageInfo *iterator.PageInfo + nextFunc func() error + + // Response is the raw response for the current page. + // It must be cast to the RPC response type. + // Calling Next() or InternalFetch() updates this value. + Response interface{} + + // InternalFetch is for use by the Google Cloud Libraries only. + // It is not part of the stable interface of this package. + // + // InternalFetch returns results from a single call to the underlying RPC. + // The number of results is no greater than pageSize. + // If there are no more results, nextPageToken is empty and err is nil. + InternalFetch func(pageSize int, pageToken string) (results []*privatecapb.CaPool, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *CaPoolIterator) PageInfo() *iterator.PageInfo { + return it.pageInfo +} + +// Next returns the next result. Its second return value is iterator.Done if there are no more +// results. Once Next returns Done, all subsequent calls will return Done. +func (it *CaPoolIterator) Next() (*privatecapb.CaPool, error) { + var item *privatecapb.CaPool + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *CaPoolIterator) bufLen() int { + return len(it.items) +} + +func (it *CaPoolIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + +// CertificateAuthorityIterator manages a stream of *privatecapb.CertificateAuthority. +type CertificateAuthorityIterator struct { + items []*privatecapb.CertificateAuthority + pageInfo *iterator.PageInfo + nextFunc func() error + + // Response is the raw response for the current page. + // It must be cast to the RPC response type. + // Calling Next() or InternalFetch() updates this value. + Response interface{} + + // InternalFetch is for use by the Google Cloud Libraries only. + // It is not part of the stable interface of this package. + // + // InternalFetch returns results from a single call to the underlying RPC. + // The number of results is no greater than pageSize. + // If there are no more results, nextPageToken is empty and err is nil. + InternalFetch func(pageSize int, pageToken string) (results []*privatecapb.CertificateAuthority, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *CertificateAuthorityIterator) PageInfo() *iterator.PageInfo { + return it.pageInfo +} + +// Next returns the next result. Its second return value is iterator.Done if there are no more +// results. Once Next returns Done, all subsequent calls will return Done. +func (it *CertificateAuthorityIterator) Next() (*privatecapb.CertificateAuthority, error) { + var item *privatecapb.CertificateAuthority + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *CertificateAuthorityIterator) bufLen() int { + return len(it.items) +} + +func (it *CertificateAuthorityIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + +// CertificateIterator manages a stream of *privatecapb.Certificate. +type CertificateIterator struct { + items []*privatecapb.Certificate + pageInfo *iterator.PageInfo + nextFunc func() error + + // Response is the raw response for the current page. + // It must be cast to the RPC response type. + // Calling Next() or InternalFetch() updates this value. + Response interface{} + + // InternalFetch is for use by the Google Cloud Libraries only. + // It is not part of the stable interface of this package. + // + // InternalFetch returns results from a single call to the underlying RPC. + // The number of results is no greater than pageSize. + // If there are no more results, nextPageToken is empty and err is nil. + InternalFetch func(pageSize int, pageToken string) (results []*privatecapb.Certificate, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *CertificateIterator) PageInfo() *iterator.PageInfo { + return it.pageInfo +} + +// Next returns the next result. Its second return value is iterator.Done if there are no more +// results. Once Next returns Done, all subsequent calls will return Done. +func (it *CertificateIterator) Next() (*privatecapb.Certificate, error) { + var item *privatecapb.Certificate + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *CertificateIterator) bufLen() int { + return len(it.items) +} + +func (it *CertificateIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + +// CertificateRevocationListIterator manages a stream of *privatecapb.CertificateRevocationList. +type CertificateRevocationListIterator struct { + items []*privatecapb.CertificateRevocationList + pageInfo *iterator.PageInfo + nextFunc func() error + + // Response is the raw response for the current page. + // It must be cast to the RPC response type. + // Calling Next() or InternalFetch() updates this value. + Response interface{} + + // InternalFetch is for use by the Google Cloud Libraries only. + // It is not part of the stable interface of this package. + // + // InternalFetch returns results from a single call to the underlying RPC. + // The number of results is no greater than pageSize. + // If there are no more results, nextPageToken is empty and err is nil. + InternalFetch func(pageSize int, pageToken string) (results []*privatecapb.CertificateRevocationList, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *CertificateRevocationListIterator) PageInfo() *iterator.PageInfo { + return it.pageInfo +} + +// Next returns the next result. Its second return value is iterator.Done if there are no more +// results. Once Next returns Done, all subsequent calls will return Done. +func (it *CertificateRevocationListIterator) Next() (*privatecapb.CertificateRevocationList, error) { + var item *privatecapb.CertificateRevocationList + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *CertificateRevocationListIterator) bufLen() int { + return len(it.items) +} + +func (it *CertificateRevocationListIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + +// CertificateTemplateIterator manages a stream of *privatecapb.CertificateTemplate. +type CertificateTemplateIterator struct { + items []*privatecapb.CertificateTemplate + pageInfo *iterator.PageInfo + nextFunc func() error + + // Response is the raw response for the current page. + // It must be cast to the RPC response type. + // Calling Next() or InternalFetch() updates this value. + Response interface{} + + // InternalFetch is for use by the Google Cloud Libraries only. + // It is not part of the stable interface of this package. + // + // InternalFetch returns results from a single call to the underlying RPC. + // The number of results is no greater than pageSize. + // If there are no more results, nextPageToken is empty and err is nil. + InternalFetch func(pageSize int, pageToken string) (results []*privatecapb.CertificateTemplate, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *CertificateTemplateIterator) PageInfo() *iterator.PageInfo { + return it.pageInfo +} + +// Next returns the next result. Its second return value is iterator.Done if there are no more +// results. Once Next returns Done, all subsequent calls will return Done. +func (it *CertificateTemplateIterator) Next() (*privatecapb.CertificateTemplate, error) { + var item *privatecapb.CertificateTemplate + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *CertificateTemplateIterator) bufLen() int { + return len(it.items) +} + +func (it *CertificateTemplateIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/security/privateca/apiv1/certificate_authority_client_example_test.go b/security/privateca/apiv1/certificate_authority_client_example_test.go new file mode 100644 index 00000000000..4f3ae6c33c6 --- /dev/null +++ b/security/privateca/apiv1/certificate_authority_client_example_test.go @@ -0,0 +1,718 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package privateca_test + +import ( + "context" + + privateca "cloud.google.com/go/security/privateca/apiv1" + "google.golang.org/api/iterator" + privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" +) + +func ExampleNewCertificateAuthorityClient() { + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use client. + _ = c +} + +func ExampleCertificateAuthorityClient_CreateCertificate() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.CreateCertificateRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.CreateCertificate(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_GetCertificate() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.GetCertificateRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetCertificate(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_ListCertificates() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + // import "google.golang.org/api/iterator" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.ListCertificatesRequest{ + // TODO: Fill request struct fields. + } + it := c.ListCertificates(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleCertificateAuthorityClient_RevokeCertificate() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.RevokeCertificateRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.RevokeCertificate(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_UpdateCertificate() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.UpdateCertificateRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.UpdateCertificate(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_ActivateCertificateAuthority() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.ActivateCertificateAuthorityRequest{ + // TODO: Fill request struct fields. + } + op, err := c.ActivateCertificateAuthority(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_CreateCertificateAuthority() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.CreateCertificateAuthorityRequest{ + // TODO: Fill request struct fields. + } + op, err := c.CreateCertificateAuthority(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_DisableCertificateAuthority() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.DisableCertificateAuthorityRequest{ + // TODO: Fill request struct fields. + } + op, err := c.DisableCertificateAuthority(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_EnableCertificateAuthority() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.EnableCertificateAuthorityRequest{ + // TODO: Fill request struct fields. + } + op, err := c.EnableCertificateAuthority(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_FetchCertificateAuthorityCsr() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.FetchCertificateAuthorityCsrRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.FetchCertificateAuthorityCsr(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_GetCertificateAuthority() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.GetCertificateAuthorityRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetCertificateAuthority(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_ListCertificateAuthorities() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + // import "google.golang.org/api/iterator" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.ListCertificateAuthoritiesRequest{ + // TODO: Fill request struct fields. + } + it := c.ListCertificateAuthorities(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleCertificateAuthorityClient_UndeleteCertificateAuthority() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.UndeleteCertificateAuthorityRequest{ + // TODO: Fill request struct fields. + } + op, err := c.UndeleteCertificateAuthority(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_DeleteCertificateAuthority() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.DeleteCertificateAuthorityRequest{ + // TODO: Fill request struct fields. + } + op, err := c.DeleteCertificateAuthority(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_UpdateCertificateAuthority() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.UpdateCertificateAuthorityRequest{ + // TODO: Fill request struct fields. + } + op, err := c.UpdateCertificateAuthority(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_CreateCaPool() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.CreateCaPoolRequest{ + // TODO: Fill request struct fields. + } + op, err := c.CreateCaPool(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_UpdateCaPool() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.UpdateCaPoolRequest{ + // TODO: Fill request struct fields. + } + op, err := c.UpdateCaPool(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_GetCaPool() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.GetCaPoolRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetCaPool(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_ListCaPools() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + // import "google.golang.org/api/iterator" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.ListCaPoolsRequest{ + // TODO: Fill request struct fields. + } + it := c.ListCaPools(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleCertificateAuthorityClient_DeleteCaPool() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.DeleteCaPoolRequest{ + // TODO: Fill request struct fields. + } + op, err := c.DeleteCaPool(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_FetchCaCerts() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.FetchCaCertsRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.FetchCaCerts(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_GetCertificateRevocationList() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.GetCertificateRevocationListRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetCertificateRevocationList(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_ListCertificateRevocationLists() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + // import "google.golang.org/api/iterator" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.ListCertificateRevocationListsRequest{ + // TODO: Fill request struct fields. + } + it := c.ListCertificateRevocationLists(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleCertificateAuthorityClient_UpdateCertificateRevocationList() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.UpdateCertificateRevocationListRequest{ + // TODO: Fill request struct fields. + } + op, err := c.UpdateCertificateRevocationList(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_CreateCertificateTemplate() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.CreateCertificateTemplateRequest{ + // TODO: Fill request struct fields. + } + op, err := c.CreateCertificateTemplate(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_DeleteCertificateTemplate() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.DeleteCertificateTemplateRequest{ + // TODO: Fill request struct fields. + } + op, err := c.DeleteCertificateTemplate(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleCertificateAuthorityClient_GetCertificateTemplate() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.GetCertificateTemplateRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetCertificateTemplate(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCertificateAuthorityClient_ListCertificateTemplates() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + // import "google.golang.org/api/iterator" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.ListCertificateTemplatesRequest{ + // TODO: Fill request struct fields. + } + it := c.ListCertificateTemplates(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleCertificateAuthorityClient_UpdateCertificateTemplate() { + // import privatecapb "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + + ctx := context.Background() + c, err := privateca.NewCertificateAuthorityClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &privatecapb.UpdateCertificateTemplateRequest{ + // TODO: Fill request struct fields. + } + op, err := c.UpdateCertificateTemplate(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} diff --git a/security/privateca/apiv1/doc.go b/security/privateca/apiv1/doc.go new file mode 100644 index 00000000000..808fd4a3776 --- /dev/null +++ b/security/privateca/apiv1/doc.go @@ -0,0 +1,119 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +// Package privateca is an auto-generated package for the +// Certificate Authority API. +// +// The Certificate Authority Service API is a highly-available, scalable +// service that enables you to simplify and automate the management of +// private certificate authorities (CAs) while staying in control of your +// private keys." +// +// Use of Context +// +// The ctx passed to NewClient is used for authentication requests and +// for creating the underlying connection, but is not used for subsequent calls. +// Individual methods on the client use the ctx given to them. +// +// To close the open connection, use the Close() method. +// +// For information about setting deadlines, reusing contexts, and more +// please visit pkg.go.dev/cloud.google.com/go. +package privateca // import "cloud.google.com/go/security/privateca/apiv1" + +import ( + "context" + "os" + "runtime" + "strconv" + "strings" + "unicode" + + "google.golang.org/api/option" + "google.golang.org/grpc/metadata" +) + +// For more information on implementing a client constructor hook, see +// https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors. +type clientHookParams struct{} +type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) + +const versionClient = "20210429" + +func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { + out, _ := metadata.FromOutgoingContext(ctx) + out = out.Copy() + for _, md := range mds { + for k, v := range md { + out[k] = append(out[k], v...) + } + } + return metadata.NewOutgoingContext(ctx, out) +} + +func checkDisableDeadlines() (bool, error) { + raw, ok := os.LookupEnv("GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE") + if !ok { + return false, nil + } + + b, err := strconv.ParseBool(raw) + return b, err +} + +// DefaultAuthScopes reports the default set of authentication scopes to use with this package. +func DefaultAuthScopes() []string { + return []string{ + "https://www.googleapis.com/auth/cloud-platform", + } +} + +// versionGo returns the Go runtime version. The returned string +// has no whitespace, suitable for reporting in header. +func versionGo() string { + const develPrefix = "devel +" + + s := runtime.Version() + if strings.HasPrefix(s, develPrefix) { + s = s[len(develPrefix):] + if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { + s = s[:p] + } + return s + } + + notSemverRune := func(r rune) bool { + return !strings.ContainsRune("0123456789.", r) + } + + if strings.HasPrefix(s, "go1") { + s = s[2:] + var prerelease string + if p := strings.IndexFunc(s, notSemverRune); p >= 0 { + s, prerelease = s[:p], s[p:] + } + if strings.HasSuffix(s, ".") { + s += "0" + } else if strings.Count(s, ".") < 2 { + s += ".0" + } + if prerelease != "" { + s += "-" + prerelease + } + return s + } + return "UNKNOWN" +} diff --git a/security/privateca/apiv1/gapic_metadata.json b/security/privateca/apiv1/gapic_metadata.json new file mode 100644 index 00000000000..c979b6d151b --- /dev/null +++ b/security/privateca/apiv1/gapic_metadata.json @@ -0,0 +1,163 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods.", + "language": "go", + "protoPackage": "google.cloud.security.privateca.v1", + "libraryPackage": "cloud.google.com/go/security/privateca/apiv1", + "services": { + "CertificateAuthorityService": { + "clients": { + "grpc": { + "libraryClient": "CertificateAuthorityClient", + "rpcs": { + "ActivateCertificateAuthority": { + "methods": [ + "ActivateCertificateAuthority" + ] + }, + "CreateCaPool": { + "methods": [ + "CreateCaPool" + ] + }, + "CreateCertificate": { + "methods": [ + "CreateCertificate" + ] + }, + "CreateCertificateAuthority": { + "methods": [ + "CreateCertificateAuthority" + ] + }, + "CreateCertificateTemplate": { + "methods": [ + "CreateCertificateTemplate" + ] + }, + "DeleteCaPool": { + "methods": [ + "DeleteCaPool" + ] + }, + "DeleteCertificateAuthority": { + "methods": [ + "DeleteCertificateAuthority" + ] + }, + "DeleteCertificateTemplate": { + "methods": [ + "DeleteCertificateTemplate" + ] + }, + "DisableCertificateAuthority": { + "methods": [ + "DisableCertificateAuthority" + ] + }, + "EnableCertificateAuthority": { + "methods": [ + "EnableCertificateAuthority" + ] + }, + "FetchCaCerts": { + "methods": [ + "FetchCaCerts" + ] + }, + "FetchCertificateAuthorityCsr": { + "methods": [ + "FetchCertificateAuthorityCsr" + ] + }, + "GetCaPool": { + "methods": [ + "GetCaPool" + ] + }, + "GetCertificate": { + "methods": [ + "GetCertificate" + ] + }, + "GetCertificateAuthority": { + "methods": [ + "GetCertificateAuthority" + ] + }, + "GetCertificateRevocationList": { + "methods": [ + "GetCertificateRevocationList" + ] + }, + "GetCertificateTemplate": { + "methods": [ + "GetCertificateTemplate" + ] + }, + "ListCaPools": { + "methods": [ + "ListCaPools" + ] + }, + "ListCertificateAuthorities": { + "methods": [ + "ListCertificateAuthorities" + ] + }, + "ListCertificateRevocationLists": { + "methods": [ + "ListCertificateRevocationLists" + ] + }, + "ListCertificateTemplates": { + "methods": [ + "ListCertificateTemplates" + ] + }, + "ListCertificates": { + "methods": [ + "ListCertificates" + ] + }, + "RevokeCertificate": { + "methods": [ + "RevokeCertificate" + ] + }, + "UndeleteCertificateAuthority": { + "methods": [ + "UndeleteCertificateAuthority" + ] + }, + "UpdateCaPool": { + "methods": [ + "UpdateCaPool" + ] + }, + "UpdateCertificate": { + "methods": [ + "UpdateCertificate" + ] + }, + "UpdateCertificateAuthority": { + "methods": [ + "UpdateCertificateAuthority" + ] + }, + "UpdateCertificateRevocationList": { + "methods": [ + "UpdateCertificateRevocationList" + ] + }, + "UpdateCertificateTemplate": { + "methods": [ + "UpdateCertificateTemplate" + ] + } + } + } + } + } + } +}