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 monitoring
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	monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
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 newUptimeCheckClientHook clientHook
39
40// UptimeCheckCallOptions contains the retry settings for each method of UptimeCheckClient.
41type UptimeCheckCallOptions struct {
42	ListUptimeCheckConfigs  []gax.CallOption
43	GetUptimeCheckConfig    []gax.CallOption
44	CreateUptimeCheckConfig []gax.CallOption
45	UpdateUptimeCheckConfig []gax.CallOption
46	DeleteUptimeCheckConfig []gax.CallOption
47	ListUptimeCheckIps      []gax.CallOption
48}
49
50func defaultUptimeCheckGRPCClientOptions() []option.ClientOption {
51	return []option.ClientOption{
52		internaloption.WithDefaultEndpoint("monitoring.googleapis.com:443"),
53		internaloption.WithDefaultMTLSEndpoint("monitoring.mtls.googleapis.com:443"),
54		internaloption.WithDefaultAudience("https://monitoring.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 defaultUptimeCheckCallOptions() *UptimeCheckCallOptions {
64	return &UptimeCheckCallOptions{
65		ListUptimeCheckConfigs: []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:        30000 * time.Millisecond,
72					Multiplier: 1.30,
73				})
74			}),
75		},
76		GetUptimeCheckConfig: []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:        30000 * time.Millisecond,
83					Multiplier: 1.30,
84				})
85			}),
86		},
87		CreateUptimeCheckConfig: []gax.CallOption{},
88		UpdateUptimeCheckConfig: []gax.CallOption{},
89		DeleteUptimeCheckConfig: []gax.CallOption{
90			gax.WithRetry(func() gax.Retryer {
91				return gax.OnCodes([]codes.Code{
92					codes.Unavailable,
93				}, gax.Backoff{
94					Initial:    100 * time.Millisecond,
95					Max:        30000 * time.Millisecond,
96					Multiplier: 1.30,
97				})
98			}),
99		},
100		ListUptimeCheckIps: []gax.CallOption{
101			gax.WithRetry(func() gax.Retryer {
102				return gax.OnCodes([]codes.Code{
103					codes.Unavailable,
104				}, gax.Backoff{
105					Initial:    100 * time.Millisecond,
106					Max:        30000 * time.Millisecond,
107					Multiplier: 1.30,
108				})
109			}),
110		},
111	}
112}
113
114// internalUptimeCheckClient is an interface that defines the methods availaible from Cloud Monitoring API.
115type internalUptimeCheckClient interface {
116	Close() error
117	setGoogleClientInfo(...string)
118	Connection() *grpc.ClientConn
119	ListUptimeCheckConfigs(context.Context, *monitoringpb.ListUptimeCheckConfigsRequest, ...gax.CallOption) *UptimeCheckConfigIterator
120	GetUptimeCheckConfig(context.Context, *monitoringpb.GetUptimeCheckConfigRequest, ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error)
121	CreateUptimeCheckConfig(context.Context, *monitoringpb.CreateUptimeCheckConfigRequest, ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error)
122	UpdateUptimeCheckConfig(context.Context, *monitoringpb.UpdateUptimeCheckConfigRequest, ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error)
123	DeleteUptimeCheckConfig(context.Context, *monitoringpb.DeleteUptimeCheckConfigRequest, ...gax.CallOption) error
124	ListUptimeCheckIps(context.Context, *monitoringpb.ListUptimeCheckIpsRequest, ...gax.CallOption) *UptimeCheckIpIterator
125}
126
127// UptimeCheckClient is a client for interacting with Cloud Monitoring API.
128// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
129//
130// The UptimeCheckService API is used to manage (list, create, delete, edit)
131// Uptime check configurations in the Stackdriver Monitoring product. An Uptime
132// check is a piece of configuration that determines which resources and
133// services to monitor for availability. These configurations can also be
134// configured interactively by navigating to the [Cloud Console]
135// (http://console.cloud.google.com (at http://console.cloud.google.com)), selecting the appropriate project,
136// clicking on “Monitoring” on the left-hand side to navigate to Stackdriver,
137// and then clicking on “Uptime”.
138type UptimeCheckClient struct {
139	// The internal transport-dependent client.
140	internalClient internalUptimeCheckClient
141
142	// The call options for this service.
143	CallOptions *UptimeCheckCallOptions
144}
145
146// Wrapper methods routed to the internal client.
147
148// Close closes the connection to the API service. The user should invoke this when
149// the client is no longer required.
150func (c *UptimeCheckClient) Close() error {
151	return c.internalClient.Close()
152}
153
154// setGoogleClientInfo sets the name and version of the application in
155// the `x-goog-api-client` header passed on each request. Intended for
156// use by Google-written clients.
157func (c *UptimeCheckClient) setGoogleClientInfo(keyval ...string) {
158	c.internalClient.setGoogleClientInfo(keyval...)
159}
160
161// Connection returns a connection to the API service.
162//
163// Deprecated.
164func (c *UptimeCheckClient) Connection() *grpc.ClientConn {
165	return c.internalClient.Connection()
166}
167
168// ListUptimeCheckConfigs lists the existing valid Uptime check configurations for the project
169// (leaving out any invalid configurations).
170func (c *UptimeCheckClient) ListUptimeCheckConfigs(ctx context.Context, req *monitoringpb.ListUptimeCheckConfigsRequest, opts ...gax.CallOption) *UptimeCheckConfigIterator {
171	return c.internalClient.ListUptimeCheckConfigs(ctx, req, opts...)
172}
173
174// GetUptimeCheckConfig gets a single Uptime check configuration.
175func (c *UptimeCheckClient) GetUptimeCheckConfig(ctx context.Context, req *monitoringpb.GetUptimeCheckConfigRequest, opts ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error) {
176	return c.internalClient.GetUptimeCheckConfig(ctx, req, opts...)
177}
178
179// CreateUptimeCheckConfig creates a new Uptime check configuration.
180func (c *UptimeCheckClient) CreateUptimeCheckConfig(ctx context.Context, req *monitoringpb.CreateUptimeCheckConfigRequest, opts ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error) {
181	return c.internalClient.CreateUptimeCheckConfig(ctx, req, opts...)
182}
183
184// UpdateUptimeCheckConfig updates an Uptime check configuration. You can either replace the entire
185// configuration with a new one or replace only certain fields in the current
186// configuration by specifying the fields to be updated via updateMask.
187// Returns the updated configuration.
188func (c *UptimeCheckClient) UpdateUptimeCheckConfig(ctx context.Context, req *monitoringpb.UpdateUptimeCheckConfigRequest, opts ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error) {
189	return c.internalClient.UpdateUptimeCheckConfig(ctx, req, opts...)
190}
191
192// DeleteUptimeCheckConfig deletes an Uptime check configuration. Note that this method will fail
193// if the Uptime check configuration is referenced by an alert policy or
194// other dependent configs that would be rendered invalid by the deletion.
195func (c *UptimeCheckClient) DeleteUptimeCheckConfig(ctx context.Context, req *monitoringpb.DeleteUptimeCheckConfigRequest, opts ...gax.CallOption) error {
196	return c.internalClient.DeleteUptimeCheckConfig(ctx, req, opts...)
197}
198
199// ListUptimeCheckIps returns the list of IP addresses that checkers run from
200func (c *UptimeCheckClient) ListUptimeCheckIps(ctx context.Context, req *monitoringpb.ListUptimeCheckIpsRequest, opts ...gax.CallOption) *UptimeCheckIpIterator {
201	return c.internalClient.ListUptimeCheckIps(ctx, req, opts...)
202}
203
204// uptimeCheckGRPCClient is a client for interacting with Cloud Monitoring API over gRPC transport.
205//
206// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
207type uptimeCheckGRPCClient struct {
208	// Connection pool of gRPC connections to the service.
209	connPool gtransport.ConnPool
210
211	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
212	disableDeadlines bool
213
214	// Points back to the CallOptions field of the containing UptimeCheckClient
215	CallOptions **UptimeCheckCallOptions
216
217	// The gRPC API client.
218	uptimeCheckClient monitoringpb.UptimeCheckServiceClient
219
220	// The x-goog-* metadata to be sent with each request.
221	xGoogMetadata metadata.MD
222}
223
224// NewUptimeCheckClient creates a new uptime check service client based on gRPC.
225// The returned client must be Closed when it is done being used to clean up its underlying connections.
226//
227// The UptimeCheckService API is used to manage (list, create, delete, edit)
228// Uptime check configurations in the Stackdriver Monitoring product. An Uptime
229// check is a piece of configuration that determines which resources and
230// services to monitor for availability. These configurations can also be
231// configured interactively by navigating to the [Cloud Console]
232// (http://console.cloud.google.com (at http://console.cloud.google.com)), selecting the appropriate project,
233// clicking on “Monitoring” on the left-hand side to navigate to Stackdriver,
234// and then clicking on “Uptime”.
235func NewUptimeCheckClient(ctx context.Context, opts ...option.ClientOption) (*UptimeCheckClient, error) {
236	clientOpts := defaultUptimeCheckGRPCClientOptions()
237	if newUptimeCheckClientHook != nil {
238		hookOpts, err := newUptimeCheckClientHook(ctx, clientHookParams{})
239		if err != nil {
240			return nil, err
241		}
242		clientOpts = append(clientOpts, hookOpts...)
243	}
244
245	disableDeadlines, err := checkDisableDeadlines()
246	if err != nil {
247		return nil, err
248	}
249
250	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
251	if err != nil {
252		return nil, err
253	}
254	client := UptimeCheckClient{CallOptions: defaultUptimeCheckCallOptions()}
255
256	c := &uptimeCheckGRPCClient{
257		connPool:          connPool,
258		disableDeadlines:  disableDeadlines,
259		uptimeCheckClient: monitoringpb.NewUptimeCheckServiceClient(connPool),
260		CallOptions:       &client.CallOptions,
261	}
262	c.setGoogleClientInfo()
263
264	client.internalClient = c
265
266	return &client, nil
267}
268
269// Connection returns a connection to the API service.
270//
271// Deprecated.
272func (c *uptimeCheckGRPCClient) Connection() *grpc.ClientConn {
273	return c.connPool.Conn()
274}
275
276// setGoogleClientInfo sets the name and version of the application in
277// the `x-goog-api-client` header passed on each request. Intended for
278// use by Google-written clients.
279func (c *uptimeCheckGRPCClient) setGoogleClientInfo(keyval ...string) {
280	kv := append([]string{"gl-go", versionGo()}, keyval...)
281	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
282	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
283}
284
285// Close closes the connection to the API service. The user should invoke this when
286// the client is no longer required.
287func (c *uptimeCheckGRPCClient) Close() error {
288	return c.connPool.Close()
289}
290
291func (c *uptimeCheckGRPCClient) ListUptimeCheckConfigs(ctx context.Context, req *monitoringpb.ListUptimeCheckConfigsRequest, opts ...gax.CallOption) *UptimeCheckConfigIterator {
292	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
293	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
294	opts = append((*c.CallOptions).ListUptimeCheckConfigs[0:len((*c.CallOptions).ListUptimeCheckConfigs):len((*c.CallOptions).ListUptimeCheckConfigs)], opts...)
295	it := &UptimeCheckConfigIterator{}
296	req = proto.Clone(req).(*monitoringpb.ListUptimeCheckConfigsRequest)
297	it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.UptimeCheckConfig, string, error) {
298		resp := &monitoringpb.ListUptimeCheckConfigsResponse{}
299		if pageToken != "" {
300			req.PageToken = pageToken
301		}
302		if pageSize > math.MaxInt32 {
303			req.PageSize = math.MaxInt32
304		} else if pageSize != 0 {
305			req.PageSize = int32(pageSize)
306		}
307		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
308			var err error
309			resp, err = c.uptimeCheckClient.ListUptimeCheckConfigs(ctx, req, settings.GRPC...)
310			return err
311		}, opts...)
312		if err != nil {
313			return nil, "", err
314		}
315
316		it.Response = resp
317		return resp.GetUptimeCheckConfigs(), resp.GetNextPageToken(), nil
318	}
319	fetch := func(pageSize int, pageToken string) (string, error) {
320		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
321		if err != nil {
322			return "", err
323		}
324		it.items = append(it.items, items...)
325		return nextPageToken, nil
326	}
327
328	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
329	it.pageInfo.MaxSize = int(req.GetPageSize())
330	it.pageInfo.Token = req.GetPageToken()
331
332	return it
333}
334
335func (c *uptimeCheckGRPCClient) GetUptimeCheckConfig(ctx context.Context, req *monitoringpb.GetUptimeCheckConfigRequest, opts ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error) {
336	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
337		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
338		defer cancel()
339		ctx = cctx
340	}
341	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
342	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
343	opts = append((*c.CallOptions).GetUptimeCheckConfig[0:len((*c.CallOptions).GetUptimeCheckConfig):len((*c.CallOptions).GetUptimeCheckConfig)], opts...)
344	var resp *monitoringpb.UptimeCheckConfig
345	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
346		var err error
347		resp, err = c.uptimeCheckClient.GetUptimeCheckConfig(ctx, req, settings.GRPC...)
348		return err
349	}, opts...)
350	if err != nil {
351		return nil, err
352	}
353	return resp, nil
354}
355
356func (c *uptimeCheckGRPCClient) CreateUptimeCheckConfig(ctx context.Context, req *monitoringpb.CreateUptimeCheckConfigRequest, opts ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error) {
357	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
358		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
359		defer cancel()
360		ctx = cctx
361	}
362	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
363	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
364	opts = append((*c.CallOptions).CreateUptimeCheckConfig[0:len((*c.CallOptions).CreateUptimeCheckConfig):len((*c.CallOptions).CreateUptimeCheckConfig)], opts...)
365	var resp *monitoringpb.UptimeCheckConfig
366	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
367		var err error
368		resp, err = c.uptimeCheckClient.CreateUptimeCheckConfig(ctx, req, settings.GRPC...)
369		return err
370	}, opts...)
371	if err != nil {
372		return nil, err
373	}
374	return resp, nil
375}
376
377func (c *uptimeCheckGRPCClient) UpdateUptimeCheckConfig(ctx context.Context, req *monitoringpb.UpdateUptimeCheckConfigRequest, opts ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error) {
378	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
379		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
380		defer cancel()
381		ctx = cctx
382	}
383	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "uptime_check_config.name", url.QueryEscape(req.GetUptimeCheckConfig().GetName())))
384	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
385	opts = append((*c.CallOptions).UpdateUptimeCheckConfig[0:len((*c.CallOptions).UpdateUptimeCheckConfig):len((*c.CallOptions).UpdateUptimeCheckConfig)], opts...)
386	var resp *monitoringpb.UptimeCheckConfig
387	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
388		var err error
389		resp, err = c.uptimeCheckClient.UpdateUptimeCheckConfig(ctx, req, settings.GRPC...)
390		return err
391	}, opts...)
392	if err != nil {
393		return nil, err
394	}
395	return resp, nil
396}
397
398func (c *uptimeCheckGRPCClient) DeleteUptimeCheckConfig(ctx context.Context, req *monitoringpb.DeleteUptimeCheckConfigRequest, opts ...gax.CallOption) error {
399	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
400		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
401		defer cancel()
402		ctx = cctx
403	}
404	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
405	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
406	opts = append((*c.CallOptions).DeleteUptimeCheckConfig[0:len((*c.CallOptions).DeleteUptimeCheckConfig):len((*c.CallOptions).DeleteUptimeCheckConfig)], opts...)
407	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
408		var err error
409		_, err = c.uptimeCheckClient.DeleteUptimeCheckConfig(ctx, req, settings.GRPC...)
410		return err
411	}, opts...)
412	return err
413}
414
415func (c *uptimeCheckGRPCClient) ListUptimeCheckIps(ctx context.Context, req *monitoringpb.ListUptimeCheckIpsRequest, opts ...gax.CallOption) *UptimeCheckIpIterator {
416	ctx = insertMetadata(ctx, c.xGoogMetadata)
417	opts = append((*c.CallOptions).ListUptimeCheckIps[0:len((*c.CallOptions).ListUptimeCheckIps):len((*c.CallOptions).ListUptimeCheckIps)], opts...)
418	it := &UptimeCheckIpIterator{}
419	req = proto.Clone(req).(*monitoringpb.ListUptimeCheckIpsRequest)
420	it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.UptimeCheckIp, string, error) {
421		resp := &monitoringpb.ListUptimeCheckIpsResponse{}
422		if pageToken != "" {
423			req.PageToken = pageToken
424		}
425		if pageSize > math.MaxInt32 {
426			req.PageSize = math.MaxInt32
427		} else if pageSize != 0 {
428			req.PageSize = int32(pageSize)
429		}
430		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
431			var err error
432			resp, err = c.uptimeCheckClient.ListUptimeCheckIps(ctx, req, settings.GRPC...)
433			return err
434		}, opts...)
435		if err != nil {
436			return nil, "", err
437		}
438
439		it.Response = resp
440		return resp.GetUptimeCheckIps(), resp.GetNextPageToken(), nil
441	}
442	fetch := func(pageSize int, pageToken string) (string, error) {
443		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
444		if err != nil {
445			return "", err
446		}
447		it.items = append(it.items, items...)
448		return nextPageToken, nil
449	}
450
451	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
452	it.pageInfo.MaxSize = int(req.GetPageSize())
453	it.pageInfo.Token = req.GetPageToken()
454
455	return it
456}
457
458// UptimeCheckConfigIterator manages a stream of *monitoringpb.UptimeCheckConfig.
459type UptimeCheckConfigIterator struct {
460	items    []*monitoringpb.UptimeCheckConfig
461	pageInfo *iterator.PageInfo
462	nextFunc func() error
463
464	// Response is the raw response for the current page.
465	// It must be cast to the RPC response type.
466	// Calling Next() or InternalFetch() updates this value.
467	Response interface{}
468
469	// InternalFetch is for use by the Google Cloud Libraries only.
470	// It is not part of the stable interface of this package.
471	//
472	// InternalFetch returns results from a single call to the underlying RPC.
473	// The number of results is no greater than pageSize.
474	// If there are no more results, nextPageToken is empty and err is nil.
475	InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.UptimeCheckConfig, nextPageToken string, err error)
476}
477
478// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
479func (it *UptimeCheckConfigIterator) PageInfo() *iterator.PageInfo {
480	return it.pageInfo
481}
482
483// Next returns the next result. Its second return value is iterator.Done if there are no more
484// results. Once Next returns Done, all subsequent calls will return Done.
485func (it *UptimeCheckConfigIterator) Next() (*monitoringpb.UptimeCheckConfig, error) {
486	var item *monitoringpb.UptimeCheckConfig
487	if err := it.nextFunc(); err != nil {
488		return item, err
489	}
490	item = it.items[0]
491	it.items = it.items[1:]
492	return item, nil
493}
494
495func (it *UptimeCheckConfigIterator) bufLen() int {
496	return len(it.items)
497}
498
499func (it *UptimeCheckConfigIterator) takeBuf() interface{} {
500	b := it.items
501	it.items = nil
502	return b
503}
504
505// UptimeCheckIpIterator manages a stream of *monitoringpb.UptimeCheckIp.
506type UptimeCheckIpIterator struct {
507	items    []*monitoringpb.UptimeCheckIp
508	pageInfo *iterator.PageInfo
509	nextFunc func() error
510
511	// Response is the raw response for the current page.
512	// It must be cast to the RPC response type.
513	// Calling Next() or InternalFetch() updates this value.
514	Response interface{}
515
516	// InternalFetch is for use by the Google Cloud Libraries only.
517	// It is not part of the stable interface of this package.
518	//
519	// InternalFetch returns results from a single call to the underlying RPC.
520	// The number of results is no greater than pageSize.
521	// If there are no more results, nextPageToken is empty and err is nil.
522	InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.UptimeCheckIp, nextPageToken string, err error)
523}
524
525// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
526func (it *UptimeCheckIpIterator) PageInfo() *iterator.PageInfo {
527	return it.pageInfo
528}
529
530// Next returns the next result. Its second return value is iterator.Done if there are no more
531// results. Once Next returns Done, all subsequent calls will return Done.
532func (it *UptimeCheckIpIterator) Next() (*monitoringpb.UptimeCheckIp, error) {
533	var item *monitoringpb.UptimeCheckIp
534	if err := it.nextFunc(); err != nil {
535		return item, err
536	}
537	item = it.items[0]
538	it.items = it.items[1:]
539	return item, nil
540}
541
542func (it *UptimeCheckIpIterator) bufLen() int {
543	return len(it.items)
544}
545
546func (it *UptimeCheckIpIterator) takeBuf() interface{} {
547	b := it.items
548	it.items = nil
549	return b
550}
551