Debian Codegraph @

dialogflow/apiv2beta1/participants_client.go

raw symbols SCIP
1 // Copyright 2025 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
17 package dialogflow
18
19 import (
20 "bytes"
21 "context"
22 "errors"
23 "fmt"
24 "log/slog"
25 "math"
26 "net/http"
27 "net/url"
28 "time"
29
30 dialogflowpb "cloud.google.com/go/dialogflow/apiv2beta1/dialogflowpb"
31 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
32 gax "github.com/googleapis/gax-go/v2"
33 "google.golang.org/api/iterator"
34 "google.golang.org/api/option"
35 "google.golang.org/api/option/internaloption"
36 gtransport "google.golang.org/api/transport/grpc"
37 httptransport "google.golang.org/api/transport/http"
38 locationpb "google.golang.org/genproto/googleapis/cloud/location"
39 "google.golang.org/grpc"
40 "google.golang.org/grpc/codes"
41 "google.golang.org/protobuf/encoding/protojson"
42 "google.golang.org/protobuf/proto"
43 )
44
45 var newParticipantsClientHook clientHook
46
47 // ParticipantsCallOptions contains the retry settings for each method of ParticipantsClient.
48 type ParticipantsCallOptions struct {
49 CreateParticipant []gax.CallOption
50 GetParticipant []gax.CallOption
51 ListParticipants []gax.CallOption
52 UpdateParticipant []gax.CallOption
53 AnalyzeContent []gax.CallOption
54 StreamingAnalyzeContent []gax.CallOption
55 SuggestArticles []gax.CallOption
56 SuggestFaqAnswers []gax.CallOption
57 SuggestSmartReplies []gax.CallOption
58 SuggestKnowledgeAssist []gax.CallOption
59 ListSuggestions []gax.CallOption
60 CompileSuggestion []gax.CallOption
61 GetLocation []gax.CallOption
62 ListLocations []gax.CallOption
63 CancelOperation []gax.CallOption
64 GetOperation []gax.CallOption
65 ListOperations []gax.CallOption
66 }
67
68 func defaultParticipantsGRPCClientOptions() []option.ClientOption {
69 return []option.ClientOption{
70 internaloption.WithDefaultEndpoint("dialogflow.googleapis.com:443"),
71 internaloption.WithDefaultEndpointTemplate("dialogflow.UNIVERSE_DOMAIN:443"),
72 internaloption.WithDefaultMTLSEndpoint("dialogflow.mtls.googleapis.com:443"),
73 internaloption.WithDefaultUniverseDomain("googleapis.com"),
74 internaloption.WithDefaultAudience("https://dialogflow.googleapis.com/"),
75 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
76 internaloption.EnableJwtWithScope(),
77 internaloption.EnableNewAuthLibrary(),
78 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
79 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
80 }
81 }
82
83 func defaultParticipantsCallOptions() *ParticipantsCallOptions {
84 return &ParticipantsCallOptions{
85 CreateParticipant: []gax.CallOption{
86 gax.WithTimeout(60000 * time.Millisecond),
87 gax.WithRetry(func() gax.Retryer {
88 return gax.OnCodes([]codes.Code{
89 codes.Unavailable,
90 }, gax.Backoff{
91 Initial: 100 * time.Millisecond,
92 Max: 60000 * time.Millisecond,
93 Multiplier: 1.30,
94 })
95 }),
96 },
97 GetParticipant: []gax.CallOption{
98 gax.WithTimeout(60000 * time.Millisecond),
99 gax.WithRetry(func() gax.Retryer {
100 return gax.OnCodes([]codes.Code{
101 codes.Unavailable,
102 }, gax.Backoff{
103 Initial: 100 * time.Millisecond,
104 Max: 60000 * time.Millisecond,
105 Multiplier: 1.30,
106 })
107 }),
108 },
109 ListParticipants: []gax.CallOption{
110 gax.WithTimeout(60000 * time.Millisecond),
111 gax.WithRetry(func() gax.Retryer {
112 return gax.OnCodes([]codes.Code{
113 codes.Unavailable,
114 }, gax.Backoff{
115 Initial: 100 * time.Millisecond,
116 Max: 60000 * time.Millisecond,
117 Multiplier: 1.30,
118 })
119 }),
120 },
121 UpdateParticipant: []gax.CallOption{
122 gax.WithTimeout(60000 * time.Millisecond),
123 gax.WithRetry(func() gax.Retryer {
124 return gax.OnCodes([]codes.Code{
125 codes.Unavailable,
126 }, gax.Backoff{
127 Initial: 100 * time.Millisecond,
128 Max: 60000 * time.Millisecond,
129 Multiplier: 1.30,
130 })
131 }),
132 },
133 AnalyzeContent: []gax.CallOption{
134 gax.WithTimeout(220000 * time.Millisecond),
135 gax.WithRetry(func() gax.Retryer {
136 return gax.OnCodes([]codes.Code{
137 codes.Unavailable,
138 }, gax.Backoff{
139 Initial: 100 * time.Millisecond,
140 Max: 60000 * time.Millisecond,
141 Multiplier: 1.30,
142 })
143 }),
144 },
145 StreamingAnalyzeContent: []gax.CallOption{},
146 SuggestArticles: []gax.CallOption{
147 gax.WithTimeout(60000 * time.Millisecond),
148 gax.WithRetry(func() gax.Retryer {
149 return gax.OnCodes([]codes.Code{
150 codes.Unavailable,
151 }, gax.Backoff{
152 Initial: 100 * time.Millisecond,
153 Max: 60000 * time.Millisecond,
154 Multiplier: 1.30,
155 })
156 }),
157 },
158 SuggestFaqAnswers: []gax.CallOption{
159 gax.WithTimeout(60000 * time.Millisecond),
160 gax.WithRetry(func() gax.Retryer {
161 return gax.OnCodes([]codes.Code{
162 codes.Unavailable,
163 }, gax.Backoff{
164 Initial: 100 * time.Millisecond,
165 Max: 60000 * time.Millisecond,
166 Multiplier: 1.30,
167 })
168 }),
169 },
170 SuggestSmartReplies: []gax.CallOption{
171 gax.WithTimeout(60000 * time.Millisecond),
172 gax.WithRetry(func() gax.Retryer {
173 return gax.OnCodes([]codes.Code{
174 codes.Unavailable,
175 }, gax.Backoff{
176 Initial: 100 * time.Millisecond,
177 Max: 60000 * time.Millisecond,
178 Multiplier: 1.30,
179 })
180 }),
181 },
182 SuggestKnowledgeAssist: []gax.CallOption{
183 gax.WithTimeout(60000 * time.Millisecond),
184 gax.WithRetry(func() gax.Retryer {
185 return gax.OnCodes([]codes.Code{
186 codes.Unavailable,
187 }, gax.Backoff{
188 Initial: 100 * time.Millisecond,
189 Max: 60000 * time.Millisecond,
190 Multiplier: 1.30,
191 })
192 }),
193 },
194 ListSuggestions: []gax.CallOption{
195 gax.WithTimeout(60000 * time.Millisecond),
196 gax.WithRetry(func() gax.Retryer {
197 return gax.OnCodes([]codes.Code{
198 codes.Unavailable,
199 }, gax.Backoff{
200 Initial: 100 * time.Millisecond,
201 Max: 60000 * time.Millisecond,
202 Multiplier: 1.30,
203 })
204 }),
205 },
206 CompileSuggestion: []gax.CallOption{
207 gax.WithTimeout(60000 * time.Millisecond),
208 gax.WithRetry(func() gax.Retryer {
209 return gax.OnCodes([]codes.Code{
210 codes.Unavailable,
211 }, gax.Backoff{
212 Initial: 100 * time.Millisecond,
213 Max: 60000 * time.Millisecond,
214 Multiplier: 1.30,
215 })
216 }),
217 },
218 GetLocation: []gax.CallOption{},
219 ListLocations: []gax.CallOption{},
220 CancelOperation: []gax.CallOption{},
221 GetOperation: []gax.CallOption{},
222 ListOperations: []gax.CallOption{},
223 }
224 }
225
226 func defaultParticipantsRESTCallOptions() *ParticipantsCallOptions {
227 return &ParticipantsCallOptions{
228 CreateParticipant: []gax.CallOption{
229 gax.WithTimeout(60000 * time.Millisecond),
230 gax.WithRetry(func() gax.Retryer {
231 return gax.OnHTTPCodes(gax.Backoff{
232 Initial: 100 * time.Millisecond,
233 Max: 60000 * time.Millisecond,
234 Multiplier: 1.30,
235 },
236 http.StatusServiceUnavailable)
237 }),
238 },
239 GetParticipant: []gax.CallOption{
240 gax.WithTimeout(60000 * time.Millisecond),
241 gax.WithRetry(func() gax.Retryer {
242 return gax.OnHTTPCodes(gax.Backoff{
243 Initial: 100 * time.Millisecond,
244 Max: 60000 * time.Millisecond,
245 Multiplier: 1.30,
246 },
247 http.StatusServiceUnavailable)
248 }),
249 },
250 ListParticipants: []gax.CallOption{
251 gax.WithTimeout(60000 * time.Millisecond),
252 gax.WithRetry(func() gax.Retryer {
253 return gax.OnHTTPCodes(gax.Backoff{
254 Initial: 100 * time.Millisecond,
255 Max: 60000 * time.Millisecond,
256 Multiplier: 1.30,
257 },
258 http.StatusServiceUnavailable)
259 }),
260 },
261 UpdateParticipant: []gax.CallOption{
262 gax.WithTimeout(60000 * time.Millisecond),
263 gax.WithRetry(func() gax.Retryer {
264 return gax.OnHTTPCodes(gax.Backoff{
265 Initial: 100 * time.Millisecond,
266 Max: 60000 * time.Millisecond,
267 Multiplier: 1.30,
268 },
269 http.StatusServiceUnavailable)
270 }),
271 },
272 AnalyzeContent: []gax.CallOption{
273 gax.WithTimeout(220000 * time.Millisecond),
274 gax.WithRetry(func() gax.Retryer {
275 return gax.OnHTTPCodes(gax.Backoff{
276 Initial: 100 * time.Millisecond,
277 Max: 60000 * time.Millisecond,
278 Multiplier: 1.30,
279 },
280 http.StatusServiceUnavailable)
281 }),
282 },
283 StreamingAnalyzeContent: []gax.CallOption{
284 gax.WithTimeout(220000 * time.Millisecond),
285 },
286 SuggestArticles: []gax.CallOption{
287 gax.WithTimeout(60000 * time.Millisecond),
288 gax.WithRetry(func() gax.Retryer {
289 return gax.OnHTTPCodes(gax.Backoff{
290 Initial: 100 * time.Millisecond,
291 Max: 60000 * time.Millisecond,
292 Multiplier: 1.30,
293 },
294 http.StatusServiceUnavailable)
295 }),
296 },
297 SuggestFaqAnswers: []gax.CallOption{
298 gax.WithTimeout(60000 * time.Millisecond),
299 gax.WithRetry(func() gax.Retryer {
300 return gax.OnHTTPCodes(gax.Backoff{
301 Initial: 100 * time.Millisecond,
302 Max: 60000 * time.Millisecond,
303 Multiplier: 1.30,
304 },
305 http.StatusServiceUnavailable)
306 }),
307 },
308 SuggestSmartReplies: []gax.CallOption{
309 gax.WithTimeout(60000 * time.Millisecond),
310 gax.WithRetry(func() gax.Retryer {
311 return gax.OnHTTPCodes(gax.Backoff{
312 Initial: 100 * time.Millisecond,
313 Max: 60000 * time.Millisecond,
314 Multiplier: 1.30,
315 },
316 http.StatusServiceUnavailable)
317 }),
318 },
319 SuggestKnowledgeAssist: []gax.CallOption{
320 gax.WithTimeout(60000 * time.Millisecond),
321 gax.WithRetry(func() gax.Retryer {
322 return gax.OnHTTPCodes(gax.Backoff{
323 Initial: 100 * time.Millisecond,
324 Max: 60000 * time.Millisecond,
325 Multiplier: 1.30,
326 },
327 http.StatusServiceUnavailable)
328 }),
329 },
330 ListSuggestions: []gax.CallOption{
331 gax.WithTimeout(60000 * time.Millisecond),
332 gax.WithRetry(func() gax.Retryer {
333 return gax.OnHTTPCodes(gax.Backoff{
334 Initial: 100 * time.Millisecond,
335 Max: 60000 * time.Millisecond,
336 Multiplier: 1.30,
337 },
338 http.StatusServiceUnavailable)
339 }),
340 },
341 CompileSuggestion: []gax.CallOption{
342 gax.WithTimeout(60000 * time.Millisecond),
343 gax.WithRetry(func() gax.Retryer {
344 return gax.OnHTTPCodes(gax.Backoff{
345 Initial: 100 * time.Millisecond,
346 Max: 60000 * time.Millisecond,
347 Multiplier: 1.30,
348 },
349 http.StatusServiceUnavailable)
350 }),
351 },
352 GetLocation: []gax.CallOption{},
353 ListLocations: []gax.CallOption{},
354 CancelOperation: []gax.CallOption{},
355 GetOperation: []gax.CallOption{},
356 ListOperations: []gax.CallOption{},
357 }
358 }
359
360 // internalParticipantsClient is an interface that defines the methods available from Dialogflow API.
361 type internalParticipantsClient interface {
362 Close() error
363 setGoogleClientInfo(...string)
364 Connection() *grpc.ClientConn
365 CreateParticipant(context.Context, *dialogflowpb.CreateParticipantRequest, ...gax.CallOption) (*dialogflowpb.Participant, error)
366 GetParticipant(context.Context, *dialogflowpb.GetParticipantRequest, ...gax.CallOption) (*dialogflowpb.Participant, error)
367 ListParticipants(context.Context, *dialogflowpb.ListParticipantsRequest, ...gax.CallOption) *ParticipantIterator
368 UpdateParticipant(context.Context, *dialogflowpb.UpdateParticipantRequest, ...gax.CallOption) (*dialogflowpb.Participant, error)
369 AnalyzeContent(context.Context, *dialogflowpb.AnalyzeContentRequest, ...gax.CallOption) (*dialogflowpb.AnalyzeContentResponse, error)
370 StreamingAnalyzeContent(context.Context, ...gax.CallOption) (dialogflowpb.Participants_StreamingAnalyzeContentClient, error)
371 SuggestArticles(context.Context, *dialogflowpb.SuggestArticlesRequest, ...gax.CallOption) (*dialogflowpb.SuggestArticlesResponse, error)
372 SuggestFaqAnswers(context.Context, *dialogflowpb.SuggestFaqAnswersRequest, ...gax.CallOption) (*dialogflowpb.SuggestFaqAnswersResponse, error)
373 SuggestSmartReplies(context.Context, *dialogflowpb.SuggestSmartRepliesRequest, ...gax.CallOption) (*dialogflowpb.SuggestSmartRepliesResponse, error)
374 SuggestKnowledgeAssist(context.Context, *dialogflowpb.SuggestKnowledgeAssistRequest, ...gax.CallOption) (*dialogflowpb.SuggestKnowledgeAssistResponse, error)
375 ListSuggestions(context.Context, *dialogflowpb.ListSuggestionsRequest, ...gax.CallOption) *SuggestionIterator
376 CompileSuggestion(context.Context, *dialogflowpb.CompileSuggestionRequest, ...gax.CallOption) (*dialogflowpb.CompileSuggestionResponse, error)
377 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
378 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
379 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
380 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
381 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
382 }
383
384 // ParticipantsClient is a client for interacting with Dialogflow API.
385 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
386 //
387 // Service for managing
388 // Participants.
389 type ParticipantsClient struct {
390 // The internal transport-dependent client.
391 internalClient internalParticipantsClient
392
393 // The call options for this service.
394 CallOptions *ParticipantsCallOptions
395 }
396
397 // Wrapper methods routed to the internal client.
398
399 // Close closes the connection to the API service. The user should invoke this when
400 // the client is no longer required.
401 func (c *ParticipantsClient) Close() error {
402 return c.internalClient.Close()
403 }
404
405 // setGoogleClientInfo sets the name and version of the application in
406 // the `x-goog-api-client` header passed on each request. Intended for
407 // use by Google-written clients.
408 func (c *ParticipantsClient) setGoogleClientInfo(keyval ...string) {
409 c.internalClient.setGoogleClientInfo(keyval...)
410 }
411
412 // Connection returns a connection to the API service.
413 //
414 // Deprecated: Connections are now pooled so this method does not always
415 // return the same resource.
416 func (c *ParticipantsClient) Connection() *grpc.ClientConn {
417 return c.internalClient.Connection()
418 }
419
420 // CreateParticipant creates a new participant in a conversation.
421 func (c *ParticipantsClient) CreateParticipant(ctx context.Context, req *dialogflowpb.CreateParticipantRequest, opts ...gax.CallOption) (*dialogflowpb.Participant, error) {
422 return c.internalClient.CreateParticipant(ctx, req, opts...)
423 }
424
425 // GetParticipant retrieves a conversation participant.
426 func (c *ParticipantsClient) GetParticipant(ctx context.Context, req *dialogflowpb.GetParticipantRequest, opts ...gax.CallOption) (*dialogflowpb.Participant, error) {
427 return c.internalClient.GetParticipant(ctx, req, opts...)
428 }
429
430 // ListParticipants returns the list of all participants in the specified conversation.
431 func (c *ParticipantsClient) ListParticipants(ctx context.Context, req *dialogflowpb.ListParticipantsRequest, opts ...gax.CallOption) *ParticipantIterator {
432 return c.internalClient.ListParticipants(ctx, req, opts...)
433 }
434
435 // UpdateParticipant updates the specified participant.
436 func (c *ParticipantsClient) UpdateParticipant(ctx context.Context, req *dialogflowpb.UpdateParticipantRequest, opts ...gax.CallOption) (*dialogflowpb.Participant, error) {
437 return c.internalClient.UpdateParticipant(ctx, req, opts...)
438 }
439
440 // AnalyzeContent adds a text (chat, for example), or audio (phone recording, for example)
441 // message from a participant into the conversation.
442 //
443 // Note: Always use agent versions for production traffic
444 // sent to virtual agents. See Versions and
445 // environments (at https://cloud.google.com/dialogflow/es/docs/agents-versions).
446 func (c *ParticipantsClient) AnalyzeContent(ctx context.Context, req *dialogflowpb.AnalyzeContentRequest, opts ...gax.CallOption) (*dialogflowpb.AnalyzeContentResponse, error) {
447 return c.internalClient.AnalyzeContent(ctx, req, opts...)
448 }
449
450 // StreamingAnalyzeContent adds a text (e.g., chat) or audio (e.g., phone recording) message from a
451 // participant into the conversation.
452 // Note: This method is only available through the gRPC API (not REST).
453 //
454 // The top-level message sent to the client by the server is
455 // StreamingAnalyzeContentResponse. Multiple response messages can be
456 // returned in order. The first one or more messages contain the
457 // recognition_result field. Each result represents a more complete
458 // transcript of what the user said. The next message contains the
459 // reply_text field, and potentially the reply_audio and/or the
460 // automated_agent_reply fields.
461 //
462 // Note: Always use agent versions for production traffic
463 // sent to virtual agents. See Versions and
464 // environments (at https://cloud.google.com/dialogflow/es/docs/agents-versions).
465 //
466 // This method is not supported for the REST transport.
467 func (c *ParticipantsClient) StreamingAnalyzeContent(ctx context.Context, opts ...gax.CallOption) (dialogflowpb.Participants_StreamingAnalyzeContentClient, error) {
468 return c.internalClient.StreamingAnalyzeContent(ctx, opts...)
469 }
470
471 // SuggestArticles gets suggested articles for a participant based on specific historical
472 // messages.
473 //
474 // Note that
475 // ListSuggestions
476 // will only list the auto-generated suggestions, while
477 // CompileSuggestion
478 // will try to compile suggestion based on the provided conversation context
479 // in the real time.
480 func (c *ParticipantsClient) SuggestArticles(ctx context.Context, req *dialogflowpb.SuggestArticlesRequest, opts ...gax.CallOption) (*dialogflowpb.SuggestArticlesResponse, error) {
481 return c.internalClient.SuggestArticles(ctx, req, opts...)
482 }
483
484 // SuggestFaqAnswers gets suggested faq answers for a participant based on specific historical
485 // messages.
486 func (c *ParticipantsClient) SuggestFaqAnswers(ctx context.Context, req *dialogflowpb.SuggestFaqAnswersRequest, opts ...gax.CallOption) (*dialogflowpb.SuggestFaqAnswersResponse, error) {
487 return c.internalClient.SuggestFaqAnswers(ctx, req, opts...)
488 }
489
490 // SuggestSmartReplies gets smart replies for a participant based on specific historical
491 // messages.
492 func (c *ParticipantsClient) SuggestSmartReplies(ctx context.Context, req *dialogflowpb.SuggestSmartRepliesRequest, opts ...gax.CallOption) (*dialogflowpb.SuggestSmartRepliesResponse, error) {
493 return c.internalClient.SuggestSmartReplies(ctx, req, opts...)
494 }
495
496 // SuggestKnowledgeAssist gets knowledge assist suggestions based on historical messages.
497 func (c *ParticipantsClient) SuggestKnowledgeAssist(ctx context.Context, req *dialogflowpb.SuggestKnowledgeAssistRequest, opts ...gax.CallOption) (*dialogflowpb.SuggestKnowledgeAssistResponse, error) {
498 return c.internalClient.SuggestKnowledgeAssist(ctx, req, opts...)
499 }
500
501 // ListSuggestions deprecated: Use inline suggestion, event based suggestion or
502 // Suggestion* API instead.
503 // See
504 // [HumanAgentAssistantConfig.name (at http://HumanAgentAssistantConfig.name)][google.cloud.dialogflow.v2beta1.HumanAgentAssistantConfig.name (at http://google.cloud.dialogflow.v2beta1.HumanAgentAssistantConfig.name)]
505 // for more details. Removal Date: 2020-09-01.
506 //
507 // Retrieves suggestions for live agents.
508 //
509 // This method should be used by human agent client software to fetch auto
510 // generated suggestions in real-time, while the conversation with an end user
511 // is in progress. The functionality is implemented in terms of the
512 // list
513 // pagination (at https://cloud.google.com/apis/design/design_patterns#list_pagination)
514 // design pattern. The client app should use the next_page_token field
515 // to fetch the next batch of suggestions. suggestions are sorted by
516 // create_time in descending order.
517 // To fetch latest suggestion, just set page_size to 1.
518 // To fetch new suggestions without duplication, send request with filter
519 // create_time_epoch_microseconds > [first item's create_time of previous request] and empty page_token.
520 //
521 // Deprecated: ListSuggestions may be removed in a future version.
522 func (c *ParticipantsClient) ListSuggestions(ctx context.Context, req *dialogflowpb.ListSuggestionsRequest, opts ...gax.CallOption) *SuggestionIterator {
523 return c.internalClient.ListSuggestions(ctx, req, opts...)
524 }
525
526 // CompileSuggestion deprecated. use
527 // SuggestArticles
528 // and
529 // SuggestFaqAnswers
530 // instead.
531 //
532 // Gets suggestions for a participant based on specific historical
533 // messages.
534 //
535 // Note that
536 // ListSuggestions
537 // will only list the auto-generated suggestions, while
538 // CompileSuggestion
539 // will try to compile suggestion based on the provided conversation context
540 // in the real time.
541 //
542 // Deprecated: CompileSuggestion may be removed in a future version.
543 func (c *ParticipantsClient) CompileSuggestion(ctx context.Context, req *dialogflowpb.CompileSuggestionRequest, opts ...gax.CallOption) (*dialogflowpb.CompileSuggestionResponse, error) {
544 return c.internalClient.CompileSuggestion(ctx, req, opts...)
545 }
546
547 // GetLocation gets information about a location.
548 func (c *ParticipantsClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
549 return c.internalClient.GetLocation(ctx, req, opts...)
550 }
551
552 // ListLocations lists information about the supported locations for this service.
553 func (c *ParticipantsClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
554 return c.internalClient.ListLocations(ctx, req, opts...)
555 }
556
557 // CancelOperation is a utility method from google.longrunning.Operations.
558 func (c *ParticipantsClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
559 return c.internalClient.CancelOperation(ctx, req, opts...)
560 }
561
562 // GetOperation is a utility method from google.longrunning.Operations.
563 func (c *ParticipantsClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
564 return c.internalClient.GetOperation(ctx, req, opts...)
565 }
566
567 // ListOperations is a utility method from google.longrunning.Operations.
568 func (c *ParticipantsClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
569 return c.internalClient.ListOperations(ctx, req, opts...)
570 }
571
572 // participantsGRPCClient is a client for interacting with Dialogflow API over gRPC transport.
573 //
574 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
575 type participantsGRPCClient struct {
576 // Connection pool of gRPC connections to the service.
577 connPool gtransport.ConnPool
578
579 // Points back to the CallOptions field of the containing ParticipantsClient
580 CallOptions **ParticipantsCallOptions
581
582 // The gRPC API client.
583 participantsClient dialogflowpb.ParticipantsClient
584
585 operationsClient longrunningpb.OperationsClient
586
587 locationsClient locationpb.LocationsClient
588
589 // The x-goog-* metadata to be sent with each request.
590 xGoogHeaders []string
591
592 logger *slog.Logger
593 }
594
595 // NewParticipantsClient creates a new participants client based on gRPC.
596 // The returned client must be Closed when it is done being used to clean up its underlying connections.
597 //
598 // Service for managing
599 // Participants.
600 func NewParticipantsClient(ctx context.Context, opts ...option.ClientOption) (*ParticipantsClient, error) {
601 clientOpts := defaultParticipantsGRPCClientOptions()
602 if newParticipantsClientHook != nil {
603 hookOpts, err := newParticipantsClientHook(ctx, clientHookParams{})
604 if err != nil {
605 return nil, err
606 }
607 clientOpts = append(clientOpts, hookOpts...)
608 }
609
610 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
611 if err != nil {
612 return nil, err
613 }
614 client := ParticipantsClient{CallOptions: defaultParticipantsCallOptions()}
615
616 c := &participantsGRPCClient{
617 connPool: connPool,
618 participantsClient: dialogflowpb.NewParticipantsClient(connPool),
619 CallOptions: &client.CallOptions,
620 logger: internaloption.GetLogger(opts),
621 operationsClient: longrunningpb.NewOperationsClient(connPool),
622 locationsClient: locationpb.NewLocationsClient(connPool),
623 }
624 c.setGoogleClientInfo()
625
626 client.internalClient = c
627
628 return &client, nil
629 }
630
631 // Connection returns a connection to the API service.
632 //
633 // Deprecated: Connections are now pooled so this method does not always
634 // return the same resource.
635 func (c *participantsGRPCClient) Connection() *grpc.ClientConn {
636 return c.connPool.Conn()
637 }
638
639 // setGoogleClientInfo sets the name and version of the application in
640 // the `x-goog-api-client` header passed on each request. Intended for
641 // use by Google-written clients.
642 func (c *participantsGRPCClient) setGoogleClientInfo(keyval ...string) {
643 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
644 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
645 c.xGoogHeaders = []string{
646 "x-goog-api-client", gax.XGoogHeader(kv...),
647 }
648 }
649
650 // Close closes the connection to the API service. The user should invoke this when
651 // the client is no longer required.
652 func (c *participantsGRPCClient) Close() error {
653 return c.connPool.Close()
654 }
655
656 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
657 type participantsRESTClient struct {
658 // The http endpoint to connect to.
659 endpoint string
660
661 // The http client.
662 httpClient *http.Client
663
664 // The x-goog-* headers to be sent with each request.
665 xGoogHeaders []string
666
667 // Points back to the CallOptions field of the containing ParticipantsClient
668 CallOptions **ParticipantsCallOptions
669
670 logger *slog.Logger
671 }
672
673 // NewParticipantsRESTClient creates a new participants rest client.
674 //
675 // Service for managing
676 // Participants.
677 func NewParticipantsRESTClient(ctx context.Context, opts ...option.ClientOption) (*ParticipantsClient, error) {
678 clientOpts := append(defaultParticipantsRESTClientOptions(), opts...)
679 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
680 if err != nil {
681 return nil, err
682 }
683
684 callOpts := defaultParticipantsRESTCallOptions()
685 c := &participantsRESTClient{
686 endpoint: endpoint,
687 httpClient: httpClient,
688 CallOptions: &callOpts,
689 logger: internaloption.GetLogger(opts),
690 }
691 c.setGoogleClientInfo()
692
693 return &ParticipantsClient{internalClient: c, CallOptions: callOpts}, nil
694 }
695
696 func defaultParticipantsRESTClientOptions() []option.ClientOption {
697 return []option.ClientOption{
698 internaloption.WithDefaultEndpoint("https://dialogflow.googleapis.com"),
699 internaloption.WithDefaultEndpointTemplate("https://dialogflow.UNIVERSE_DOMAIN"),
700 internaloption.WithDefaultMTLSEndpoint("https://dialogflow.mtls.googleapis.com"),
701 internaloption.WithDefaultUniverseDomain("googleapis.com"),
702 internaloption.WithDefaultAudience("https://dialogflow.googleapis.com/"),
703 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
704 internaloption.EnableNewAuthLibrary(),
705 }
706 }
707
708 // setGoogleClientInfo sets the name and version of the application in
709 // the `x-goog-api-client` header passed on each request. Intended for
710 // use by Google-written clients.
711 func (c *participantsRESTClient) setGoogleClientInfo(keyval ...string) {
712 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
713 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
714 c.xGoogHeaders = []string{
715 "x-goog-api-client", gax.XGoogHeader(kv...),
716 }
717 }
718
719 // Close closes the connection to the API service. The user should invoke this when
720 // the client is no longer required.
721 func (c *participantsRESTClient) Close() error {
722 // Replace httpClient with nil to force cleanup.
723 c.httpClient = nil
724 return nil
725 }
726
727 // Connection returns a connection to the API service.
728 //
729 // Deprecated: This method always returns nil.
730 func (c *participantsRESTClient) Connection() *grpc.ClientConn {
731 return nil
732 }
733 func (c *participantsGRPCClient) CreateParticipant(ctx context.Context, req *dialogflowpb.CreateParticipantRequest, opts ...gax.CallOption) (*dialogflowpb.Participant, error) {
734 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
735
736 hds = append(c.xGoogHeaders, hds...)
737 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
738 opts = append((*c.CallOptions).CreateParticipant[0:len((*c.CallOptions).CreateParticipant):len((*c.CallOptions).CreateParticipant)], opts...)
739 var resp *dialogflowpb.Participant
740 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
741 var err error
742 resp, err = executeRPC(ctx, c.participantsClient.CreateParticipant, req, settings.GRPC, c.logger, "CreateParticipant")
743 return err
744 }, opts...)
745 if err != nil {
746 return nil, err
747 }
748 return resp, nil
749 }
750
751 func (c *participantsGRPCClient) GetParticipant(ctx context.Context, req *dialogflowpb.GetParticipantRequest, opts ...gax.CallOption) (*dialogflowpb.Participant, error) {
752 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
753
754 hds = append(c.xGoogHeaders, hds...)
755 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
756 opts = append((*c.CallOptions).GetParticipant[0:len((*c.CallOptions).GetParticipant):len((*c.CallOptions).GetParticipant)], opts...)
757 var resp *dialogflowpb.Participant
758 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
759 var err error
760 resp, err = executeRPC(ctx, c.participantsClient.GetParticipant, req, settings.GRPC, c.logger, "GetParticipant")
761 return err
762 }, opts...)
763 if err != nil {
764 return nil, err
765 }
766 return resp, nil
767 }
768
769 func (c *participantsGRPCClient) ListParticipants(ctx context.Context, req *dialogflowpb.ListParticipantsRequest, opts ...gax.CallOption) *ParticipantIterator {
770 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
771
772 hds = append(c.xGoogHeaders, hds...)
773 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
774 opts = append((*c.CallOptions).ListParticipants[0:len((*c.CallOptions).ListParticipants):len((*c.CallOptions).ListParticipants)], opts...)
775 it := &ParticipantIterator{}
776 req = proto.Clone(req).(*dialogflowpb.ListParticipantsRequest)
777 it.InternalFetch = func(pageSize int, pageToken string) ([]*dialogflowpb.Participant, string, error) {
778 resp := &dialogflowpb.ListParticipantsResponse{}
779 if pageToken != "" {
780 req.PageToken = pageToken
781 }
782 if pageSize > math.MaxInt32 {
783 req.PageSize = math.MaxInt32
784 } else if pageSize != 0 {
785 req.PageSize = int32(pageSize)
786 }
787 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
788 var err error
789 resp, err = executeRPC(ctx, c.participantsClient.ListParticipants, req, settings.GRPC, c.logger, "ListParticipants")
790 return err
791 }, opts...)
792 if err != nil {
793 return nil, "", err
794 }
795
796 it.Response = resp
797 return resp.GetParticipants(), resp.GetNextPageToken(), nil
798 }
799 fetch := func(pageSize int, pageToken string) (string, error) {
800 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
801 if err != nil {
802 return "", err
803 }
804 it.items = append(it.items, items...)
805 return nextPageToken, nil
806 }
807
808 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
809 it.pageInfo.MaxSize = int(req.GetPageSize())
810 it.pageInfo.Token = req.GetPageToken()
811
812 return it
813 }
814
815 func (c *participantsGRPCClient) UpdateParticipant(ctx context.Context, req *dialogflowpb.UpdateParticipantRequest, opts ...gax.CallOption) (*dialogflowpb.Participant, error) {
816 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "participant.name", url.QueryEscape(req.GetParticipant().GetName()))}
817
818 hds = append(c.xGoogHeaders, hds...)
819 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
820 opts = append((*c.CallOptions).UpdateParticipant[0:len((*c.CallOptions).UpdateParticipant):len((*c.CallOptions).UpdateParticipant)], opts...)
821 var resp *dialogflowpb.Participant
822 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
823 var err error
824 resp, err = executeRPC(ctx, c.participantsClient.UpdateParticipant, req, settings.GRPC, c.logger, "UpdateParticipant")
825 return err
826 }, opts...)
827 if err != nil {
828 return nil, err
829 }
830 return resp, nil
831 }
832
833 func (c *participantsGRPCClient) AnalyzeContent(ctx context.Context, req *dialogflowpb.AnalyzeContentRequest, opts ...gax.CallOption) (*dialogflowpb.AnalyzeContentResponse, error) {
834 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "participant", url.QueryEscape(req.GetParticipant()))}
835
836 hds = append(c.xGoogHeaders, hds...)
837 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
838 opts = append((*c.CallOptions).AnalyzeContent[0:len((*c.CallOptions).AnalyzeContent):len((*c.CallOptions).AnalyzeContent)], opts...)
839 var resp *dialogflowpb.AnalyzeContentResponse
840 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
841 var err error
842 resp, err = executeRPC(ctx, c.participantsClient.AnalyzeContent, req, settings.GRPC, c.logger, "AnalyzeContent")
843 return err
844 }, opts...)
845 if err != nil {
846 return nil, err
847 }
848 return resp, nil
849 }
850
851 func (c *participantsGRPCClient) StreamingAnalyzeContent(ctx context.Context, opts ...gax.CallOption) (dialogflowpb.Participants_StreamingAnalyzeContentClient, error) {
852 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
853 var resp dialogflowpb.Participants_StreamingAnalyzeContentClient
854 opts = append((*c.CallOptions).StreamingAnalyzeContent[0:len((*c.CallOptions).StreamingAnalyzeContent):len((*c.CallOptions).StreamingAnalyzeContent)], opts...)
855 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
856 var err error
857 c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "StreamingAnalyzeContent")
858 resp, err = c.participantsClient.StreamingAnalyzeContent(ctx, settings.GRPC...)
859 c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "StreamingAnalyzeContent")
860 return err
861 }, opts...)
862 if err != nil {
863 return nil, err
864 }
865 return resp, nil
866 }
867
868 func (c *participantsGRPCClient) SuggestArticles(ctx context.Context, req *dialogflowpb.SuggestArticlesRequest, opts ...gax.CallOption) (*dialogflowpb.SuggestArticlesResponse, error) {
869 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
870
871 hds = append(c.xGoogHeaders, hds...)
872 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
873 opts = append((*c.CallOptions).SuggestArticles[0:len((*c.CallOptions).SuggestArticles):len((*c.CallOptions).SuggestArticles)], opts...)
874 var resp *dialogflowpb.SuggestArticlesResponse
875 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
876 var err error
877 resp, err = executeRPC(ctx, c.participantsClient.SuggestArticles, req, settings.GRPC, c.logger, "SuggestArticles")
878 return err
879 }, opts...)
880 if err != nil {
881 return nil, err
882 }
883 return resp, nil
884 }
885
886 func (c *participantsGRPCClient) SuggestFaqAnswers(ctx context.Context, req *dialogflowpb.SuggestFaqAnswersRequest, opts ...gax.CallOption) (*dialogflowpb.SuggestFaqAnswersResponse, error) {
887 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
888
889 hds = append(c.xGoogHeaders, hds...)
890 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
891 opts = append((*c.CallOptions).SuggestFaqAnswers[0:len((*c.CallOptions).SuggestFaqAnswers):len((*c.CallOptions).SuggestFaqAnswers)], opts...)
892 var resp *dialogflowpb.SuggestFaqAnswersResponse
893 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
894 var err error
895 resp, err = executeRPC(ctx, c.participantsClient.SuggestFaqAnswers, req, settings.GRPC, c.logger, "SuggestFaqAnswers")
896 return err
897 }, opts...)
898 if err != nil {
899 return nil, err
900 }
901 return resp, nil
902 }
903
904 func (c *participantsGRPCClient) SuggestSmartReplies(ctx context.Context, req *dialogflowpb.SuggestSmartRepliesRequest, opts ...gax.CallOption) (*dialogflowpb.SuggestSmartRepliesResponse, error) {
905 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
906
907 hds = append(c.xGoogHeaders, hds...)
908 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
909 opts = append((*c.CallOptions).SuggestSmartReplies[0:len((*c.CallOptions).SuggestSmartReplies):len((*c.CallOptions).SuggestSmartReplies)], opts...)
910 var resp *dialogflowpb.SuggestSmartRepliesResponse
911 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
912 var err error
913 resp, err = executeRPC(ctx, c.participantsClient.SuggestSmartReplies, req, settings.GRPC, c.logger, "SuggestSmartReplies")
914 return err
915 }, opts...)
916 if err != nil {
917 return nil, err
918 }
919 return resp, nil
920 }
921
922 func (c *participantsGRPCClient) SuggestKnowledgeAssist(ctx context.Context, req *dialogflowpb.SuggestKnowledgeAssistRequest, opts ...gax.CallOption) (*dialogflowpb.SuggestKnowledgeAssistResponse, error) {
923 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
924
925 hds = append(c.xGoogHeaders, hds...)
926 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
927 opts = append((*c.CallOptions).SuggestKnowledgeAssist[0:len((*c.CallOptions).SuggestKnowledgeAssist):len((*c.CallOptions).SuggestKnowledgeAssist)], opts...)
928 var resp *dialogflowpb.SuggestKnowledgeAssistResponse
929 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
930 var err error
931 resp, err = executeRPC(ctx, c.participantsClient.SuggestKnowledgeAssist, req, settings.GRPC, c.logger, "SuggestKnowledgeAssist")
932 return err
933 }, opts...)
934 if err != nil {
935 return nil, err
936 }
937 return resp, nil
938 }
939
940 func (c *participantsGRPCClient) ListSuggestions(ctx context.Context, req *dialogflowpb.ListSuggestionsRequest, opts ...gax.CallOption) *SuggestionIterator {
941 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
942
943 hds = append(c.xGoogHeaders, hds...)
944 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
945 opts = append((*c.CallOptions).ListSuggestions[0:len((*c.CallOptions).ListSuggestions):len((*c.CallOptions).ListSuggestions)], opts...)
946 it := &SuggestionIterator{}
947 req = proto.Clone(req).(*dialogflowpb.ListSuggestionsRequest)
948 it.InternalFetch = func(pageSize int, pageToken string) ([]*dialogflowpb.Suggestion, string, error) {
949 resp := &dialogflowpb.ListSuggestionsResponse{}
950 if pageToken != "" {
951 req.PageToken = pageToken
952 }
953 if pageSize > math.MaxInt32 {
954 req.PageSize = math.MaxInt32
955 } else if pageSize != 0 {
956 req.PageSize = int32(pageSize)
957 }
958 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
959 var err error
960 resp, err = executeRPC(ctx, c.participantsClient.ListSuggestions, req, settings.GRPC, c.logger, "ListSuggestions")
961 return err
962 }, opts...)
963 if err != nil {
964 return nil, "", err
965 }
966
967 it.Response = resp
968 return resp.GetSuggestions(), resp.GetNextPageToken(), nil
969 }
970 fetch := func(pageSize int, pageToken string) (string, error) {
971 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
972 if err != nil {
973 return "", err
974 }
975 it.items = append(it.items, items...)
976 return nextPageToken, nil
977 }
978
979 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
980 it.pageInfo.MaxSize = int(req.GetPageSize())
981 it.pageInfo.Token = req.GetPageToken()
982
983 return it
984 }
985
986 func (c *participantsGRPCClient) CompileSuggestion(ctx context.Context, req *dialogflowpb.CompileSuggestionRequest, opts ...gax.CallOption) (*dialogflowpb.CompileSuggestionResponse, error) {
987 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
988
989 hds = append(c.xGoogHeaders, hds...)
990 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
991 opts = append((*c.CallOptions).CompileSuggestion[0:len((*c.CallOptions).CompileSuggestion):len((*c.CallOptions).CompileSuggestion)], opts...)
992 var resp *dialogflowpb.CompileSuggestionResponse
993 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
994 var err error
995 resp, err = executeRPC(ctx, c.participantsClient.CompileSuggestion, req, settings.GRPC, c.logger, "CompileSuggestion")
996 return err
997 }, opts...)
998 if err != nil {
999 return nil, err
1000 }
1001 return resp, nil
1002 }
1003
1004 func (c *participantsGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
1005 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1006
1007 hds = append(c.xGoogHeaders, hds...)
1008 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1009 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
1010 var resp *locationpb.Location
1011 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1012 var err error
1013 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
1014 return err
1015 }, opts...)
1016 if err != nil {
1017 return nil, err
1018 }
1019 return resp, nil
1020 }
1021
1022 func (c *participantsGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
1023 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1024
1025 hds = append(c.xGoogHeaders, hds...)
1026 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1027 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
1028 it := &LocationIterator{}
1029 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
1030 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
1031 resp := &locationpb.ListLocationsResponse{}
1032 if pageToken != "" {
1033 req.PageToken = pageToken
1034 }
1035 if pageSize > math.MaxInt32 {
1036 req.PageSize = math.MaxInt32
1037 } else if pageSize != 0 {
1038 req.PageSize = int32(pageSize)
1039 }
1040 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1041 var err error
1042 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
1043 return err
1044 }, opts...)
1045 if err != nil {
1046 return nil, "", err
1047 }
1048
1049 it.Response = resp
1050 return resp.GetLocations(), resp.GetNextPageToken(), nil
1051 }
1052 fetch := func(pageSize int, pageToken string) (string, error) {
1053 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1054 if err != nil {
1055 return "", err
1056 }
1057 it.items = append(it.items, items...)
1058 return nextPageToken, nil
1059 }
1060
1061 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1062 it.pageInfo.MaxSize = int(req.GetPageSize())
1063 it.pageInfo.Token = req.GetPageToken()
1064
1065 return it
1066 }
1067
1068 func (c *participantsGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
1069 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1070
1071 hds = append(c.xGoogHeaders, hds...)
1072 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1073 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
1074 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1075 var err error
1076 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
1077 return err
1078 }, opts...)
1079 return err
1080 }
1081
1082 func (c *participantsGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
1083 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1084
1085 hds = append(c.xGoogHeaders, hds...)
1086 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1087 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
1088 var resp *longrunningpb.Operation
1089 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1090 var err error
1091 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
1092 return err
1093 }, opts...)
1094 if err != nil {
1095 return nil, err
1096 }
1097 return resp, nil
1098 }
1099
1100 func (c *participantsGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
1101 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1102
1103 hds = append(c.xGoogHeaders, hds...)
1104 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1105 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
1106 it := &OperationIterator{}
1107 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
1108 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
1109 resp := &longrunningpb.ListOperationsResponse{}
1110 if pageToken != "" {
1111 req.PageToken = pageToken
1112 }
1113 if pageSize > math.MaxInt32 {
1114 req.PageSize = math.MaxInt32
1115 } else if pageSize != 0 {
1116 req.PageSize = int32(pageSize)
1117 }
1118 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1119 var err error
1120 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
1121 return err
1122 }, opts...)
1123 if err != nil {
1124 return nil, "", err
1125 }
1126
1127 it.Response = resp
1128 return resp.GetOperations(), resp.GetNextPageToken(), nil
1129 }
1130 fetch := func(pageSize int, pageToken string) (string, error) {
1131 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1132 if err != nil {
1133 return "", err
1134 }
1135 it.items = append(it.items, items...)
1136 return nextPageToken, nil
1137 }
1138
1139 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1140 it.pageInfo.MaxSize = int(req.GetPageSize())
1141 it.pageInfo.Token = req.GetPageToken()
1142
1143 return it
1144 }
1145
1146 // CreateParticipant creates a new participant in a conversation.
1147 func (c *participantsRESTClient) CreateParticipant(ctx context.Context, req *dialogflowpb.CreateParticipantRequest, opts ...gax.CallOption) (*dialogflowpb.Participant, error) {
1148 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1149 body := req.GetParticipant()
1150 jsonReq, err := m.Marshal(body)
1151 if err != nil {
1152 return nil, err
1153 }
1154
1155 baseUrl, err := url.Parse(c.endpoint)
1156 if err != nil {
1157 return nil, err
1158 }
1159 baseUrl.Path += fmt.Sprintf("/v2beta1/%v/participants", req.GetParent())
1160
1161 params := url.Values{}
1162 params.Add("$alt", "json;enum-encoding=int")
1163
1164 baseUrl.RawQuery = params.Encode()
1165
1166 // Build HTTP headers from client and context metadata.
1167 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1168
1169 hds = append(c.xGoogHeaders, hds...)
1170 hds = append(hds, "Content-Type", "application/json")
1171 headers := gax.BuildHeaders(ctx, hds...)
1172 opts = append((*c.CallOptions).CreateParticipant[0:len((*c.CallOptions).CreateParticipant):len((*c.CallOptions).CreateParticipant)], opts...)
1173 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1174 resp := &dialogflowpb.Participant{}
1175 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1176 if settings.Path != "" {
1177 baseUrl.Path = settings.Path
1178 }
1179 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1180 if err != nil {
1181 return err
1182 }
1183 httpReq = httpReq.WithContext(ctx)
1184 httpReq.Header = headers
1185
1186 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateParticipant")
1187 if err != nil {
1188 return err
1189 }
1190
1191 if err := unm.Unmarshal(buf, resp); err != nil {
1192 return err
1193 }
1194
1195 return nil
1196 }, opts...)
1197 if e != nil {
1198 return nil, e
1199 }
1200 return resp, nil
1201 }
1202
1203 // GetParticipant retrieves a conversation participant.
1204 func (c *participantsRESTClient) GetParticipant(ctx context.Context, req *dialogflowpb.GetParticipantRequest, opts ...gax.CallOption) (*dialogflowpb.Participant, error) {
1205 baseUrl, err := url.Parse(c.endpoint)
1206 if err != nil {
1207 return nil, err
1208 }
1209 baseUrl.Path += fmt.Sprintf("/v2beta1/%v", req.GetName())
1210
1211 params := url.Values{}
1212 params.Add("$alt", "json;enum-encoding=int")
1213
1214 baseUrl.RawQuery = params.Encode()
1215
1216 // Build HTTP headers from client and context metadata.
1217 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1218
1219 hds = append(c.xGoogHeaders, hds...)
1220 hds = append(hds, "Content-Type", "application/json")
1221 headers := gax.BuildHeaders(ctx, hds...)
1222 opts = append((*c.CallOptions).GetParticipant[0:len((*c.CallOptions).GetParticipant):len((*c.CallOptions).GetParticipant)], opts...)
1223 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1224 resp := &dialogflowpb.Participant{}
1225 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1226 if settings.Path != "" {
1227 baseUrl.Path = settings.Path
1228 }
1229 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1230 if err != nil {
1231 return err
1232 }
1233 httpReq = httpReq.WithContext(ctx)
1234 httpReq.Header = headers
1235
1236 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetParticipant")
1237 if err != nil {
1238 return err
1239 }
1240
1241 if err := unm.Unmarshal(buf, resp); err != nil {
1242 return err
1243 }
1244
1245 return nil
1246 }, opts...)
1247 if e != nil {
1248 return nil, e
1249 }
1250 return resp, nil
1251 }
1252
1253 // ListParticipants returns the list of all participants in the specified conversation.
1254 func (c *participantsRESTClient) ListParticipants(ctx context.Context, req *dialogflowpb.ListParticipantsRequest, opts ...gax.CallOption) *ParticipantIterator {
1255 it := &ParticipantIterator{}
1256 req = proto.Clone(req).(*dialogflowpb.ListParticipantsRequest)
1257 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1258 it.InternalFetch = func(pageSize int, pageToken string) ([]*dialogflowpb.Participant, string, error) {
1259 resp := &dialogflowpb.ListParticipantsResponse{}
1260 if pageToken != "" {
1261 req.PageToken = pageToken
1262 }
1263 if pageSize > math.MaxInt32 {
1264 req.PageSize = math.MaxInt32
1265 } else if pageSize != 0 {
1266 req.PageSize = int32(pageSize)
1267 }
1268 baseUrl, err := url.Parse(c.endpoint)
1269 if err != nil {
1270 return nil, "", err
1271 }
1272 baseUrl.Path += fmt.Sprintf("/v2beta1/%v/participants", req.GetParent())
1273
1274 params := url.Values{}
1275 params.Add("$alt", "json;enum-encoding=int")
1276 if req.GetPageSize() != 0 {
1277 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1278 }
1279 if req.GetPageToken() != "" {
1280 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1281 }
1282
1283 baseUrl.RawQuery = params.Encode()
1284
1285 // Build HTTP headers from client and context metadata.
1286 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1287 headers := gax.BuildHeaders(ctx, hds...)
1288 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1289 if settings.Path != "" {
1290 baseUrl.Path = settings.Path
1291 }
1292 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1293 if err != nil {
1294 return err
1295 }
1296 httpReq.Header = headers
1297
1298 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListParticipants")
1299 if err != nil {
1300 return err
1301 }
1302 if err := unm.Unmarshal(buf, resp); err != nil {
1303 return err
1304 }
1305
1306 return nil
1307 }, opts...)
1308 if e != nil {
1309 return nil, "", e
1310 }
1311 it.Response = resp
1312 return resp.GetParticipants(), resp.GetNextPageToken(), nil
1313 }
1314
1315 fetch := func(pageSize int, pageToken string) (string, error) {
1316 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1317 if err != nil {
1318 return "", err
1319 }
1320 it.items = append(it.items, items...)
1321 return nextPageToken, nil
1322 }
1323
1324 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1325 it.pageInfo.MaxSize = int(req.GetPageSize())
1326 it.pageInfo.Token = req.GetPageToken()
1327
1328 return it
1329 }
1330
1331 // UpdateParticipant updates the specified participant.
1332 func (c *participantsRESTClient) UpdateParticipant(ctx context.Context, req *dialogflowpb.UpdateParticipantRequest, opts ...gax.CallOption) (*dialogflowpb.Participant, error) {
1333 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1334 body := req.GetParticipant()
1335 jsonReq, err := m.Marshal(body)
1336 if err != nil {
1337 return nil, err
1338 }
1339
1340 baseUrl, err := url.Parse(c.endpoint)
1341 if err != nil {
1342 return nil, err
1343 }
1344 baseUrl.Path += fmt.Sprintf("/v2beta1/%v", req.GetParticipant().GetName())
1345
1346 params := url.Values{}
1347 params.Add("$alt", "json;enum-encoding=int")
1348 if req.GetUpdateMask() != nil {
1349 field, err := protojson.Marshal(req.GetUpdateMask())
1350 if err != nil {
1351 return nil, err
1352 }
1353 params.Add("updateMask", string(field[1:len(field)-1]))
1354 }
1355
1356 baseUrl.RawQuery = params.Encode()
1357
1358 // Build HTTP headers from client and context metadata.
1359 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "participant.name", url.QueryEscape(req.GetParticipant().GetName()))}
1360
1361 hds = append(c.xGoogHeaders, hds...)
1362 hds = append(hds, "Content-Type", "application/json")
1363 headers := gax.BuildHeaders(ctx, hds...)
1364 opts = append((*c.CallOptions).UpdateParticipant[0:len((*c.CallOptions).UpdateParticipant):len((*c.CallOptions).UpdateParticipant)], opts...)
1365 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1366 resp := &dialogflowpb.Participant{}
1367 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1368 if settings.Path != "" {
1369 baseUrl.Path = settings.Path
1370 }
1371 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1372 if err != nil {
1373 return err
1374 }
1375 httpReq = httpReq.WithContext(ctx)
1376 httpReq.Header = headers
1377
1378 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateParticipant")
1379 if err != nil {
1380 return err
1381 }
1382
1383 if err := unm.Unmarshal(buf, resp); err != nil {
1384 return err
1385 }
1386
1387 return nil
1388 }, opts...)
1389 if e != nil {
1390 return nil, e
1391 }
1392 return resp, nil
1393 }
1394
1395 // AnalyzeContent adds a text (chat, for example), or audio (phone recording, for example)
1396 // message from a participant into the conversation.
1397 //
1398 // Note: Always use agent versions for production traffic
1399 // sent to virtual agents. See Versions and
1400 // environments (at https://cloud.google.com/dialogflow/es/docs/agents-versions).
1401 func (c *participantsRESTClient) AnalyzeContent(ctx context.Context, req *dialogflowpb.AnalyzeContentRequest, opts ...gax.CallOption) (*dialogflowpb.AnalyzeContentResponse, error) {
1402 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1403 jsonReq, err := m.Marshal(req)
1404 if err != nil {
1405 return nil, err
1406 }
1407
1408 baseUrl, err := url.Parse(c.endpoint)
1409 if err != nil {
1410 return nil, err
1411 }
1412 baseUrl.Path += fmt.Sprintf("/v2beta1/%v:analyzeContent", req.GetParticipant())
1413
1414 params := url.Values{}
1415 params.Add("$alt", "json;enum-encoding=int")
1416
1417 baseUrl.RawQuery = params.Encode()
1418
1419 // Build HTTP headers from client and context metadata.
1420 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "participant", url.QueryEscape(req.GetParticipant()))}
1421
1422 hds = append(c.xGoogHeaders, hds...)
1423 hds = append(hds, "Content-Type", "application/json")
1424 headers := gax.BuildHeaders(ctx, hds...)
1425 opts = append((*c.CallOptions).AnalyzeContent[0:len((*c.CallOptions).AnalyzeContent):len((*c.CallOptions).AnalyzeContent)], opts...)
1426 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1427 resp := &dialogflowpb.AnalyzeContentResponse{}
1428 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1429 if settings.Path != "" {
1430 baseUrl.Path = settings.Path
1431 }
1432 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1433 if err != nil {
1434 return err
1435 }
1436 httpReq = httpReq.WithContext(ctx)
1437 httpReq.Header = headers
1438
1439 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "AnalyzeContent")
1440 if err != nil {
1441 return err
1442 }
1443
1444 if err := unm.Unmarshal(buf, resp); err != nil {
1445 return err
1446 }
1447
1448 return nil
1449 }, opts...)
1450 if e != nil {
1451 return nil, e
1452 }
1453 return resp, nil
1454 }
1455
1456 // StreamingAnalyzeContent adds a text (e.g., chat) or audio (e.g., phone recording) message from a
1457 // participant into the conversation.
1458 // Note: This method is only available through the gRPC API (not REST).
1459 //
1460 // The top-level message sent to the client by the server is
1461 // StreamingAnalyzeContentResponse. Multiple response messages can be
1462 // returned in order. The first one or more messages contain the
1463 // recognition_result field. Each result represents a more complete
1464 // transcript of what the user said. The next message contains the
1465 // reply_text field, and potentially the reply_audio and/or the
1466 // automated_agent_reply fields.
1467 //
1468 // Note: Always use agent versions for production traffic
1469 // sent to virtual agents. See Versions and
1470 // environments (at https://cloud.google.com/dialogflow/es/docs/agents-versions).
1471 //
1472 // This method is not supported for the REST transport.
1473 func (c *participantsRESTClient) StreamingAnalyzeContent(ctx context.Context, opts ...gax.CallOption) (dialogflowpb.Participants_StreamingAnalyzeContentClient, error) {
1474 return nil, errors.New("StreamingAnalyzeContent not yet supported for REST clients")
1475 }
1476
1477 // SuggestArticles gets suggested articles for a participant based on specific historical
1478 // messages.
1479 //
1480 // Note that
1481 // ListSuggestions
1482 // will only list the auto-generated suggestions, while
1483 // CompileSuggestion
1484 // will try to compile suggestion based on the provided conversation context
1485 // in the real time.
1486 func (c *participantsRESTClient) SuggestArticles(ctx context.Context, req *dialogflowpb.SuggestArticlesRequest, opts ...gax.CallOption) (*dialogflowpb.SuggestArticlesResponse, error) {
1487 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1488 jsonReq, err := m.Marshal(req)
1489 if err != nil {
1490 return nil, err
1491 }
1492
1493 baseUrl, err := url.Parse(c.endpoint)
1494 if err != nil {
1495 return nil, err
1496 }
1497 baseUrl.Path += fmt.Sprintf("/v2beta1/%v/suggestions:suggestArticles", req.GetParent())
1498
1499 params := url.Values{}
1500 params.Add("$alt", "json;enum-encoding=int")
1501
1502 baseUrl.RawQuery = params.Encode()
1503
1504 // Build HTTP headers from client and context metadata.
1505 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1506
1507 hds = append(c.xGoogHeaders, hds...)
1508 hds = append(hds, "Content-Type", "application/json")
1509 headers := gax.BuildHeaders(ctx, hds...)
1510 opts = append((*c.CallOptions).SuggestArticles[0:len((*c.CallOptions).SuggestArticles):len((*c.CallOptions).SuggestArticles)], opts...)
1511 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1512 resp := &dialogflowpb.SuggestArticlesResponse{}
1513 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1514 if settings.Path != "" {
1515 baseUrl.Path = settings.Path
1516 }
1517 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1518 if err != nil {
1519 return err
1520 }
1521 httpReq = httpReq.WithContext(ctx)
1522 httpReq.Header = headers
1523
1524 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SuggestArticles")
1525 if err != nil {
1526 return err
1527 }
1528
1529 if err := unm.Unmarshal(buf, resp); err != nil {
1530 return err
1531 }
1532
1533 return nil
1534 }, opts...)
1535 if e != nil {
1536 return nil, e
1537 }
1538 return resp, nil
1539 }
1540
1541 // SuggestFaqAnswers gets suggested faq answers for a participant based on specific historical
1542 // messages.
1543 func (c *participantsRESTClient) SuggestFaqAnswers(ctx context.Context, req *dialogflowpb.SuggestFaqAnswersRequest, opts ...gax.CallOption) (*dialogflowpb.SuggestFaqAnswersResponse, error) {
1544 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1545 jsonReq, err := m.Marshal(req)
1546 if err != nil {
1547 return nil, err
1548 }
1549
1550 baseUrl, err := url.Parse(c.endpoint)
1551 if err != nil {
1552 return nil, err
1553 }
1554 baseUrl.Path += fmt.Sprintf("/v2beta1/%v/suggestions:suggestFaqAnswers", req.GetParent())
1555
1556 params := url.Values{}
1557 params.Add("$alt", "json;enum-encoding=int")
1558
1559 baseUrl.RawQuery = params.Encode()
1560
1561 // Build HTTP headers from client and context metadata.
1562 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1563
1564 hds = append(c.xGoogHeaders, hds...)
1565 hds = append(hds, "Content-Type", "application/json")
1566 headers := gax.BuildHeaders(ctx, hds...)
1567 opts = append((*c.CallOptions).SuggestFaqAnswers[0:len((*c.CallOptions).SuggestFaqAnswers):len((*c.CallOptions).SuggestFaqAnswers)], opts...)
1568 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1569 resp := &dialogflowpb.SuggestFaqAnswersResponse{}
1570 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1571 if settings.Path != "" {
1572 baseUrl.Path = settings.Path
1573 }
1574 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1575 if err != nil {
1576 return err
1577 }
1578 httpReq = httpReq.WithContext(ctx)
1579 httpReq.Header = headers
1580
1581 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SuggestFaqAnswers")
1582 if err != nil {
1583 return err
1584 }
1585
1586 if err := unm.Unmarshal(buf, resp); err != nil {
1587 return err
1588 }
1589
1590 return nil
1591 }, opts...)
1592 if e != nil {
1593 return nil, e
1594 }
1595 return resp, nil
1596 }
1597
1598 // SuggestSmartReplies gets smart replies for a participant based on specific historical
1599 // messages.
1600 func (c *participantsRESTClient) SuggestSmartReplies(ctx context.Context, req *dialogflowpb.SuggestSmartRepliesRequest, opts ...gax.CallOption) (*dialogflowpb.SuggestSmartRepliesResponse, error) {
1601 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1602 jsonReq, err := m.Marshal(req)
1603 if err != nil {
1604 return nil, err
1605 }
1606
1607 baseUrl, err := url.Parse(c.endpoint)
1608 if err != nil {
1609 return nil, err
1610 }
1611 baseUrl.Path += fmt.Sprintf("/v2beta1/%v/suggestions:suggestSmartReplies", req.GetParent())
1612
1613 params := url.Values{}
1614 params.Add("$alt", "json;enum-encoding=int")
1615
1616 baseUrl.RawQuery = params.Encode()
1617
1618 // Build HTTP headers from client and context metadata.
1619 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1620
1621 hds = append(c.xGoogHeaders, hds...)
1622 hds = append(hds, "Content-Type", "application/json")
1623 headers := gax.BuildHeaders(ctx, hds...)
1624 opts = append((*c.CallOptions).SuggestSmartReplies[0:len((*c.CallOptions).SuggestSmartReplies):len((*c.CallOptions).SuggestSmartReplies)], opts...)
1625 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1626 resp := &dialogflowpb.SuggestSmartRepliesResponse{}
1627 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1628 if settings.Path != "" {
1629 baseUrl.Path = settings.Path
1630 }
1631 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1632 if err != nil {
1633 return err
1634 }
1635 httpReq = httpReq.WithContext(ctx)
1636 httpReq.Header = headers
1637
1638 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SuggestSmartReplies")
1639 if err != nil {
1640 return err
1641 }
1642
1643 if err := unm.Unmarshal(buf, resp); err != nil {
1644 return err
1645 }
1646
1647 return nil
1648 }, opts...)
1649 if e != nil {
1650 return nil, e
1651 }
1652 return resp, nil
1653 }
1654
1655 // SuggestKnowledgeAssist gets knowledge assist suggestions based on historical messages.
1656 func (c *participantsRESTClient) SuggestKnowledgeAssist(ctx context.Context, req *dialogflowpb.SuggestKnowledgeAssistRequest, opts ...gax.CallOption) (*dialogflowpb.SuggestKnowledgeAssistResponse, error) {
1657 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1658 jsonReq, err := m.Marshal(req)
1659 if err != nil {
1660 return nil, err
1661 }
1662
1663 baseUrl, err := url.Parse(c.endpoint)
1664 if err != nil {
1665 return nil, err
1666 }
1667 baseUrl.Path += fmt.Sprintf("/v2beta1/%v/suggestions:suggestKnowledgeAssist", req.GetParent())
1668
1669 params := url.Values{}
1670 params.Add("$alt", "json;enum-encoding=int")
1671
1672 baseUrl.RawQuery = params.Encode()
1673
1674 // Build HTTP headers from client and context metadata.
1675 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1676
1677 hds = append(c.xGoogHeaders, hds...)
1678 hds = append(hds, "Content-Type", "application/json")
1679 headers := gax.BuildHeaders(ctx, hds...)
1680 opts = append((*c.CallOptions).SuggestKnowledgeAssist[0:len((*c.CallOptions).SuggestKnowledgeAssist):len((*c.CallOptions).SuggestKnowledgeAssist)], opts...)
1681 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1682 resp := &dialogflowpb.SuggestKnowledgeAssistResponse{}
1683 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1684 if settings.Path != "" {
1685 baseUrl.Path = settings.Path
1686 }
1687 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1688 if err != nil {
1689 return err
1690 }
1691 httpReq = httpReq.WithContext(ctx)
1692 httpReq.Header = headers
1693
1694 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SuggestKnowledgeAssist")
1695 if err != nil {
1696 return err
1697 }
1698
1699 if err := unm.Unmarshal(buf, resp); err != nil {
1700 return err
1701 }
1702
1703 return nil
1704 }, opts...)
1705 if e != nil {
1706 return nil, e
1707 }
1708 return resp, nil
1709 }
1710
1711 // ListSuggestions deprecated: Use inline suggestion, event based suggestion or
1712 // Suggestion* API instead.
1713 // See
1714 // [HumanAgentAssistantConfig.name (at http://HumanAgentAssistantConfig.name)][google.cloud.dialogflow.v2beta1.HumanAgentAssistantConfig.name (at http://google.cloud.dialogflow.v2beta1.HumanAgentAssistantConfig.name)]
1715 // for more details. Removal Date: 2020-09-01.
1716 //
1717 // Retrieves suggestions for live agents.
1718 //
1719 // This method should be used by human agent client software to fetch auto
1720 // generated suggestions in real-time, while the conversation with an end user
1721 // is in progress. The functionality is implemented in terms of the
1722 // list
1723 // pagination (at https://cloud.google.com/apis/design/design_patterns#list_pagination)
1724 // design pattern. The client app should use the next_page_token field
1725 // to fetch the next batch of suggestions. suggestions are sorted by
1726 // create_time in descending order.
1727 // To fetch latest suggestion, just set page_size to 1.
1728 // To fetch new suggestions without duplication, send request with filter
1729 // create_time_epoch_microseconds > [first item's create_time of previous request] and empty page_token.
1730 //
1731 // Deprecated: ListSuggestions may be removed in a future version.
1732 func (c *participantsRESTClient) ListSuggestions(ctx context.Context, req *dialogflowpb.ListSuggestionsRequest, opts ...gax.CallOption) *SuggestionIterator {
1733 it := &SuggestionIterator{}
1734 req = proto.Clone(req).(*dialogflowpb.ListSuggestionsRequest)
1735 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1736 it.InternalFetch = func(pageSize int, pageToken string) ([]*dialogflowpb.Suggestion, string, error) {
1737 resp := &dialogflowpb.ListSuggestionsResponse{}
1738 if pageToken != "" {
1739 req.PageToken = pageToken
1740 }
1741 if pageSize > math.MaxInt32 {
1742 req.PageSize = math.MaxInt32
1743 } else if pageSize != 0 {
1744 req.PageSize = int32(pageSize)
1745 }
1746 baseUrl, err := url.Parse(c.endpoint)
1747 if err != nil {
1748 return nil, "", err
1749 }
1750 baseUrl.Path += fmt.Sprintf("/v2beta1/%v/suggestions", req.GetParent())
1751
1752 params := url.Values{}
1753 params.Add("$alt", "json;enum-encoding=int")
1754 if req.GetFilter() != "" {
1755 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1756 }
1757 if req.GetPageSize() != 0 {
1758 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1759 }
1760 if req.GetPageToken() != "" {
1761 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1762 }
1763
1764 baseUrl.RawQuery = params.Encode()
1765
1766 // Build HTTP headers from client and context metadata.
1767 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1768 headers := gax.BuildHeaders(ctx, hds...)
1769 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1770 if settings.Path != "" {
1771 baseUrl.Path = settings.Path
1772 }
1773 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1774 if err != nil {
1775 return err
1776 }
1777 httpReq.Header = headers
1778
1779 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListSuggestions")
1780 if err != nil {
1781 return err
1782 }
1783 if err := unm.Unmarshal(buf, resp); err != nil {
1784 return err
1785 }
1786
1787 return nil
1788 }, opts...)
1789 if e != nil {
1790 return nil, "", e
1791 }
1792 it.Response = resp
1793 return resp.GetSuggestions(), resp.GetNextPageToken(), nil
1794 }
1795
1796 fetch := func(pageSize int, pageToken string) (string, error) {
1797 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1798 if err != nil {
1799 return "", err
1800 }
1801 it.items = append(it.items, items...)
1802 return nextPageToken, nil
1803 }
1804
1805 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1806 it.pageInfo.MaxSize = int(req.GetPageSize())
1807 it.pageInfo.Token = req.GetPageToken()
1808
1809 return it
1810 }
1811
1812 // CompileSuggestion deprecated. use
1813 // SuggestArticles
1814 // and
1815 // SuggestFaqAnswers
1816 // instead.
1817 //
1818 // Gets suggestions for a participant based on specific historical
1819 // messages.
1820 //
1821 // Note that
1822 // ListSuggestions
1823 // will only list the auto-generated suggestions, while
1824 // CompileSuggestion
1825 // will try to compile suggestion based on the provided conversation context
1826 // in the real time.
1827 //
1828 // Deprecated: CompileSuggestion may be removed in a future version.
1829 func (c *participantsRESTClient) CompileSuggestion(ctx context.Context, req *dialogflowpb.CompileSuggestionRequest, opts ...gax.CallOption) (*dialogflowpb.CompileSuggestionResponse, error) {
1830 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1831 jsonReq, err := m.Marshal(req)
1832 if err != nil {
1833 return nil, err
1834 }
1835
1836 baseUrl, err := url.Parse(c.endpoint)
1837 if err != nil {
1838 return nil, err
1839 }
1840 baseUrl.Path += fmt.Sprintf("/v2beta1/%v/suggestions:compile", req.GetParent())
1841
1842 params := url.Values{}
1843 params.Add("$alt", "json;enum-encoding=int")
1844
1845 baseUrl.RawQuery = params.Encode()
1846
1847 // Build HTTP headers from client and context metadata.
1848 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1849
1850 hds = append(c.xGoogHeaders, hds...)
1851 hds = append(hds, "Content-Type", "application/json")
1852 headers := gax.BuildHeaders(ctx, hds...)
1853 opts = append((*c.CallOptions).CompileSuggestion[0:len((*c.CallOptions).CompileSuggestion):len((*c.CallOptions).CompileSuggestion)], opts...)
1854 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1855 resp := &dialogflowpb.CompileSuggestionResponse{}
1856 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1857 if settings.Path != "" {
1858 baseUrl.Path = settings.Path
1859 }
1860 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1861 if err != nil {
1862 return err
1863 }
1864 httpReq = httpReq.WithContext(ctx)
1865 httpReq.Header = headers
1866
1867 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CompileSuggestion")
1868 if err != nil {
1869 return err
1870 }
1871
1872 if err := unm.Unmarshal(buf, resp); err != nil {
1873 return err
1874 }
1875
1876 return nil
1877 }, opts...)
1878 if e != nil {
1879 return nil, e
1880 }
1881 return resp, nil
1882 }
1883
1884 // GetLocation gets information about a location.
1885 func (c *participantsRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
1886 baseUrl, err := url.Parse(c.endpoint)
1887 if err != nil {
1888 return nil, err
1889 }
1890 baseUrl.Path += fmt.Sprintf("/v2beta1/%v", req.GetName())
1891
1892 params := url.Values{}
1893 params.Add("$alt", "json;enum-encoding=int")
1894
1895 baseUrl.RawQuery = params.Encode()
1896
1897 // Build HTTP headers from client and context metadata.
1898 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1899
1900 hds = append(c.xGoogHeaders, hds...)
1901 hds = append(hds, "Content-Type", "application/json")
1902 headers := gax.BuildHeaders(ctx, hds...)
1903 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
1904 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1905 resp := &locationpb.Location{}
1906 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1907 if settings.Path != "" {
1908 baseUrl.Path = settings.Path
1909 }
1910 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1911 if err != nil {
1912 return err
1913 }
1914 httpReq = httpReq.WithContext(ctx)
1915 httpReq.Header = headers
1916
1917 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
1918 if err != nil {
1919 return err
1920 }
1921
1922 if err := unm.Unmarshal(buf, resp); err != nil {
1923 return err
1924 }
1925
1926 return nil
1927 }, opts...)
1928 if e != nil {
1929 return nil, e
1930 }
1931 return resp, nil
1932 }
1933
1934 // ListLocations lists information about the supported locations for this service.
1935 func (c *participantsRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
1936 it := &LocationIterator{}
1937 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
1938 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1939 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
1940 resp := &locationpb.ListLocationsResponse{}
1941 if pageToken != "" {
1942 req.PageToken = pageToken
1943 }
1944 if pageSize > math.MaxInt32 {
1945 req.PageSize = math.MaxInt32
1946 } else if pageSize != 0 {
1947 req.PageSize = int32(pageSize)
1948 }
1949 baseUrl, err := url.Parse(c.endpoint)
1950 if err != nil {
1951 return nil, "", err
1952 }
1953 baseUrl.Path += fmt.Sprintf("/v2beta1/%v/locations", req.GetName())
1954
1955 params := url.Values{}
1956 params.Add("$alt", "json;enum-encoding=int")
1957 if req.GetFilter() != "" {
1958 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1959 }
1960 if req.GetPageSize() != 0 {
1961 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1962 }
1963 if req.GetPageToken() != "" {
1964 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1965 }
1966
1967 baseUrl.RawQuery = params.Encode()
1968
1969 // Build HTTP headers from client and context metadata.
1970 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1971 headers := gax.BuildHeaders(ctx, hds...)
1972 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1973 if settings.Path != "" {
1974 baseUrl.Path = settings.Path
1975 }
1976 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1977 if err != nil {
1978 return err
1979 }
1980 httpReq.Header = headers
1981
1982 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
1983 if err != nil {
1984 return err
1985 }
1986 if err := unm.Unmarshal(buf, resp); err != nil {
1987 return err
1988 }
1989
1990 return nil
1991 }, opts...)
1992 if e != nil {
1993 return nil, "", e
1994 }
1995 it.Response = resp
1996 return resp.GetLocations(), resp.GetNextPageToken(), nil
1997 }
1998
1999 fetch := func(pageSize int, pageToken string) (string, error) {
2000 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2001 if err != nil {
2002 return "", err
2003 }
2004 it.items = append(it.items, items...)
2005 return nextPageToken, nil
2006 }
2007
2008 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2009 it.pageInfo.MaxSize = int(req.GetPageSize())
2010 it.pageInfo.Token = req.GetPageToken()
2011
2012 return it
2013 }
2014
2015 // CancelOperation is a utility method from google.longrunning.Operations.
2016 func (c *participantsRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
2017 baseUrl, err := url.Parse(c.endpoint)
2018 if err != nil {
2019 return err
2020 }
2021 baseUrl.Path += fmt.Sprintf("/v2beta1/%v:cancel", req.GetName())
2022
2023 params := url.Values{}
2024 params.Add("$alt", "json;enum-encoding=int")
2025
2026 baseUrl.RawQuery = params.Encode()
2027
2028 // Build HTTP headers from client and context metadata.
2029 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2030
2031 hds = append(c.xGoogHeaders, hds...)
2032 hds = append(hds, "Content-Type", "application/json")
2033 headers := gax.BuildHeaders(ctx, hds...)
2034 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2035 if settings.Path != "" {
2036 baseUrl.Path = settings.Path
2037 }
2038 httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
2039 if err != nil {
2040 return err
2041 }
2042 httpReq = httpReq.WithContext(ctx)
2043 httpReq.Header = headers
2044
2045 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation")
2046 return err
2047 }, opts...)
2048 }
2049
2050 // GetOperation is a utility method from google.longrunning.Operations.
2051 func (c *participantsRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
2052 baseUrl, err := url.Parse(c.endpoint)
2053 if err != nil {
2054 return nil, err
2055 }
2056 baseUrl.Path += fmt.Sprintf("/v2beta1/%v", req.GetName())
2057
2058 params := url.Values{}
2059 params.Add("$alt", "json;enum-encoding=int")
2060
2061 baseUrl.RawQuery = params.Encode()
2062
2063 // Build HTTP headers from client and context metadata.
2064 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2065
2066 hds = append(c.xGoogHeaders, hds...)
2067 hds = append(hds, "Content-Type", "application/json")
2068 headers := gax.BuildHeaders(ctx, hds...)
2069 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
2070 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2071 resp := &longrunningpb.Operation{}
2072 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2073 if settings.Path != "" {
2074 baseUrl.Path = settings.Path
2075 }
2076 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2077 if err != nil {
2078 return err
2079 }
2080 httpReq = httpReq.WithContext(ctx)
2081 httpReq.Header = headers
2082
2083 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
2084 if err != nil {
2085 return err
2086 }
2087
2088 if err := unm.Unmarshal(buf, resp); err != nil {
2089 return err
2090 }
2091
2092 return nil
2093 }, opts...)
2094 if e != nil {
2095 return nil, e
2096 }
2097 return resp, nil
2098 }
2099
2100 // ListOperations is a utility method from google.longrunning.Operations.
2101 func (c *participantsRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
2102 it := &OperationIterator{}
2103 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
2104 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2105 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
2106 resp := &longrunningpb.ListOperationsResponse{}
2107 if pageToken != "" {
2108 req.PageToken = pageToken
2109 }
2110 if pageSize > math.MaxInt32 {
2111 req.PageSize = math.MaxInt32
2112 } else if pageSize != 0 {
2113 req.PageSize = int32(pageSize)
2114 }
2115 baseUrl, err := url.Parse(c.endpoint)
2116 if err != nil {
2117 return nil, "", err
2118 }
2119 baseUrl.Path += fmt.Sprintf("/v2beta1/%v/operations", req.GetName())
2120
2121 params := url.Values{}
2122 params.Add("$alt", "json;enum-encoding=int")
2123 if req.GetFilter() != "" {
2124 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2125 }
2126 if req.GetPageSize() != 0 {
2127 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2128 }
2129 if req.GetPageToken() != "" {
2130 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2131 }
2132
2133 baseUrl.RawQuery = params.Encode()
2134
2135 // Build HTTP headers from client and context metadata.
2136 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2137 headers := gax.BuildHeaders(ctx, hds...)
2138 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2139 if settings.Path != "" {
2140 baseUrl.Path = settings.Path
2141 }
2142 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2143 if err != nil {
2144 return err
2145 }
2146 httpReq.Header = headers
2147
2148 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
2149 if err != nil {
2150 return err
2151 }
2152 if err := unm.Unmarshal(buf, resp); err != nil {
2153 return err
2154 }
2155
2156 return nil
2157 }, opts...)
2158 if e != nil {
2159 return nil, "", e
2160 }
2161 it.Response = resp
2162 return resp.GetOperations(), resp.GetNextPageToken(), nil
2163 }
2164
2165 fetch := func(pageSize int, pageToken string) (string, error) {
2166 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2167 if err != nil {
2168 return "", err
2169 }
2170 it.items = append(it.items, items...)
2171 return nextPageToken, nil
2172 }
2173
2174 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2175 it.pageInfo.MaxSize = int(req.GetPageSize())
2176 it.pageInfo.Token = req.GetPageToken()
2177
2178 return it
2179 }