1// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17package dialogflow
18
19import (
20	"context"
21	"fmt"
22	"math"
23	"net/url"
24	"time"
25
26	gax "github.com/googleapis/gax-go/v2"
27	"google.golang.org/api/iterator"
28	"google.golang.org/api/option"
29	"google.golang.org/api/option/internaloption"
30	gtransport "google.golang.org/api/transport/grpc"
31	dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2"
32	"google.golang.org/grpc"
33	"google.golang.org/grpc/codes"
34	"google.golang.org/grpc/metadata"
35	"google.golang.org/protobuf/proto"
36)
37
38var newEnvironmentsClientHook clientHook
39
40// EnvironmentsCallOptions contains the retry settings for each method of EnvironmentsClient.
41type EnvironmentsCallOptions struct {
42	ListEnvironments      []gax.CallOption
43	GetEnvironment        []gax.CallOption
44	CreateEnvironment     []gax.CallOption
45	UpdateEnvironment     []gax.CallOption
46	DeleteEnvironment     []gax.CallOption
47	GetEnvironmentHistory []gax.CallOption
48}
49
50func defaultEnvironmentsGRPCClientOptions() []option.ClientOption {
51	return []option.ClientOption{
52		internaloption.WithDefaultEndpoint("dialogflow.googleapis.com:443"),
53		internaloption.WithDefaultMTLSEndpoint("dialogflow.mtls.googleapis.com:443"),
54		internaloption.WithDefaultAudience("https://dialogflow.googleapis.com/"),
55		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
56		internaloption.EnableJwtWithScope(),
57		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
58		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
59			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
60	}
61}
62
63func defaultEnvironmentsCallOptions() *EnvironmentsCallOptions {
64	return &EnvironmentsCallOptions{
65		ListEnvironments: []gax.CallOption{
66			gax.WithRetry(func() gax.Retryer {
67				return gax.OnCodes([]codes.Code{
68					codes.Unavailable,
69				}, gax.Backoff{
70					Initial:    100 * time.Millisecond,
71					Max:        60000 * time.Millisecond,
72					Multiplier: 1.30,
73				})
74			}),
75		},
76		GetEnvironment: []gax.CallOption{
77			gax.WithRetry(func() gax.Retryer {
78				return gax.OnCodes([]codes.Code{
79					codes.Unavailable,
80				}, gax.Backoff{
81					Initial:    100 * time.Millisecond,
82					Max:        60000 * time.Millisecond,
83					Multiplier: 1.30,
84				})
85			}),
86		},
87		CreateEnvironment: []gax.CallOption{
88			gax.WithRetry(func() gax.Retryer {
89				return gax.OnCodes([]codes.Code{
90					codes.Unavailable,
91				}, gax.Backoff{
92					Initial:    100 * time.Millisecond,
93					Max:        60000 * time.Millisecond,
94					Multiplier: 1.30,
95				})
96			}),
97		},
98		UpdateEnvironment: []gax.CallOption{
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		DeleteEnvironment: []gax.CallOption{
110			gax.WithRetry(func() gax.Retryer {
111				return gax.OnCodes([]codes.Code{
112					codes.Unavailable,
113				}, gax.Backoff{
114					Initial:    100 * time.Millisecond,
115					Max:        60000 * time.Millisecond,
116					Multiplier: 1.30,
117				})
118			}),
119		},
120		GetEnvironmentHistory: []gax.CallOption{
121			gax.WithRetry(func() gax.Retryer {
122				return gax.OnCodes([]codes.Code{
123					codes.Unavailable,
124				}, gax.Backoff{
125					Initial:    100 * time.Millisecond,
126					Max:        60000 * time.Millisecond,
127					Multiplier: 1.30,
128				})
129			}),
130		},
131	}
132}
133
134// internalEnvironmentsClient is an interface that defines the methods availaible from Dialogflow API.
135type internalEnvironmentsClient interface {
136	Close() error
137	setGoogleClientInfo(...string)
138	Connection() *grpc.ClientConn
139	ListEnvironments(context.Context, *dialogflowpb.ListEnvironmentsRequest, ...gax.CallOption) *EnvironmentIterator
140	GetEnvironment(context.Context, *dialogflowpb.GetEnvironmentRequest, ...gax.CallOption) (*dialogflowpb.Environment, error)
141	CreateEnvironment(context.Context, *dialogflowpb.CreateEnvironmentRequest, ...gax.CallOption) (*dialogflowpb.Environment, error)
142	UpdateEnvironment(context.Context, *dialogflowpb.UpdateEnvironmentRequest, ...gax.CallOption) (*dialogflowpb.Environment, error)
143	DeleteEnvironment(context.Context, *dialogflowpb.DeleteEnvironmentRequest, ...gax.CallOption) error
144	GetEnvironmentHistory(context.Context, *dialogflowpb.GetEnvironmentHistoryRequest, ...gax.CallOption) *EnvironmentHistory_EntryIterator
145}
146
147// EnvironmentsClient is a client for interacting with Dialogflow API.
148// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
149//
150// Service for managing Environments.
151type EnvironmentsClient struct {
152	// The internal transport-dependent client.
153	internalClient internalEnvironmentsClient
154
155	// The call options for this service.
156	CallOptions *EnvironmentsCallOptions
157}
158
159// Wrapper methods routed to the internal client.
160
161// Close closes the connection to the API service. The user should invoke this when
162// the client is no longer required.
163func (c *EnvironmentsClient) Close() error {
164	return c.internalClient.Close()
165}
166
167// setGoogleClientInfo sets the name and version of the application in
168// the `x-goog-api-client` header passed on each request. Intended for
169// use by Google-written clients.
170func (c *EnvironmentsClient) setGoogleClientInfo(keyval ...string) {
171	c.internalClient.setGoogleClientInfo(keyval...)
172}
173
174// Connection returns a connection to the API service.
175//
176// Deprecated.
177func (c *EnvironmentsClient) Connection() *grpc.ClientConn {
178	return c.internalClient.Connection()
179}
180
181// ListEnvironments returns the list of all non-default environments of the specified agent.
182func (c *EnvironmentsClient) ListEnvironments(ctx context.Context, req *dialogflowpb.ListEnvironmentsRequest, opts ...gax.CallOption) *EnvironmentIterator {
183	return c.internalClient.ListEnvironments(ctx, req, opts...)
184}
185
186// GetEnvironment retrieves the specified agent environment.
187func (c *EnvironmentsClient) GetEnvironment(ctx context.Context, req *dialogflowpb.GetEnvironmentRequest, opts ...gax.CallOption) (*dialogflowpb.Environment, error) {
188	return c.internalClient.GetEnvironment(ctx, req, opts...)
189}
190
191// CreateEnvironment creates an agent environment.
192func (c *EnvironmentsClient) CreateEnvironment(ctx context.Context, req *dialogflowpb.CreateEnvironmentRequest, opts ...gax.CallOption) (*dialogflowpb.Environment, error) {
193	return c.internalClient.CreateEnvironment(ctx, req, opts...)
194}
195
196// UpdateEnvironment updates the specified agent environment.
197//
198// This method allows you to deploy new agent versions into the environment.
199// When an environment is pointed to a new agent version by setting
200// environment.agent_version, the environment is temporarily set to the
201// LOADING state. During that time, the environment continues serving the
202// previous version of the agent. After the new agent version is done loading,
203// the environment is set back to the RUNNING state.
204// You can use “-” as Environment ID in environment name to update an agent
205// version in the default environment. WARNING: this will negate all recent
206// changes to the draft agent and can’t be undone. You may want to save the
207// draft agent to a version before calling this method.
208func (c *EnvironmentsClient) UpdateEnvironment(ctx context.Context, req *dialogflowpb.UpdateEnvironmentRequest, opts ...gax.CallOption) (*dialogflowpb.Environment, error) {
209	return c.internalClient.UpdateEnvironment(ctx, req, opts...)
210}
211
212// DeleteEnvironment deletes the specified agent environment.
213func (c *EnvironmentsClient) DeleteEnvironment(ctx context.Context, req *dialogflowpb.DeleteEnvironmentRequest, opts ...gax.CallOption) error {
214	return c.internalClient.DeleteEnvironment(ctx, req, opts...)
215}
216
217// GetEnvironmentHistory gets the history of the specified environment.
218func (c *EnvironmentsClient) GetEnvironmentHistory(ctx context.Context, req *dialogflowpb.GetEnvironmentHistoryRequest, opts ...gax.CallOption) *EnvironmentHistory_EntryIterator {
219	return c.internalClient.GetEnvironmentHistory(ctx, req, opts...)
220}
221
222// environmentsGRPCClient is a client for interacting with Dialogflow API over gRPC transport.
223//
224// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
225type environmentsGRPCClient struct {
226	// Connection pool of gRPC connections to the service.
227	connPool gtransport.ConnPool
228
229	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
230	disableDeadlines bool
231
232	// Points back to the CallOptions field of the containing EnvironmentsClient
233	CallOptions **EnvironmentsCallOptions
234
235	// The gRPC API client.
236	environmentsClient dialogflowpb.EnvironmentsClient
237
238	// The x-goog-* metadata to be sent with each request.
239	xGoogMetadata metadata.MD
240}
241
242// NewEnvironmentsClient creates a new environments client based on gRPC.
243// The returned client must be Closed when it is done being used to clean up its underlying connections.
244//
245// Service for managing Environments.
246func NewEnvironmentsClient(ctx context.Context, opts ...option.ClientOption) (*EnvironmentsClient, error) {
247	clientOpts := defaultEnvironmentsGRPCClientOptions()
248	if newEnvironmentsClientHook != nil {
249		hookOpts, err := newEnvironmentsClientHook(ctx, clientHookParams{})
250		if err != nil {
251			return nil, err
252		}
253		clientOpts = append(clientOpts, hookOpts...)
254	}
255
256	disableDeadlines, err := checkDisableDeadlines()
257	if err != nil {
258		return nil, err
259	}
260
261	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
262	if err != nil {
263		return nil, err
264	}
265	client := EnvironmentsClient{CallOptions: defaultEnvironmentsCallOptions()}
266
267	c := &environmentsGRPCClient{
268		connPool:           connPool,
269		disableDeadlines:   disableDeadlines,
270		environmentsClient: dialogflowpb.NewEnvironmentsClient(connPool),
271		CallOptions:        &client.CallOptions,
272	}
273	c.setGoogleClientInfo()
274
275	client.internalClient = c
276
277	return &client, nil
278}
279
280// Connection returns a connection to the API service.
281//
282// Deprecated.
283func (c *environmentsGRPCClient) Connection() *grpc.ClientConn {
284	return c.connPool.Conn()
285}
286
287// setGoogleClientInfo sets the name and version of the application in
288// the `x-goog-api-client` header passed on each request. Intended for
289// use by Google-written clients.
290func (c *environmentsGRPCClient) setGoogleClientInfo(keyval ...string) {
291	kv := append([]string{"gl-go", versionGo()}, keyval...)
292	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
293	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
294}
295
296// Close closes the connection to the API service. The user should invoke this when
297// the client is no longer required.
298func (c *environmentsGRPCClient) Close() error {
299	return c.connPool.Close()
300}
301
302func (c *environmentsGRPCClient) ListEnvironments(ctx context.Context, req *dialogflowpb.ListEnvironmentsRequest, opts ...gax.CallOption) *EnvironmentIterator {
303	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
304	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
305	opts = append((*c.CallOptions).ListEnvironments[0:len((*c.CallOptions).ListEnvironments):len((*c.CallOptions).ListEnvironments)], opts...)
306	it := &EnvironmentIterator{}
307	req = proto.Clone(req).(*dialogflowpb.ListEnvironmentsRequest)
308	it.InternalFetch = func(pageSize int, pageToken string) ([]*dialogflowpb.Environment, string, error) {
309		resp := &dialogflowpb.ListEnvironmentsResponse{}
310		if pageToken != "" {
311			req.PageToken = pageToken
312		}
313		if pageSize > math.MaxInt32 {
314			req.PageSize = math.MaxInt32
315		} else if pageSize != 0 {
316			req.PageSize = int32(pageSize)
317		}
318		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
319			var err error
320			resp, err = c.environmentsClient.ListEnvironments(ctx, req, settings.GRPC...)
321			return err
322		}, opts...)
323		if err != nil {
324			return nil, "", err
325		}
326
327		it.Response = resp
328		return resp.GetEnvironments(), resp.GetNextPageToken(), nil
329	}
330	fetch := func(pageSize int, pageToken string) (string, error) {
331		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
332		if err != nil {
333			return "", err
334		}
335		it.items = append(it.items, items...)
336		return nextPageToken, nil
337	}
338
339	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
340	it.pageInfo.MaxSize = int(req.GetPageSize())
341	it.pageInfo.Token = req.GetPageToken()
342
343	return it
344}
345
346func (c *environmentsGRPCClient) GetEnvironment(ctx context.Context, req *dialogflowpb.GetEnvironmentRequest, opts ...gax.CallOption) (*dialogflowpb.Environment, 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).GetEnvironment[0:len((*c.CallOptions).GetEnvironment):len((*c.CallOptions).GetEnvironment)], opts...)
355	var resp *dialogflowpb.Environment
356	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
357		var err error
358		resp, err = c.environmentsClient.GetEnvironment(ctx, req, settings.GRPC...)
359		return err
360	}, opts...)
361	if err != nil {
362		return nil, err
363	}
364	return resp, nil
365}
366
367func (c *environmentsGRPCClient) CreateEnvironment(ctx context.Context, req *dialogflowpb.CreateEnvironmentRequest, opts ...gax.CallOption) (*dialogflowpb.Environment, error) {
368	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
369		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
370		defer cancel()
371		ctx = cctx
372	}
373	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
374	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
375	opts = append((*c.CallOptions).CreateEnvironment[0:len((*c.CallOptions).CreateEnvironment):len((*c.CallOptions).CreateEnvironment)], opts...)
376	var resp *dialogflowpb.Environment
377	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
378		var err error
379		resp, err = c.environmentsClient.CreateEnvironment(ctx, req, settings.GRPC...)
380		return err
381	}, opts...)
382	if err != nil {
383		return nil, err
384	}
385	return resp, nil
386}
387
388func (c *environmentsGRPCClient) UpdateEnvironment(ctx context.Context, req *dialogflowpb.UpdateEnvironmentRequest, opts ...gax.CallOption) (*dialogflowpb.Environment, error) {
389	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
390		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
391		defer cancel()
392		ctx = cctx
393	}
394	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "environment.name", url.QueryEscape(req.GetEnvironment().GetName())))
395	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
396	opts = append((*c.CallOptions).UpdateEnvironment[0:len((*c.CallOptions).UpdateEnvironment):len((*c.CallOptions).UpdateEnvironment)], opts...)
397	var resp *dialogflowpb.Environment
398	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
399		var err error
400		resp, err = c.environmentsClient.UpdateEnvironment(ctx, req, settings.GRPC...)
401		return err
402	}, opts...)
403	if err != nil {
404		return nil, err
405	}
406	return resp, nil
407}
408
409func (c *environmentsGRPCClient) DeleteEnvironment(ctx context.Context, req *dialogflowpb.DeleteEnvironmentRequest, opts ...gax.CallOption) error {
410	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
411		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
412		defer cancel()
413		ctx = cctx
414	}
415	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
416	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
417	opts = append((*c.CallOptions).DeleteEnvironment[0:len((*c.CallOptions).DeleteEnvironment):len((*c.CallOptions).DeleteEnvironment)], opts...)
418	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
419		var err error
420		_, err = c.environmentsClient.DeleteEnvironment(ctx, req, settings.GRPC...)
421		return err
422	}, opts...)
423	return err
424}
425
426func (c *environmentsGRPCClient) GetEnvironmentHistory(ctx context.Context, req *dialogflowpb.GetEnvironmentHistoryRequest, opts ...gax.CallOption) *EnvironmentHistory_EntryIterator {
427	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
428	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
429	opts = append((*c.CallOptions).GetEnvironmentHistory[0:len((*c.CallOptions).GetEnvironmentHistory):len((*c.CallOptions).GetEnvironmentHistory)], opts...)
430	it := &EnvironmentHistory_EntryIterator{}
431	req = proto.Clone(req).(*dialogflowpb.GetEnvironmentHistoryRequest)
432	it.InternalFetch = func(pageSize int, pageToken string) ([]*dialogflowpb.EnvironmentHistory_Entry, string, error) {
433		resp := &dialogflowpb.EnvironmentHistory{}
434		if pageToken != "" {
435			req.PageToken = pageToken
436		}
437		if pageSize > math.MaxInt32 {
438			req.PageSize = math.MaxInt32
439		} else if pageSize != 0 {
440			req.PageSize = int32(pageSize)
441		}
442		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
443			var err error
444			resp, err = c.environmentsClient.GetEnvironmentHistory(ctx, req, settings.GRPC...)
445			return err
446		}, opts...)
447		if err != nil {
448			return nil, "", err
449		}
450
451		it.Response = resp
452		return resp.GetEntries(), resp.GetNextPageToken(), nil
453	}
454	fetch := func(pageSize int, pageToken string) (string, error) {
455		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
456		if err != nil {
457			return "", err
458		}
459		it.items = append(it.items, items...)
460		return nextPageToken, nil
461	}
462
463	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
464	it.pageInfo.MaxSize = int(req.GetPageSize())
465	it.pageInfo.Token = req.GetPageToken()
466
467	return it
468}
469
470// EnvironmentHistory_EntryIterator manages a stream of *dialogflowpb.EnvironmentHistory_Entry.
471type EnvironmentHistory_EntryIterator struct {
472	items    []*dialogflowpb.EnvironmentHistory_Entry
473	pageInfo *iterator.PageInfo
474	nextFunc func() error
475
476	// Response is the raw response for the current page.
477	// It must be cast to the RPC response type.
478	// Calling Next() or InternalFetch() updates this value.
479	Response interface{}
480
481	// InternalFetch is for use by the Google Cloud Libraries only.
482	// It is not part of the stable interface of this package.
483	//
484	// InternalFetch returns results from a single call to the underlying RPC.
485	// The number of results is no greater than pageSize.
486	// If there are no more results, nextPageToken is empty and err is nil.
487	InternalFetch func(pageSize int, pageToken string) (results []*dialogflowpb.EnvironmentHistory_Entry, nextPageToken string, err error)
488}
489
490// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
491func (it *EnvironmentHistory_EntryIterator) PageInfo() *iterator.PageInfo {
492	return it.pageInfo
493}
494
495// Next returns the next result. Its second return value is iterator.Done if there are no more
496// results. Once Next returns Done, all subsequent calls will return Done.
497func (it *EnvironmentHistory_EntryIterator) Next() (*dialogflowpb.EnvironmentHistory_Entry, error) {
498	var item *dialogflowpb.EnvironmentHistory_Entry
499	if err := it.nextFunc(); err != nil {
500		return item, err
501	}
502	item = it.items[0]
503	it.items = it.items[1:]
504	return item, nil
505}
506
507func (it *EnvironmentHistory_EntryIterator) bufLen() int {
508	return len(it.items)
509}
510
511func (it *EnvironmentHistory_EntryIterator) takeBuf() interface{} {
512	b := it.items
513	it.items = nil
514	return b
515}
516
517// EnvironmentIterator manages a stream of *dialogflowpb.Environment.
518type EnvironmentIterator struct {
519	items    []*dialogflowpb.Environment
520	pageInfo *iterator.PageInfo
521	nextFunc func() error
522
523	// Response is the raw response for the current page.
524	// It must be cast to the RPC response type.
525	// Calling Next() or InternalFetch() updates this value.
526	Response interface{}
527
528	// InternalFetch is for use by the Google Cloud Libraries only.
529	// It is not part of the stable interface of this package.
530	//
531	// InternalFetch returns results from a single call to the underlying RPC.
532	// The number of results is no greater than pageSize.
533	// If there are no more results, nextPageToken is empty and err is nil.
534	InternalFetch func(pageSize int, pageToken string) (results []*dialogflowpb.Environment, nextPageToken string, err error)
535}
536
537// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
538func (it *EnvironmentIterator) PageInfo() *iterator.PageInfo {
539	return it.pageInfo
540}
541
542// Next returns the next result. Its second return value is iterator.Done if there are no more
543// results. Once Next returns Done, all subsequent calls will return Done.
544func (it *EnvironmentIterator) Next() (*dialogflowpb.Environment, error) {
545	var item *dialogflowpb.Environment
546	if err := it.nextFunc(); err != nil {
547		return item, err
548	}
549	item = it.items[0]
550	it.items = it.items[1:]
551	return item, nil
552}
553
554func (it *EnvironmentIterator) bufLen() int {
555	return len(it.items)
556}
557
558func (it *EnvironmentIterator) takeBuf() interface{} {
559	b := it.items
560	it.items = nil
561	return b
562}
563