...

Source file src/cloud.google.com/go/monitoring/apiv3/service_monitoring_client.go

Documentation: cloud.google.com/go/monitoring/apiv3

     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  
    17  package monitoring
    18  
    19  import (
    20  	"context"
    21  	"fmt"
    22  	"math"
    23  	"net/url"
    24  	"time"
    25  
    26  	"cloud.google.com/go/monitoring/apiv3/v2/monitoringpb"
    27  	gax "github.com/googleapis/gax-go/v2"
    28  	"google.golang.org/api/iterator"
    29  	"google.golang.org/api/option"
    30  	gtransport "google.golang.org/api/transport/grpc"
    31  	"google.golang.org/grpc"
    32  	"google.golang.org/grpc/codes"
    33  	"google.golang.org/grpc/metadata"
    34  	"google.golang.org/protobuf/proto"
    35  )
    36  
    37  var newServiceMonitoringClientHook clientHook
    38  
    39  // ServiceMonitoringCallOptions contains the retry settings for each method of ServiceMonitoringClient.
    40  type ServiceMonitoringCallOptions struct {
    41  	CreateService               []gax.CallOption
    42  	GetService                  []gax.CallOption
    43  	ListServices                []gax.CallOption
    44  	UpdateService               []gax.CallOption
    45  	DeleteService               []gax.CallOption
    46  	CreateServiceLevelObjective []gax.CallOption
    47  	GetServiceLevelObjective    []gax.CallOption
    48  	ListServiceLevelObjectives  []gax.CallOption
    49  	UpdateServiceLevelObjective []gax.CallOption
    50  	DeleteServiceLevelObjective []gax.CallOption
    51  }
    52  
    53  func defaultServiceMonitoringClientOptions() []option.ClientOption {
    54  	return []option.ClientOption{
    55  		option.WithEndpoint("monitoring.googleapis.com:443"),
    56  		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
    57  		option.WithScopes(DefaultAuthScopes()...),
    58  		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
    59  			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
    60  	}
    61  }
    62  
    63  func defaultServiceMonitoringCallOptions() *ServiceMonitoringCallOptions {
    64  	return &ServiceMonitoringCallOptions{
    65  		CreateService: []gax.CallOption{},
    66  		GetService: []gax.CallOption{
    67  			gax.WithRetry(func() gax.Retryer {
    68  				return gax.OnCodes([]codes.Code{
    69  					codes.DeadlineExceeded,
    70  					codes.Unavailable,
    71  				}, gax.Backoff{
    72  					Initial:    100 * time.Millisecond,
    73  					Max:        30000 * time.Millisecond,
    74  					Multiplier: 1.30,
    75  				})
    76  			}),
    77  		},
    78  		ListServices: []gax.CallOption{
    79  			gax.WithRetry(func() gax.Retryer {
    80  				return gax.OnCodes([]codes.Code{
    81  					codes.DeadlineExceeded,
    82  					codes.Unavailable,
    83  				}, gax.Backoff{
    84  					Initial:    100 * time.Millisecond,
    85  					Max:        30000 * time.Millisecond,
    86  					Multiplier: 1.30,
    87  				})
    88  			}),
    89  		},
    90  		UpdateService: []gax.CallOption{},
    91  		DeleteService: []gax.CallOption{
    92  			gax.WithRetry(func() gax.Retryer {
    93  				return gax.OnCodes([]codes.Code{
    94  					codes.DeadlineExceeded,
    95  					codes.Unavailable,
    96  				}, gax.Backoff{
    97  					Initial:    100 * time.Millisecond,
    98  					Max:        30000 * time.Millisecond,
    99  					Multiplier: 1.30,
   100  				})
   101  			}),
   102  		},
   103  		CreateServiceLevelObjective: []gax.CallOption{},
   104  		GetServiceLevelObjective: []gax.CallOption{
   105  			gax.WithRetry(func() gax.Retryer {
   106  				return gax.OnCodes([]codes.Code{
   107  					codes.DeadlineExceeded,
   108  					codes.Unavailable,
   109  				}, gax.Backoff{
   110  					Initial:    100 * time.Millisecond,
   111  					Max:        30000 * time.Millisecond,
   112  					Multiplier: 1.30,
   113  				})
   114  			}),
   115  		},
   116  		ListServiceLevelObjectives: []gax.CallOption{
   117  			gax.WithRetry(func() gax.Retryer {
   118  				return gax.OnCodes([]codes.Code{
   119  					codes.DeadlineExceeded,
   120  					codes.Unavailable,
   121  				}, gax.Backoff{
   122  					Initial:    100 * time.Millisecond,
   123  					Max:        30000 * time.Millisecond,
   124  					Multiplier: 1.30,
   125  				})
   126  			}),
   127  		},
   128  		UpdateServiceLevelObjective: []gax.CallOption{},
   129  		DeleteServiceLevelObjective: []gax.CallOption{
   130  			gax.WithRetry(func() gax.Retryer {
   131  				return gax.OnCodes([]codes.Code{
   132  					codes.DeadlineExceeded,
   133  					codes.Unavailable,
   134  				}, gax.Backoff{
   135  					Initial:    100 * time.Millisecond,
   136  					Max:        30000 * time.Millisecond,
   137  					Multiplier: 1.30,
   138  				})
   139  			}),
   140  		},
   141  	}
   142  }
   143  
   144  // ServiceMonitoringClient is a client for interacting with Cloud Monitoring API.
   145  //
   146  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   147  type ServiceMonitoringClient struct {
   148  	// Connection pool of gRPC connections to the service.
   149  	connPool gtransport.ConnPool
   150  
   151  	// The gRPC API client.
   152  	serviceMonitoringClient monitoringpb.ServiceMonitoringServiceClient
   153  
   154  	// The call options for this service.
   155  	CallOptions *ServiceMonitoringCallOptions
   156  
   157  	// The x-goog-* metadata to be sent with each request.
   158  	xGoogMetadata metadata.MD
   159  }
   160  
   161  // NewServiceMonitoringClient creates a new service monitoring service client.
   162  //
   163  // The Cloud Monitoring Service-Oriented Monitoring API has endpoints for
   164  // managing and querying aspects of a workspace’s services. These include the
   165  // Service's monitored resources, its Service-Level Objectives, and a taxonomy
   166  // of categorized Health Metrics.
   167  func NewServiceMonitoringClient(ctx context.Context, opts ...option.ClientOption) (*ServiceMonitoringClient, error) {
   168  	clientOpts := defaultServiceMonitoringClientOptions()
   169  
   170  	if newServiceMonitoringClientHook != nil {
   171  		hookOpts, err := newServiceMonitoringClientHook(ctx, clientHookParams{})
   172  		if err != nil {
   173  			return nil, err
   174  		}
   175  		clientOpts = append(clientOpts, hookOpts...)
   176  	}
   177  
   178  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   179  	if err != nil {
   180  		return nil, err
   181  	}
   182  	c := &ServiceMonitoringClient{
   183  		connPool:    connPool,
   184  		CallOptions: defaultServiceMonitoringCallOptions(),
   185  
   186  		serviceMonitoringClient: monitoringpb.NewServiceMonitoringServiceClient(connPool),
   187  	}
   188  	c.setGoogleClientInfo()
   189  
   190  	return c, nil
   191  }
   192  
   193  // Connection returns a connection to the API service.
   194  //
   195  // Deprecated.
   196  func (c *ServiceMonitoringClient) Connection() *grpc.ClientConn {
   197  	return c.connPool.Conn()
   198  }
   199  
   200  // Close closes the connection to the API service. The user should invoke this when
   201  // the client is no longer required.
   202  func (c *ServiceMonitoringClient) Close() error {
   203  	return c.connPool.Close()
   204  }
   205  
   206  // setGoogleClientInfo sets the name and version of the application in
   207  // the `x-goog-api-client` header passed on each request. Intended for
   208  // use by Google-written clients.
   209  func (c *ServiceMonitoringClient) setGoogleClientInfo(keyval ...string) {
   210  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   211  	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
   212  	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
   213  }
   214  
   215  // CreateService create a Service.
   216  func (c *ServiceMonitoringClient) CreateService(ctx context.Context, req *monitoringpb.CreateServiceRequest, opts ...gax.CallOption) (*monitoringpb.Service, error) {
   217  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
   218  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   219  	opts = append(c.CallOptions.CreateService[0:len(c.CallOptions.CreateService):len(c.CallOptions.CreateService)], opts...)
   220  	var resp *monitoringpb.Service
   221  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   222  		var err error
   223  		resp, err = c.serviceMonitoringClient.CreateService(ctx, req, settings.GRPC...)
   224  		return err
   225  	}, opts...)
   226  	if err != nil {
   227  		return nil, err
   228  	}
   229  	return resp, nil
   230  }
   231  
   232  // GetService get the named Service.
   233  func (c *ServiceMonitoringClient) GetService(ctx context.Context, req *monitoringpb.GetServiceRequest, opts ...gax.CallOption) (*monitoringpb.Service, error) {
   234  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   235  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   236  	opts = append(c.CallOptions.GetService[0:len(c.CallOptions.GetService):len(c.CallOptions.GetService)], opts...)
   237  	var resp *monitoringpb.Service
   238  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   239  		var err error
   240  		resp, err = c.serviceMonitoringClient.GetService(ctx, req, settings.GRPC...)
   241  		return err
   242  	}, opts...)
   243  	if err != nil {
   244  		return nil, err
   245  	}
   246  	return resp, nil
   247  }
   248  
   249  // ListServices list Services for this workspace.
   250  func (c *ServiceMonitoringClient) ListServices(ctx context.Context, req *monitoringpb.ListServicesRequest, opts ...gax.CallOption) *ServiceIterator {
   251  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
   252  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   253  	opts = append(c.CallOptions.ListServices[0:len(c.CallOptions.ListServices):len(c.CallOptions.ListServices)], opts...)
   254  	it := &ServiceIterator{}
   255  	req = proto.Clone(req).(*monitoringpb.ListServicesRequest)
   256  	it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.Service, string, error) {
   257  		var resp *monitoringpb.ListServicesResponse
   258  		req.PageToken = pageToken
   259  		if pageSize > math.MaxInt32 {
   260  			req.PageSize = math.MaxInt32
   261  		} else {
   262  			req.PageSize = int32(pageSize)
   263  		}
   264  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   265  			var err error
   266  			resp, err = c.serviceMonitoringClient.ListServices(ctx, req, settings.GRPC...)
   267  			return err
   268  		}, opts...)
   269  		if err != nil {
   270  			return nil, "", err
   271  		}
   272  
   273  		it.Response = resp
   274  		return resp.Services, resp.NextPageToken, nil
   275  	}
   276  	fetch := func(pageSize int, pageToken string) (string, error) {
   277  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   278  		if err != nil {
   279  			return "", err
   280  		}
   281  		it.items = append(it.items, items...)
   282  		return nextPageToken, nil
   283  	}
   284  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   285  	it.pageInfo.MaxSize = int(req.PageSize)
   286  	it.pageInfo.Token = req.PageToken
   287  	return it
   288  }
   289  
   290  // UpdateService update this Service.
   291  func (c *ServiceMonitoringClient) UpdateService(ctx context.Context, req *monitoringpb.UpdateServiceRequest, opts ...gax.CallOption) (*monitoringpb.Service, error) {
   292  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service.name", url.QueryEscape(req.GetService().GetName())))
   293  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   294  	opts = append(c.CallOptions.UpdateService[0:len(c.CallOptions.UpdateService):len(c.CallOptions.UpdateService)], opts...)
   295  	var resp *monitoringpb.Service
   296  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   297  		var err error
   298  		resp, err = c.serviceMonitoringClient.UpdateService(ctx, req, settings.GRPC...)
   299  		return err
   300  	}, opts...)
   301  	if err != nil {
   302  		return nil, err
   303  	}
   304  	return resp, nil
   305  }
   306  
   307  // DeleteService soft delete this Service.
   308  func (c *ServiceMonitoringClient) DeleteService(ctx context.Context, req *monitoringpb.DeleteServiceRequest, opts ...gax.CallOption) error {
   309  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   310  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   311  	opts = append(c.CallOptions.DeleteService[0:len(c.CallOptions.DeleteService):len(c.CallOptions.DeleteService)], opts...)
   312  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   313  		var err error
   314  		_, err = c.serviceMonitoringClient.DeleteService(ctx, req, settings.GRPC...)
   315  		return err
   316  	}, opts...)
   317  	return err
   318  }
   319  
   320  // CreateServiceLevelObjective create a ServiceLevelObjective for the given Service.
   321  func (c *ServiceMonitoringClient) CreateServiceLevelObjective(ctx context.Context, req *monitoringpb.CreateServiceLevelObjectiveRequest, opts ...gax.CallOption) (*monitoringpb.ServiceLevelObjective, error) {
   322  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
   323  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   324  	opts = append(c.CallOptions.CreateServiceLevelObjective[0:len(c.CallOptions.CreateServiceLevelObjective):len(c.CallOptions.CreateServiceLevelObjective)], opts...)
   325  	var resp *monitoringpb.ServiceLevelObjective
   326  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   327  		var err error
   328  		resp, err = c.serviceMonitoringClient.CreateServiceLevelObjective(ctx, req, settings.GRPC...)
   329  		return err
   330  	}, opts...)
   331  	if err != nil {
   332  		return nil, err
   333  	}
   334  	return resp, nil
   335  }
   336  
   337  // GetServiceLevelObjective get a ServiceLevelObjective by name.
   338  func (c *ServiceMonitoringClient) GetServiceLevelObjective(ctx context.Context, req *monitoringpb.GetServiceLevelObjectiveRequest, opts ...gax.CallOption) (*monitoringpb.ServiceLevelObjective, error) {
   339  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   340  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   341  	opts = append(c.CallOptions.GetServiceLevelObjective[0:len(c.CallOptions.GetServiceLevelObjective):len(c.CallOptions.GetServiceLevelObjective)], opts...)
   342  	var resp *monitoringpb.ServiceLevelObjective
   343  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   344  		var err error
   345  		resp, err = c.serviceMonitoringClient.GetServiceLevelObjective(ctx, req, settings.GRPC...)
   346  		return err
   347  	}, opts...)
   348  	if err != nil {
   349  		return nil, err
   350  	}
   351  	return resp, nil
   352  }
   353  
   354  // ListServiceLevelObjectives list the ServiceLevelObjectives for the given Service.
   355  func (c *ServiceMonitoringClient) ListServiceLevelObjectives(ctx context.Context, req *monitoringpb.ListServiceLevelObjectivesRequest, opts ...gax.CallOption) *ServiceLevelObjectiveIterator {
   356  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
   357  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   358  	opts = append(c.CallOptions.ListServiceLevelObjectives[0:len(c.CallOptions.ListServiceLevelObjectives):len(c.CallOptions.ListServiceLevelObjectives)], opts...)
   359  	it := &ServiceLevelObjectiveIterator{}
   360  	req = proto.Clone(req).(*monitoringpb.ListServiceLevelObjectivesRequest)
   361  	it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.ServiceLevelObjective, string, error) {
   362  		var resp *monitoringpb.ListServiceLevelObjectivesResponse
   363  		req.PageToken = pageToken
   364  		if pageSize > math.MaxInt32 {
   365  			req.PageSize = math.MaxInt32
   366  		} else {
   367  			req.PageSize = int32(pageSize)
   368  		}
   369  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   370  			var err error
   371  			resp, err = c.serviceMonitoringClient.ListServiceLevelObjectives(ctx, req, settings.GRPC...)
   372  			return err
   373  		}, opts...)
   374  		if err != nil {
   375  			return nil, "", err
   376  		}
   377  
   378  		it.Response = resp
   379  		return resp.ServiceLevelObjectives, resp.NextPageToken, nil
   380  	}
   381  	fetch := func(pageSize int, pageToken string) (string, error) {
   382  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   383  		if err != nil {
   384  			return "", err
   385  		}
   386  		it.items = append(it.items, items...)
   387  		return nextPageToken, nil
   388  	}
   389  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   390  	it.pageInfo.MaxSize = int(req.PageSize)
   391  	it.pageInfo.Token = req.PageToken
   392  	return it
   393  }
   394  
   395  // UpdateServiceLevelObjective update the given ServiceLevelObjective.
   396  func (c *ServiceMonitoringClient) UpdateServiceLevelObjective(ctx context.Context, req *monitoringpb.UpdateServiceLevelObjectiveRequest, opts ...gax.CallOption) (*monitoringpb.ServiceLevelObjective, error) {
   397  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_level_objective.name", url.QueryEscape(req.GetServiceLevelObjective().GetName())))
   398  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   399  	opts = append(c.CallOptions.UpdateServiceLevelObjective[0:len(c.CallOptions.UpdateServiceLevelObjective):len(c.CallOptions.UpdateServiceLevelObjective)], opts...)
   400  	var resp *monitoringpb.ServiceLevelObjective
   401  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   402  		var err error
   403  		resp, err = c.serviceMonitoringClient.UpdateServiceLevelObjective(ctx, req, settings.GRPC...)
   404  		return err
   405  	}, opts...)
   406  	if err != nil {
   407  		return nil, err
   408  	}
   409  	return resp, nil
   410  }
   411  
   412  // DeleteServiceLevelObjective delete the given ServiceLevelObjective.
   413  func (c *ServiceMonitoringClient) DeleteServiceLevelObjective(ctx context.Context, req *monitoringpb.DeleteServiceLevelObjectiveRequest, opts ...gax.CallOption) error {
   414  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   415  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   416  	opts = append(c.CallOptions.DeleteServiceLevelObjective[0:len(c.CallOptions.DeleteServiceLevelObjective):len(c.CallOptions.DeleteServiceLevelObjective)], opts...)
   417  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   418  		var err error
   419  		_, err = c.serviceMonitoringClient.DeleteServiceLevelObjective(ctx, req, settings.GRPC...)
   420  		return err
   421  	}, opts...)
   422  	return err
   423  }
   424  
   425  // ServiceIterator manages a stream of *monitoringpb.Service.
   426  type ServiceIterator struct {
   427  	items    []*monitoringpb.Service
   428  	pageInfo *iterator.PageInfo
   429  	nextFunc func() error
   430  
   431  	// Response is the raw response for the current page.
   432  	// It must be cast to the RPC response type.
   433  	// Calling Next() or InternalFetch() updates this value.
   434  	Response interface{}
   435  
   436  	// InternalFetch is for use by the Google Cloud Libraries only.
   437  	// It is not part of the stable interface of this package.
   438  	//
   439  	// InternalFetch returns results from a single call to the underlying RPC.
   440  	// The number of results is no greater than pageSize.
   441  	// If there are no more results, nextPageToken is empty and err is nil.
   442  	InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.Service, nextPageToken string, err error)
   443  }
   444  
   445  // PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
   446  func (it *ServiceIterator) PageInfo() *iterator.PageInfo {
   447  	return it.pageInfo
   448  }
   449  
   450  // Next returns the next result. Its second return value is iterator.Done if there are no more
   451  // results. Once Next returns Done, all subsequent calls will return Done.
   452  func (it *ServiceIterator) Next() (*monitoringpb.Service, error) {
   453  	var item *monitoringpb.Service
   454  	if err := it.nextFunc(); err != nil {
   455  		return item, err
   456  	}
   457  	item = it.items[0]
   458  	it.items = it.items[1:]
   459  	return item, nil
   460  }
   461  
   462  func (it *ServiceIterator) bufLen() int {
   463  	return len(it.items)
   464  }
   465  
   466  func (it *ServiceIterator) takeBuf() interface{} {
   467  	b := it.items
   468  	it.items = nil
   469  	return b
   470  }
   471  
   472  // ServiceLevelObjectiveIterator manages a stream of *monitoringpb.ServiceLevelObjective.
   473  type ServiceLevelObjectiveIterator struct {
   474  	items    []*monitoringpb.ServiceLevelObjective
   475  	pageInfo *iterator.PageInfo
   476  	nextFunc func() error
   477  
   478  	// Response is the raw response for the current page.
   479  	// It must be cast to the RPC response type.
   480  	// Calling Next() or InternalFetch() updates this value.
   481  	Response interface{}
   482  
   483  	// InternalFetch is for use by the Google Cloud Libraries only.
   484  	// It is not part of the stable interface of this package.
   485  	//
   486  	// InternalFetch returns results from a single call to the underlying RPC.
   487  	// The number of results is no greater than pageSize.
   488  	// If there are no more results, nextPageToken is empty and err is nil.
   489  	InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.ServiceLevelObjective, nextPageToken string, err error)
   490  }
   491  
   492  // PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
   493  func (it *ServiceLevelObjectiveIterator) PageInfo() *iterator.PageInfo {
   494  	return it.pageInfo
   495  }
   496  
   497  // Next returns the next result. Its second return value is iterator.Done if there are no more
   498  // results. Once Next returns Done, all subsequent calls will return Done.
   499  func (it *ServiceLevelObjectiveIterator) Next() (*monitoringpb.ServiceLevelObjective, error) {
   500  	var item *monitoringpb.ServiceLevelObjective
   501  	if err := it.nextFunc(); err != nil {
   502  		return item, err
   503  	}
   504  	item = it.items[0]
   505  	it.items = it.items[1:]
   506  	return item, nil
   507  }
   508  
   509  func (it *ServiceLevelObjectiveIterator) bufLen() int {
   510  	return len(it.items)
   511  }
   512  
   513  func (it *ServiceLevelObjectiveIterator) takeBuf() interface{} {
   514  	b := it.items
   515  	it.items = nil
   516  	return b
   517  }
   518  

View as plain text