diff --git a/compute/go.sum b/compute/go.sum index 901850703fe8..27f0f6f80aef 100644 --- a/compute/go.sum +++ b/compute/go.sum @@ -523,8 +523,6 @@ google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf h1:SVYXkUz2yZS9FWb2Gm8ivSlbNQzL2Z/NpPKE3RG2jWk= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220228155957-1da8797a5878 h1:gERY0VtsF9UyyyCsPSjRk9/RWlcKSa/Gw/aenR/5z48= google.golang.org/genproto v0.0.0-20220228155957-1da8797a5878/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= diff --git a/dialogflow/apiv2/conversation_datasets_client.go b/dialogflow/apiv2/conversation_datasets_client.go new file mode 100644 index 000000000000..3f48f8764d91 --- /dev/null +++ b/dialogflow/apiv2/conversation_datasets_client.go @@ -0,0 +1,731 @@ +// 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 dialogflow + +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" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/protobuf/proto" +) + +var newConversationDatasetsClientHook clientHook + +// ConversationDatasetsCallOptions contains the retry settings for each method of ConversationDatasetsClient. +type ConversationDatasetsCallOptions struct { + CreateConversationDataset []gax.CallOption + GetConversationDataset []gax.CallOption + ListConversationDatasets []gax.CallOption + DeleteConversationDataset []gax.CallOption + ImportConversationData []gax.CallOption +} + +func defaultConversationDatasetsGRPCClientOptions() []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.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultConversationDatasetsCallOptions() *ConversationDatasetsCallOptions { + return &ConversationDatasetsCallOptions{ + CreateConversationDataset: []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, + }) + }), + }, + GetConversationDataset: []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, + }) + }), + }, + ListConversationDatasets: []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, + }) + }), + }, + DeleteConversationDataset: []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, + }) + }), + }, + ImportConversationData: []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, + }) + }), + }, + } +} + +// internalConversationDatasetsClient is an interface that defines the methods availaible from Dialogflow API. +type internalConversationDatasetsClient interface { + Close() error + setGoogleClientInfo(...string) + Connection() *grpc.ClientConn + CreateConversationDataset(context.Context, *dialogflowpb.CreateConversationDatasetRequest, ...gax.CallOption) (*CreateConversationDatasetOperation, error) + CreateConversationDatasetOperation(name string) *CreateConversationDatasetOperation + GetConversationDataset(context.Context, *dialogflowpb.GetConversationDatasetRequest, ...gax.CallOption) (*dialogflowpb.ConversationDataset, error) + ListConversationDatasets(context.Context, *dialogflowpb.ListConversationDatasetsRequest, ...gax.CallOption) *ConversationDatasetIterator + DeleteConversationDataset(context.Context, *dialogflowpb.DeleteConversationDatasetRequest, ...gax.CallOption) (*DeleteConversationDatasetOperation, error) + DeleteConversationDatasetOperation(name string) *DeleteConversationDatasetOperation + ImportConversationData(context.Context, *dialogflowpb.ImportConversationDataRequest, ...gax.CallOption) (*ImportConversationDataOperation, error) + ImportConversationDataOperation(name string) *ImportConversationDataOperation +} + +// ConversationDatasetsClient 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. +// +// Conversation datasets. +// +// Conversation datasets contain raw conversation files and their +// customizable metadata that can be used for model training. +type ConversationDatasetsClient struct { + // The internal transport-dependent client. + internalClient internalConversationDatasetsClient + + // The call options for this service. + CallOptions *ConversationDatasetsCallOptions + + // 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 *ConversationDatasetsClient) 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 *ConversationDatasetsClient) setGoogleClientInfo(keyval ...string) { + c.internalClient.setGoogleClientInfo(keyval...) +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *ConversationDatasetsClient) Connection() *grpc.ClientConn { + return c.internalClient.Connection() +} + +// CreateConversationDataset creates a new conversation dataset. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). +// The returned Operation type has the following method-specific fields: +// +// metadata: CreateConversationDatasetOperationMetadata +// +// response: ConversationDataset +func (c *ConversationDatasetsClient) CreateConversationDataset(ctx context.Context, req *dialogflowpb.CreateConversationDatasetRequest, opts ...gax.CallOption) (*CreateConversationDatasetOperation, error) { + return c.internalClient.CreateConversationDataset(ctx, req, opts...) +} + +// CreateConversationDatasetOperation returns a new CreateConversationDatasetOperation from a given name. +// The name must be that of a previously created CreateConversationDatasetOperation, possibly from a different process. +func (c *ConversationDatasetsClient) CreateConversationDatasetOperation(name string) *CreateConversationDatasetOperation { + return c.internalClient.CreateConversationDatasetOperation(name) +} + +// GetConversationDataset retrieves the specified conversation dataset. +func (c *ConversationDatasetsClient) GetConversationDataset(ctx context.Context, req *dialogflowpb.GetConversationDatasetRequest, opts ...gax.CallOption) (*dialogflowpb.ConversationDataset, error) { + return c.internalClient.GetConversationDataset(ctx, req, opts...) +} + +// ListConversationDatasets returns the list of all conversation datasets in the specified +// project and location. +func (c *ConversationDatasetsClient) ListConversationDatasets(ctx context.Context, req *dialogflowpb.ListConversationDatasetsRequest, opts ...gax.CallOption) *ConversationDatasetIterator { + return c.internalClient.ListConversationDatasets(ctx, req, opts...) +} + +// DeleteConversationDataset deletes the specified conversation dataset. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). +// The returned Operation type has the following method-specific fields: +// +// metadata: DeleteConversationDatasetOperationMetadata +// +// response: An Empty +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) +func (c *ConversationDatasetsClient) DeleteConversationDataset(ctx context.Context, req *dialogflowpb.DeleteConversationDatasetRequest, opts ...gax.CallOption) (*DeleteConversationDatasetOperation, error) { + return c.internalClient.DeleteConversationDataset(ctx, req, opts...) +} + +// DeleteConversationDatasetOperation returns a new DeleteConversationDatasetOperation from a given name. +// The name must be that of a previously created DeleteConversationDatasetOperation, possibly from a different process. +func (c *ConversationDatasetsClient) DeleteConversationDatasetOperation(name string) *DeleteConversationDatasetOperation { + return c.internalClient.DeleteConversationDatasetOperation(name) +} + +// ImportConversationData import data into the specified conversation dataset. Note that it +// is not allowed to import data to a conversation dataset that +// already has data in it. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). +// The returned Operation type has the following method-specific fields: +// +// metadata: ImportConversationDataOperationMetadata +// +// response: ImportConversationDataOperationResponse +func (c *ConversationDatasetsClient) ImportConversationData(ctx context.Context, req *dialogflowpb.ImportConversationDataRequest, opts ...gax.CallOption) (*ImportConversationDataOperation, error) { + return c.internalClient.ImportConversationData(ctx, req, opts...) +} + +// ImportConversationDataOperation returns a new ImportConversationDataOperation from a given name. +// The name must be that of a previously created ImportConversationDataOperation, possibly from a different process. +func (c *ConversationDatasetsClient) ImportConversationDataOperation(name string) *ImportConversationDataOperation { + return c.internalClient.ImportConversationDataOperation(name) +} + +// conversationDatasetsGRPCClient 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 conversationDatasetsGRPCClient 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 ConversationDatasetsClient + CallOptions **ConversationDatasetsCallOptions + + // The gRPC API client. + conversationDatasetsClient dialogflowpb.ConversationDatasetsClient + + // 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 + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewConversationDatasetsClient creates a new conversation datasets client based on gRPC. +// The returned client must be Closed when it is done being used to clean up its underlying connections. +// +// Conversation datasets. +// +// Conversation datasets contain raw conversation files and their +// customizable metadata that can be used for model training. +func NewConversationDatasetsClient(ctx context.Context, opts ...option.ClientOption) (*ConversationDatasetsClient, error) { + clientOpts := defaultConversationDatasetsGRPCClientOptions() + if newConversationDatasetsClientHook != nil { + hookOpts, err := newConversationDatasetsClientHook(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 := ConversationDatasetsClient{CallOptions: defaultConversationDatasetsCallOptions()} + + c := &conversationDatasetsGRPCClient{ + connPool: connPool, + disableDeadlines: disableDeadlines, + conversationDatasetsClient: dialogflowpb.NewConversationDatasetsClient(connPool), + CallOptions: &client.CallOptions, + } + 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. +func (c *conversationDatasetsGRPCClient) 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 *conversationDatasetsGRPCClient) 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 *conversationDatasetsGRPCClient) Close() error { + return c.connPool.Close() +} + +func (c *conversationDatasetsGRPCClient) CreateConversationDataset(ctx context.Context, req *dialogflowpb.CreateConversationDatasetRequest, opts ...gax.CallOption) (*CreateConversationDatasetOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).CreateConversationDataset[0:len((*c.CallOptions).CreateConversationDataset):len((*c.CallOptions).CreateConversationDataset)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationDatasetsClient.CreateConversationDataset(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateConversationDatasetOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + +func (c *conversationDatasetsGRPCClient) GetConversationDataset(ctx context.Context, req *dialogflowpb.GetConversationDatasetRequest, opts ...gax.CallOption) (*dialogflowpb.ConversationDataset, 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).GetConversationDataset[0:len((*c.CallOptions).GetConversationDataset):len((*c.CallOptions).GetConversationDataset)], opts...) + var resp *dialogflowpb.ConversationDataset + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationDatasetsClient.GetConversationDataset(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *conversationDatasetsGRPCClient) ListConversationDatasets(ctx context.Context, req *dialogflowpb.ListConversationDatasetsRequest, opts ...gax.CallOption) *ConversationDatasetIterator { + 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).ListConversationDatasets[0:len((*c.CallOptions).ListConversationDatasets):len((*c.CallOptions).ListConversationDatasets)], opts...) + it := &ConversationDatasetIterator{} + req = proto.Clone(req).(*dialogflowpb.ListConversationDatasetsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*dialogflowpb.ConversationDataset, string, error) { + resp := &dialogflowpb.ListConversationDatasetsResponse{} + 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.conversationDatasetsClient.ListConversationDatasets(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetConversationDatasets(), 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 *conversationDatasetsGRPCClient) DeleteConversationDataset(ctx context.Context, req *dialogflowpb.DeleteConversationDatasetRequest, opts ...gax.CallOption) (*DeleteConversationDatasetOperation, 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).DeleteConversationDataset[0:len((*c.CallOptions).DeleteConversationDataset):len((*c.CallOptions).DeleteConversationDataset)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationDatasetsClient.DeleteConversationDataset(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteConversationDatasetOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + +func (c *conversationDatasetsGRPCClient) ImportConversationData(ctx context.Context, req *dialogflowpb.ImportConversationDataRequest, opts ...gax.CallOption) (*ImportConversationDataOperation, 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).ImportConversationData[0:len((*c.CallOptions).ImportConversationData):len((*c.CallOptions).ImportConversationData)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationDatasetsClient.ImportConversationData(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &ImportConversationDataOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + +// CreateConversationDatasetOperation manages a long-running operation from CreateConversationDataset. +type CreateConversationDatasetOperation struct { + lro *longrunning.Operation +} + +// CreateConversationDatasetOperation returns a new CreateConversationDatasetOperation from a given name. +// The name must be that of a previously created CreateConversationDatasetOperation, possibly from a different process. +func (c *conversationDatasetsGRPCClient) CreateConversationDatasetOperation(name string) *CreateConversationDatasetOperation { + return &CreateConversationDatasetOperation{ + 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 *CreateConversationDatasetOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.ConversationDataset, error) { + var resp dialogflowpb.ConversationDataset + 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 *CreateConversationDatasetOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.ConversationDataset, error) { + var resp dialogflowpb.ConversationDataset + 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 *CreateConversationDatasetOperation) Metadata() (*dialogflowpb.CreateConversationDatasetOperationMetadata, error) { + var meta dialogflowpb.CreateConversationDatasetOperationMetadata + 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 *CreateConversationDatasetOperation) 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 *CreateConversationDatasetOperation) Name() string { + return op.lro.Name() +} + +// DeleteConversationDatasetOperation manages a long-running operation from DeleteConversationDataset. +type DeleteConversationDatasetOperation struct { + lro *longrunning.Operation +} + +// DeleteConversationDatasetOperation returns a new DeleteConversationDatasetOperation from a given name. +// The name must be that of a previously created DeleteConversationDatasetOperation, possibly from a different process. +func (c *conversationDatasetsGRPCClient) DeleteConversationDatasetOperation(name string) *DeleteConversationDatasetOperation { + return &DeleteConversationDatasetOperation{ + 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 *DeleteConversationDatasetOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *DeleteConversationDatasetOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeleteConversationDatasetOperation) Metadata() (*dialogflowpb.DeleteConversationDatasetOperationMetadata, error) { + var meta dialogflowpb.DeleteConversationDatasetOperationMetadata + 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 *DeleteConversationDatasetOperation) 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 *DeleteConversationDatasetOperation) Name() string { + return op.lro.Name() +} + +// ImportConversationDataOperation manages a long-running operation from ImportConversationData. +type ImportConversationDataOperation struct { + lro *longrunning.Operation +} + +// ImportConversationDataOperation returns a new ImportConversationDataOperation from a given name. +// The name must be that of a previously created ImportConversationDataOperation, possibly from a different process. +func (c *conversationDatasetsGRPCClient) ImportConversationDataOperation(name string) *ImportConversationDataOperation { + return &ImportConversationDataOperation{ + 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 *ImportConversationDataOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.ImportConversationDataOperationResponse, error) { + var resp dialogflowpb.ImportConversationDataOperationResponse + 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 *ImportConversationDataOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.ImportConversationDataOperationResponse, error) { + var resp dialogflowpb.ImportConversationDataOperationResponse + 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 *ImportConversationDataOperation) Metadata() (*dialogflowpb.ImportConversationDataOperationMetadata, error) { + var meta dialogflowpb.ImportConversationDataOperationMetadata + 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 *ImportConversationDataOperation) 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 *ImportConversationDataOperation) Name() string { + return op.lro.Name() +} + +// ConversationDatasetIterator manages a stream of *dialogflowpb.ConversationDataset. +type ConversationDatasetIterator struct { + items []*dialogflowpb.ConversationDataset + 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 []*dialogflowpb.ConversationDataset, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *ConversationDatasetIterator) 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 *ConversationDatasetIterator) Next() (*dialogflowpb.ConversationDataset, error) { + var item *dialogflowpb.ConversationDataset + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *ConversationDatasetIterator) bufLen() int { + return len(it.items) +} + +func (it *ConversationDatasetIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/dialogflow/apiv2/conversation_datasets_client_example_test.go b/dialogflow/apiv2/conversation_datasets_client_example_test.go new file mode 100644 index 000000000000..4e17967db3a7 --- /dev/null +++ b/dialogflow/apiv2/conversation_datasets_client_example_test.go @@ -0,0 +1,156 @@ +// 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 dialogflow_test + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + "google.golang.org/api/iterator" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func ExampleNewConversationDatasetsClient() { + ctx := context.Background() + c, err := dialogflow.NewConversationDatasetsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + // TODO: Use client. + _ = c +} + +func ExampleConversationDatasetsClient_CreateConversationDataset() { + ctx := context.Background() + c, err := dialogflow.NewConversationDatasetsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.CreateConversationDatasetRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#CreateConversationDatasetRequest. + } + op, err := c.CreateConversationDataset(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleConversationDatasetsClient_GetConversationDataset() { + ctx := context.Background() + c, err := dialogflow.NewConversationDatasetsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.GetConversationDatasetRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#GetConversationDatasetRequest. + } + resp, err := c.GetConversationDataset(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleConversationDatasetsClient_ListConversationDatasets() { + ctx := context.Background() + c, err := dialogflow.NewConversationDatasetsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.ListConversationDatasetsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#ListConversationDatasetsRequest. + } + it := c.ListConversationDatasets(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleConversationDatasetsClient_DeleteConversationDataset() { + ctx := context.Background() + c, err := dialogflow.NewConversationDatasetsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.DeleteConversationDatasetRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#DeleteConversationDatasetRequest. + } + op, err := c.DeleteConversationDataset(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleConversationDatasetsClient_ImportConversationData() { + ctx := context.Background() + c, err := dialogflow.NewConversationDatasetsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.ImportConversationDataRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#ImportConversationDataRequest. + } + op, err := c.ImportConversationData(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/apiv2/conversation_models_client.go b/dialogflow/apiv2/conversation_models_client.go new file mode 100644 index 000000000000..b2e24f1c3126 --- /dev/null +++ b/dialogflow/apiv2/conversation_models_client.go @@ -0,0 +1,1103 @@ +// 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 dialogflow + +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" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/protobuf/proto" +) + +var newConversationModelsClientHook clientHook + +// ConversationModelsCallOptions contains the retry settings for each method of ConversationModelsClient. +type ConversationModelsCallOptions struct { + CreateConversationModel []gax.CallOption + GetConversationModel []gax.CallOption + ListConversationModels []gax.CallOption + DeleteConversationModel []gax.CallOption + DeployConversationModel []gax.CallOption + UndeployConversationModel []gax.CallOption + GetConversationModelEvaluation []gax.CallOption + ListConversationModelEvaluations []gax.CallOption + CreateConversationModelEvaluation []gax.CallOption +} + +func defaultConversationModelsGRPCClientOptions() []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.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultConversationModelsCallOptions() *ConversationModelsCallOptions { + return &ConversationModelsCallOptions{ + CreateConversationModel: []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, + }) + }), + }, + GetConversationModel: []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, + }) + }), + }, + ListConversationModels: []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, + }) + }), + }, + DeleteConversationModel: []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, + }) + }), + }, + DeployConversationModel: []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, + }) + }), + }, + UndeployConversationModel: []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, + }) + }), + }, + GetConversationModelEvaluation: []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, + }) + }), + }, + ListConversationModelEvaluations: []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, + }) + }), + }, + CreateConversationModelEvaluation: []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, + }) + }), + }, + } +} + +// internalConversationModelsClient is an interface that defines the methods availaible from Dialogflow API. +type internalConversationModelsClient interface { + Close() error + setGoogleClientInfo(...string) + Connection() *grpc.ClientConn + CreateConversationModel(context.Context, *dialogflowpb.CreateConversationModelRequest, ...gax.CallOption) (*CreateConversationModelOperation, error) + CreateConversationModelOperation(name string) *CreateConversationModelOperation + GetConversationModel(context.Context, *dialogflowpb.GetConversationModelRequest, ...gax.CallOption) (*dialogflowpb.ConversationModel, error) + ListConversationModels(context.Context, *dialogflowpb.ListConversationModelsRequest, ...gax.CallOption) *ConversationModelIterator + DeleteConversationModel(context.Context, *dialogflowpb.DeleteConversationModelRequest, ...gax.CallOption) (*DeleteConversationModelOperation, error) + DeleteConversationModelOperation(name string) *DeleteConversationModelOperation + DeployConversationModel(context.Context, *dialogflowpb.DeployConversationModelRequest, ...gax.CallOption) (*DeployConversationModelOperation, error) + DeployConversationModelOperation(name string) *DeployConversationModelOperation + UndeployConversationModel(context.Context, *dialogflowpb.UndeployConversationModelRequest, ...gax.CallOption) (*UndeployConversationModelOperation, error) + UndeployConversationModelOperation(name string) *UndeployConversationModelOperation + GetConversationModelEvaluation(context.Context, *dialogflowpb.GetConversationModelEvaluationRequest, ...gax.CallOption) (*dialogflowpb.ConversationModelEvaluation, error) + ListConversationModelEvaluations(context.Context, *dialogflowpb.ListConversationModelEvaluationsRequest, ...gax.CallOption) *ConversationModelEvaluationIterator + CreateConversationModelEvaluation(context.Context, *dialogflowpb.CreateConversationModelEvaluationRequest, ...gax.CallOption) (*CreateConversationModelEvaluationOperation, error) + CreateConversationModelEvaluationOperation(name string) *CreateConversationModelEvaluationOperation +} + +// ConversationModelsClient 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. +// +// Manages a collection of models for human agent assistant. +type ConversationModelsClient struct { + // The internal transport-dependent client. + internalClient internalConversationModelsClient + + // The call options for this service. + CallOptions *ConversationModelsCallOptions + + // 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 *ConversationModelsClient) 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 *ConversationModelsClient) setGoogleClientInfo(keyval ...string) { + c.internalClient.setGoogleClientInfo(keyval...) +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *ConversationModelsClient) Connection() *grpc.ClientConn { + return c.internalClient.Connection() +} + +// CreateConversationModel creates a model. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). +// The returned Operation type has the following method-specific fields: +// +// metadata: CreateConversationModelOperationMetadata +// +// response: ConversationModel +func (c *ConversationModelsClient) CreateConversationModel(ctx context.Context, req *dialogflowpb.CreateConversationModelRequest, opts ...gax.CallOption) (*CreateConversationModelOperation, error) { + return c.internalClient.CreateConversationModel(ctx, req, opts...) +} + +// CreateConversationModelOperation returns a new CreateConversationModelOperation from a given name. +// The name must be that of a previously created CreateConversationModelOperation, possibly from a different process. +func (c *ConversationModelsClient) CreateConversationModelOperation(name string) *CreateConversationModelOperation { + return c.internalClient.CreateConversationModelOperation(name) +} + +// GetConversationModel gets conversation model. +func (c *ConversationModelsClient) GetConversationModel(ctx context.Context, req *dialogflowpb.GetConversationModelRequest, opts ...gax.CallOption) (*dialogflowpb.ConversationModel, error) { + return c.internalClient.GetConversationModel(ctx, req, opts...) +} + +// ListConversationModels lists conversation models. +func (c *ConversationModelsClient) ListConversationModels(ctx context.Context, req *dialogflowpb.ListConversationModelsRequest, opts ...gax.CallOption) *ConversationModelIterator { + return c.internalClient.ListConversationModels(ctx, req, opts...) +} + +// DeleteConversationModel deletes a model. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). +// The returned Operation type has the following method-specific fields: +// +// metadata: DeleteConversationModelOperationMetadata +// +// response: An Empty +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) +func (c *ConversationModelsClient) DeleteConversationModel(ctx context.Context, req *dialogflowpb.DeleteConversationModelRequest, opts ...gax.CallOption) (*DeleteConversationModelOperation, error) { + return c.internalClient.DeleteConversationModel(ctx, req, opts...) +} + +// DeleteConversationModelOperation returns a new DeleteConversationModelOperation from a given name. +// The name must be that of a previously created DeleteConversationModelOperation, possibly from a different process. +func (c *ConversationModelsClient) DeleteConversationModelOperation(name string) *DeleteConversationModelOperation { + return c.internalClient.DeleteConversationModelOperation(name) +} + +// DeployConversationModel deploys a model. If a model is already deployed, deploying it +// has no effect. A model can only serve prediction requests after it gets +// deployed. For article suggestion, custom model will not be used unless +// it is deployed. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). +// The returned Operation type has the following method-specific fields: +// +// metadata: DeployConversationModelOperationMetadata +// +// response: An Empty +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) +func (c *ConversationModelsClient) DeployConversationModel(ctx context.Context, req *dialogflowpb.DeployConversationModelRequest, opts ...gax.CallOption) (*DeployConversationModelOperation, error) { + return c.internalClient.DeployConversationModel(ctx, req, opts...) +} + +// DeployConversationModelOperation returns a new DeployConversationModelOperation from a given name. +// The name must be that of a previously created DeployConversationModelOperation, possibly from a different process. +func (c *ConversationModelsClient) DeployConversationModelOperation(name string) *DeployConversationModelOperation { + return c.internalClient.DeployConversationModelOperation(name) +} + +// UndeployConversationModel undeploys a model. If the model is not deployed this method has no effect. +// If the model is currently being used: +// +// For article suggestion, article suggestion will fallback to the default +// model if model is undeployed. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). +// The returned Operation type has the following method-specific fields: +// +// metadata: UndeployConversationModelOperationMetadata +// +// response: An Empty +// message (at https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) +func (c *ConversationModelsClient) UndeployConversationModel(ctx context.Context, req *dialogflowpb.UndeployConversationModelRequest, opts ...gax.CallOption) (*UndeployConversationModelOperation, error) { + return c.internalClient.UndeployConversationModel(ctx, req, opts...) +} + +// UndeployConversationModelOperation returns a new UndeployConversationModelOperation from a given name. +// The name must be that of a previously created UndeployConversationModelOperation, possibly from a different process. +func (c *ConversationModelsClient) UndeployConversationModelOperation(name string) *UndeployConversationModelOperation { + return c.internalClient.UndeployConversationModelOperation(name) +} + +// GetConversationModelEvaluation gets an evaluation of conversation model. +func (c *ConversationModelsClient) GetConversationModelEvaluation(ctx context.Context, req *dialogflowpb.GetConversationModelEvaluationRequest, opts ...gax.CallOption) (*dialogflowpb.ConversationModelEvaluation, error) { + return c.internalClient.GetConversationModelEvaluation(ctx, req, opts...) +} + +// ListConversationModelEvaluations lists evaluations of a conversation model. +func (c *ConversationModelsClient) ListConversationModelEvaluations(ctx context.Context, req *dialogflowpb.ListConversationModelEvaluationsRequest, opts ...gax.CallOption) *ConversationModelEvaluationIterator { + return c.internalClient.ListConversationModelEvaluations(ctx, req, opts...) +} + +// CreateConversationModelEvaluation creates evaluation of a conversation model. +func (c *ConversationModelsClient) CreateConversationModelEvaluation(ctx context.Context, req *dialogflowpb.CreateConversationModelEvaluationRequest, opts ...gax.CallOption) (*CreateConversationModelEvaluationOperation, error) { + return c.internalClient.CreateConversationModelEvaluation(ctx, req, opts...) +} + +// CreateConversationModelEvaluationOperation returns a new CreateConversationModelEvaluationOperation from a given name. +// The name must be that of a previously created CreateConversationModelEvaluationOperation, possibly from a different process. +func (c *ConversationModelsClient) CreateConversationModelEvaluationOperation(name string) *CreateConversationModelEvaluationOperation { + return c.internalClient.CreateConversationModelEvaluationOperation(name) +} + +// conversationModelsGRPCClient 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 conversationModelsGRPCClient 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 ConversationModelsClient + CallOptions **ConversationModelsCallOptions + + // The gRPC API client. + conversationModelsClient dialogflowpb.ConversationModelsClient + + // 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 + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewConversationModelsClient creates a new conversation models client based on gRPC. +// The returned client must be Closed when it is done being used to clean up its underlying connections. +// +// Manages a collection of models for human agent assistant. +func NewConversationModelsClient(ctx context.Context, opts ...option.ClientOption) (*ConversationModelsClient, error) { + clientOpts := defaultConversationModelsGRPCClientOptions() + if newConversationModelsClientHook != nil { + hookOpts, err := newConversationModelsClientHook(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 := ConversationModelsClient{CallOptions: defaultConversationModelsCallOptions()} + + c := &conversationModelsGRPCClient{ + connPool: connPool, + disableDeadlines: disableDeadlines, + conversationModelsClient: dialogflowpb.NewConversationModelsClient(connPool), + CallOptions: &client.CallOptions, + } + 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. +func (c *conversationModelsGRPCClient) 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 *conversationModelsGRPCClient) 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 *conversationModelsGRPCClient) Close() error { + return c.connPool.Close() +} + +func (c *conversationModelsGRPCClient) CreateConversationModel(ctx context.Context, req *dialogflowpb.CreateConversationModelRequest, opts ...gax.CallOption) (*CreateConversationModelOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).CreateConversationModel[0:len((*c.CallOptions).CreateConversationModel):len((*c.CallOptions).CreateConversationModel)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationModelsClient.CreateConversationModel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateConversationModelOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + +func (c *conversationModelsGRPCClient) GetConversationModel(ctx context.Context, req *dialogflowpb.GetConversationModelRequest, opts ...gax.CallOption) (*dialogflowpb.ConversationModel, 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).GetConversationModel[0:len((*c.CallOptions).GetConversationModel):len((*c.CallOptions).GetConversationModel)], opts...) + var resp *dialogflowpb.ConversationModel + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationModelsClient.GetConversationModel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *conversationModelsGRPCClient) ListConversationModels(ctx context.Context, req *dialogflowpb.ListConversationModelsRequest, opts ...gax.CallOption) *ConversationModelIterator { + 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).ListConversationModels[0:len((*c.CallOptions).ListConversationModels):len((*c.CallOptions).ListConversationModels)], opts...) + it := &ConversationModelIterator{} + req = proto.Clone(req).(*dialogflowpb.ListConversationModelsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*dialogflowpb.ConversationModel, string, error) { + resp := &dialogflowpb.ListConversationModelsResponse{} + 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.conversationModelsClient.ListConversationModels(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetConversationModels(), 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 *conversationModelsGRPCClient) DeleteConversationModel(ctx context.Context, req *dialogflowpb.DeleteConversationModelRequest, opts ...gax.CallOption) (*DeleteConversationModelOperation, 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).DeleteConversationModel[0:len((*c.CallOptions).DeleteConversationModel):len((*c.CallOptions).DeleteConversationModel)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationModelsClient.DeleteConversationModel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteConversationModelOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + +func (c *conversationModelsGRPCClient) DeployConversationModel(ctx context.Context, req *dialogflowpb.DeployConversationModelRequest, opts ...gax.CallOption) (*DeployConversationModelOperation, 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).DeployConversationModel[0:len((*c.CallOptions).DeployConversationModel):len((*c.CallOptions).DeployConversationModel)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationModelsClient.DeployConversationModel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeployConversationModelOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + +func (c *conversationModelsGRPCClient) UndeployConversationModel(ctx context.Context, req *dialogflowpb.UndeployConversationModelRequest, opts ...gax.CallOption) (*UndeployConversationModelOperation, 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).UndeployConversationModel[0:len((*c.CallOptions).UndeployConversationModel):len((*c.CallOptions).UndeployConversationModel)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationModelsClient.UndeployConversationModel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UndeployConversationModelOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + +func (c *conversationModelsGRPCClient) GetConversationModelEvaluation(ctx context.Context, req *dialogflowpb.GetConversationModelEvaluationRequest, opts ...gax.CallOption) (*dialogflowpb.ConversationModelEvaluation, 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).GetConversationModelEvaluation[0:len((*c.CallOptions).GetConversationModelEvaluation):len((*c.CallOptions).GetConversationModelEvaluation)], opts...) + var resp *dialogflowpb.ConversationModelEvaluation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationModelsClient.GetConversationModelEvaluation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *conversationModelsGRPCClient) ListConversationModelEvaluations(ctx context.Context, req *dialogflowpb.ListConversationModelEvaluationsRequest, opts ...gax.CallOption) *ConversationModelEvaluationIterator { + 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).ListConversationModelEvaluations[0:len((*c.CallOptions).ListConversationModelEvaluations):len((*c.CallOptions).ListConversationModelEvaluations)], opts...) + it := &ConversationModelEvaluationIterator{} + req = proto.Clone(req).(*dialogflowpb.ListConversationModelEvaluationsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*dialogflowpb.ConversationModelEvaluation, string, error) { + resp := &dialogflowpb.ListConversationModelEvaluationsResponse{} + 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.conversationModelsClient.ListConversationModelEvaluations(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetConversationModelEvaluations(), 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 *conversationModelsGRPCClient) CreateConversationModelEvaluation(ctx context.Context, req *dialogflowpb.CreateConversationModelEvaluationRequest, opts ...gax.CallOption) (*CreateConversationModelEvaluationOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).CreateConversationModelEvaluation[0:len((*c.CallOptions).CreateConversationModelEvaluation):len((*c.CallOptions).CreateConversationModelEvaluation)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationModelsClient.CreateConversationModelEvaluation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateConversationModelEvaluationOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + +// CreateConversationModelOperation manages a long-running operation from CreateConversationModel. +type CreateConversationModelOperation struct { + lro *longrunning.Operation +} + +// CreateConversationModelOperation returns a new CreateConversationModelOperation from a given name. +// The name must be that of a previously created CreateConversationModelOperation, possibly from a different process. +func (c *conversationModelsGRPCClient) CreateConversationModelOperation(name string) *CreateConversationModelOperation { + return &CreateConversationModelOperation{ + 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 *CreateConversationModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.ConversationModel, error) { + var resp dialogflowpb.ConversationModel + 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 *CreateConversationModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.ConversationModel, error) { + var resp dialogflowpb.ConversationModel + 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 *CreateConversationModelOperation) Metadata() (*dialogflowpb.CreateConversationModelOperationMetadata, error) { + var meta dialogflowpb.CreateConversationModelOperationMetadata + 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 *CreateConversationModelOperation) 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 *CreateConversationModelOperation) Name() string { + return op.lro.Name() +} + +// CreateConversationModelEvaluationOperation manages a long-running operation from CreateConversationModelEvaluation. +type CreateConversationModelEvaluationOperation struct { + lro *longrunning.Operation +} + +// CreateConversationModelEvaluationOperation returns a new CreateConversationModelEvaluationOperation from a given name. +// The name must be that of a previously created CreateConversationModelEvaluationOperation, possibly from a different process. +func (c *conversationModelsGRPCClient) CreateConversationModelEvaluationOperation(name string) *CreateConversationModelEvaluationOperation { + return &CreateConversationModelEvaluationOperation{ + 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 *CreateConversationModelEvaluationOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.ConversationModelEvaluation, error) { + var resp dialogflowpb.ConversationModelEvaluation + 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 *CreateConversationModelEvaluationOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.ConversationModelEvaluation, error) { + var resp dialogflowpb.ConversationModelEvaluation + 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 *CreateConversationModelEvaluationOperation) Metadata() (*dialogflowpb.CreateConversationModelEvaluationOperationMetadata, error) { + var meta dialogflowpb.CreateConversationModelEvaluationOperationMetadata + 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 *CreateConversationModelEvaluationOperation) 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 *CreateConversationModelEvaluationOperation) Name() string { + return op.lro.Name() +} + +// DeleteConversationModelOperation manages a long-running operation from DeleteConversationModel. +type DeleteConversationModelOperation struct { + lro *longrunning.Operation +} + +// DeleteConversationModelOperation returns a new DeleteConversationModelOperation from a given name. +// The name must be that of a previously created DeleteConversationModelOperation, possibly from a different process. +func (c *conversationModelsGRPCClient) DeleteConversationModelOperation(name string) *DeleteConversationModelOperation { + return &DeleteConversationModelOperation{ + 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 *DeleteConversationModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *DeleteConversationModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeleteConversationModelOperation) Metadata() (*dialogflowpb.DeleteConversationModelOperationMetadata, error) { + var meta dialogflowpb.DeleteConversationModelOperationMetadata + 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 *DeleteConversationModelOperation) 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 *DeleteConversationModelOperation) Name() string { + return op.lro.Name() +} + +// DeployConversationModelOperation manages a long-running operation from DeployConversationModel. +type DeployConversationModelOperation struct { + lro *longrunning.Operation +} + +// DeployConversationModelOperation returns a new DeployConversationModelOperation from a given name. +// The name must be that of a previously created DeployConversationModelOperation, possibly from a different process. +func (c *conversationModelsGRPCClient) DeployConversationModelOperation(name string) *DeployConversationModelOperation { + return &DeployConversationModelOperation{ + 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 *DeployConversationModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *DeployConversationModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeployConversationModelOperation) Metadata() (*dialogflowpb.DeployConversationModelOperationMetadata, error) { + var meta dialogflowpb.DeployConversationModelOperationMetadata + 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 *DeployConversationModelOperation) 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 *DeployConversationModelOperation) Name() string { + return op.lro.Name() +} + +// UndeployConversationModelOperation manages a long-running operation from UndeployConversationModel. +type UndeployConversationModelOperation struct { + lro *longrunning.Operation +} + +// UndeployConversationModelOperation returns a new UndeployConversationModelOperation from a given name. +// The name must be that of a previously created UndeployConversationModelOperation, possibly from a different process. +func (c *conversationModelsGRPCClient) UndeployConversationModelOperation(name string) *UndeployConversationModelOperation { + return &UndeployConversationModelOperation{ + 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 *UndeployConversationModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *UndeployConversationModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *UndeployConversationModelOperation) Metadata() (*dialogflowpb.UndeployConversationModelOperationMetadata, error) { + var meta dialogflowpb.UndeployConversationModelOperationMetadata + 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 *UndeployConversationModelOperation) 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 *UndeployConversationModelOperation) Name() string { + return op.lro.Name() +} + +// ConversationModelEvaluationIterator manages a stream of *dialogflowpb.ConversationModelEvaluation. +type ConversationModelEvaluationIterator struct { + items []*dialogflowpb.ConversationModelEvaluation + 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 []*dialogflowpb.ConversationModelEvaluation, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *ConversationModelEvaluationIterator) 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 *ConversationModelEvaluationIterator) Next() (*dialogflowpb.ConversationModelEvaluation, error) { + var item *dialogflowpb.ConversationModelEvaluation + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *ConversationModelEvaluationIterator) bufLen() int { + return len(it.items) +} + +func (it *ConversationModelEvaluationIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + +// ConversationModelIterator manages a stream of *dialogflowpb.ConversationModel. +type ConversationModelIterator struct { + items []*dialogflowpb.ConversationModel + 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 []*dialogflowpb.ConversationModel, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *ConversationModelIterator) 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 *ConversationModelIterator) Next() (*dialogflowpb.ConversationModel, error) { + var item *dialogflowpb.ConversationModel + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *ConversationModelIterator) bufLen() int { + return len(it.items) +} + +func (it *ConversationModelIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/dialogflow/apiv2/conversation_models_client_example_test.go b/dialogflow/apiv2/conversation_models_client_example_test.go new file mode 100644 index 000000000000..b38f8bbe4557 --- /dev/null +++ b/dialogflow/apiv2/conversation_models_client_example_test.go @@ -0,0 +1,248 @@ +// 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 dialogflow_test + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + "google.golang.org/api/iterator" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func ExampleNewConversationModelsClient() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + // TODO: Use client. + _ = c +} + +func ExampleConversationModelsClient_CreateConversationModel() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.CreateConversationModelRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#CreateConversationModelRequest. + } + op, err := c.CreateConversationModel(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleConversationModelsClient_GetConversationModel() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.GetConversationModelRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#GetConversationModelRequest. + } + resp, err := c.GetConversationModel(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleConversationModelsClient_ListConversationModels() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.ListConversationModelsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#ListConversationModelsRequest. + } + it := c.ListConversationModels(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleConversationModelsClient_DeleteConversationModel() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.DeleteConversationModelRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#DeleteConversationModelRequest. + } + op, err := c.DeleteConversationModel(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleConversationModelsClient_DeployConversationModel() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.DeployConversationModelRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#DeployConversationModelRequest. + } + op, err := c.DeployConversationModel(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleConversationModelsClient_UndeployConversationModel() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.UndeployConversationModelRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#UndeployConversationModelRequest. + } + op, err := c.UndeployConversationModel(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleConversationModelsClient_GetConversationModelEvaluation() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.GetConversationModelEvaluationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#GetConversationModelEvaluationRequest. + } + resp, err := c.GetConversationModelEvaluation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleConversationModelsClient_ListConversationModelEvaluations() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.ListConversationModelEvaluationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#ListConversationModelEvaluationsRequest. + } + it := c.ListConversationModelEvaluations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleConversationModelsClient_CreateConversationModelEvaluation() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.CreateConversationModelEvaluationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#CreateConversationModelEvaluationRequest. + } + op, err := c.CreateConversationModelEvaluation(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/apiv2/conversation_profiles_client.go b/dialogflow/apiv2/conversation_profiles_client.go index 06143268cc06..6f373362d6aa 100644 --- a/dialogflow/apiv2/conversation_profiles_client.go +++ b/dialogflow/apiv2/conversation_profiles_client.go @@ -23,12 +23,15 @@ import ( "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" dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" @@ -39,11 +42,13 @@ var newConversationProfilesClientHook clientHook // ConversationProfilesCallOptions contains the retry settings for each method of ConversationProfilesClient. type ConversationProfilesCallOptions struct { - ListConversationProfiles []gax.CallOption - GetConversationProfile []gax.CallOption - CreateConversationProfile []gax.CallOption - UpdateConversationProfile []gax.CallOption - DeleteConversationProfile []gax.CallOption + ListConversationProfiles []gax.CallOption + GetConversationProfile []gax.CallOption + CreateConversationProfile []gax.CallOption + UpdateConversationProfile []gax.CallOption + DeleteConversationProfile []gax.CallOption + SetSuggestionFeatureConfig []gax.CallOption + ClearSuggestionFeatureConfig []gax.CallOption } func defaultConversationProfilesGRPCClientOptions() []option.ClientOption { @@ -115,6 +120,28 @@ func defaultConversationProfilesCallOptions() *ConversationProfilesCallOptions { }) }), }, + SetSuggestionFeatureConfig: []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, + }) + }), + }, + ClearSuggestionFeatureConfig: []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, + }) + }), + }, } } @@ -128,6 +155,10 @@ type internalConversationProfilesClient interface { CreateConversationProfile(context.Context, *dialogflowpb.CreateConversationProfileRequest, ...gax.CallOption) (*dialogflowpb.ConversationProfile, error) UpdateConversationProfile(context.Context, *dialogflowpb.UpdateConversationProfileRequest, ...gax.CallOption) (*dialogflowpb.ConversationProfile, error) DeleteConversationProfile(context.Context, *dialogflowpb.DeleteConversationProfileRequest, ...gax.CallOption) error + SetSuggestionFeatureConfig(context.Context, *dialogflowpb.SetSuggestionFeatureConfigRequest, ...gax.CallOption) (*SetSuggestionFeatureConfigOperation, error) + SetSuggestionFeatureConfigOperation(name string) *SetSuggestionFeatureConfigOperation + ClearSuggestionFeatureConfig(context.Context, *dialogflowpb.ClearSuggestionFeatureConfigRequest, ...gax.CallOption) (*ClearSuggestionFeatureConfigOperation, error) + ClearSuggestionFeatureConfigOperation(name string) *ClearSuggestionFeatureConfigOperation } // ConversationProfilesClient is a client for interacting with Dialogflow API. @@ -140,6 +171,11 @@ type ConversationProfilesClient struct { // The call options for this service. CallOptions *ConversationProfilesCallOptions + + // 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. @@ -197,6 +233,53 @@ func (c *ConversationProfilesClient) DeleteConversationProfile(ctx context.Conte return c.internalClient.DeleteConversationProfile(ctx, req, opts...) } +// SetSuggestionFeatureConfig adds or updates a suggestion feature in a conversation profile. +// If the conversation profile contains the type of suggestion feature for +// the participant role, it will update it. Otherwise it will insert the +// suggestion feature. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). +// The returned Operation type has the following method-specific fields: +// +// metadata: SetSuggestionFeatureConfigOperationMetadata +// +// response: ConversationProfile +// +// If a long running operation to add or update suggestion feature +// config for the same conversation profile, participant role and suggestion +// feature type exists, please cancel the existing long running operation +// before sending such request, otherwise the request will be rejected. +func (c *ConversationProfilesClient) SetSuggestionFeatureConfig(ctx context.Context, req *dialogflowpb.SetSuggestionFeatureConfigRequest, opts ...gax.CallOption) (*SetSuggestionFeatureConfigOperation, error) { + return c.internalClient.SetSuggestionFeatureConfig(ctx, req, opts...) +} + +// SetSuggestionFeatureConfigOperation returns a new SetSuggestionFeatureConfigOperation from a given name. +// The name must be that of a previously created SetSuggestionFeatureConfigOperation, possibly from a different process. +func (c *ConversationProfilesClient) SetSuggestionFeatureConfigOperation(name string) *SetSuggestionFeatureConfigOperation { + return c.internalClient.SetSuggestionFeatureConfigOperation(name) +} + +// ClearSuggestionFeatureConfig clears a suggestion feature from a conversation profile for the given +// participant role. +// +// This method is a long-running +// operation (at https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). +// The returned Operation type has the following method-specific fields: +// +// metadata: ClearSuggestionFeatureConfigOperationMetadata +// +// response: ConversationProfile +func (c *ConversationProfilesClient) ClearSuggestionFeatureConfig(ctx context.Context, req *dialogflowpb.ClearSuggestionFeatureConfigRequest, opts ...gax.CallOption) (*ClearSuggestionFeatureConfigOperation, error) { + return c.internalClient.ClearSuggestionFeatureConfig(ctx, req, opts...) +} + +// ClearSuggestionFeatureConfigOperation returns a new ClearSuggestionFeatureConfigOperation from a given name. +// The name must be that of a previously created ClearSuggestionFeatureConfigOperation, possibly from a different process. +func (c *ConversationProfilesClient) ClearSuggestionFeatureConfigOperation(name string) *ClearSuggestionFeatureConfigOperation { + return c.internalClient.ClearSuggestionFeatureConfigOperation(name) +} + // conversationProfilesGRPCClient 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. @@ -213,6 +296,11 @@ type conversationProfilesGRPCClient struct { // The gRPC API client. conversationProfilesClient dialogflowpb.ConversationProfilesClient + // 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 + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -252,6 +340,17 @@ func NewConversationProfilesClient(ctx context.Context, opts ...option.ClientOpt 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 } @@ -406,6 +505,192 @@ func (c *conversationProfilesGRPCClient) DeleteConversationProfile(ctx context.C return err } +func (c *conversationProfilesGRPCClient) SetSuggestionFeatureConfig(ctx context.Context, req *dialogflowpb.SetSuggestionFeatureConfigRequest, opts ...gax.CallOption) (*SetSuggestionFeatureConfigOperation, 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", "conversation_profile", url.QueryEscape(req.GetConversationProfile()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).SetSuggestionFeatureConfig[0:len((*c.CallOptions).SetSuggestionFeatureConfig):len((*c.CallOptions).SetSuggestionFeatureConfig)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationProfilesClient.SetSuggestionFeatureConfig(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &SetSuggestionFeatureConfigOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + +func (c *conversationProfilesGRPCClient) ClearSuggestionFeatureConfig(ctx context.Context, req *dialogflowpb.ClearSuggestionFeatureConfigRequest, opts ...gax.CallOption) (*ClearSuggestionFeatureConfigOperation, 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", "conversation_profile", url.QueryEscape(req.GetConversationProfile()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).ClearSuggestionFeatureConfig[0:len((*c.CallOptions).ClearSuggestionFeatureConfig):len((*c.CallOptions).ClearSuggestionFeatureConfig)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.conversationProfilesClient.ClearSuggestionFeatureConfig(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &ClearSuggestionFeatureConfigOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + +// ClearSuggestionFeatureConfigOperation manages a long-running operation from ClearSuggestionFeatureConfig. +type ClearSuggestionFeatureConfigOperation struct { + lro *longrunning.Operation +} + +// ClearSuggestionFeatureConfigOperation returns a new ClearSuggestionFeatureConfigOperation from a given name. +// The name must be that of a previously created ClearSuggestionFeatureConfigOperation, possibly from a different process. +func (c *conversationProfilesGRPCClient) ClearSuggestionFeatureConfigOperation(name string) *ClearSuggestionFeatureConfigOperation { + return &ClearSuggestionFeatureConfigOperation{ + 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 *ClearSuggestionFeatureConfigOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.ConversationProfile, error) { + var resp dialogflowpb.ConversationProfile + 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 *ClearSuggestionFeatureConfigOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.ConversationProfile, error) { + var resp dialogflowpb.ConversationProfile + 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 *ClearSuggestionFeatureConfigOperation) Metadata() (*dialogflowpb.ClearSuggestionFeatureConfigOperationMetadata, error) { + var meta dialogflowpb.ClearSuggestionFeatureConfigOperationMetadata + 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 *ClearSuggestionFeatureConfigOperation) 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 *ClearSuggestionFeatureConfigOperation) Name() string { + return op.lro.Name() +} + +// SetSuggestionFeatureConfigOperation manages a long-running operation from SetSuggestionFeatureConfig. +type SetSuggestionFeatureConfigOperation struct { + lro *longrunning.Operation +} + +// SetSuggestionFeatureConfigOperation returns a new SetSuggestionFeatureConfigOperation from a given name. +// The name must be that of a previously created SetSuggestionFeatureConfigOperation, possibly from a different process. +func (c *conversationProfilesGRPCClient) SetSuggestionFeatureConfigOperation(name string) *SetSuggestionFeatureConfigOperation { + return &SetSuggestionFeatureConfigOperation{ + 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 *SetSuggestionFeatureConfigOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.ConversationProfile, error) { + var resp dialogflowpb.ConversationProfile + 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 *SetSuggestionFeatureConfigOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.ConversationProfile, error) { + var resp dialogflowpb.ConversationProfile + 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 *SetSuggestionFeatureConfigOperation) Metadata() (*dialogflowpb.SetSuggestionFeatureConfigOperationMetadata, error) { + var meta dialogflowpb.SetSuggestionFeatureConfigOperationMetadata + 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 *SetSuggestionFeatureConfigOperation) 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 *SetSuggestionFeatureConfigOperation) Name() string { + return op.lro.Name() +} + // ConversationProfileIterator manages a stream of *dialogflowpb.ConversationProfile. type ConversationProfileIterator struct { items []*dialogflowpb.ConversationProfile diff --git a/dialogflow/apiv2/conversation_profiles_client_example_test.go b/dialogflow/apiv2/conversation_profiles_client_example_test.go index 447b8efcb7ab..2a7fdf59b69e 100644 --- a/dialogflow/apiv2/conversation_profiles_client_example_test.go +++ b/dialogflow/apiv2/conversation_profiles_client_example_test.go @@ -139,3 +139,53 @@ func ExampleConversationProfilesClient_DeleteConversationProfile() { // TODO: Handle error. } } + +func ExampleConversationProfilesClient_SetSuggestionFeatureConfig() { + ctx := context.Background() + c, err := dialogflow.NewConversationProfilesClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.SetSuggestionFeatureConfigRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#SetSuggestionFeatureConfigRequest. + } + op, err := c.SetSuggestionFeatureConfig(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleConversationProfilesClient_ClearSuggestionFeatureConfig() { + ctx := context.Background() + c, err := dialogflow.NewConversationProfilesClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.ClearSuggestionFeatureConfigRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#ClearSuggestionFeatureConfigRequest. + } + op, err := c.ClearSuggestionFeatureConfig(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/apiv2/gapic_metadata.json b/dialogflow/apiv2/gapic_metadata.json index fe4a6899d183..63f5ceb2214b 100644 --- a/dialogflow/apiv2/gapic_metadata.json +++ b/dialogflow/apiv2/gapic_metadata.json @@ -117,11 +117,104 @@ } } }, + "ConversationDatasets": { + "clients": { + "grpc": { + "libraryClient": "ConversationDatasetsClient", + "rpcs": { + "CreateConversationDataset": { + "methods": [ + "CreateConversationDataset" + ] + }, + "DeleteConversationDataset": { + "methods": [ + "DeleteConversationDataset" + ] + }, + "GetConversationDataset": { + "methods": [ + "GetConversationDataset" + ] + }, + "ImportConversationData": { + "methods": [ + "ImportConversationData" + ] + }, + "ListConversationDatasets": { + "methods": [ + "ListConversationDatasets" + ] + } + } + } + } + }, + "ConversationModels": { + "clients": { + "grpc": { + "libraryClient": "ConversationModelsClient", + "rpcs": { + "CreateConversationModel": { + "methods": [ + "CreateConversationModel" + ] + }, + "CreateConversationModelEvaluation": { + "methods": [ + "CreateConversationModelEvaluation" + ] + }, + "DeleteConversationModel": { + "methods": [ + "DeleteConversationModel" + ] + }, + "DeployConversationModel": { + "methods": [ + "DeployConversationModel" + ] + }, + "GetConversationModel": { + "methods": [ + "GetConversationModel" + ] + }, + "GetConversationModelEvaluation": { + "methods": [ + "GetConversationModelEvaluation" + ] + }, + "ListConversationModelEvaluations": { + "methods": [ + "ListConversationModelEvaluations" + ] + }, + "ListConversationModels": { + "methods": [ + "ListConversationModels" + ] + }, + "UndeployConversationModel": { + "methods": [ + "UndeployConversationModel" + ] + } + } + } + } + }, "ConversationProfiles": { "clients": { "grpc": { "libraryClient": "ConversationProfilesClient", "rpcs": { + "ClearSuggestionFeatureConfig": { + "methods": [ + "ClearSuggestionFeatureConfig" + ] + }, "CreateConversationProfile": { "methods": [ "CreateConversationProfile" @@ -142,6 +235,11 @@ "ListConversationProfiles" ] }, + "SetSuggestionFeatureConfig": { + "methods": [ + "SetSuggestionFeatureConfig" + ] + }, "UpdateConversationProfile": { "methods": [ "UpdateConversationProfile" diff --git a/dialogflow/go.mod b/dialogflow/go.mod index 0e56db5144f7..acc230c89248 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.70.0 - google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf + google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7 google.golang.org/grpc v1.44.0 google.golang.org/protobuf v1.27.1 ) diff --git a/dialogflow/go.sum b/dialogflow/go.sum index eebcbca7b66b..ce6dd29d9c6c 100644 --- a/dialogflow/go.sum +++ b/dialogflow/go.sum @@ -524,8 +524,8 @@ google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf h1:SVYXkUz2yZS9FWb2Gm8ivSlbNQzL2Z/NpPKE3RG2jWk= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7 h1:ntPPoHzFW6Xp09ueznmahONZufyoSakK/piXnr2BU3I= +google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= 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 9124565e71b5..805d00f1caca 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 google.golang.org/api v0.70.0 - google.golang.org/genproto v0.0.0-20220228155957-1da8797a5878 + google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7 google.golang.org/grpc v1.44.0 google.golang.org/protobuf v1.27.1 ) diff --git a/go.sum b/go.sum index 991624b46455..8aa15d9750c1 100644 --- a/go.sum +++ b/go.sum @@ -529,8 +529,8 @@ google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220228155957-1da8797a5878 h1:gERY0VtsF9UyyyCsPSjRk9/RWlcKSa/Gw/aenR/5z48= -google.golang.org/genproto v0.0.0-20220228155957-1da8797a5878/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7 h1:ntPPoHzFW6Xp09ueznmahONZufyoSakK/piXnr2BU3I= +google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= 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/apiv2/ConversationDatasetsClient/CreateConversationDataset/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/CreateConversationDataset/main.go new file mode 100644 index 000000000000..821dd410ca28 --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/CreateConversationDataset/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 dialogflow_v2_generated_ConversationDatasets_CreateConversationDataset_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationDatasetsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.CreateConversationDatasetRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#CreateConversationDatasetRequest. + } + op, err := c.CreateConversationDataset(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_v2_generated_ConversationDatasets_CreateConversationDataset_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/DeleteConversationDataset/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/DeleteConversationDataset/main.go new file mode 100644 index 000000000000..920f1a754410 --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/DeleteConversationDataset/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 dialogflow_v2_generated_ConversationDatasets_DeleteConversationDataset_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationDatasetsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.DeleteConversationDatasetRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#DeleteConversationDatasetRequest. + } + op, err := c.DeleteConversationDataset(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END dialogflow_v2_generated_ConversationDatasets_DeleteConversationDataset_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/GetConversationDataset/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/GetConversationDataset/main.go new file mode 100644 index 000000000000..cd1307ae3e20 --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/GetConversationDataset/main.go @@ -0,0 +1,48 @@ +// 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 dialogflow_v2_generated_ConversationDatasets_GetConversationDataset_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationDatasetsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.GetConversationDatasetRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#GetConversationDatasetRequest. + } + resp, err := c.GetConversationDataset(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END dialogflow_v2_generated_ConversationDatasets_GetConversationDataset_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/ImportConversationData/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/ImportConversationData/main.go new file mode 100644 index 000000000000..70719c55ba27 --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/ImportConversationData/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 dialogflow_v2_generated_ConversationDatasets_ImportConversationData_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationDatasetsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.ImportConversationDataRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#ImportConversationDataRequest. + } + op, err := c.ImportConversationData(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_v2_generated_ConversationDatasets_ImportConversationData_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/ListConversationDatasets/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/ListConversationDatasets/main.go new file mode 100644 index 000000000000..d3824d5375da --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationDatasetsClient/ListConversationDatasets/main.go @@ -0,0 +1,55 @@ +// 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 dialogflow_v2_generated_ConversationDatasets_ListConversationDatasets_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + "google.golang.org/api/iterator" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationDatasetsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.ListConversationDatasetsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#ListConversationDatasetsRequest. + } + it := c.ListConversationDatasets(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END dialogflow_v2_generated_ConversationDatasets_ListConversationDatasets_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/CreateConversationModel/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/CreateConversationModel/main.go new file mode 100644 index 000000000000..7227059be0ff --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/CreateConversationModel/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 dialogflow_v2_generated_ConversationModels_CreateConversationModel_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.CreateConversationModelRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#CreateConversationModelRequest. + } + op, err := c.CreateConversationModel(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_v2_generated_ConversationModels_CreateConversationModel_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/CreateConversationModelEvaluation/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/CreateConversationModelEvaluation/main.go new file mode 100644 index 000000000000..761ed30e2113 --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/CreateConversationModelEvaluation/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 dialogflow_v2_generated_ConversationModels_CreateConversationModelEvaluation_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.CreateConversationModelEvaluationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#CreateConversationModelEvaluationRequest. + } + op, err := c.CreateConversationModelEvaluation(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_v2_generated_ConversationModels_CreateConversationModelEvaluation_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/DeleteConversationModel/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/DeleteConversationModel/main.go new file mode 100644 index 000000000000..46ed928439f5 --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/DeleteConversationModel/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 dialogflow_v2_generated_ConversationModels_DeleteConversationModel_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.DeleteConversationModelRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#DeleteConversationModelRequest. + } + op, err := c.DeleteConversationModel(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END dialogflow_v2_generated_ConversationModels_DeleteConversationModel_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/DeployConversationModel/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/DeployConversationModel/main.go new file mode 100644 index 000000000000..e23759bb8e40 --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/DeployConversationModel/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 dialogflow_v2_generated_ConversationModels_DeployConversationModel_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.DeployConversationModelRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#DeployConversationModelRequest. + } + op, err := c.DeployConversationModel(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END dialogflow_v2_generated_ConversationModels_DeployConversationModel_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/GetConversationModel/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/GetConversationModel/main.go new file mode 100644 index 000000000000..00ea94f43c2a --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/GetConversationModel/main.go @@ -0,0 +1,48 @@ +// 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 dialogflow_v2_generated_ConversationModels_GetConversationModel_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.GetConversationModelRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#GetConversationModelRequest. + } + resp, err := c.GetConversationModel(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END dialogflow_v2_generated_ConversationModels_GetConversationModel_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/GetConversationModelEvaluation/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/GetConversationModelEvaluation/main.go new file mode 100644 index 000000000000..b5956e0cf3ed --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/GetConversationModelEvaluation/main.go @@ -0,0 +1,48 @@ +// 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 dialogflow_v2_generated_ConversationModels_GetConversationModelEvaluation_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.GetConversationModelEvaluationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#GetConversationModelEvaluationRequest. + } + resp, err := c.GetConversationModelEvaluation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END dialogflow_v2_generated_ConversationModels_GetConversationModelEvaluation_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/ListConversationModelEvaluations/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/ListConversationModelEvaluations/main.go new file mode 100644 index 000000000000..4f027b4098fe --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/ListConversationModelEvaluations/main.go @@ -0,0 +1,55 @@ +// 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 dialogflow_v2_generated_ConversationModels_ListConversationModelEvaluations_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + "google.golang.org/api/iterator" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.ListConversationModelEvaluationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#ListConversationModelEvaluationsRequest. + } + it := c.ListConversationModelEvaluations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END dialogflow_v2_generated_ConversationModels_ListConversationModelEvaluations_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/ListConversationModels/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/ListConversationModels/main.go new file mode 100644 index 000000000000..fad76b6f105e --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/ListConversationModels/main.go @@ -0,0 +1,55 @@ +// 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 dialogflow_v2_generated_ConversationModels_ListConversationModels_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + "google.golang.org/api/iterator" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.ListConversationModelsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#ListConversationModelsRequest. + } + it := c.ListConversationModels(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END dialogflow_v2_generated_ConversationModels_ListConversationModels_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/UndeployConversationModel/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/UndeployConversationModel/main.go new file mode 100644 index 000000000000..37e76d7c929c --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationModelsClient/UndeployConversationModel/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 dialogflow_v2_generated_ConversationModels_UndeployConversationModel_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationModelsClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.UndeployConversationModelRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#UndeployConversationModelRequest. + } + op, err := c.UndeployConversationModel(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END dialogflow_v2_generated_ConversationModels_UndeployConversationModel_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationProfilesClient/ClearSuggestionFeatureConfig/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationProfilesClient/ClearSuggestionFeatureConfig/main.go new file mode 100644 index 000000000000..28d8eb124a6a --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationProfilesClient/ClearSuggestionFeatureConfig/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 dialogflow_v2_generated_ConversationProfiles_ClearSuggestionFeatureConfig_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationProfilesClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.ClearSuggestionFeatureConfigRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#ClearSuggestionFeatureConfigRequest. + } + op, err := c.ClearSuggestionFeatureConfig(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_v2_generated_ConversationProfiles_ClearSuggestionFeatureConfig_sync] diff --git a/internal/generated/snippets/dialogflow/apiv2/ConversationProfilesClient/SetSuggestionFeatureConfig/main.go b/internal/generated/snippets/dialogflow/apiv2/ConversationProfilesClient/SetSuggestionFeatureConfig/main.go new file mode 100644 index 000000000000..ee38ef79a562 --- /dev/null +++ b/internal/generated/snippets/dialogflow/apiv2/ConversationProfilesClient/SetSuggestionFeatureConfig/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 dialogflow_v2_generated_ConversationProfiles_SetSuggestionFeatureConfig_sync] + +package main + +import ( + "context" + + dialogflow "cloud.google.com/go/dialogflow/apiv2" + dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2" +) + +func main() { + ctx := context.Background() + c, err := dialogflow.NewConversationProfilesClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &dialogflowpb.SetSuggestionFeatureConfigRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dialogflow/v2#SetSuggestionFeatureConfigRequest. + } + op, err := c.SetSuggestionFeatureConfig(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_v2_generated_ConversationProfiles_SetSuggestionFeatureConfig_sync] diff --git a/internal/generated/snippets/go.mod b/internal/generated/snippets/go.mod index 563a5c731956..760184722e15 100644 --- a/internal/generated/snippets/go.mod +++ b/internal/generated/snippets/go.mod @@ -111,7 +111,7 @@ require ( cloud.google.com/go/workflows v1.1.0 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect google.golang.org/api v0.70.0 - google.golang.org/genproto v0.0.0-20220228155957-1da8797a5878 + google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7 ) replace cloud.google.com/go/storagetransfer => ../../../storagetransfer diff --git a/internal/generated/snippets/go.sum b/internal/generated/snippets/go.sum index e36b1779a3fe..c27fc871c605 100644 --- a/internal/generated/snippets/go.sum +++ b/internal/generated/snippets/go.sum @@ -167,8 +167,9 @@ google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEc google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220228155957-1da8797a5878 h1:gERY0VtsF9UyyyCsPSjRk9/RWlcKSa/Gw/aenR/5z48= google.golang.org/genproto v0.0.0-20220228155957-1da8797a5878/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7 h1:ntPPoHzFW6Xp09ueznmahONZufyoSakK/piXnr2BU3I= +google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= 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/godocfx/go.sum b/internal/godocfx/go.sum index af1899813978..5eb8c649a700 100644 --- a/internal/godocfx/go.sum +++ b/internal/godocfx/go.sum @@ -344,8 +344,8 @@ google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220228155957-1da8797a5878 h1:gERY0VtsF9UyyyCsPSjRk9/RWlcKSa/Gw/aenR/5z48= -google.golang.org/genproto v0.0.0-20220228155957-1da8797a5878/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7 h1:ntPPoHzFW6Xp09ueznmahONZufyoSakK/piXnr2BU3I= +google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= 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=