From 9e41088bb395fbae0e757738277d5c95fa2749c8 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 11 Oct 2021 09:04:11 -0700 Subject: [PATCH] chore(all): auto-regenerate gapics (#4966) 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/695 Changes: feat(monitoring/apiv3): add CreateServiceTimeSeries RPC PiperOrigin-RevId: 401594069 Source-Link: https://github.com/googleapis/googleapis/commit/3b9c98eda3bded7bb01e2f5f5c7d20f4a5d3e121 --- dialogflow/cx/apiv3/agents_client.go | 11 + dialogflow/cx/apiv3/deployments_client.go | 329 ++++++++++++++++++ .../apiv3/deployments_client_example_test.go | 83 +++++ dialogflow/cx/apiv3/doc.go | 2 +- dialogflow/cx/apiv3/environments_client.go | 151 ++++++++ .../apiv3/environments_client_example_test.go | 25 ++ dialogflow/cx/apiv3/flows_client.go | 28 ++ dialogflow/cx/apiv3/gapic_metadata.json | 24 ++ dialogflow/cx/apiv3/test_cases_client.go | 25 ++ dialogflow/cx/apiv3/versions_client.go | 18 + dialogflow/go.mod | 2 +- dialogflow/go.sum | 4 +- go.mod | 2 +- go.sum | 4 +- .../DeploymentsClient/GetDeployment/main.go | 48 +++ .../DeploymentsClient/ListDeployments/main.go | 55 +++ .../EnvironmentsClient/DeployFlow/main.go | 53 +++ internal/generated/snippets/go.mod | 2 +- internal/generated/snippets/go.sum | 4 +- .../CreateServiceTimeSeries/main.go | 46 +++ internal/godocfx/go.sum | 4 +- monitoring/apiv3/v2/doc.go | 2 +- monitoring/apiv3/v2/gapic_metadata.json | 5 + monitoring/apiv3/v2/metric_client.go | 32 +- .../apiv3/v2/metric_client_example_test.go | 18 + monitoring/go.mod | 2 +- monitoring/go.sum | 4 +- 27 files changed, 966 insertions(+), 17 deletions(-) create mode 100644 dialogflow/cx/apiv3/deployments_client.go create mode 100644 dialogflow/cx/apiv3/deployments_client_example_test.go create mode 100644 internal/generated/snippets/dialogflow/cx/apiv3/DeploymentsClient/GetDeployment/main.go create mode 100644 internal/generated/snippets/dialogflow/cx/apiv3/DeploymentsClient/ListDeployments/main.go create mode 100644 internal/generated/snippets/dialogflow/cx/apiv3/EnvironmentsClient/DeployFlow/main.go create mode 100644 internal/generated/snippets/monitoring/apiv3/v2/MetricClient/CreateServiceTimeSeries/main.go diff --git a/dialogflow/cx/apiv3/agents_client.go b/dialogflow/cx/apiv3/agents_client.go index 7141e01ee34..3b69e932dfb 100644 --- a/dialogflow/cx/apiv3/agents_client.go +++ b/dialogflow/cx/apiv3/agents_client.go @@ -262,6 +262,7 @@ func (c *AgentsClient) DeleteAgent(ctx context.Context, req *cxpb.DeleteAgentReq } // ExportAgent exports the specified agent to a binary file. +// // This method is a long-running // operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). // The returned Operation type has the following method-specific fields: @@ -285,6 +286,16 @@ func (c *AgentsClient) ExportAgentOperation(name string) *ExportAgentOperation { // Replaces the current agent with a new one. Note that all existing resources // in agent (e.g. intents, entity types, flows) will be removed. // +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: An empty Struct +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) +// +// response: An Empty +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) +// // Note: You should always train flows prior to sending them queries. See the // training // documentation (at https://cloud.google.com/dialogflow/cx/docs/concept/training). diff --git a/dialogflow/cx/apiv3/deployments_client.go b/dialogflow/cx/apiv3/deployments_client.go new file mode 100644 index 00000000000..d4f4730ee54 --- /dev/null +++ b/dialogflow/cx/apiv3/deployments_client.go @@ -0,0 +1,329 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package cx + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + 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" + cxpb "google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/protobuf/proto" +) + +var newDeploymentsClientHook clientHook + +// DeploymentsCallOptions contains the retry settings for each method of DeploymentsClient. +type DeploymentsCallOptions struct { + ListDeployments []gax.CallOption + GetDeployment []gax.CallOption +} + +func defaultDeploymentsGRPCClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("dialogflow.googleapis.com:443"), + internaloption.WithDefaultMTLSEndpoint("dialogflow.mtls.googleapis.com:443"), + internaloption.WithDefaultAudience("https://dialogflow.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + internaloption.EnableJwtWithScope(), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultDeploymentsCallOptions() *DeploymentsCallOptions { + return &DeploymentsCallOptions{ + ListDeployments: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetDeployment: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + } +} + +// internalDeploymentsClient is an interface that defines the methods availaible from Dialogflow API. +type internalDeploymentsClient interface { + Close() error + setGoogleClientInfo(...string) + Connection() *grpc.ClientConn + ListDeployments(context.Context, *cxpb.ListDeploymentsRequest, ...gax.CallOption) *DeploymentIterator + GetDeployment(context.Context, *cxpb.GetDeploymentRequest, ...gax.CallOption) (*cxpb.Deployment, error) +} + +// DeploymentsClient is a client for interacting with Dialogflow API. +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +// +// Service for managing Deployments. +type DeploymentsClient struct { + // The internal transport-dependent client. + internalClient internalDeploymentsClient + + // The call options for this service. + CallOptions *DeploymentsCallOptions +} + +// 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 *DeploymentsClient) 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 *DeploymentsClient) setGoogleClientInfo(keyval ...string) { + c.internalClient.setGoogleClientInfo(keyval...) +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *DeploymentsClient) Connection() *grpc.ClientConn { + return c.internalClient.Connection() +} + +// ListDeployments returns the list of all deployments in the specified Environment. +func (c *DeploymentsClient) ListDeployments(ctx context.Context, req *cxpb.ListDeploymentsRequest, opts ...gax.CallOption) *DeploymentIterator { + return c.internalClient.ListDeployments(ctx, req, opts...) +} + +// GetDeployment retrieves the specified Deployment. +func (c *DeploymentsClient) GetDeployment(ctx context.Context, req *cxpb.GetDeploymentRequest, opts ...gax.CallOption) (*cxpb.Deployment, error) { + return c.internalClient.GetDeployment(ctx, req, opts...) +} + +// deploymentsGRPCClient is a client for interacting with Dialogflow API over gRPC transport. +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type deploymentsGRPCClient 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 DeploymentsClient + CallOptions **DeploymentsCallOptions + + // The gRPC API client. + deploymentsClient cxpb.DeploymentsClient + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewDeploymentsClient creates a new deployments client based on gRPC. +// The returned client must be Closed when it is done being used to clean up its underlying connections. +// +// Service for managing Deployments. +func NewDeploymentsClient(ctx context.Context, opts ...option.ClientOption) (*DeploymentsClient, error) { + clientOpts := defaultDeploymentsGRPCClientOptions() + if newDeploymentsClientHook != nil { + hookOpts, err := newDeploymentsClientHook(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 := DeploymentsClient{CallOptions: defaultDeploymentsCallOptions()} + + c := &deploymentsGRPCClient{ + connPool: connPool, + disableDeadlines: disableDeadlines, + deploymentsClient: cxpb.NewDeploymentsClient(connPool), + CallOptions: &client.CallOptions, + } + c.setGoogleClientInfo() + + client.internalClient = c + + return &client, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *deploymentsGRPCClient) 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 *deploymentsGRPCClient) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *deploymentsGRPCClient) Close() error { + return c.connPool.Close() +} + +func (c *deploymentsGRPCClient) ListDeployments(ctx context.Context, req *cxpb.ListDeploymentsRequest, opts ...gax.CallOption) *DeploymentIterator { + 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).ListDeployments[0:len((*c.CallOptions).ListDeployments):len((*c.CallOptions).ListDeployments)], opts...) + it := &DeploymentIterator{} + req = proto.Clone(req).(*cxpb.ListDeploymentsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*cxpb.Deployment, string, error) { + resp := &cxpb.ListDeploymentsResponse{} + 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.deploymentsClient.ListDeployments(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetDeployments(), 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 *deploymentsGRPCClient) GetDeployment(ctx context.Context, req *cxpb.GetDeploymentRequest, opts ...gax.CallOption) (*cxpb.Deployment, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).GetDeployment[0:len((*c.CallOptions).GetDeployment):len((*c.CallOptions).GetDeployment)], opts...) + var resp *cxpb.Deployment + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.deploymentsClient.GetDeployment(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// DeploymentIterator manages a stream of *cxpb.Deployment. +type DeploymentIterator struct { + items []*cxpb.Deployment + 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 []*cxpb.Deployment, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *DeploymentIterator) 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 *DeploymentIterator) Next() (*cxpb.Deployment, error) { + var item *cxpb.Deployment + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *DeploymentIterator) bufLen() int { + return len(it.items) +} + +func (it *DeploymentIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/dialogflow/cx/apiv3/deployments_client_example_test.go b/dialogflow/cx/apiv3/deployments_client_example_test.go new file mode 100644 index 00000000000..3f3ec294cf2 --- /dev/null +++ b/dialogflow/cx/apiv3/deployments_client_example_test.go @@ -0,0 +1,83 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package cx_test + +import ( + "context" + + cx "cloud.google.com/go/dialogflow/cx/apiv3" + "google.golang.org/api/iterator" + cxpb "google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3" +) + +func ExampleNewDeploymentsClient() { + ctx := context.Background() + c, err := cx.NewDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + // TODO: Use client. + _ = c +} + +func ExampleDeploymentsClient_ListDeployments() { + ctx := context.Background() + c, err := cx.NewDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &cxpb.ListDeploymentsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3#ListDeploymentsRequest. + } + it := c.ListDeployments(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleDeploymentsClient_GetDeployment() { + ctx := context.Background() + c, err := cx.NewDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &cxpb.GetDeploymentRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3#GetDeploymentRequest. + } + resp, err := c.GetDeployment(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} diff --git a/dialogflow/cx/apiv3/doc.go b/dialogflow/cx/apiv3/doc.go index a3b3e42edfa..c0619e9755c 100644 --- a/dialogflow/cx/apiv3/doc.go +++ b/dialogflow/cx/apiv3/doc.go @@ -91,7 +91,7 @@ import ( type clientHookParams struct{} type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) -const versionClient = "20210921" +const versionClient = "20211008" func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { out, _ := metadata.FromOutgoingContext(ctx) diff --git a/dialogflow/cx/apiv3/environments_client.go b/dialogflow/cx/apiv3/environments_client.go index 8fb5511adf1..35ffc8f8686 100644 --- a/dialogflow/cx/apiv3/environments_client.go +++ b/dialogflow/cx/apiv3/environments_client.go @@ -51,6 +51,7 @@ type EnvironmentsCallOptions struct { LookupEnvironmentHistory []gax.CallOption RunContinuousTest []gax.CallOption ListContinuousTestResults []gax.CallOption + DeployFlow []gax.CallOption } func defaultEnvironmentsGRPCClientOptions() []option.ClientOption { @@ -156,6 +157,17 @@ func defaultEnvironmentsCallOptions() *EnvironmentsCallOptions { }) }), }, + DeployFlow: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, } } @@ -175,6 +187,8 @@ type internalEnvironmentsClient interface { RunContinuousTest(context.Context, *cxpb.RunContinuousTestRequest, ...gax.CallOption) (*RunContinuousTestOperation, error) RunContinuousTestOperation(name string) *RunContinuousTestOperation ListContinuousTestResults(context.Context, *cxpb.ListContinuousTestResultsRequest, ...gax.CallOption) *ContinuousTestResultIterator + DeployFlow(context.Context, *cxpb.DeployFlowRequest, ...gax.CallOption) (*DeployFlowOperation, error) + DeployFlowOperation(name string) *DeployFlowOperation } // EnvironmentsClient is a client for interacting with Dialogflow API. @@ -227,6 +241,15 @@ func (c *EnvironmentsClient) GetEnvironment(ctx context.Context, req *cxpb.GetEn } // CreateEnvironment creates an Environment in the specified Agent. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: An empty Struct +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) +// +// response: Environment func (c *EnvironmentsClient) CreateEnvironment(ctx context.Context, req *cxpb.CreateEnvironmentRequest, opts ...gax.CallOption) (*CreateEnvironmentOperation, error) { return c.internalClient.CreateEnvironment(ctx, req, opts...) } @@ -238,6 +261,15 @@ func (c *EnvironmentsClient) CreateEnvironmentOperation(name string) *CreateEnvi } // UpdateEnvironment updates the specified Environment. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: An empty Struct +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) +// +// response: Environment func (c *EnvironmentsClient) UpdateEnvironment(ctx context.Context, req *cxpb.UpdateEnvironmentRequest, opts ...gax.CallOption) (*UpdateEnvironmentOperation, error) { return c.internalClient.UpdateEnvironment(ctx, req, opts...) } @@ -259,6 +291,14 @@ func (c *EnvironmentsClient) LookupEnvironmentHistory(ctx context.Context, req * } // RunContinuousTest kicks off a continuous test under the specified Environment. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: RunContinuousTestMetadata +// +// response: RunContinuousTestResponse func (c *EnvironmentsClient) RunContinuousTest(ctx context.Context, req *cxpb.RunContinuousTestRequest, opts ...gax.CallOption) (*RunContinuousTestOperation, error) { return c.internalClient.RunContinuousTest(ctx, req, opts...) } @@ -274,6 +314,25 @@ func (c *EnvironmentsClient) ListContinuousTestResults(ctx context.Context, req return c.internalClient.ListContinuousTestResults(ctx, req, opts...) } +// DeployFlow deploys a flow to the specified Environment. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: DeployFlowMetadata +// +// response: DeployFlowResponse +func (c *EnvironmentsClient) DeployFlow(ctx context.Context, req *cxpb.DeployFlowRequest, opts ...gax.CallOption) (*DeployFlowOperation, error) { + return c.internalClient.DeployFlow(ctx, req, opts...) +} + +// DeployFlowOperation returns a new DeployFlowOperation from a given name. +// The name must be that of a previously created DeployFlowOperation, possibly from a different process. +func (c *EnvironmentsClient) DeployFlowOperation(name string) *DeployFlowOperation { + return c.internalClient.DeployFlowOperation(name) +} + // environmentsGRPCClient is a client for interacting with Dialogflow API over gRPC transport. // // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. @@ -609,6 +668,29 @@ func (c *environmentsGRPCClient) ListContinuousTestResults(ctx context.Context, return it } +func (c *environmentsGRPCClient) DeployFlow(ctx context.Context, req *cxpb.DeployFlowRequest, opts ...gax.CallOption) (*DeployFlowOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "environment", url.QueryEscape(req.GetEnvironment()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).DeployFlow[0:len((*c.CallOptions).DeployFlow):len((*c.CallOptions).DeployFlow)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.environmentsClient.DeployFlow(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeployFlowOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + // CreateEnvironmentOperation manages a long-running operation from CreateEnvironment. type CreateEnvironmentOperation struct { lro *longrunning.Operation @@ -678,6 +760,75 @@ func (op *CreateEnvironmentOperation) Name() string { return op.lro.Name() } +// DeployFlowOperation manages a long-running operation from DeployFlow. +type DeployFlowOperation struct { + lro *longrunning.Operation +} + +// DeployFlowOperation returns a new DeployFlowOperation from a given name. +// The name must be that of a previously created DeployFlowOperation, possibly from a different process. +func (c *environmentsGRPCClient) DeployFlowOperation(name string) *DeployFlowOperation { + return &DeployFlowOperation{ + 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 *DeployFlowOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*cxpb.DeployFlowResponse, error) { + var resp cxpb.DeployFlowResponse + 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 *DeployFlowOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*cxpb.DeployFlowResponse, error) { + var resp cxpb.DeployFlowResponse + 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 *DeployFlowOperation) Metadata() (*cxpb.DeployFlowMetadata, error) { + var meta cxpb.DeployFlowMetadata + 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 *DeployFlowOperation) 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 *DeployFlowOperation) Name() string { + return op.lro.Name() +} + // RunContinuousTestOperation manages a long-running operation from RunContinuousTest. type RunContinuousTestOperation struct { lro *longrunning.Operation diff --git a/dialogflow/cx/apiv3/environments_client_example_test.go b/dialogflow/cx/apiv3/environments_client_example_test.go index 3f9d6400dc0..cedfe182009 100644 --- a/dialogflow/cx/apiv3/environments_client_example_test.go +++ b/dialogflow/cx/apiv3/environments_client_example_test.go @@ -226,3 +226,28 @@ func ExampleEnvironmentsClient_ListContinuousTestResults() { _ = resp } } + +func ExampleEnvironmentsClient_DeployFlow() { + ctx := context.Background() + c, err := cx.NewEnvironmentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &cxpb.DeployFlowRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3#DeployFlowRequest. + } + op, err := c.DeployFlow(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} diff --git a/dialogflow/cx/apiv3/flows_client.go b/dialogflow/cx/apiv3/flows_client.go index c9a6c660673..e34eb675ca1 100644 --- a/dialogflow/cx/apiv3/flows_client.go +++ b/dialogflow/cx/apiv3/flows_client.go @@ -278,6 +278,16 @@ func (c *FlowsClient) UpdateFlow(ctx context.Context, req *cxpb.UpdateFlowReques // TrainFlow trains the specified flow. Note that only the flow in ‘draft’ environment // is trained. // +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: An empty Struct +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) +// +// response: An Empty +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) +// // Note: You should always train a flow prior to sending it queries. See the // training // documentation (at https://cloud.google.com/dialogflow/cx/docs/concept/training). @@ -306,6 +316,15 @@ func (c *FlowsClient) GetFlowValidationResult(ctx context.Context, req *cxpb.Get // ImportFlow imports the specified flow to the specified agent from a binary file. // +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: An empty Struct +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) +// +// response: ImportFlowResponse +// // Note: You should always train a flow prior to sending it queries. See the // training // documentation (at https://cloud.google.com/dialogflow/cx/docs/concept/training). @@ -321,6 +340,15 @@ func (c *FlowsClient) ImportFlowOperation(name string) *ImportFlowOperation { // ExportFlow exports the specified flow to a binary file. // +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: An empty Struct +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) +// +// response: ExportFlowResponse +// // Note that resources (e.g. intents, entities, webhooks) that the flow // references will also be exported. func (c *FlowsClient) ExportFlow(ctx context.Context, req *cxpb.ExportFlowRequest, opts ...gax.CallOption) (*ExportFlowOperation, error) { diff --git a/dialogflow/cx/apiv3/gapic_metadata.json b/dialogflow/cx/apiv3/gapic_metadata.json index 409bc550939..e9acf025930 100644 --- a/dialogflow/cx/apiv3/gapic_metadata.json +++ b/dialogflow/cx/apiv3/gapic_metadata.json @@ -59,6 +59,25 @@ } } }, + "Deployments": { + "clients": { + "grpc": { + "libraryClient": "DeploymentsClient", + "rpcs": { + "GetDeployment": { + "methods": [ + "GetDeployment" + ] + }, + "ListDeployments": { + "methods": [ + "ListDeployments" + ] + } + } + } + } + }, "EntityTypes": { "clients": { "grpc": { @@ -108,6 +127,11 @@ "DeleteEnvironment" ] }, + "DeployFlow": { + "methods": [ + "DeployFlow" + ] + }, "GetEnvironment": { "methods": [ "GetEnvironment" diff --git a/dialogflow/cx/apiv3/test_cases_client.go b/dialogflow/cx/apiv3/test_cases_client.go index 680ac2c8828..1f4653fcdfe 100644 --- a/dialogflow/cx/apiv3/test_cases_client.go +++ b/dialogflow/cx/apiv3/test_cases_client.go @@ -295,6 +295,7 @@ func (c *TestCasesClient) UpdateTestCase(ctx context.Context, req *cxpb.UpdateTe } // RunTestCase kicks off a test case run. +// // This method is a long-running // operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). // The returned Operation type has the following method-specific fields: @@ -313,6 +314,14 @@ func (c *TestCasesClient) RunTestCaseOperation(name string) *RunTestCaseOperatio } // BatchRunTestCases kicks off a batch run of test cases. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: BatchRunTestCasesMetadata +// +// response: BatchRunTestCasesResponse func (c *TestCasesClient) BatchRunTestCases(ctx context.Context, req *cxpb.BatchRunTestCasesRequest, opts ...gax.CallOption) (*BatchRunTestCasesOperation, error) { return c.internalClient.BatchRunTestCases(ctx, req, opts...) } @@ -331,6 +340,14 @@ func (c *TestCasesClient) CalculateCoverage(ctx context.Context, req *cxpb.Calcu // ImportTestCases imports the test cases from a Cloud Storage bucket or a local file. It // always creates new test cases and won’t overwite any existing ones. The // provided ID in the imported test case is neglected. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: ImportTestCasesMetadata +// +// response: ImportTestCasesResponse func (c *TestCasesClient) ImportTestCases(ctx context.Context, req *cxpb.ImportTestCasesRequest, opts ...gax.CallOption) (*ImportTestCasesOperation, error) { return c.internalClient.ImportTestCases(ctx, req, opts...) } @@ -343,6 +360,14 @@ func (c *TestCasesClient) ImportTestCasesOperation(name string) *ImportTestCases // ExportTestCases exports the test cases under the agent to a Cloud Storage bucket or a local // file. Filter can be applied to export a subset of test cases. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: ExportTestCasesMetadata +// +// response: ExportTestCasesResponse func (c *TestCasesClient) ExportTestCases(ctx context.Context, req *cxpb.ExportTestCasesRequest, opts ...gax.CallOption) (*ExportTestCasesOperation, error) { return c.internalClient.ExportTestCases(ctx, req, opts...) } diff --git a/dialogflow/cx/apiv3/versions_client.go b/dialogflow/cx/apiv3/versions_client.go index 8f6e3120fc4..9fd8c2964d3 100644 --- a/dialogflow/cx/apiv3/versions_client.go +++ b/dialogflow/cx/apiv3/versions_client.go @@ -200,6 +200,14 @@ func (c *VersionsClient) GetVersion(ctx context.Context, req *cxpb.GetVersionReq } // CreateVersion creates a Version in the specified Flow. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: CreateVersionOperationMetadata +// +// response: Version func (c *VersionsClient) CreateVersion(ctx context.Context, req *cxpb.CreateVersionRequest, opts ...gax.CallOption) (*CreateVersionOperation, error) { return c.internalClient.CreateVersion(ctx, req, opts...) } @@ -221,6 +229,16 @@ func (c *VersionsClient) DeleteVersion(ctx context.Context, req *cxpb.DeleteVers } // LoadVersion loads resources in the specified version to the draft flow. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). +// The returned Operation type has the following method-specific fields: +// +// metadata: An empty Struct +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) +// +// response: An Empty +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) func (c *VersionsClient) LoadVersion(ctx context.Context, req *cxpb.LoadVersionRequest, opts ...gax.CallOption) (*LoadVersionOperation, error) { return c.internalClient.LoadVersion(ctx, req, opts...) } diff --git a/dialogflow/go.mod b/dialogflow/go.mod index 945bada6887..7ac5d242443 100644 --- a/dialogflow/go.mod +++ b/dialogflow/go.mod @@ -7,7 +7,7 @@ require ( github.com/golang/protobuf v1.5.2 github.com/googleapis/gax-go/v2 v2.1.1 google.golang.org/api v0.58.0 - google.golang.org/genproto v0.0.0-20210930144712-2e2e1008e8a3 + google.golang.org/genproto v0.0.0-20211008145708-270636b82663 google.golang.org/grpc v1.40.0 google.golang.org/protobuf v1.27.1 ) diff --git a/dialogflow/go.sum b/dialogflow/go.sum index d250dcad66a..69b5cfaeb9c 100644 --- a/dialogflow/go.sum +++ b/dialogflow/go.sum @@ -488,8 +488,8 @@ google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEc google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210930144712-2e2e1008e8a3 h1:+F3FcO6LTrzNq5wp1Z6JtoBvnJzX6euyN70FoyMDXy4= -google.golang.org/genproto v0.0.0-20210930144712-2e2e1008e8a3/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663 h1:33YYJanAOLxgS7pGjzC1IUrFLpwN//bbgtnKYikOmQU= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/go.mod b/go.mod index 2d1c2ec3fed..c67eabcc92b 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 google.golang.org/api v0.58.0 - google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9 + google.golang.org/genproto v0.0.0-20211008145708-270636b82663 google.golang.org/grpc v1.40.0 google.golang.org/protobuf v1.27.1 ) diff --git a/go.sum b/go.sum index b5dc9194c11..e850d1b48d1 100644 --- a/go.sum +++ b/go.sum @@ -491,8 +491,8 @@ google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEc google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9 h1:eF1wcrhdz56Vugf8qNX5dD93ItkrhothojQyHXqloe0= -google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663 h1:33YYJanAOLxgS7pGjzC1IUrFLpwN//bbgtnKYikOmQU= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/internal/generated/snippets/dialogflow/cx/apiv3/DeploymentsClient/GetDeployment/main.go b/internal/generated/snippets/dialogflow/cx/apiv3/DeploymentsClient/GetDeployment/main.go new file mode 100644 index 00000000000..89a323fea36 --- /dev/null +++ b/internal/generated/snippets/dialogflow/cx/apiv3/DeploymentsClient/GetDeployment/main.go @@ -0,0 +1,48 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 dialogflow_v3_generated_Deployments_GetDeployment_sync] + +package main + +import ( + "context" + + cx "cloud.google.com/go/dialogflow/cx/apiv3" + cxpb "google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3" +) + +func main() { + ctx := context.Background() + c, err := cx.NewDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &cxpb.GetDeploymentRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3#GetDeploymentRequest. + } + resp, err := c.GetDeployment(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END dialogflow_v3_generated_Deployments_GetDeployment_sync] diff --git a/internal/generated/snippets/dialogflow/cx/apiv3/DeploymentsClient/ListDeployments/main.go b/internal/generated/snippets/dialogflow/cx/apiv3/DeploymentsClient/ListDeployments/main.go new file mode 100644 index 00000000000..073df7461d6 --- /dev/null +++ b/internal/generated/snippets/dialogflow/cx/apiv3/DeploymentsClient/ListDeployments/main.go @@ -0,0 +1,55 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 dialogflow_v3_generated_Deployments_ListDeployments_sync] + +package main + +import ( + "context" + + cx "cloud.google.com/go/dialogflow/cx/apiv3" + "google.golang.org/api/iterator" + cxpb "google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3" +) + +func main() { + ctx := context.Background() + c, err := cx.NewDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &cxpb.ListDeploymentsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3#ListDeploymentsRequest. + } + it := c.ListDeployments(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END dialogflow_v3_generated_Deployments_ListDeployments_sync] diff --git a/internal/generated/snippets/dialogflow/cx/apiv3/EnvironmentsClient/DeployFlow/main.go b/internal/generated/snippets/dialogflow/cx/apiv3/EnvironmentsClient/DeployFlow/main.go new file mode 100644 index 00000000000..12af6c01414 --- /dev/null +++ b/internal/generated/snippets/dialogflow/cx/apiv3/EnvironmentsClient/DeployFlow/main.go @@ -0,0 +1,53 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 dialogflow_v3_generated_Environments_DeployFlow_sync] + +package main + +import ( + "context" + + cx "cloud.google.com/go/dialogflow/cx/apiv3" + cxpb "google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3" +) + +func main() { + ctx := context.Background() + c, err := cx.NewEnvironmentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &cxpb.DeployFlowRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3#DeployFlowRequest. + } + op, err := c.DeployFlow(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END dialogflow_v3_generated_Environments_DeployFlow_sync] diff --git a/internal/generated/snippets/go.mod b/internal/generated/snippets/go.mod index fd7b175c849..fe841f0845f 100644 --- a/internal/generated/snippets/go.mod +++ b/internal/generated/snippets/go.mod @@ -124,7 +124,7 @@ require ( cloud.google.com/go/websecurityscanner v0.1.0 cloud.google.com/go/workflows v0.1.0 google.golang.org/api v0.58.0 - google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9 + google.golang.org/genproto v0.0.0-20211008145708-270636b82663 ) replace cloud.google.com/go/storagetransfer => ../../../storagetransfer diff --git a/internal/generated/snippets/go.sum b/internal/generated/snippets/go.sum index bea8c1b90ac..e99c289e7d6 100644 --- a/internal/generated/snippets/go.sum +++ b/internal/generated/snippets/go.sum @@ -160,10 +160,10 @@ google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEc google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20210927142257-433400c27d05/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20210928142010-c7af6a1a74c9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20210930144712-2e2e1008e8a3/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9 h1:eF1wcrhdz56Vugf8qNX5dD93ItkrhothojQyHXqloe0= google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663 h1:33YYJanAOLxgS7pGjzC1IUrFLpwN//bbgtnKYikOmQU= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= diff --git a/internal/generated/snippets/monitoring/apiv3/v2/MetricClient/CreateServiceTimeSeries/main.go b/internal/generated/snippets/monitoring/apiv3/v2/MetricClient/CreateServiceTimeSeries/main.go new file mode 100644 index 00000000000..1e23822f108 --- /dev/null +++ b/internal/generated/snippets/monitoring/apiv3/v2/MetricClient/CreateServiceTimeSeries/main.go @@ -0,0 +1,46 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 monitoring_v3_generated_MetricService_CreateServiceTimeSeries_sync] + +package main + +import ( + "context" + + monitoring "cloud.google.com/go/monitoring/apiv3/v2" + monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" +) + +func main() { + ctx := context.Background() + c, err := monitoring.NewMetricClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &monitoringpb.CreateTimeSeriesRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/monitoring/v3#CreateTimeSeriesRequest. + } + err = c.CreateServiceTimeSeries(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +// [END monitoring_v3_generated_MetricService_CreateServiceTimeSeries_sync] diff --git a/internal/godocfx/go.sum b/internal/godocfx/go.sum index b412794c980..6b4011ac83d 100644 --- a/internal/godocfx/go.sum +++ b/internal/godocfx/go.sum @@ -309,8 +309,8 @@ google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEc google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9 h1:eF1wcrhdz56Vugf8qNX5dD93ItkrhothojQyHXqloe0= -google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663 h1:33YYJanAOLxgS7pGjzC1IUrFLpwN//bbgtnKYikOmQU= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/monitoring/apiv3/v2/doc.go b/monitoring/apiv3/v2/doc.go index 1a7fc1050ef..f483eaffc38 100644 --- a/monitoring/apiv3/v2/doc.go +++ b/monitoring/apiv3/v2/doc.go @@ -95,7 +95,7 @@ import ( type clientHookParams struct{} type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) -const versionClient = "20210921" +const versionClient = "20211008" func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { out, _ := metadata.FromOutgoingContext(ctx) diff --git a/monitoring/apiv3/v2/gapic_metadata.json b/monitoring/apiv3/v2/gapic_metadata.json index c522dbe1359..ad03f6ffbcf 100644 --- a/monitoring/apiv3/v2/gapic_metadata.json +++ b/monitoring/apiv3/v2/gapic_metadata.json @@ -88,6 +88,11 @@ "CreateMetricDescriptor" ] }, + "CreateServiceTimeSeries": { + "methods": [ + "CreateServiceTimeSeries" + ] + }, "CreateTimeSeries": { "methods": [ "CreateTimeSeries" diff --git a/monitoring/apiv3/v2/metric_client.go b/monitoring/apiv3/v2/metric_client.go index 7acc31c9a1a..756456e7b91 100644 --- a/monitoring/apiv3/v2/metric_client.go +++ b/monitoring/apiv3/v2/metric_client.go @@ -49,6 +49,7 @@ type MetricCallOptions struct { DeleteMetricDescriptor []gax.CallOption ListTimeSeries []gax.CallOption CreateTimeSeries []gax.CallOption + CreateServiceTimeSeries []gax.CallOption } func defaultMetricGRPCClientOptions() []option.ClientOption { @@ -133,7 +134,8 @@ func defaultMetricCallOptions() *MetricCallOptions { }) }), }, - CreateTimeSeries: []gax.CallOption{}, + CreateTimeSeries: []gax.CallOption{}, + CreateServiceTimeSeries: []gax.CallOption{}, } } @@ -150,6 +152,7 @@ type internalMetricClient interface { DeleteMetricDescriptor(context.Context, *monitoringpb.DeleteMetricDescriptorRequest, ...gax.CallOption) error ListTimeSeries(context.Context, *monitoringpb.ListTimeSeriesRequest, ...gax.CallOption) *TimeSeriesIterator CreateTimeSeries(context.Context, *monitoringpb.CreateTimeSeriesRequest, ...gax.CallOption) error + CreateServiceTimeSeries(context.Context, *monitoringpb.CreateTimeSeriesRequest, ...gax.CallOption) error } // MetricClient is a client for interacting with Cloud Monitoring API. @@ -208,6 +211,8 @@ func (c *MetricClient) GetMetricDescriptor(ctx context.Context, req *monitoringp } // CreateMetricDescriptor creates a new metric descriptor. +// The creation is executed asynchronously and callers may check the returned +// operation to track its progress. // User-created metric descriptors define // custom metrics (at https://cloud.google.com/monitoring/custom-metrics). func (c *MetricClient) CreateMetricDescriptor(ctx context.Context, req *monitoringpb.CreateMetricDescriptorRequest, opts ...gax.CallOption) (*metricpb.MetricDescriptor, error) { @@ -234,6 +239,19 @@ func (c *MetricClient) CreateTimeSeries(ctx context.Context, req *monitoringpb.C return c.internalClient.CreateTimeSeries(ctx, req, opts...) } +// CreateServiceTimeSeries creates or adds data to one or more service time series. A service time +// series is a time series for a metric from a Google Cloud service. The +// response is empty if all time series in the request were written. If any +// time series could not be written, a corresponding failure message is +// included in the error response. This endpoint rejects writes to +// user-defined metrics. +// This method is only for use by Google Cloud services. Use +// projects.timeSeries.create +// instead. +func (c *MetricClient) CreateServiceTimeSeries(ctx context.Context, req *monitoringpb.CreateTimeSeriesRequest, opts ...gax.CallOption) error { + return c.internalClient.CreateServiceTimeSeries(ctx, req, opts...) +} + // metricGRPCClient is a client for interacting with Cloud Monitoring API over gRPC transport. // // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. @@ -544,6 +562,18 @@ func (c *metricGRPCClient) CreateTimeSeries(ctx context.Context, req *monitoring return err } +func (c *metricGRPCClient) CreateServiceTimeSeries(ctx context.Context, req *monitoringpb.CreateTimeSeriesRequest, 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).CreateServiceTimeSeries[0:len((*c.CallOptions).CreateServiceTimeSeries):len((*c.CallOptions).CreateServiceTimeSeries)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.metricClient.CreateServiceTimeSeries(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + // MetricDescriptorIterator manages a stream of *metricpb.MetricDescriptor. type MetricDescriptorIterator struct { items []*metricpb.MetricDescriptor diff --git a/monitoring/apiv3/v2/metric_client_example_test.go b/monitoring/apiv3/v2/metric_client_example_test.go index 0d4ab01ee8a..e9dd2740045 100644 --- a/monitoring/apiv3/v2/metric_client_example_test.go +++ b/monitoring/apiv3/v2/metric_client_example_test.go @@ -209,3 +209,21 @@ func ExampleMetricClient_CreateTimeSeries() { // TODO: Handle error. } } + +func ExampleMetricClient_CreateServiceTimeSeries() { + ctx := context.Background() + c, err := monitoring.NewMetricClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &monitoringpb.CreateTimeSeriesRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/monitoring/v3#CreateTimeSeriesRequest. + } + err = c.CreateServiceTimeSeries(ctx, req) + if err != nil { + // TODO: Handle error. + } +} diff --git a/monitoring/go.mod b/monitoring/go.mod index a89659a5525..5f76508dff0 100644 --- a/monitoring/go.mod +++ b/monitoring/go.mod @@ -7,7 +7,7 @@ require ( github.com/golang/protobuf v1.5.2 github.com/googleapis/gax-go/v2 v2.1.1 google.golang.org/api v0.58.0 - google.golang.org/genproto v0.0.0-20210928142010-c7af6a1a74c9 + google.golang.org/genproto v0.0.0-20211008145708-270636b82663 google.golang.org/grpc v1.40.0 google.golang.org/protobuf v1.27.1 ) diff --git a/monitoring/go.sum b/monitoring/go.sum index 66dde77ba42..69b5cfaeb9c 100644 --- a/monitoring/go.sum +++ b/monitoring/go.sum @@ -488,8 +488,8 @@ google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEc google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210928142010-c7af6a1a74c9 h1:XTH066D35LyHehRwlYhoK3qA+Hcgvg5xREG4kFQEW1Y= -google.golang.org/genproto v0.0.0-20210928142010-c7af6a1a74c9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663 h1:33YYJanAOLxgS7pGjzC1IUrFLpwN//bbgtnKYikOmQU= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=