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