1// Copyright 2020 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 dialogflow
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	"github.com/golang/protobuf/proto"
29	structpbpb "github.com/golang/protobuf/ptypes/struct"
30	gax "github.com/googleapis/gax-go/v2"
31	"google.golang.org/api/iterator"
32	"google.golang.org/api/option"
33	gtransport "google.golang.org/api/transport/grpc"
34	dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2"
35	longrunningpb "google.golang.org/genproto/googleapis/longrunning"
36	"google.golang.org/grpc"
37	"google.golang.org/grpc/codes"
38	"google.golang.org/grpc/metadata"
39)
40
41var newIntentsClientHook clientHook
42
43// IntentsCallOptions contains the retry settings for each method of IntentsClient.
44type IntentsCallOptions struct {
45	ListIntents        []gax.CallOption
46	GetIntent          []gax.CallOption
47	CreateIntent       []gax.CallOption
48	UpdateIntent       []gax.CallOption
49	DeleteIntent       []gax.CallOption
50	BatchUpdateIntents []gax.CallOption
51	BatchDeleteIntents []gax.CallOption
52}
53
54func defaultIntentsClientOptions() []option.ClientOption {
55	return []option.ClientOption{
56		option.WithEndpoint("dialogflow.googleapis.com:443"),
57		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
58		option.WithScopes(DefaultAuthScopes()...),
59		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
60			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
61	}
62}
63
64func defaultIntentsCallOptions() *IntentsCallOptions {
65	return &IntentsCallOptions{
66		ListIntents: []gax.CallOption{
67			gax.WithRetry(func() gax.Retryer {
68				return gax.OnCodes([]codes.Code{
69					codes.Unavailable,
70				}, gax.Backoff{
71					Initial:    100 * time.Millisecond,
72					Max:        60000 * time.Millisecond,
73					Multiplier: 1.30,
74				})
75			}),
76		},
77		GetIntent: []gax.CallOption{
78			gax.WithRetry(func() gax.Retryer {
79				return gax.OnCodes([]codes.Code{
80					codes.Unavailable,
81				}, gax.Backoff{
82					Initial:    100 * time.Millisecond,
83					Max:        60000 * time.Millisecond,
84					Multiplier: 1.30,
85				})
86			}),
87		},
88		CreateIntent: []gax.CallOption{
89			gax.WithRetry(func() gax.Retryer {
90				return gax.OnCodes([]codes.Code{
91					codes.Unavailable,
92				}, gax.Backoff{
93					Initial:    100 * time.Millisecond,
94					Max:        60000 * time.Millisecond,
95					Multiplier: 1.30,
96				})
97			}),
98		},
99		UpdateIntent: []gax.CallOption{
100			gax.WithRetry(func() gax.Retryer {
101				return gax.OnCodes([]codes.Code{
102					codes.Unavailable,
103				}, gax.Backoff{
104					Initial:    100 * time.Millisecond,
105					Max:        60000 * time.Millisecond,
106					Multiplier: 1.30,
107				})
108			}),
109		},
110		DeleteIntent: []gax.CallOption{
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		BatchUpdateIntents: []gax.CallOption{
122			gax.WithRetry(func() gax.Retryer {
123				return gax.OnCodes([]codes.Code{
124					codes.Unavailable,
125				}, gax.Backoff{
126					Initial:    100 * time.Millisecond,
127					Max:        60000 * time.Millisecond,
128					Multiplier: 1.30,
129				})
130			}),
131		},
132		BatchDeleteIntents: []gax.CallOption{
133			gax.WithRetry(func() gax.Retryer {
134				return gax.OnCodes([]codes.Code{
135					codes.Unavailable,
136				}, gax.Backoff{
137					Initial:    100 * time.Millisecond,
138					Max:        60000 * time.Millisecond,
139					Multiplier: 1.30,
140				})
141			}),
142		},
143	}
144}
145
146// IntentsClient is a client for interacting with Dialogflow API.
147//
148// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
149type IntentsClient struct {
150	// Connection pool of gRPC connections to the service.
151	connPool gtransport.ConnPool
152
153	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
154	disableDeadlines bool
155
156	// The gRPC API client.
157	intentsClient dialogflowpb.IntentsClient
158
159	// LROClient is used internally to handle longrunning operations.
160	// It is exposed so that its CallOptions can be modified if required.
161	// Users should not Close this client.
162	LROClient *lroauto.OperationsClient
163
164	// The call options for this service.
165	CallOptions *IntentsCallOptions
166
167	// The x-goog-* metadata to be sent with each request.
168	xGoogMetadata metadata.MD
169}
170
171// NewIntentsClient creates a new intents client.
172//
173// Service for managing Intents.
174func NewIntentsClient(ctx context.Context, opts ...option.ClientOption) (*IntentsClient, error) {
175	clientOpts := defaultIntentsClientOptions()
176
177	if newIntentsClientHook != nil {
178		hookOpts, err := newIntentsClientHook(ctx, clientHookParams{})
179		if err != nil {
180			return nil, err
181		}
182		clientOpts = append(clientOpts, hookOpts...)
183	}
184
185	disableDeadlines, err := checkDisableDeadlines()
186	if err != nil {
187		return nil, err
188	}
189
190	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
191	if err != nil {
192		return nil, err
193	}
194	c := &IntentsClient{
195		connPool:         connPool,
196		disableDeadlines: disableDeadlines,
197		CallOptions:      defaultIntentsCallOptions(),
198
199		intentsClient: dialogflowpb.NewIntentsClient(connPool),
200	}
201	c.setGoogleClientInfo()
202
203	c.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
204	if err != nil {
205		// This error "should not happen", since we are just reusing old connection pool
206		// and never actually need to dial.
207		// If this does happen, we could leak connp. However, we cannot close conn:
208		// If the user invoked the constructor with option.WithGRPCConn,
209		// we would close a connection that's still in use.
210		// TODO: investigate error conditions.
211		return nil, err
212	}
213	return c, nil
214}
215
216// Connection returns a connection to the API service.
217//
218// Deprecated.
219func (c *IntentsClient) Connection() *grpc.ClientConn {
220	return c.connPool.Conn()
221}
222
223// Close closes the connection to the API service. The user should invoke this when
224// the client is no longer required.
225func (c *IntentsClient) Close() error {
226	return c.connPool.Close()
227}
228
229// setGoogleClientInfo sets the name and version of the application in
230// the `x-goog-api-client` header passed on each request. Intended for
231// use by Google-written clients.
232func (c *IntentsClient) setGoogleClientInfo(keyval ...string) {
233	kv := append([]string{"gl-go", versionGo()}, keyval...)
234	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
235	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
236}
237
238// ListIntents returns the list of all intents in the specified agent.
239func (c *IntentsClient) ListIntents(ctx context.Context, req *dialogflowpb.ListIntentsRequest, opts ...gax.CallOption) *IntentIterator {
240	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
241	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
242	opts = append(c.CallOptions.ListIntents[0:len(c.CallOptions.ListIntents):len(c.CallOptions.ListIntents)], opts...)
243	it := &IntentIterator{}
244	req = proto.Clone(req).(*dialogflowpb.ListIntentsRequest)
245	it.InternalFetch = func(pageSize int, pageToken string) ([]*dialogflowpb.Intent, string, error) {
246		var resp *dialogflowpb.ListIntentsResponse
247		req.PageToken = pageToken
248		if pageSize > math.MaxInt32 {
249			req.PageSize = math.MaxInt32
250		} else {
251			req.PageSize = int32(pageSize)
252		}
253		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
254			var err error
255			resp, err = c.intentsClient.ListIntents(ctx, req, settings.GRPC...)
256			return err
257		}, opts...)
258		if err != nil {
259			return nil, "", err
260		}
261
262		it.Response = resp
263		return resp.GetIntents(), resp.GetNextPageToken(), nil
264	}
265	fetch := func(pageSize int, pageToken string) (string, error) {
266		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
267		if err != nil {
268			return "", err
269		}
270		it.items = append(it.items, items...)
271		return nextPageToken, nil
272	}
273	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
274	it.pageInfo.MaxSize = int(req.GetPageSize())
275	it.pageInfo.Token = req.GetPageToken()
276	return it
277}
278
279// GetIntent retrieves the specified intent.
280func (c *IntentsClient) GetIntent(ctx context.Context, req *dialogflowpb.GetIntentRequest, opts ...gax.CallOption) (*dialogflowpb.Intent, error) {
281	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
282		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
283		defer cancel()
284		ctx = cctx
285	}
286	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
287	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
288	opts = append(c.CallOptions.GetIntent[0:len(c.CallOptions.GetIntent):len(c.CallOptions.GetIntent)], opts...)
289	var resp *dialogflowpb.Intent
290	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
291		var err error
292		resp, err = c.intentsClient.GetIntent(ctx, req, settings.GRPC...)
293		return err
294	}, opts...)
295	if err != nil {
296		return nil, err
297	}
298	return resp, nil
299}
300
301// CreateIntent creates an intent in the specified agent.
302func (c *IntentsClient) CreateIntent(ctx context.Context, req *dialogflowpb.CreateIntentRequest, opts ...gax.CallOption) (*dialogflowpb.Intent, error) {
303	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
304		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
305		defer cancel()
306		ctx = cctx
307	}
308	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
309	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
310	opts = append(c.CallOptions.CreateIntent[0:len(c.CallOptions.CreateIntent):len(c.CallOptions.CreateIntent)], opts...)
311	var resp *dialogflowpb.Intent
312	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
313		var err error
314		resp, err = c.intentsClient.CreateIntent(ctx, req, settings.GRPC...)
315		return err
316	}, opts...)
317	if err != nil {
318		return nil, err
319	}
320	return resp, nil
321}
322
323// UpdateIntent updates the specified intent.
324func (c *IntentsClient) UpdateIntent(ctx context.Context, req *dialogflowpb.UpdateIntentRequest, opts ...gax.CallOption) (*dialogflowpb.Intent, error) {
325	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
326		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
327		defer cancel()
328		ctx = cctx
329	}
330	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "intent.name", url.QueryEscape(req.GetIntent().GetName())))
331	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
332	opts = append(c.CallOptions.UpdateIntent[0:len(c.CallOptions.UpdateIntent):len(c.CallOptions.UpdateIntent)], opts...)
333	var resp *dialogflowpb.Intent
334	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
335		var err error
336		resp, err = c.intentsClient.UpdateIntent(ctx, req, settings.GRPC...)
337		return err
338	}, opts...)
339	if err != nil {
340		return nil, err
341	}
342	return resp, nil
343}
344
345// DeleteIntent deletes the specified intent and its direct or indirect followup intents.
346func (c *IntentsClient) DeleteIntent(ctx context.Context, req *dialogflowpb.DeleteIntentRequest, opts ...gax.CallOption) error {
347	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
348		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
349		defer cancel()
350		ctx = cctx
351	}
352	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
353	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
354	opts = append(c.CallOptions.DeleteIntent[0:len(c.CallOptions.DeleteIntent):len(c.CallOptions.DeleteIntent)], opts...)
355	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
356		var err error
357		_, err = c.intentsClient.DeleteIntent(ctx, req, settings.GRPC...)
358		return err
359	}, opts...)
360	return err
361}
362
363// BatchUpdateIntents updates/Creates multiple intents in the specified agent.
364//
365// Operation <response: BatchUpdateIntentsResponse>
366func (c *IntentsClient) BatchUpdateIntents(ctx context.Context, req *dialogflowpb.BatchUpdateIntentsRequest, opts ...gax.CallOption) (*BatchUpdateIntentsOperation, error) {
367	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
368		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
369		defer cancel()
370		ctx = cctx
371	}
372	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
373	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
374	opts = append(c.CallOptions.BatchUpdateIntents[0:len(c.CallOptions.BatchUpdateIntents):len(c.CallOptions.BatchUpdateIntents)], opts...)
375	var resp *longrunningpb.Operation
376	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
377		var err error
378		resp, err = c.intentsClient.BatchUpdateIntents(ctx, req, settings.GRPC...)
379		return err
380	}, opts...)
381	if err != nil {
382		return nil, err
383	}
384	return &BatchUpdateIntentsOperation{
385		lro: longrunning.InternalNewOperation(c.LROClient, resp),
386	}, nil
387}
388
389// BatchDeleteIntents deletes intents in the specified agent.
390//
391// Operation <response: google.protobuf.Empty>
392func (c *IntentsClient) BatchDeleteIntents(ctx context.Context, req *dialogflowpb.BatchDeleteIntentsRequest, opts ...gax.CallOption) (*BatchDeleteIntentsOperation, error) {
393	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
394		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
395		defer cancel()
396		ctx = cctx
397	}
398	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
399	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
400	opts = append(c.CallOptions.BatchDeleteIntents[0:len(c.CallOptions.BatchDeleteIntents):len(c.CallOptions.BatchDeleteIntents)], opts...)
401	var resp *longrunningpb.Operation
402	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
403		var err error
404		resp, err = c.intentsClient.BatchDeleteIntents(ctx, req, settings.GRPC...)
405		return err
406	}, opts...)
407	if err != nil {
408		return nil, err
409	}
410	return &BatchDeleteIntentsOperation{
411		lro: longrunning.InternalNewOperation(c.LROClient, resp),
412	}, nil
413}
414
415// BatchDeleteIntentsOperation manages a long-running operation from BatchDeleteIntents.
416type BatchDeleteIntentsOperation struct {
417	lro *longrunning.Operation
418}
419
420// BatchDeleteIntentsOperation returns a new BatchDeleteIntentsOperation from a given name.
421// The name must be that of a previously created BatchDeleteIntentsOperation, possibly from a different process.
422func (c *IntentsClient) BatchDeleteIntentsOperation(name string) *BatchDeleteIntentsOperation {
423	return &BatchDeleteIntentsOperation{
424		lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
425	}
426}
427
428// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
429//
430// See documentation of Poll for error-handling information.
431func (op *BatchDeleteIntentsOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
432	return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
433}
434
435// Poll fetches the latest state of the long-running operation.
436//
437// Poll also fetches the latest metadata, which can be retrieved by Metadata.
438//
439// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
440// the operation has completed with failure, the error is returned and op.Done will return true.
441// If Poll succeeds and the operation has completed successfully,
442// op.Done will return true, and the response of the operation is returned.
443// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
444func (op *BatchDeleteIntentsOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
445	return op.lro.Poll(ctx, nil, opts...)
446}
447
448// Metadata returns metadata associated with the long-running operation.
449// Metadata itself does not contact the server, but Poll does.
450// To get the latest metadata, call this method after a successful call to Poll.
451// If the metadata is not available, the returned metadata and error are both nil.
452func (op *BatchDeleteIntentsOperation) Metadata() (*structpbpb.Struct, error) {
453	var meta structpbpb.Struct
454	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
455		return nil, nil
456	} else if err != nil {
457		return nil, err
458	}
459	return &meta, nil
460}
461
462// Done reports whether the long-running operation has completed.
463func (op *BatchDeleteIntentsOperation) Done() bool {
464	return op.lro.Done()
465}
466
467// Name returns the name of the long-running operation.
468// The name is assigned by the server and is unique within the service from which the operation is created.
469func (op *BatchDeleteIntentsOperation) Name() string {
470	return op.lro.Name()
471}
472
473// BatchUpdateIntentsOperation manages a long-running operation from BatchUpdateIntents.
474type BatchUpdateIntentsOperation struct {
475	lro *longrunning.Operation
476}
477
478// BatchUpdateIntentsOperation returns a new BatchUpdateIntentsOperation from a given name.
479// The name must be that of a previously created BatchUpdateIntentsOperation, possibly from a different process.
480func (c *IntentsClient) BatchUpdateIntentsOperation(name string) *BatchUpdateIntentsOperation {
481	return &BatchUpdateIntentsOperation{
482		lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
483	}
484}
485
486// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
487//
488// See documentation of Poll for error-handling information.
489func (op *BatchUpdateIntentsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.BatchUpdateIntentsResponse, error) {
490	var resp dialogflowpb.BatchUpdateIntentsResponse
491	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
492		return nil, err
493	}
494	return &resp, nil
495}
496
497// Poll fetches the latest state of the long-running operation.
498//
499// Poll also fetches the latest metadata, which can be retrieved by Metadata.
500//
501// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
502// the operation has completed with failure, the error is returned and op.Done will return true.
503// If Poll succeeds and the operation has completed successfully,
504// op.Done will return true, and the response of the operation is returned.
505// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
506func (op *BatchUpdateIntentsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*dialogflowpb.BatchUpdateIntentsResponse, error) {
507	var resp dialogflowpb.BatchUpdateIntentsResponse
508	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
509		return nil, err
510	}
511	if !op.Done() {
512		return nil, nil
513	}
514	return &resp, nil
515}
516
517// Metadata returns metadata associated with the long-running operation.
518// Metadata itself does not contact the server, but Poll does.
519// To get the latest metadata, call this method after a successful call to Poll.
520// If the metadata is not available, the returned metadata and error are both nil.
521func (op *BatchUpdateIntentsOperation) Metadata() (*structpbpb.Struct, error) {
522	var meta structpbpb.Struct
523	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
524		return nil, nil
525	} else if err != nil {
526		return nil, err
527	}
528	return &meta, nil
529}
530
531// Done reports whether the long-running operation has completed.
532func (op *BatchUpdateIntentsOperation) Done() bool {
533	return op.lro.Done()
534}
535
536// Name returns the name of the long-running operation.
537// The name is assigned by the server and is unique within the service from which the operation is created.
538func (op *BatchUpdateIntentsOperation) Name() string {
539	return op.lro.Name()
540}
541
542// IntentIterator manages a stream of *dialogflowpb.Intent.
543type IntentIterator struct {
544	items    []*dialogflowpb.Intent
545	pageInfo *iterator.PageInfo
546	nextFunc func() error
547
548	// Response is the raw response for the current page.
549	// It must be cast to the RPC response type.
550	// Calling Next() or InternalFetch() updates this value.
551	Response interface{}
552
553	// InternalFetch is for use by the Google Cloud Libraries only.
554	// It is not part of the stable interface of this package.
555	//
556	// InternalFetch returns results from a single call to the underlying RPC.
557	// The number of results is no greater than pageSize.
558	// If there are no more results, nextPageToken is empty and err is nil.
559	InternalFetch func(pageSize int, pageToken string) (results []*dialogflowpb.Intent, nextPageToken string, err error)
560}
561
562// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
563func (it *IntentIterator) PageInfo() *iterator.PageInfo {
564	return it.pageInfo
565}
566
567// Next returns the next result. Its second return value is iterator.Done if there are no more
568// results. Once Next returns Done, all subsequent calls will return Done.
569func (it *IntentIterator) Next() (*dialogflowpb.Intent, error) {
570	var item *dialogflowpb.Intent
571	if err := it.nextFunc(); err != nil {
572		return item, err
573	}
574	item = it.items[0]
575	it.items = it.items[1:]
576	return item, nil
577}
578
579func (it *IntentIterator) bufLen() int {
580	return len(it.items)
581}
582
583func (it *IntentIterator) takeBuf() interface{} {
584	b := it.items
585	it.items = nil
586	return b
587}
588