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 logging
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	monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres"
32	loggingpb "google.golang.org/genproto/googleapis/logging/v2"
33	"google.golang.org/grpc"
34	"google.golang.org/grpc/codes"
35	"google.golang.org/grpc/metadata"
36	"google.golang.org/protobuf/proto"
37)
38
39var newClientHook clientHook
40
41// CallOptions contains the retry settings for each method of Client.
42type CallOptions struct {
43	DeleteLog                        []gax.CallOption
44	WriteLogEntries                  []gax.CallOption
45	ListLogEntries                   []gax.CallOption
46	ListMonitoredResourceDescriptors []gax.CallOption
47	ListLogs                         []gax.CallOption
48	TailLogEntries                   []gax.CallOption
49}
50
51func defaultGRPCClientOptions() []option.ClientOption {
52	return []option.ClientOption{
53		internaloption.WithDefaultEndpoint("logging.googleapis.com:443"),
54		internaloption.WithDefaultMTLSEndpoint("logging.mtls.googleapis.com:443"),
55		internaloption.WithDefaultAudience("https://logging.googleapis.com/"),
56		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
57		internaloption.EnableJwtWithScope(),
58		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
59		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
60			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
61	}
62}
63
64func defaultCallOptions() *CallOptions {
65	return &CallOptions{
66		DeleteLog: []gax.CallOption{
67			gax.WithRetry(func() gax.Retryer {
68				return gax.OnCodes([]codes.Code{
69					codes.DeadlineExceeded,
70					codes.Internal,
71					codes.Unavailable,
72				}, gax.Backoff{
73					Initial:    100 * time.Millisecond,
74					Max:        60000 * time.Millisecond,
75					Multiplier: 1.30,
76				})
77			}),
78		},
79		WriteLogEntries: []gax.CallOption{
80			gax.WithRetry(func() gax.Retryer {
81				return gax.OnCodes([]codes.Code{
82					codes.DeadlineExceeded,
83					codes.Internal,
84					codes.Unavailable,
85				}, gax.Backoff{
86					Initial:    100 * time.Millisecond,
87					Max:        60000 * time.Millisecond,
88					Multiplier: 1.30,
89				})
90			}),
91		},
92		ListLogEntries: []gax.CallOption{
93			gax.WithRetry(func() gax.Retryer {
94				return gax.OnCodes([]codes.Code{
95					codes.DeadlineExceeded,
96					codes.Internal,
97					codes.Unavailable,
98				}, gax.Backoff{
99					Initial:    100 * time.Millisecond,
100					Max:        60000 * time.Millisecond,
101					Multiplier: 1.30,
102				})
103			}),
104		},
105		ListMonitoredResourceDescriptors: []gax.CallOption{
106			gax.WithRetry(func() gax.Retryer {
107				return gax.OnCodes([]codes.Code{
108					codes.DeadlineExceeded,
109					codes.Internal,
110					codes.Unavailable,
111				}, gax.Backoff{
112					Initial:    100 * time.Millisecond,
113					Max:        60000 * time.Millisecond,
114					Multiplier: 1.30,
115				})
116			}),
117		},
118		ListLogs: []gax.CallOption{
119			gax.WithRetry(func() gax.Retryer {
120				return gax.OnCodes([]codes.Code{
121					codes.DeadlineExceeded,
122					codes.Internal,
123					codes.Unavailable,
124				}, gax.Backoff{
125					Initial:    100 * time.Millisecond,
126					Max:        60000 * time.Millisecond,
127					Multiplier: 1.30,
128				})
129			}),
130		},
131		TailLogEntries: []gax.CallOption{
132			gax.WithRetry(func() gax.Retryer {
133				return gax.OnCodes([]codes.Code{
134					codes.DeadlineExceeded,
135					codes.Internal,
136					codes.Unavailable,
137				}, gax.Backoff{
138					Initial:    100 * time.Millisecond,
139					Max:        60000 * time.Millisecond,
140					Multiplier: 1.30,
141				})
142			}),
143		},
144	}
145}
146
147// internalClient is an interface that defines the methods availaible from Cloud Logging API.
148type internalClient interface {
149	Close() error
150	setGoogleClientInfo(...string)
151	Connection() *grpc.ClientConn
152	DeleteLog(context.Context, *loggingpb.DeleteLogRequest, ...gax.CallOption) error
153	WriteLogEntries(context.Context, *loggingpb.WriteLogEntriesRequest, ...gax.CallOption) (*loggingpb.WriteLogEntriesResponse, error)
154	ListLogEntries(context.Context, *loggingpb.ListLogEntriesRequest, ...gax.CallOption) *LogEntryIterator
155	ListMonitoredResourceDescriptors(context.Context, *loggingpb.ListMonitoredResourceDescriptorsRequest, ...gax.CallOption) *MonitoredResourceDescriptorIterator
156	ListLogs(context.Context, *loggingpb.ListLogsRequest, ...gax.CallOption) *StringIterator
157	TailLogEntries(context.Context, ...gax.CallOption) (loggingpb.LoggingServiceV2_TailLogEntriesClient, error)
158}
159
160// Client is a client for interacting with Cloud Logging API.
161// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
162//
163// Service for ingesting and querying logs.
164type Client struct {
165	// The internal transport-dependent client.
166	internalClient internalClient
167
168	// The call options for this service.
169	CallOptions *CallOptions
170}
171
172// Wrapper methods routed to the internal client.
173
174// Close closes the connection to the API service. The user should invoke this when
175// the client is no longer required.
176func (c *Client) Close() error {
177	return c.internalClient.Close()
178}
179
180// setGoogleClientInfo sets the name and version of the application in
181// the `x-goog-api-client` header passed on each request. Intended for
182// use by Google-written clients.
183func (c *Client) setGoogleClientInfo(keyval ...string) {
184	c.internalClient.setGoogleClientInfo(keyval...)
185}
186
187// Connection returns a connection to the API service.
188//
189// Deprecated.
190func (c *Client) Connection() *grpc.ClientConn {
191	return c.internalClient.Connection()
192}
193
194// DeleteLog deletes all the log entries in a log. The log reappears if it receives new
195// entries. Log entries written shortly before the delete operation might not
196// be deleted. Entries received after the delete operation with a timestamp
197// before the operation will be deleted.
198func (c *Client) DeleteLog(ctx context.Context, req *loggingpb.DeleteLogRequest, opts ...gax.CallOption) error {
199	return c.internalClient.DeleteLog(ctx, req, opts...)
200}
201
202// WriteLogEntries writes log entries to Logging. This API method is the
203// only way to send log entries to Logging. This method
204// is used, directly or indirectly, by the Logging agent
205// (fluentd) and all logging libraries configured to use Logging.
206// A single request may contain log entries for a maximum of 1000
207// different resources (projects, organizations, billing accounts or
208// folders)
209func (c *Client) WriteLogEntries(ctx context.Context, req *loggingpb.WriteLogEntriesRequest, opts ...gax.CallOption) (*loggingpb.WriteLogEntriesResponse, error) {
210	return c.internalClient.WriteLogEntries(ctx, req, opts...)
211}
212
213// ListLogEntries lists log entries.  Use this method to retrieve log entries that originated
214// from a project/folder/organization/billing account.  For ways to export log
215// entries, see Exporting
216// Logs (at https://cloud.google.com/logging/docs/export).
217func (c *Client) ListLogEntries(ctx context.Context, req *loggingpb.ListLogEntriesRequest, opts ...gax.CallOption) *LogEntryIterator {
218	return c.internalClient.ListLogEntries(ctx, req, opts...)
219}
220
221// ListMonitoredResourceDescriptors lists the descriptors for monitored resource types used by Logging.
222func (c *Client) ListMonitoredResourceDescriptors(ctx context.Context, req *loggingpb.ListMonitoredResourceDescriptorsRequest, opts ...gax.CallOption) *MonitoredResourceDescriptorIterator {
223	return c.internalClient.ListMonitoredResourceDescriptors(ctx, req, opts...)
224}
225
226// ListLogs lists the logs in projects, organizations, folders, or billing accounts.
227// Only logs that have entries are listed.
228func (c *Client) ListLogs(ctx context.Context, req *loggingpb.ListLogsRequest, opts ...gax.CallOption) *StringIterator {
229	return c.internalClient.ListLogs(ctx, req, opts...)
230}
231
232// TailLogEntries streaming read of log entries as they are ingested. Until the stream is
233// terminated, it will continue reading logs.
234func (c *Client) TailLogEntries(ctx context.Context, opts ...gax.CallOption) (loggingpb.LoggingServiceV2_TailLogEntriesClient, error) {
235	return c.internalClient.TailLogEntries(ctx, opts...)
236}
237
238// gRPCClient is a client for interacting with Cloud Logging API over gRPC transport.
239//
240// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
241type gRPCClient struct {
242	// Connection pool of gRPC connections to the service.
243	connPool gtransport.ConnPool
244
245	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
246	disableDeadlines bool
247
248	// Points back to the CallOptions field of the containing Client
249	CallOptions **CallOptions
250
251	// The gRPC API client.
252	client loggingpb.LoggingServiceV2Client
253
254	// The x-goog-* metadata to be sent with each request.
255	xGoogMetadata metadata.MD
256}
257
258// NewClient creates a new logging service v2 client based on gRPC.
259// The returned client must be Closed when it is done being used to clean up its underlying connections.
260//
261// Service for ingesting and querying logs.
262func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
263	clientOpts := defaultGRPCClientOptions()
264	if newClientHook != nil {
265		hookOpts, err := newClientHook(ctx, clientHookParams{})
266		if err != nil {
267			return nil, err
268		}
269		clientOpts = append(clientOpts, hookOpts...)
270	}
271
272	disableDeadlines, err := checkDisableDeadlines()
273	if err != nil {
274		return nil, err
275	}
276
277	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
278	if err != nil {
279		return nil, err
280	}
281	client := Client{CallOptions: defaultCallOptions()}
282
283	c := &gRPCClient{
284		connPool:         connPool,
285		disableDeadlines: disableDeadlines,
286		client:           loggingpb.NewLoggingServiceV2Client(connPool),
287		CallOptions:      &client.CallOptions,
288	}
289	c.setGoogleClientInfo()
290
291	client.internalClient = c
292
293	return &client, nil
294}
295
296// Connection returns a connection to the API service.
297//
298// Deprecated.
299func (c *gRPCClient) Connection() *grpc.ClientConn {
300	return c.connPool.Conn()
301}
302
303// setGoogleClientInfo sets the name and version of the application in
304// the `x-goog-api-client` header passed on each request. Intended for
305// use by Google-written clients.
306func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
307	kv := append([]string{"gl-go", versionGo()}, keyval...)
308	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
309	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
310}
311
312// Close closes the connection to the API service. The user should invoke this when
313// the client is no longer required.
314func (c *gRPCClient) Close() error {
315	return c.connPool.Close()
316}
317
318func (c *gRPCClient) DeleteLog(ctx context.Context, req *loggingpb.DeleteLogRequest, opts ...gax.CallOption) error {
319	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
320		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
321		defer cancel()
322		ctx = cctx
323	}
324	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "log_name", url.QueryEscape(req.GetLogName())))
325	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
326	opts = append((*c.CallOptions).DeleteLog[0:len((*c.CallOptions).DeleteLog):len((*c.CallOptions).DeleteLog)], opts...)
327	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
328		var err error
329		_, err = c.client.DeleteLog(ctx, req, settings.GRPC...)
330		return err
331	}, opts...)
332	return err
333}
334
335func (c *gRPCClient) WriteLogEntries(ctx context.Context, req *loggingpb.WriteLogEntriesRequest, opts ...gax.CallOption) (*loggingpb.WriteLogEntriesResponse, error) {
336	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
337		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
338		defer cancel()
339		ctx = cctx
340	}
341	ctx = insertMetadata(ctx, c.xGoogMetadata)
342	opts = append((*c.CallOptions).WriteLogEntries[0:len((*c.CallOptions).WriteLogEntries):len((*c.CallOptions).WriteLogEntries)], opts...)
343	var resp *loggingpb.WriteLogEntriesResponse
344	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
345		var err error
346		resp, err = c.client.WriteLogEntries(ctx, req, settings.GRPC...)
347		return err
348	}, opts...)
349	if err != nil {
350		return nil, err
351	}
352	return resp, nil
353}
354
355func (c *gRPCClient) ListLogEntries(ctx context.Context, req *loggingpb.ListLogEntriesRequest, opts ...gax.CallOption) *LogEntryIterator {
356	ctx = insertMetadata(ctx, c.xGoogMetadata)
357	opts = append((*c.CallOptions).ListLogEntries[0:len((*c.CallOptions).ListLogEntries):len((*c.CallOptions).ListLogEntries)], opts...)
358	it := &LogEntryIterator{}
359	req = proto.Clone(req).(*loggingpb.ListLogEntriesRequest)
360	it.InternalFetch = func(pageSize int, pageToken string) ([]*loggingpb.LogEntry, string, error) {
361		resp := &loggingpb.ListLogEntriesResponse{}
362		if pageToken != "" {
363			req.PageToken = pageToken
364		}
365		if pageSize > math.MaxInt32 {
366			req.PageSize = math.MaxInt32
367		} else if pageSize != 0 {
368			req.PageSize = int32(pageSize)
369		}
370		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
371			var err error
372			resp, err = c.client.ListLogEntries(ctx, req, settings.GRPC...)
373			return err
374		}, opts...)
375		if err != nil {
376			return nil, "", err
377		}
378
379		it.Response = resp
380		return resp.GetEntries(), resp.GetNextPageToken(), nil
381	}
382	fetch := func(pageSize int, pageToken string) (string, error) {
383		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
384		if err != nil {
385			return "", err
386		}
387		it.items = append(it.items, items...)
388		return nextPageToken, nil
389	}
390
391	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
392	it.pageInfo.MaxSize = int(req.GetPageSize())
393	it.pageInfo.Token = req.GetPageToken()
394
395	return it
396}
397
398func (c *gRPCClient) ListMonitoredResourceDescriptors(ctx context.Context, req *loggingpb.ListMonitoredResourceDescriptorsRequest, opts ...gax.CallOption) *MonitoredResourceDescriptorIterator {
399	ctx = insertMetadata(ctx, c.xGoogMetadata)
400	opts = append((*c.CallOptions).ListMonitoredResourceDescriptors[0:len((*c.CallOptions).ListMonitoredResourceDescriptors):len((*c.CallOptions).ListMonitoredResourceDescriptors)], opts...)
401	it := &MonitoredResourceDescriptorIterator{}
402	req = proto.Clone(req).(*loggingpb.ListMonitoredResourceDescriptorsRequest)
403	it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoredrespb.MonitoredResourceDescriptor, string, error) {
404		resp := &loggingpb.ListMonitoredResourceDescriptorsResponse{}
405		if pageToken != "" {
406			req.PageToken = pageToken
407		}
408		if pageSize > math.MaxInt32 {
409			req.PageSize = math.MaxInt32
410		} else if pageSize != 0 {
411			req.PageSize = int32(pageSize)
412		}
413		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
414			var err error
415			resp, err = c.client.ListMonitoredResourceDescriptors(ctx, req, settings.GRPC...)
416			return err
417		}, opts...)
418		if err != nil {
419			return nil, "", err
420		}
421
422		it.Response = resp
423		return resp.GetResourceDescriptors(), resp.GetNextPageToken(), nil
424	}
425	fetch := func(pageSize int, pageToken string) (string, error) {
426		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
427		if err != nil {
428			return "", err
429		}
430		it.items = append(it.items, items...)
431		return nextPageToken, nil
432	}
433
434	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
435	it.pageInfo.MaxSize = int(req.GetPageSize())
436	it.pageInfo.Token = req.GetPageToken()
437
438	return it
439}
440
441func (c *gRPCClient) ListLogs(ctx context.Context, req *loggingpb.ListLogsRequest, opts ...gax.CallOption) *StringIterator {
442	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
443	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
444	opts = append((*c.CallOptions).ListLogs[0:len((*c.CallOptions).ListLogs):len((*c.CallOptions).ListLogs)], opts...)
445	it := &StringIterator{}
446	req = proto.Clone(req).(*loggingpb.ListLogsRequest)
447	it.InternalFetch = func(pageSize int, pageToken string) ([]string, string, error) {
448		resp := &loggingpb.ListLogsResponse{}
449		if pageToken != "" {
450			req.PageToken = pageToken
451		}
452		if pageSize > math.MaxInt32 {
453			req.PageSize = math.MaxInt32
454		} else if pageSize != 0 {
455			req.PageSize = int32(pageSize)
456		}
457		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
458			var err error
459			resp, err = c.client.ListLogs(ctx, req, settings.GRPC...)
460			return err
461		}, opts...)
462		if err != nil {
463			return nil, "", err
464		}
465
466		it.Response = resp
467		return resp.GetLogNames(), resp.GetNextPageToken(), nil
468	}
469	fetch := func(pageSize int, pageToken string) (string, error) {
470		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
471		if err != nil {
472			return "", err
473		}
474		it.items = append(it.items, items...)
475		return nextPageToken, nil
476	}
477
478	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
479	it.pageInfo.MaxSize = int(req.GetPageSize())
480	it.pageInfo.Token = req.GetPageToken()
481
482	return it
483}
484
485func (c *gRPCClient) TailLogEntries(ctx context.Context, opts ...gax.CallOption) (loggingpb.LoggingServiceV2_TailLogEntriesClient, error) {
486	ctx = insertMetadata(ctx, c.xGoogMetadata)
487	var resp loggingpb.LoggingServiceV2_TailLogEntriesClient
488	opts = append((*c.CallOptions).TailLogEntries[0:len((*c.CallOptions).TailLogEntries):len((*c.CallOptions).TailLogEntries)], opts...)
489	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
490		var err error
491		resp, err = c.client.TailLogEntries(ctx, settings.GRPC...)
492		return err
493	}, opts...)
494	if err != nil {
495		return nil, err
496	}
497	return resp, nil
498}
499
500// LogEntryIterator manages a stream of *loggingpb.LogEntry.
501type LogEntryIterator struct {
502	items    []*loggingpb.LogEntry
503	pageInfo *iterator.PageInfo
504	nextFunc func() error
505
506	// Response is the raw response for the current page.
507	// It must be cast to the RPC response type.
508	// Calling Next() or InternalFetch() updates this value.
509	Response interface{}
510
511	// InternalFetch is for use by the Google Cloud Libraries only.
512	// It is not part of the stable interface of this package.
513	//
514	// InternalFetch returns results from a single call to the underlying RPC.
515	// The number of results is no greater than pageSize.
516	// If there are no more results, nextPageToken is empty and err is nil.
517	InternalFetch func(pageSize int, pageToken string) (results []*loggingpb.LogEntry, nextPageToken string, err error)
518}
519
520// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
521func (it *LogEntryIterator) PageInfo() *iterator.PageInfo {
522	return it.pageInfo
523}
524
525// Next returns the next result. Its second return value is iterator.Done if there are no more
526// results. Once Next returns Done, all subsequent calls will return Done.
527func (it *LogEntryIterator) Next() (*loggingpb.LogEntry, error) {
528	var item *loggingpb.LogEntry
529	if err := it.nextFunc(); err != nil {
530		return item, err
531	}
532	item = it.items[0]
533	it.items = it.items[1:]
534	return item, nil
535}
536
537func (it *LogEntryIterator) bufLen() int {
538	return len(it.items)
539}
540
541func (it *LogEntryIterator) takeBuf() interface{} {
542	b := it.items
543	it.items = nil
544	return b
545}
546
547// MonitoredResourceDescriptorIterator manages a stream of *monitoredrespb.MonitoredResourceDescriptor.
548type MonitoredResourceDescriptorIterator struct {
549	items    []*monitoredrespb.MonitoredResourceDescriptor
550	pageInfo *iterator.PageInfo
551	nextFunc func() error
552
553	// Response is the raw response for the current page.
554	// It must be cast to the RPC response type.
555	// Calling Next() or InternalFetch() updates this value.
556	Response interface{}
557
558	// InternalFetch is for use by the Google Cloud Libraries only.
559	// It is not part of the stable interface of this package.
560	//
561	// InternalFetch returns results from a single call to the underlying RPC.
562	// The number of results is no greater than pageSize.
563	// If there are no more results, nextPageToken is empty and err is nil.
564	InternalFetch func(pageSize int, pageToken string) (results []*monitoredrespb.MonitoredResourceDescriptor, nextPageToken string, err error)
565}
566
567// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
568func (it *MonitoredResourceDescriptorIterator) PageInfo() *iterator.PageInfo {
569	return it.pageInfo
570}
571
572// Next returns the next result. Its second return value is iterator.Done if there are no more
573// results. Once Next returns Done, all subsequent calls will return Done.
574func (it *MonitoredResourceDescriptorIterator) Next() (*monitoredrespb.MonitoredResourceDescriptor, error) {
575	var item *monitoredrespb.MonitoredResourceDescriptor
576	if err := it.nextFunc(); err != nil {
577		return item, err
578	}
579	item = it.items[0]
580	it.items = it.items[1:]
581	return item, nil
582}
583
584func (it *MonitoredResourceDescriptorIterator) bufLen() int {
585	return len(it.items)
586}
587
588func (it *MonitoredResourceDescriptorIterator) takeBuf() interface{} {
589	b := it.items
590	it.items = nil
591	return b
592}
593
594// StringIterator manages a stream of string.
595type StringIterator struct {
596	items    []string
597	pageInfo *iterator.PageInfo
598	nextFunc func() error
599
600	// Response is the raw response for the current page.
601	// It must be cast to the RPC response type.
602	// Calling Next() or InternalFetch() updates this value.
603	Response interface{}
604
605	// InternalFetch is for use by the Google Cloud Libraries only.
606	// It is not part of the stable interface of this package.
607	//
608	// InternalFetch returns results from a single call to the underlying RPC.
609	// The number of results is no greater than pageSize.
610	// If there are no more results, nextPageToken is empty and err is nil.
611	InternalFetch func(pageSize int, pageToken string) (results []string, nextPageToken string, err error)
612}
613
614// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
615func (it *StringIterator) PageInfo() *iterator.PageInfo {
616	return it.pageInfo
617}
618
619// Next returns the next result. Its second return value is iterator.Done if there are no more
620// results. Once Next returns Done, all subsequent calls will return Done.
621func (it *StringIterator) Next() (string, error) {
622	var item string
623	if err := it.nextFunc(); err != nil {
624		return item, err
625	}
626	item = it.items[0]
627	it.items = it.items[1:]
628	return item, nil
629}
630
631func (it *StringIterator) bufLen() int {
632	return len(it.items)
633}
634
635func (it *StringIterator) takeBuf() interface{} {
636	b := it.items
637	it.items = nil
638	return b
639}
640