From d7e4588e19e3198d67e6dd7704c67daf5f5bc4bb Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 18 Oct 2022 15:24:55 +0000 Subject: [PATCH] chore(all): auto-regenerate gapics This is an auto-generated regeneration of the gapic clients by cloud.google.com/go/internal/gapicgen. Once the corresponding genproto PR is submitted, genbot will update this PR with a newer dependency to the newer version of genproto and assign reviewers to this PR. If you have been assigned to review this PR, please: - Ensure that the version of genproto in go.mod has been updated. - Ensure that CI is passing. If it's failing, it requires your manual attention. - Approve and submit this PR if you believe it's ready to ship. Corresponding genproto PR: https://github.com/googleapis/go-genproto/pull/923 Changes: feat(spanner): Update transaction.proto to include different lock modes PiperOrigin-RevId: 481838475 Source-Link: https://github.com/googleapis/googleapis/commit/922f1f33bb239addc9816fbbecbf15376e03a4aa feat(kms): enable generation of Locations mixin PiperOrigin-RevId: 481650929 Source-Link: https://github.com/googleapis/googleapis/commit/62e82e76c6ab8405731c1dfc9edb604745beedfb feat(channel): Add CloudChannelReportsService to CloudChannel API PiperOrigin-RevId: 481642499 Source-Link: https://github.com/googleapis/googleapis/commit/0c78b0c2ef2a623784a6434316c80ee33a33dac1 feat(securitycenter): Adding project/folder level parents to notification configs in SCC PiperOrigin-RevId: 481230115 Source-Link: https://github.com/googleapis/googleapis/commit/94efa50017258958b7ce637bab25d459c67de8e9 --- channel/apiv1/cloud_channel_client.go | 50 +- channel/apiv1/cloud_channel_reports_client.go | 712 ++++++++++++++++++ ...oud_channel_reports_client_example_test.go | 237 ++++++ channel/apiv1/doc.go | 32 +- channel/apiv1/gapic_metadata.json | 44 ++ ...nippet_metadata.google.cloud.asset.v1.json | 2 +- ...metadata.google.cloud.asset.v1p2beta1.json | 2 +- ...metadata.google.cloud.asset.v1p5beta1.json | 2 +- ...data.google.cloud.assuredworkloads.v1.json | 2 +- ...google.cloud.assuredworkloads.v1beta1.json | 2 +- ...ta.google.cloud.certificatemanager.v1.json | 2 +- .../CancelOperation/main.go | 51 ++ .../DeleteOperation/main.go | 51 ++ .../FetchReportResults/main.go | 60 ++ .../GetOperation/main.go | 53 ++ .../ListOperations/main.go | 60 ++ .../ListReports/main.go | 60 ++ .../RunReportJob/main.go | 58 ++ ...ppet_metadata.google.cloud.channel.v1.json | 322 +++++++- .../snippet_metadata.google.container.v1.json | 2 +- ...pet_metadata.google.cloud.dataplex.v1.json | 2 +- ...ippet_metadata.google.cloud.deploy.v1.json | 2 +- ...t_metadata.google.cloud.dialogflow.v2.json | 2 +- ...adata.google.cloud.dialogflow.v2beta1.json | 2 +- ...etadata.google.cloud.dialogflow.cx.v3.json | 2 +- ...ta.google.cloud.dialogflow.cx.v3beta1.json | 2 +- ...nippet_metadata.google.privacy.dlp.v2.json | 2 +- ...etadata.google.cloud.edgecontainer.v1.json | 2 +- ...et_metadata.google.firestore.admin.v1.json | 2 +- .../snippet_metadata.google.firestore.v1.json | 2 +- kms/apiv1/ekm_client.go | 129 ++++ kms/apiv1/ekm_client_example_test.go | 57 ++ kms/apiv1/gapic_metadata.json | 20 + kms/apiv1/key_management_client.go | 82 ++ .../key_management_client_example_test.go | 57 ++ 35 files changed, 2087 insertions(+), 82 deletions(-) create mode 100644 channel/apiv1/cloud_channel_reports_client.go create mode 100644 channel/apiv1/cloud_channel_reports_client_example_test.go create mode 100644 internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/CancelOperation/main.go create mode 100644 internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/DeleteOperation/main.go create mode 100644 internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/FetchReportResults/main.go create mode 100644 internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/GetOperation/main.go create mode 100644 internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/ListOperations/main.go create mode 100644 internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/ListReports/main.go create mode 100644 internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/RunReportJob/main.go diff --git a/channel/apiv1/cloud_channel_client.go b/channel/apiv1/cloud_channel_client.go index 7aa5e472dccc..efbd3bdc170a 100644 --- a/channel/apiv1/cloud_channel_client.go +++ b/channel/apiv1/cloud_channel_client.go @@ -850,7 +850,8 @@ func (c *CloudChannelClient) ListTransferableSkus(ctx context.Context, req *chan // // The customer doesn’t belong to the reseller and has no auth token. // -// The supplied auth token is invalid. +// The customer provided incorrect reseller information when generating +// auth token. // // The reseller account making the request is different // from the reseller account in the query. @@ -4414,53 +4415,6 @@ func (it *OfferIterator) takeBuf() interface{} { return b } -// OperationIterator manages a stream of *longrunningpb.Operation. -type OperationIterator struct { - items []*longrunningpb.Operation - 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 []*longrunningpb.Operation, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *OperationIterator) 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 *OperationIterator) Next() (*longrunningpb.Operation, error) { - var item *longrunningpb.Operation - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *OperationIterator) bufLen() int { - return len(it.items) -} - -func (it *OperationIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} - // ProductIterator manages a stream of *channelpb.Product. type ProductIterator struct { items []*channelpb.Product diff --git a/channel/apiv1/cloud_channel_reports_client.go b/channel/apiv1/cloud_channel_reports_client.go new file mode 100644 index 000000000000..9611647e1a04 --- /dev/null +++ b/channel/apiv1/cloud_channel_reports_client.go @@ -0,0 +1,712 @@ +// Copyright 2022 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 channel + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + "cloud.google.com/go/longrunning" + lroauto "cloud.google.com/go/longrunning/autogen" + 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" + channelpb "google.golang.org/genproto/googleapis/cloud/channel/v1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" + "google.golang.org/protobuf/proto" +) + +var newCloudChannelReportsClientHook clientHook + +// CloudChannelReportsCallOptions contains the retry settings for each method of CloudChannelReportsClient. +type CloudChannelReportsCallOptions struct { + RunReportJob []gax.CallOption + FetchReportResults []gax.CallOption + ListReports []gax.CallOption + CancelOperation []gax.CallOption + DeleteOperation []gax.CallOption + GetOperation []gax.CallOption + ListOperations []gax.CallOption +} + +func defaultCloudChannelReportsGRPCClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("cloudchannel.googleapis.com:443"), + internaloption.WithDefaultMTLSEndpoint("cloudchannel.mtls.googleapis.com:443"), + internaloption.WithDefaultAudience("https://cloudchannel.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + internaloption.EnableJwtWithScope(), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultCloudChannelReportsCallOptions() *CloudChannelReportsCallOptions { + return &CloudChannelReportsCallOptions{ + RunReportJob: []gax.CallOption{}, + FetchReportResults: []gax.CallOption{}, + ListReports: []gax.CallOption{}, + CancelOperation: []gax.CallOption{}, + DeleteOperation: []gax.CallOption{}, + GetOperation: []gax.CallOption{}, + ListOperations: []gax.CallOption{}, + } +} + +// internalCloudChannelReportsClient is an interface that defines the methods available from Cloud Channel API. +type internalCloudChannelReportsClient interface { + Close() error + setGoogleClientInfo(...string) + Connection() *grpc.ClientConn + RunReportJob(context.Context, *channelpb.RunReportJobRequest, ...gax.CallOption) (*RunReportJobOperation, error) + RunReportJobOperation(name string) *RunReportJobOperation + FetchReportResults(context.Context, *channelpb.FetchReportResultsRequest, ...gax.CallOption) *RowIterator + ListReports(context.Context, *channelpb.ListReportsRequest, ...gax.CallOption) *ReportIterator + CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error + DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error + GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) + ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator +} + +// CloudChannelReportsClient is a client for interacting with Cloud Channel API. +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +// +// CloudChannelReportsService lets Google Cloud resellers and +// distributors retrieve and combine a variety of data in Cloud Channel for +// multiple products (Google Cloud Platform (GCP), Google Voice, and +// Google Workspace.) +type CloudChannelReportsClient struct { + // The internal transport-dependent client. + internalClient internalCloudChannelReportsClient + + // The call options for this service. + CallOptions *CloudChannelReportsCallOptions + + // LROClient is used internally to handle long-running operations. + // It is exposed so that its CallOptions can be modified if required. + // Users should not Close this client. + LROClient *lroauto.OperationsClient +} + +// Wrapper methods routed to the internal client. + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *CloudChannelReportsClient) Close() error { + return c.internalClient.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 *CloudChannelReportsClient) setGoogleClientInfo(keyval ...string) { + c.internalClient.setGoogleClientInfo(keyval...) +} + +// Connection returns a connection to the API service. +// +// Deprecated: Connections are now pooled so this method does not always +// return the same resource. +func (c *CloudChannelReportsClient) Connection() *grpc.ClientConn { + return c.internalClient.Connection() +} + +// RunReportJob begins generation of data for a given report. The report +// identifier is a UID (for example, 613bf59q). +// +// Possible error codes: +// +// PERMISSION_DENIED: The user doesn’t have access to this report. +// +// INVALID_ARGUMENT: Required request parameters are missing +// or invalid. +// +// NOT_FOUND: The report identifier was not found. +// +// INTERNAL: Any non-user error related to a technical issue +// in the backend. Contact Cloud Channel support. +// +// UNKNOWN: Any non-user error related to a technical issue +// in the backend. Contact Cloud Channel support. +// +// Return value: +// The ID of a long-running operation. +// +// To get the results of the operation, call the GetOperation method of +// CloudChannelOperationsService. The Operation metadata contains an +// instance of OperationMetadata. +// +// To get the results of report generation, call +// CloudChannelReportsService.FetchReportResults with the +// RunReportJobResponse.report_job. +func (c *CloudChannelReportsClient) RunReportJob(ctx context.Context, req *channelpb.RunReportJobRequest, opts ...gax.CallOption) (*RunReportJobOperation, error) { + return c.internalClient.RunReportJob(ctx, req, opts...) +} + +// RunReportJobOperation returns a new RunReportJobOperation from a given name. +// The name must be that of a previously created RunReportJobOperation, possibly from a different process. +func (c *CloudChannelReportsClient) RunReportJobOperation(name string) *RunReportJobOperation { + return c.internalClient.RunReportJobOperation(name) +} + +// FetchReportResults retrieves data generated by CloudChannelReportsService.RunReportJob. +func (c *CloudChannelReportsClient) FetchReportResults(ctx context.Context, req *channelpb.FetchReportResultsRequest, opts ...gax.CallOption) *RowIterator { + return c.internalClient.FetchReportResults(ctx, req, opts...) +} + +// ListReports lists the reports that RunReportJob can run. These reports include an ID, +// a description, and the list of columns that will be in the result. +func (c *CloudChannelReportsClient) ListReports(ctx context.Context, req *channelpb.ListReportsRequest, opts ...gax.CallOption) *ReportIterator { + return c.internalClient.ListReports(ctx, req, opts...) +} + +// CancelOperation is a utility method from google.longrunning.Operations. +func (c *CloudChannelReportsClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { + return c.internalClient.CancelOperation(ctx, req, opts...) +} + +// DeleteOperation is a utility method from google.longrunning.Operations. +func (c *CloudChannelReportsClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { + return c.internalClient.DeleteOperation(ctx, req, opts...) +} + +// GetOperation is a utility method from google.longrunning.Operations. +func (c *CloudChannelReportsClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { + return c.internalClient.GetOperation(ctx, req, opts...) +} + +// ListOperations is a utility method from google.longrunning.Operations. +func (c *CloudChannelReportsClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { + return c.internalClient.ListOperations(ctx, req, opts...) +} + +// cloudChannelReportsGRPCClient is a client for interacting with Cloud Channel API over gRPC transport. +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type cloudChannelReportsGRPCClient 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 + + // Points back to the CallOptions field of the containing CloudChannelReportsClient + CallOptions **CloudChannelReportsCallOptions + + // The gRPC API client. + cloudChannelReportsClient channelpb.CloudChannelReportsServiceClient + + // LROClient is used internally to handle long-running operations. + // It is exposed so that its CallOptions can be modified if required. + // Users should not Close this client. + LROClient **lroauto.OperationsClient + + operationsClient longrunningpb.OperationsClient + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewCloudChannelReportsClient creates a new cloud channel reports service client based on gRPC. +// The returned client must be Closed when it is done being used to clean up its underlying connections. +// +// CloudChannelReportsService lets Google Cloud resellers and +// distributors retrieve and combine a variety of data in Cloud Channel for +// multiple products (Google Cloud Platform (GCP), Google Voice, and +// Google Workspace.) +func NewCloudChannelReportsClient(ctx context.Context, opts ...option.ClientOption) (*CloudChannelReportsClient, error) { + clientOpts := defaultCloudChannelReportsGRPCClientOptions() + if newCloudChannelReportsClientHook != nil { + hookOpts, err := newCloudChannelReportsClientHook(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 + } + client := CloudChannelReportsClient{CallOptions: defaultCloudChannelReportsCallOptions()} + + c := &cloudChannelReportsGRPCClient{ + connPool: connPool, + disableDeadlines: disableDeadlines, + cloudChannelReportsClient: channelpb.NewCloudChannelReportsServiceClient(connPool), + CallOptions: &client.CallOptions, + operationsClient: longrunningpb.NewOperationsClient(connPool), + } + c.setGoogleClientInfo() + + client.internalClient = c + + client.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 + } + c.LROClient = &client.LROClient + return &client, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated: Connections are now pooled so this method does not always +// return the same resource. +func (c *cloudChannelReportsGRPCClient) Connection() *grpc.ClientConn { + return c.connPool.Conn() +} + +// 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 *cloudChannelReportsGRPCClient) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version) + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *cloudChannelReportsGRPCClient) Close() error { + return c.connPool.Close() +} + +func (c *cloudChannelReportsGRPCClient) RunReportJob(ctx context.Context, req *channelpb.RunReportJobRequest, opts ...gax.CallOption) (*RunReportJobOperation, error) { + 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).RunReportJob[0:len((*c.CallOptions).RunReportJob):len((*c.CallOptions).RunReportJob)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.cloudChannelReportsClient.RunReportJob(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &RunReportJobOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + +func (c *cloudChannelReportsGRPCClient) FetchReportResults(ctx context.Context, req *channelpb.FetchReportResultsRequest, opts ...gax.CallOption) *RowIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "report_job", url.QueryEscape(req.GetReportJob()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).FetchReportResults[0:len((*c.CallOptions).FetchReportResults):len((*c.CallOptions).FetchReportResults)], opts...) + it := &RowIterator{} + req = proto.Clone(req).(*channelpb.FetchReportResultsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*channelpb.Row, string, error) { + resp := &channelpb.FetchReportResultsResponse{} + if pageToken != "" { + req.PageToken = pageToken + } + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else if pageSize != 0 { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.cloudChannelReportsClient.FetchReportResults(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetRows(), 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 +} + +func (c *cloudChannelReportsGRPCClient) ListReports(ctx context.Context, req *channelpb.ListReportsRequest, opts ...gax.CallOption) *ReportIterator { + 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).ListReports[0:len((*c.CallOptions).ListReports):len((*c.CallOptions).ListReports)], opts...) + it := &ReportIterator{} + req = proto.Clone(req).(*channelpb.ListReportsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*channelpb.Report, string, error) { + resp := &channelpb.ListReportsResponse{} + if pageToken != "" { + req.PageToken = pageToken + } + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else if pageSize != 0 { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.cloudChannelReportsClient.ListReports(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetReports(), 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 +} + +func (c *cloudChannelReportsGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { + 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).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.operationsClient.CancelOperation(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +func (c *cloudChannelReportsGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { + 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).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.operationsClient.DeleteOperation(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +func (c *cloudChannelReportsGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { + 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).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.operationsClient.GetOperation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *cloudChannelReportsGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { + 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).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...) + it := &OperationIterator{} + req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { + resp := &longrunningpb.ListOperationsResponse{} + if pageToken != "" { + req.PageToken = pageToken + } + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else if pageSize != 0 { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.operationsClient.ListOperations(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetOperations(), 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 +} + +// RunReportJobOperation manages a long-running operation from RunReportJob. +type RunReportJobOperation struct { + lro *longrunning.Operation +} + +// RunReportJobOperation returns a new RunReportJobOperation from a given name. +// The name must be that of a previously created RunReportJobOperation, possibly from a different process. +func (c *cloudChannelReportsGRPCClient) RunReportJobOperation(name string) *RunReportJobOperation { + return &RunReportJobOperation{ + 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 *RunReportJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*channelpb.RunReportJobResponse, error) { + var resp channelpb.RunReportJobResponse + 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 *RunReportJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*channelpb.RunReportJobResponse, error) { + var resp channelpb.RunReportJobResponse + 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 *RunReportJobOperation) Metadata() (*channelpb.OperationMetadata, error) { + var meta channelpb.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 *RunReportJobOperation) 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 *RunReportJobOperation) Name() string { + return op.lro.Name() +} + +// OperationIterator manages a stream of *longrunningpb.Operation. +type OperationIterator struct { + items []*longrunningpb.Operation + 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 []*longrunningpb.Operation, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *OperationIterator) 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 *OperationIterator) Next() (*longrunningpb.Operation, error) { + var item *longrunningpb.Operation + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *OperationIterator) bufLen() int { + return len(it.items) +} + +func (it *OperationIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + +// ReportIterator manages a stream of *channelpb.Report. +type ReportIterator struct { + items []*channelpb.Report + 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 []*channelpb.Report, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *ReportIterator) 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 *ReportIterator) Next() (*channelpb.Report, error) { + var item *channelpb.Report + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *ReportIterator) bufLen() int { + return len(it.items) +} + +func (it *ReportIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + +// RowIterator manages a stream of *channelpb.Row. +type RowIterator struct { + items []*channelpb.Row + 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 []*channelpb.Row, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *RowIterator) 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 *RowIterator) Next() (*channelpb.Row, error) { + var item *channelpb.Row + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *RowIterator) bufLen() int { + return len(it.items) +} + +func (it *RowIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/channel/apiv1/cloud_channel_reports_client_example_test.go b/channel/apiv1/cloud_channel_reports_client_example_test.go new file mode 100644 index 000000000000..cb1df98eca4d --- /dev/null +++ b/channel/apiv1/cloud_channel_reports_client_example_test.go @@ -0,0 +1,237 @@ +// Copyright 2022 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 channel_test + +import ( + "context" + + channel "cloud.google.com/go/channel/apiv1" + "google.golang.org/api/iterator" + channelpb "google.golang.org/genproto/googleapis/cloud/channel/v1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func ExampleNewCloudChannelReportsClient() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + // TODO: Use client. + _ = c +} + +func ExampleCloudChannelReportsClient_RunReportJob() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &channelpb.RunReportJobRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/channel/v1#RunReportJobRequest. + } + op, err := c.RunReportJob(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCloudChannelReportsClient_FetchReportResults() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &channelpb.FetchReportResultsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/channel/v1#FetchReportResultsRequest. + } + it := c.FetchReportResults(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleCloudChannelReportsClient_ListReports() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &channelpb.ListReportsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/channel/v1#ListReportsRequest. + } + it := c.ListReports(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleCloudChannelReportsClient_CancelOperation() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.CancelOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#CancelOperationRequest. + } + err = c.CancelOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleCloudChannelReportsClient_DeleteOperation() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.DeleteOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#DeleteOperationRequest. + } + err = c.DeleteOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleCloudChannelReportsClient_GetOperation() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.GetOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. + } + resp, err := c.GetOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleCloudChannelReportsClient_ListOperations() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.ListOperationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. + } + it := c.ListOperations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} diff --git a/channel/apiv1/doc.go b/channel/apiv1/doc.go index 5728f7950570..ccca5c5de3d2 100644 --- a/channel/apiv1/doc.go +++ b/channel/apiv1/doc.go @@ -31,7 +31,7 @@ // // - It may require correct/in-range values for request initialization. // // - It may require specifying regional endpoints when creating the service client as shown in: // // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options -// c, err := channel.NewCloudChannelClient(ctx) +// c, err := channel.NewCloudChannelReportsClient(ctx) // if err != nil { // // TODO: Handle error. // } @@ -51,32 +51,31 @@ // // - It may require correct/in-range values for request initialization. // // - It may require specifying regional endpoints when creating the service client as shown in: // // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options -// c, err := channel.NewCloudChannelClient(ctx) +// c, err := channel.NewCloudChannelReportsClient(ctx) // if err != nil { // // TODO: Handle error. // } // defer c.Close() // -// req := &channelpb.ListCustomersRequest{ +// req := &channelpb.RunReportJobRequest{ // // TODO: Fill request struct fields. -// // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/channel/v1#ListCustomersRequest. +// // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/channel/v1#RunReportJobRequest. // } -// it := c.ListCustomers(ctx, req) -// for { -// resp, err := it.Next() -// if err == iterator.Done { -// break -// } -// if err != nil { -// // TODO: Handle error. -// } -// // TODO: Use resp. -// _ = resp +// op, err := c.RunReportJob(ctx, req) +// if err != nil { +// // TODO: Handle error. +// } +// +// resp, err := op.Wait(ctx) +// if err != nil { +// // TODO: Handle error. // } +// // TODO: Use resp. +// _ = resp // // # Use of Context // -// The ctx passed to NewCloudChannelClient is used for authentication requests and +// The ctx passed to NewCloudChannelReportsClient 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. // @@ -137,6 +136,7 @@ func checkDisableDeadlines() (bool, error) { func DefaultAuthScopes() []string { return []string{ "https://www.googleapis.com/auth/apps.order", + "https://www.googleapis.com/auth/apps.reports.usage.readonly", } } diff --git a/channel/apiv1/gapic_metadata.json b/channel/apiv1/gapic_metadata.json index 5b76f8688e81..51f96b868f3b 100644 --- a/channel/apiv1/gapic_metadata.json +++ b/channel/apiv1/gapic_metadata.json @@ -5,6 +5,50 @@ "protoPackage": "google.cloud.channel.v1", "libraryPackage": "cloud.google.com/go/channel/apiv1", "services": { + "CloudChannelReportsService": { + "clients": { + "grpc": { + "libraryClient": "CloudChannelReportsClient", + "rpcs": { + "CancelOperation": { + "methods": [ + "CancelOperation" + ] + }, + "DeleteOperation": { + "methods": [ + "DeleteOperation" + ] + }, + "FetchReportResults": { + "methods": [ + "FetchReportResults" + ] + }, + "GetOperation": { + "methods": [ + "GetOperation" + ] + }, + "ListOperations": { + "methods": [ + "ListOperations" + ] + }, + "ListReports": { + "methods": [ + "ListReports" + ] + }, + "RunReportJob": { + "methods": [ + "RunReportJob" + ] + } + } + } + } + }, "CloudChannelService": { "clients": { "grpc": { diff --git a/internal/generated/snippets/asset/apiv1/snippet_metadata.google.cloud.asset.v1.json b/internal/generated/snippets/asset/apiv1/snippet_metadata.google.cloud.asset.v1.json index 717269e51241..a802b3d2586e 100644 --- a/internal/generated/snippets/asset/apiv1/snippet_metadata.google.cloud.asset.v1.json +++ b/internal/generated/snippets/asset/apiv1/snippet_metadata.google.cloud.asset.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/asset/apiv1", - "version": "1.7.0", + "version": "1.8.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/asset/apiv1p2beta1/snippet_metadata.google.cloud.asset.v1p2beta1.json b/internal/generated/snippets/asset/apiv1p2beta1/snippet_metadata.google.cloud.asset.v1p2beta1.json index 3ef9641d5532..ac44103a2adf 100644 --- a/internal/generated/snippets/asset/apiv1p2beta1/snippet_metadata.google.cloud.asset.v1p2beta1.json +++ b/internal/generated/snippets/asset/apiv1p2beta1/snippet_metadata.google.cloud.asset.v1p2beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/asset/apiv1p2beta1", - "version": "1.7.0", + "version": "1.8.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/asset/apiv1p5beta1/snippet_metadata.google.cloud.asset.v1p5beta1.json b/internal/generated/snippets/asset/apiv1p5beta1/snippet_metadata.google.cloud.asset.v1p5beta1.json index aef49c0e2003..c6bd6177f6f3 100644 --- a/internal/generated/snippets/asset/apiv1p5beta1/snippet_metadata.google.cloud.asset.v1p5beta1.json +++ b/internal/generated/snippets/asset/apiv1p5beta1/snippet_metadata.google.cloud.asset.v1p5beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/asset/apiv1p5beta1", - "version": "1.7.0", + "version": "1.8.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/assuredworkloads/apiv1/snippet_metadata.google.cloud.assuredworkloads.v1.json b/internal/generated/snippets/assuredworkloads/apiv1/snippet_metadata.google.cloud.assuredworkloads.v1.json index fd4f8d5b66d4..736247f61d5d 100644 --- a/internal/generated/snippets/assuredworkloads/apiv1/snippet_metadata.google.cloud.assuredworkloads.v1.json +++ b/internal/generated/snippets/assuredworkloads/apiv1/snippet_metadata.google.cloud.assuredworkloads.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/assuredworkloads/apiv1", - "version": "1.6.0", + "version": "1.7.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/assuredworkloads/apiv1beta1/snippet_metadata.google.cloud.assuredworkloads.v1beta1.json b/internal/generated/snippets/assuredworkloads/apiv1beta1/snippet_metadata.google.cloud.assuredworkloads.v1beta1.json index c21a224282a3..82fc1cf1172f 100644 --- a/internal/generated/snippets/assuredworkloads/apiv1beta1/snippet_metadata.google.cloud.assuredworkloads.v1beta1.json +++ b/internal/generated/snippets/assuredworkloads/apiv1beta1/snippet_metadata.google.cloud.assuredworkloads.v1beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/assuredworkloads/apiv1beta1", - "version": "1.6.0", + "version": "1.7.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/certificatemanager/apiv1/snippet_metadata.google.cloud.certificatemanager.v1.json b/internal/generated/snippets/certificatemanager/apiv1/snippet_metadata.google.cloud.certificatemanager.v1.json index 97648843a704..984c6ae23639 100644 --- a/internal/generated/snippets/certificatemanager/apiv1/snippet_metadata.google.cloud.certificatemanager.v1.json +++ b/internal/generated/snippets/certificatemanager/apiv1/snippet_metadata.google.cloud.certificatemanager.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/certificatemanager/apiv1", - "version": "1.1.0", + "version": "1.2.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/CancelOperation/main.go b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/CancelOperation/main.go new file mode 100644 index 000000000000..aa4e5c9e2047 --- /dev/null +++ b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/CancelOperation/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START cloudchannel_v1_generated_CloudChannelReportsService_CancelOperation_sync] + +package main + +import ( + "context" + + channel "cloud.google.com/go/channel/apiv1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.CancelOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#CancelOperationRequest. + } + err = c.CancelOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +// [END cloudchannel_v1_generated_CloudChannelReportsService_CancelOperation_sync] diff --git a/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/DeleteOperation/main.go b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/DeleteOperation/main.go new file mode 100644 index 000000000000..0c5d3d8a7092 --- /dev/null +++ b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/DeleteOperation/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START cloudchannel_v1_generated_CloudChannelReportsService_DeleteOperation_sync] + +package main + +import ( + "context" + + channel "cloud.google.com/go/channel/apiv1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.DeleteOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#DeleteOperationRequest. + } + err = c.DeleteOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +// [END cloudchannel_v1_generated_CloudChannelReportsService_DeleteOperation_sync] diff --git a/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/FetchReportResults/main.go b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/FetchReportResults/main.go new file mode 100644 index 000000000000..c4fb72371388 --- /dev/null +++ b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/FetchReportResults/main.go @@ -0,0 +1,60 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START cloudchannel_v1_generated_CloudChannelReportsService_FetchReportResults_sync] + +package main + +import ( + "context" + + channel "cloud.google.com/go/channel/apiv1" + "google.golang.org/api/iterator" + channelpb "google.golang.org/genproto/googleapis/cloud/channel/v1" +) + +func main() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &channelpb.FetchReportResultsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/channel/v1#FetchReportResultsRequest. + } + it := c.FetchReportResults(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END cloudchannel_v1_generated_CloudChannelReportsService_FetchReportResults_sync] diff --git a/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/GetOperation/main.go b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/GetOperation/main.go new file mode 100644 index 000000000000..e3830bb24f3e --- /dev/null +++ b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/GetOperation/main.go @@ -0,0 +1,53 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START cloudchannel_v1_generated_CloudChannelReportsService_GetOperation_sync] + +package main + +import ( + "context" + + channel "cloud.google.com/go/channel/apiv1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.GetOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. + } + resp, err := c.GetOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END cloudchannel_v1_generated_CloudChannelReportsService_GetOperation_sync] diff --git a/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/ListOperations/main.go b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/ListOperations/main.go new file mode 100644 index 000000000000..617bc55025f8 --- /dev/null +++ b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/ListOperations/main.go @@ -0,0 +1,60 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START cloudchannel_v1_generated_CloudChannelReportsService_ListOperations_sync] + +package main + +import ( + "context" + + channel "cloud.google.com/go/channel/apiv1" + "google.golang.org/api/iterator" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.ListOperationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. + } + it := c.ListOperations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END cloudchannel_v1_generated_CloudChannelReportsService_ListOperations_sync] diff --git a/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/ListReports/main.go b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/ListReports/main.go new file mode 100644 index 000000000000..0607f2814937 --- /dev/null +++ b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/ListReports/main.go @@ -0,0 +1,60 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START cloudchannel_v1_generated_CloudChannelReportsService_ListReports_sync] + +package main + +import ( + "context" + + channel "cloud.google.com/go/channel/apiv1" + "google.golang.org/api/iterator" + channelpb "google.golang.org/genproto/googleapis/cloud/channel/v1" +) + +func main() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &channelpb.ListReportsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/channel/v1#ListReportsRequest. + } + it := c.ListReports(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END cloudchannel_v1_generated_CloudChannelReportsService_ListReports_sync] diff --git a/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/RunReportJob/main.go b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/RunReportJob/main.go new file mode 100644 index 000000000000..70cb35b8038b --- /dev/null +++ b/internal/generated/snippets/channel/apiv1/CloudChannelReportsClient/RunReportJob/main.go @@ -0,0 +1,58 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START cloudchannel_v1_generated_CloudChannelReportsService_RunReportJob_sync] + +package main + +import ( + "context" + + channel "cloud.google.com/go/channel/apiv1" + channelpb "google.golang.org/genproto/googleapis/cloud/channel/v1" +) + +func main() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := channel.NewCloudChannelReportsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &channelpb.RunReportJobRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/channel/v1#RunReportJobRequest. + } + op, err := c.RunReportJob(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END cloudchannel_v1_generated_CloudChannelReportsService_RunReportJob_sync] diff --git a/internal/generated/snippets/channel/apiv1/snippet_metadata.google.cloud.channel.v1.json b/internal/generated/snippets/channel/apiv1/snippet_metadata.google.cloud.channel.v1.json index 997e26cc559b..6b150747be68 100644 --- a/internal/generated/snippets/channel/apiv1/snippet_metadata.google.cloud.channel.v1.json +++ b/internal/generated/snippets/channel/apiv1/snippet_metadata.google.cloud.channel.v1.json @@ -1619,7 +1619,7 @@ { "regionTag": "cloudchannel_v1_generated_CloudChannelService_ListTransferableOffers_sync", "title": "cloudchannel ListTransferableOffers Sample", - "description": "ListTransferableOffers list TransferableOffers of a customer based on Cloud Identity ID or\nCustomer Name in the request.\n\nUse this method when a reseller gets the entitlement information of an\nunowned customer. The reseller should provide the customer’s\nCloud Identity ID or Customer Name.\n\nPossible error codes: \n\n\tPERMISSION_DENIED: \n\n\t The customer doesn’t belong to the reseller and has no auth token.\n\n\t The supplied auth token is invalid.\n\n\t The reseller account making the request is different\n\t from the reseller account in the query.\n\n\tINVALID_ARGUMENT: Required request parameters are missing or invalid.\n\nReturn value: \nList of TransferableOffer for the given customer and SKU.", + "description": "ListTransferableOffers list TransferableOffers of a customer based on Cloud Identity ID or\nCustomer Name in the request.\n\nUse this method when a reseller gets the entitlement information of an\nunowned customer. The reseller should provide the customer’s\nCloud Identity ID or Customer Name.\n\nPossible error codes: \n\n\tPERMISSION_DENIED: \n\n\t The customer doesn’t belong to the reseller and has no auth token.\n\n\t The customer provided incorrect reseller information when generating\n\t auth token.\n\n\t The reseller account making the request is different\n\t from the reseller account in the query.\n\n\tINVALID_ARGUMENT: Required request parameters are missing or invalid.\n\nReturn value: \nList of TransferableOffer for the given customer and SKU.", "file": "CloudChannelClient/ListTransferableOffers/main.go", "language": "GO", "clientMethod": { @@ -2259,6 +2259,326 @@ "type": "FULL" } ] + }, + { + "regionTag": "cloudchannel_v1_generated_CloudChannelReportsService_CancelOperation_sync", + "title": "cloudchannel CancelOperation Sample", + "description": "CancelOperation is a utility method from google.longrunning.Operations.", + "file": "CloudChannelReportsClient/CancelOperation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "CancelOperation", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient.CancelOperation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.CancelOperationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "client": { + "shortName": "CloudChannelReportsClient", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient" + }, + "method": { + "shortName": "CancelOperation", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService.CancelOperation", + "service": { + "shortName": "CloudChannelReportsService", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 50, + "type": "FULL" + } + ] + }, + { + "regionTag": "cloudchannel_v1_generated_CloudChannelReportsService_DeleteOperation_sync", + "title": "cloudchannel DeleteOperation Sample", + "description": "DeleteOperation is a utility method from google.longrunning.Operations.", + "file": "CloudChannelReportsClient/DeleteOperation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "DeleteOperation", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient.DeleteOperation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.DeleteOperationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "client": { + "shortName": "CloudChannelReportsClient", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient" + }, + "method": { + "shortName": "DeleteOperation", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService.DeleteOperation", + "service": { + "shortName": "CloudChannelReportsService", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 50, + "type": "FULL" + } + ] + }, + { + "regionTag": "cloudchannel_v1_generated_CloudChannelReportsService_FetchReportResults_sync", + "title": "cloudchannel FetchReportResults Sample", + "description": "FetchReportResults retrieves data generated by CloudChannelReportsService.RunReportJob.", + "file": "CloudChannelReportsClient/FetchReportResults/main.go", + "language": "GO", + "clientMethod": { + "shortName": "FetchReportResults", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient.FetchReportResults", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "channelpb.FetchReportResultsRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "RowIterator", + "client": { + "shortName": "CloudChannelReportsClient", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient" + }, + "method": { + "shortName": "FetchReportResults", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService.FetchReportResults", + "service": { + "shortName": "CloudChannelReportsService", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 59, + "type": "FULL" + } + ] + }, + { + "regionTag": "cloudchannel_v1_generated_CloudChannelReportsService_GetOperation_sync", + "title": "cloudchannel GetOperation Sample", + "description": "GetOperation is a utility method from google.longrunning.Operations.", + "file": "CloudChannelReportsClient/GetOperation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "GetOperation", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient.GetOperation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.GetOperationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "longrunningpb.Operation", + "client": { + "shortName": "CloudChannelReportsClient", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient" + }, + "method": { + "shortName": "GetOperation", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService.GetOperation", + "service": { + "shortName": "CloudChannelReportsService", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 52, + "type": "FULL" + } + ] + }, + { + "regionTag": "cloudchannel_v1_generated_CloudChannelReportsService_ListOperations_sync", + "title": "cloudchannel ListOperations Sample", + "description": "ListOperations is a utility method from google.longrunning.Operations.", + "file": "CloudChannelReportsClient/ListOperations/main.go", + "language": "GO", + "clientMethod": { + "shortName": "ListOperations", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient.ListOperations", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.ListOperationsRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "OperationIterator", + "client": { + "shortName": "CloudChannelReportsClient", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient" + }, + "method": { + "shortName": "ListOperations", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService.ListOperations", + "service": { + "shortName": "CloudChannelReportsService", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 59, + "type": "FULL" + } + ] + }, + { + "regionTag": "cloudchannel_v1_generated_CloudChannelReportsService_ListReports_sync", + "title": "cloudchannel ListReports Sample", + "description": "ListReports lists the reports that RunReportJob can run. These reports include an ID,\na description, and the list of columns that will be in the result.", + "file": "CloudChannelReportsClient/ListReports/main.go", + "language": "GO", + "clientMethod": { + "shortName": "ListReports", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient.ListReports", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "channelpb.ListReportsRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "ReportIterator", + "client": { + "shortName": "CloudChannelReportsClient", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient" + }, + "method": { + "shortName": "ListReports", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService.ListReports", + "service": { + "shortName": "CloudChannelReportsService", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 59, + "type": "FULL" + } + ] + }, + { + "regionTag": "cloudchannel_v1_generated_CloudChannelReportsService_RunReportJob_sync", + "title": "cloudchannel RunReportJob Sample", + "description": "RunReportJob begins generation of data for a given report. The report\nidentifier is a UID (for example, 613bf59q).\n\nPossible error codes: \n\n\tPERMISSION_DENIED: The user doesn’t have access to this report.\n\n\tINVALID_ARGUMENT: Required request parameters are missing\n\tor invalid.\n\n\tNOT_FOUND: The report identifier was not found.\n\n\tINTERNAL: Any non-user error related to a technical issue\n\tin the backend. Contact Cloud Channel support.\n\n\tUNKNOWN: Any non-user error related to a technical issue\n\tin the backend. Contact Cloud Channel support.\n\nReturn value: \nThe ID of a long-running operation.\n\nTo get the results of the operation, call the GetOperation method of\nCloudChannelOperationsService. The Operation metadata contains an\ninstance of OperationMetadata.\n\nTo get the results of report generation, call\nCloudChannelReportsService.FetchReportResults with the\nRunReportJobResponse.report_job.", + "file": "CloudChannelReportsClient/RunReportJob/main.go", + "language": "GO", + "clientMethod": { + "shortName": "RunReportJob", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient.RunReportJob", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "channelpb.RunReportJobRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "RunReportJobOperation", + "client": { + "shortName": "CloudChannelReportsClient", + "fullName": "google.cloud.channel.v1.CloudChannelReportsClient" + }, + "method": { + "shortName": "RunReportJob", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService.RunReportJob", + "service": { + "shortName": "CloudChannelReportsService", + "fullName": "google.cloud.channel.v1.CloudChannelReportsService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 57, + "type": "FULL" + } + ] } ] } \ No newline at end of file diff --git a/internal/generated/snippets/container/apiv1/snippet_metadata.google.container.v1.json b/internal/generated/snippets/container/apiv1/snippet_metadata.google.container.v1.json index e205d19580fa..6ec9367f4338 100644 --- a/internal/generated/snippets/container/apiv1/snippet_metadata.google.container.v1.json +++ b/internal/generated/snippets/container/apiv1/snippet_metadata.google.container.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/container/apiv1", - "version": "1.4.0", + "version": "1.5.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/dataplex/apiv1/snippet_metadata.google.cloud.dataplex.v1.json b/internal/generated/snippets/dataplex/apiv1/snippet_metadata.google.cloud.dataplex.v1.json index 41d40282e030..53e0550a5411 100644 --- a/internal/generated/snippets/dataplex/apiv1/snippet_metadata.google.cloud.dataplex.v1.json +++ b/internal/generated/snippets/dataplex/apiv1/snippet_metadata.google.cloud.dataplex.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/dataplex/apiv1", - "version": "1.1.0", + "version": "1.2.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/deploy/apiv1/snippet_metadata.google.cloud.deploy.v1.json b/internal/generated/snippets/deploy/apiv1/snippet_metadata.google.cloud.deploy.v1.json index a99644109bd8..76cf2ce21686 100644 --- a/internal/generated/snippets/deploy/apiv1/snippet_metadata.google.cloud.deploy.v1.json +++ b/internal/generated/snippets/deploy/apiv1/snippet_metadata.google.cloud.deploy.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/deploy/apiv1", - "version": "1.2.1", + "version": "1.3.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/dialogflow/apiv2/snippet_metadata.google.cloud.dialogflow.v2.json b/internal/generated/snippets/dialogflow/apiv2/snippet_metadata.google.cloud.dialogflow.v2.json index 45e5dbd4f4f3..71bbfea285de 100644 --- a/internal/generated/snippets/dialogflow/apiv2/snippet_metadata.google.cloud.dialogflow.v2.json +++ b/internal/generated/snippets/dialogflow/apiv2/snippet_metadata.google.cloud.dialogflow.v2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/dialogflow/apiv2", - "version": "1.16.1", + "version": "1.17.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/dialogflow/apiv2beta1/snippet_metadata.google.cloud.dialogflow.v2beta1.json b/internal/generated/snippets/dialogflow/apiv2beta1/snippet_metadata.google.cloud.dialogflow.v2beta1.json index 0d6da02216d2..85db6f8241b4 100644 --- a/internal/generated/snippets/dialogflow/apiv2beta1/snippet_metadata.google.cloud.dialogflow.v2beta1.json +++ b/internal/generated/snippets/dialogflow/apiv2beta1/snippet_metadata.google.cloud.dialogflow.v2beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/dialogflow/apiv2beta1", - "version": "1.16.1", + "version": "1.17.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/dialogflow/cx/apiv3/snippet_metadata.google.cloud.dialogflow.cx.v3.json b/internal/generated/snippets/dialogflow/cx/apiv3/snippet_metadata.google.cloud.dialogflow.cx.v3.json index 7bb43c8a7391..230953b1f259 100644 --- a/internal/generated/snippets/dialogflow/cx/apiv3/snippet_metadata.google.cloud.dialogflow.cx.v3.json +++ b/internal/generated/snippets/dialogflow/cx/apiv3/snippet_metadata.google.cloud.dialogflow.cx.v3.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/dialogflow/cx/apiv3", - "version": "1.16.1", + "version": "1.17.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/dialogflow/cx/apiv3beta1/snippet_metadata.google.cloud.dialogflow.cx.v3beta1.json b/internal/generated/snippets/dialogflow/cx/apiv3beta1/snippet_metadata.google.cloud.dialogflow.cx.v3beta1.json index 9662bf24472a..c6a0b86a6585 100644 --- a/internal/generated/snippets/dialogflow/cx/apiv3beta1/snippet_metadata.google.cloud.dialogflow.cx.v3beta1.json +++ b/internal/generated/snippets/dialogflow/cx/apiv3beta1/snippet_metadata.google.cloud.dialogflow.cx.v3beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/dialogflow/cx/apiv3beta1", - "version": "1.16.1", + "version": "1.17.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/dlp/apiv2/snippet_metadata.google.privacy.dlp.v2.json b/internal/generated/snippets/dlp/apiv2/snippet_metadata.google.privacy.dlp.v2.json index 4561d63912c8..d5183f315e3b 100644 --- a/internal/generated/snippets/dlp/apiv2/snippet_metadata.google.privacy.dlp.v2.json +++ b/internal/generated/snippets/dlp/apiv2/snippet_metadata.google.privacy.dlp.v2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/dlp/apiv2", - "version": "1.5.0", + "version": "1.5.1", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/edgecontainer/apiv1/snippet_metadata.google.cloud.edgecontainer.v1.json b/internal/generated/snippets/edgecontainer/apiv1/snippet_metadata.google.cloud.edgecontainer.v1.json index 7bcf4a0a6953..22c45ae11a8a 100644 --- a/internal/generated/snippets/edgecontainer/apiv1/snippet_metadata.google.cloud.edgecontainer.v1.json +++ b/internal/generated/snippets/edgecontainer/apiv1/snippet_metadata.google.cloud.edgecontainer.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/edgecontainer/apiv1", - "version": "0.1.0", + "version": "0.2.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/firestore/apiv1/admin/snippet_metadata.google.firestore.admin.v1.json b/internal/generated/snippets/firestore/apiv1/admin/snippet_metadata.google.firestore.admin.v1.json index 163f21a19abe..a3d2760e1b3d 100644 --- a/internal/generated/snippets/firestore/apiv1/admin/snippet_metadata.google.firestore.admin.v1.json +++ b/internal/generated/snippets/firestore/apiv1/admin/snippet_metadata.google.firestore.admin.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/firestore/apiv1/admin", - "version": "1.7.0", + "version": "1.8.0", "language": "GO", "apis": [ { diff --git a/internal/generated/snippets/firestore/apiv1/snippet_metadata.google.firestore.v1.json b/internal/generated/snippets/firestore/apiv1/snippet_metadata.google.firestore.v1.json index a35b58be7318..92c6f8883f61 100644 --- a/internal/generated/snippets/firestore/apiv1/snippet_metadata.google.firestore.v1.json +++ b/internal/generated/snippets/firestore/apiv1/snippet_metadata.google.firestore.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "cloud.google.com/go/firestore/apiv1", - "version": "1.7.0", + "version": "1.8.0", "language": "GO", "apis": [ { diff --git a/kms/apiv1/ekm_client.go b/kms/apiv1/ekm_client.go index a6279d2793e8..70acd427ae74 100644 --- a/kms/apiv1/ekm_client.go +++ b/kms/apiv1/ekm_client.go @@ -29,6 +29,7 @@ import ( "google.golang.org/api/option/internaloption" gtransport "google.golang.org/api/transport/grpc" kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" iampb "google.golang.org/genproto/googleapis/iam/v1" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -44,6 +45,8 @@ type EkmCallOptions struct { GetEkmConnection []gax.CallOption CreateEkmConnection []gax.CallOption UpdateEkmConnection []gax.CallOption + GetLocation []gax.CallOption + ListLocations []gax.CallOption GetIamPolicy []gax.CallOption SetIamPolicy []gax.CallOption TestIamPermissions []gax.CallOption @@ -111,6 +114,8 @@ func defaultEkmCallOptions() *EkmCallOptions { }) }), }, + GetLocation: []gax.CallOption{}, + ListLocations: []gax.CallOption{}, GetIamPolicy: []gax.CallOption{}, SetIamPolicy: []gax.CallOption{}, TestIamPermissions: []gax.CallOption{}, @@ -126,6 +131,8 @@ type internalEkmClient interface { GetEkmConnection(context.Context, *kmspb.GetEkmConnectionRequest, ...gax.CallOption) (*kmspb.EkmConnection, error) CreateEkmConnection(context.Context, *kmspb.CreateEkmConnectionRequest, ...gax.CallOption) (*kmspb.EkmConnection, error) UpdateEkmConnection(context.Context, *kmspb.UpdateEkmConnectionRequest, ...gax.CallOption) (*kmspb.EkmConnection, error) + GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) + ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) @@ -193,6 +200,16 @@ func (c *EkmClient) UpdateEkmConnection(ctx context.Context, req *kmspb.UpdateEk return c.internalClient.UpdateEkmConnection(ctx, req, opts...) } +// GetLocation gets information about a location. +func (c *EkmClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { + return c.internalClient.GetLocation(ctx, req, opts...) +} + +// ListLocations lists information about the supported locations for this service. +func (c *EkmClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { + return c.internalClient.ListLocations(ctx, req, opts...) +} + // GetIamPolicy gets the access control policy for a resource. Returns an empty policy // if the resource exists and does not have a policy set. func (c *EkmClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { @@ -237,6 +254,8 @@ type ekmGRPCClient struct { iamPolicyClient iampb.IAMPolicyClient + locationsClient locationpb.LocationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -277,6 +296,7 @@ func NewEkmClient(ctx context.Context, opts ...option.ClientOption) (*EkmClient, ekmClient: kmspb.NewEkmServiceClient(connPool), CallOptions: &client.CallOptions, iamPolicyClient: iampb.NewIAMPolicyClient(connPool), + locationsClient: locationpb.NewLocationsClient(connPool), } c.setGoogleClientInfo() @@ -419,6 +439,68 @@ func (c *ekmGRPCClient) UpdateEkmConnection(ctx context.Context, req *kmspb.Upda return resp, nil } +func (c *ekmGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { + 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).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) + var resp *locationpb.Location + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.locationsClient.GetLocation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ekmGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { + 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).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) + it := &LocationIterator{} + req = proto.Clone(req).(*locationpb.ListLocationsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { + resp := &locationpb.ListLocationsResponse{} + if pageToken != "" { + req.PageToken = pageToken + } + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else if pageSize != 0 { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.locationsClient.ListLocations(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetLocations(), 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 +} + func (c *ekmGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))) @@ -516,3 +598,50 @@ func (it *EkmConnectionIterator) takeBuf() interface{} { it.items = nil return b } + +// LocationIterator manages a stream of *locationpb.Location. +type LocationIterator struct { + items []*locationpb.Location + 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 []*locationpb.Location, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *LocationIterator) 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 *LocationIterator) Next() (*locationpb.Location, error) { + var item *locationpb.Location + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *LocationIterator) bufLen() int { + return len(it.items) +} + +func (it *LocationIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/kms/apiv1/ekm_client_example_test.go b/kms/apiv1/ekm_client_example_test.go index 06525b9f48aa..f9cf71fad3b9 100644 --- a/kms/apiv1/ekm_client_example_test.go +++ b/kms/apiv1/ekm_client_example_test.go @@ -22,6 +22,7 @@ import ( kms "cloud.google.com/go/kms/apiv1" "google.golang.org/api/iterator" kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" iampb "google.golang.org/genproto/googleapis/iam/v1" ) @@ -148,6 +149,62 @@ func ExampleEkmClient_UpdateEkmConnection() { _ = resp } +func ExampleEkmClient_GetLocation() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := kms.NewEkmClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.GetLocationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. + } + resp, err := c.GetLocation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleEkmClient_ListLocations() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := kms.NewEkmClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.ListLocationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. + } + it := c.ListLocations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + func ExampleEkmClient_GetIamPolicy() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. diff --git a/kms/apiv1/gapic_metadata.json b/kms/apiv1/gapic_metadata.json index 4cec9d4be6aa..5b9024e715fa 100644 --- a/kms/apiv1/gapic_metadata.json +++ b/kms/apiv1/gapic_metadata.json @@ -25,11 +25,21 @@ "GetIamPolicy" ] }, + "GetLocation": { + "methods": [ + "GetLocation" + ] + }, "ListEkmConnections": { "methods": [ "ListEkmConnections" ] }, + "ListLocations": { + "methods": [ + "ListLocations" + ] + }, "SetIamPolicy": { "methods": [ "SetIamPolicy" @@ -129,6 +139,11 @@ "GetKeyRing" ] }, + "GetLocation": { + "methods": [ + "GetLocation" + ] + }, "GetPublicKey": { "methods": [ "GetPublicKey" @@ -159,6 +174,11 @@ "ListKeyRings" ] }, + "ListLocations": { + "methods": [ + "ListLocations" + ] + }, "MacSign": { "methods": [ "MacSign" diff --git a/kms/apiv1/key_management_client.go b/kms/apiv1/key_management_client.go index 2903f6993443..9d41fba31114 100644 --- a/kms/apiv1/key_management_client.go +++ b/kms/apiv1/key_management_client.go @@ -29,6 +29,7 @@ import ( "google.golang.org/api/option/internaloption" gtransport "google.golang.org/api/transport/grpc" kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" iampb "google.golang.org/genproto/googleapis/iam/v1" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -66,6 +67,8 @@ type KeyManagementCallOptions struct { MacSign []gax.CallOption MacVerify []gax.CallOption GenerateRandomBytes []gax.CallOption + GetLocation []gax.CallOption + ListLocations []gax.CallOption GetIamPolicy []gax.CallOption SetIamPolicy []gax.CallOption TestIamPermissions []gax.CallOption @@ -375,6 +378,8 @@ func defaultKeyManagementCallOptions() *KeyManagementCallOptions { }) }), }, + GetLocation: []gax.CallOption{}, + ListLocations: []gax.CallOption{}, GetIamPolicy: []gax.CallOption{}, SetIamPolicy: []gax.CallOption{}, TestIamPermissions: []gax.CallOption{}, @@ -412,6 +417,8 @@ type internalKeyManagementClient interface { MacSign(context.Context, *kmspb.MacSignRequest, ...gax.CallOption) (*kmspb.MacSignResponse, error) MacVerify(context.Context, *kmspb.MacVerifyRequest, ...gax.CallOption) (*kmspb.MacVerifyResponse, error) GenerateRandomBytes(context.Context, *kmspb.GenerateRandomBytesRequest, ...gax.CallOption) (*kmspb.GenerateRandomBytesResponse, error) + GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) + ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) @@ -690,6 +697,16 @@ func (c *KeyManagementClient) GenerateRandomBytes(ctx context.Context, req *kmsp return c.internalClient.GenerateRandomBytes(ctx, req, opts...) } +// GetLocation gets information about a location. +func (c *KeyManagementClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { + return c.internalClient.GetLocation(ctx, req, opts...) +} + +// ListLocations lists information about the supported locations for this service. +func (c *KeyManagementClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { + return c.internalClient.ListLocations(ctx, req, opts...) +} + // GetIamPolicy gets the access control policy for a resource. Returns an empty policy // if the resource exists and does not have a policy set. func (c *KeyManagementClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { @@ -734,6 +751,8 @@ type keyManagementGRPCClient struct { iamPolicyClient iampb.IAMPolicyClient + locationsClient locationpb.LocationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -783,6 +802,7 @@ func NewKeyManagementClient(ctx context.Context, opts ...option.ClientOption) (* keyManagementClient: kmspb.NewKeyManagementServiceClient(connPool), CallOptions: &client.CallOptions, iamPolicyClient: iampb.NewIAMPolicyClient(connPool), + locationsClient: locationpb.NewLocationsClient(connPool), } c.setGoogleClientInfo() @@ -1478,6 +1498,68 @@ func (c *keyManagementGRPCClient) GenerateRandomBytes(ctx context.Context, req * return resp, nil } +func (c *keyManagementGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { + 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).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) + var resp *locationpb.Location + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.locationsClient.GetLocation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *keyManagementGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { + 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).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) + it := &LocationIterator{} + req = proto.Clone(req).(*locationpb.ListLocationsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { + resp := &locationpb.ListLocationsResponse{} + if pageToken != "" { + req.PageToken = pageToken + } + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else if pageSize != 0 { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.locationsClient.ListLocations(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetLocations(), 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 +} + func (c *keyManagementGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))) diff --git a/kms/apiv1/key_management_client_example_test.go b/kms/apiv1/key_management_client_example_test.go index d0cb2c2f0405..04ae22bc64f4 100644 --- a/kms/apiv1/key_management_client_example_test.go +++ b/kms/apiv1/key_management_client_example_test.go @@ -22,6 +22,7 @@ import ( kms "cloud.google.com/go/kms/apiv1" "google.golang.org/api/iterator" kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" iampb "google.golang.org/genproto/googleapis/iam/v1" ) @@ -716,6 +717,62 @@ func ExampleKeyManagementClient_GenerateRandomBytes() { _ = resp } +func ExampleKeyManagementClient_GetLocation() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := kms.NewKeyManagementClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.GetLocationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. + } + resp, err := c.GetLocation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleKeyManagementClient_ListLocations() { + ctx := context.Background() + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in: + // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options + c, err := kms.NewKeyManagementClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.ListLocationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. + } + it := c.ListLocations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + func ExampleKeyManagementClient_GetIamPolicy() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only.