...

Source file src/cloud.google.com/go/monitoring/apiv3/notification_channel_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 newNotificationChannelClientHook clientHook
    38  
    39  // NotificationChannelCallOptions contains the retry settings for each method of NotificationChannelClient.
    40  type NotificationChannelCallOptions struct {
    41  	ListNotificationChannelDescriptors      []gax.CallOption
    42  	GetNotificationChannelDescriptor        []gax.CallOption
    43  	ListNotificationChannels                []gax.CallOption
    44  	GetNotificationChannel                  []gax.CallOption
    45  	CreateNotificationChannel               []gax.CallOption
    46  	UpdateNotificationChannel               []gax.CallOption
    47  	DeleteNotificationChannel               []gax.CallOption
    48  	SendNotificationChannelVerificationCode []gax.CallOption
    49  	GetNotificationChannelVerificationCode  []gax.CallOption
    50  	VerifyNotificationChannel               []gax.CallOption
    51  }
    52  
    53  func defaultNotificationChannelClientOptions() []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 defaultNotificationChannelCallOptions() *NotificationChannelCallOptions {
    64  	return &NotificationChannelCallOptions{
    65  		ListNotificationChannelDescriptors: []gax.CallOption{
    66  			gax.WithRetry(func() gax.Retryer {
    67  				return gax.OnCodes([]codes.Code{
    68  					codes.DeadlineExceeded,
    69  					codes.Unavailable,
    70  				}, gax.Backoff{
    71  					Initial:    100 * time.Millisecond,
    72  					Max:        30000 * time.Millisecond,
    73  					Multiplier: 1.30,
    74  				})
    75  			}),
    76  		},
    77  		GetNotificationChannelDescriptor: []gax.CallOption{
    78  			gax.WithRetry(func() gax.Retryer {
    79  				return gax.OnCodes([]codes.Code{
    80  					codes.DeadlineExceeded,
    81  					codes.Unavailable,
    82  				}, gax.Backoff{
    83  					Initial:    100 * time.Millisecond,
    84  					Max:        30000 * time.Millisecond,
    85  					Multiplier: 1.30,
    86  				})
    87  			}),
    88  		},
    89  		ListNotificationChannels: []gax.CallOption{
    90  			gax.WithRetry(func() gax.Retryer {
    91  				return gax.OnCodes([]codes.Code{
    92  					codes.DeadlineExceeded,
    93  					codes.Unavailable,
    94  				}, gax.Backoff{
    95  					Initial:    100 * time.Millisecond,
    96  					Max:        30000 * time.Millisecond,
    97  					Multiplier: 1.30,
    98  				})
    99  			}),
   100  		},
   101  		GetNotificationChannel: []gax.CallOption{
   102  			gax.WithRetry(func() gax.Retryer {
   103  				return gax.OnCodes([]codes.Code{
   104  					codes.DeadlineExceeded,
   105  					codes.Unavailable,
   106  				}, gax.Backoff{
   107  					Initial:    100 * time.Millisecond,
   108  					Max:        30000 * time.Millisecond,
   109  					Multiplier: 1.30,
   110  				})
   111  			}),
   112  		},
   113  		CreateNotificationChannel: []gax.CallOption{},
   114  		UpdateNotificationChannel: []gax.CallOption{},
   115  		DeleteNotificationChannel: []gax.CallOption{
   116  			gax.WithRetry(func() gax.Retryer {
   117  				return gax.OnCodes([]codes.Code{
   118  					codes.DeadlineExceeded,
   119  					codes.Unavailable,
   120  				}, gax.Backoff{
   121  					Initial:    100 * time.Millisecond,
   122  					Max:        30000 * time.Millisecond,
   123  					Multiplier: 1.30,
   124  				})
   125  			}),
   126  		},
   127  		SendNotificationChannelVerificationCode: []gax.CallOption{},
   128  		GetNotificationChannelVerificationCode: []gax.CallOption{
   129  			gax.WithRetry(func() gax.Retryer {
   130  				return gax.OnCodes([]codes.Code{
   131  					codes.DeadlineExceeded,
   132  					codes.Unavailable,
   133  				}, gax.Backoff{
   134  					Initial:    100 * time.Millisecond,
   135  					Max:        30000 * time.Millisecond,
   136  					Multiplier: 1.30,
   137  				})
   138  			}),
   139  		},
   140  		VerifyNotificationChannel: []gax.CallOption{
   141  			gax.WithRetry(func() gax.Retryer {
   142  				return gax.OnCodes([]codes.Code{
   143  					codes.DeadlineExceeded,
   144  					codes.Unavailable,
   145  				}, gax.Backoff{
   146  					Initial:    100 * time.Millisecond,
   147  					Max:        30000 * time.Millisecond,
   148  					Multiplier: 1.30,
   149  				})
   150  			}),
   151  		},
   152  	}
   153  }
   154  
   155  // NotificationChannelClient is a client for interacting with Cloud Monitoring API.
   156  //
   157  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   158  type NotificationChannelClient struct {
   159  	// Connection pool of gRPC connections to the service.
   160  	connPool gtransport.ConnPool
   161  
   162  	// The gRPC API client.
   163  	notificationChannelClient monitoringpb.NotificationChannelServiceClient
   164  
   165  	// The call options for this service.
   166  	CallOptions *NotificationChannelCallOptions
   167  
   168  	// The x-goog-* metadata to be sent with each request.
   169  	xGoogMetadata metadata.MD
   170  }
   171  
   172  // NewNotificationChannelClient creates a new notification channel service client.
   173  //
   174  // The Notification Channel API provides access to configuration that
   175  // controls how messages related to incidents are sent.
   176  func NewNotificationChannelClient(ctx context.Context, opts ...option.ClientOption) (*NotificationChannelClient, error) {
   177  	clientOpts := defaultNotificationChannelClientOptions()
   178  
   179  	if newNotificationChannelClientHook != nil {
   180  		hookOpts, err := newNotificationChannelClientHook(ctx, clientHookParams{})
   181  		if err != nil {
   182  			return nil, err
   183  		}
   184  		clientOpts = append(clientOpts, hookOpts...)
   185  	}
   186  
   187  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   188  	if err != nil {
   189  		return nil, err
   190  	}
   191  	c := &NotificationChannelClient{
   192  		connPool:    connPool,
   193  		CallOptions: defaultNotificationChannelCallOptions(),
   194  
   195  		notificationChannelClient: monitoringpb.NewNotificationChannelServiceClient(connPool),
   196  	}
   197  	c.setGoogleClientInfo()
   198  
   199  	return c, nil
   200  }
   201  
   202  // Connection returns a connection to the API service.
   203  //
   204  // Deprecated.
   205  func (c *NotificationChannelClient) Connection() *grpc.ClientConn {
   206  	return c.connPool.Conn()
   207  }
   208  
   209  // Close closes the connection to the API service. The user should invoke this when
   210  // the client is no longer required.
   211  func (c *NotificationChannelClient) Close() error {
   212  	return c.connPool.Close()
   213  }
   214  
   215  // setGoogleClientInfo sets the name and version of the application in
   216  // the `x-goog-api-client` header passed on each request. Intended for
   217  // use by Google-written clients.
   218  func (c *NotificationChannelClient) setGoogleClientInfo(keyval ...string) {
   219  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   220  	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
   221  	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
   222  }
   223  
   224  // ListNotificationChannelDescriptors lists the descriptors for supported channel types. The use of descriptors
   225  // makes it possible for new channel types to be dynamically added.
   226  func (c *NotificationChannelClient) ListNotificationChannelDescriptors(ctx context.Context, req *monitoringpb.ListNotificationChannelDescriptorsRequest, opts ...gax.CallOption) *NotificationChannelDescriptorIterator {
   227  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   228  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   229  	opts = append(c.CallOptions.ListNotificationChannelDescriptors[0:len(c.CallOptions.ListNotificationChannelDescriptors):len(c.CallOptions.ListNotificationChannelDescriptors)], opts...)
   230  	it := &NotificationChannelDescriptorIterator{}
   231  	req = proto.Clone(req).(*monitoringpb.ListNotificationChannelDescriptorsRequest)
   232  	it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.NotificationChannelDescriptor, string, error) {
   233  		var resp *monitoringpb.ListNotificationChannelDescriptorsResponse
   234  		req.PageToken = pageToken
   235  		if pageSize > math.MaxInt32 {
   236  			req.PageSize = math.MaxInt32
   237  		} else {
   238  			req.PageSize = int32(pageSize)
   239  		}
   240  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   241  			var err error
   242  			resp, err = c.notificationChannelClient.ListNotificationChannelDescriptors(ctx, req, settings.GRPC...)
   243  			return err
   244  		}, opts...)
   245  		if err != nil {
   246  			return nil, "", err
   247  		}
   248  
   249  		it.Response = resp
   250  		return resp.ChannelDescriptors, resp.NextPageToken, nil
   251  	}
   252  	fetch := func(pageSize int, pageToken string) (string, error) {
   253  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   254  		if err != nil {
   255  			return "", err
   256  		}
   257  		it.items = append(it.items, items...)
   258  		return nextPageToken, nil
   259  	}
   260  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   261  	it.pageInfo.MaxSize = int(req.PageSize)
   262  	it.pageInfo.Token = req.PageToken
   263  	return it
   264  }
   265  
   266  // GetNotificationChannelDescriptor gets a single channel descriptor. The descriptor indicates which fields
   267  // are expected / permitted for a notification channel of the given type.
   268  func (c *NotificationChannelClient) GetNotificationChannelDescriptor(ctx context.Context, req *monitoringpb.GetNotificationChannelDescriptorRequest, opts ...gax.CallOption) (*monitoringpb.NotificationChannelDescriptor, error) {
   269  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   270  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   271  	opts = append(c.CallOptions.GetNotificationChannelDescriptor[0:len(c.CallOptions.GetNotificationChannelDescriptor):len(c.CallOptions.GetNotificationChannelDescriptor)], opts...)
   272  	var resp *monitoringpb.NotificationChannelDescriptor
   273  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   274  		var err error
   275  		resp, err = c.notificationChannelClient.GetNotificationChannelDescriptor(ctx, req, settings.GRPC...)
   276  		return err
   277  	}, opts...)
   278  	if err != nil {
   279  		return nil, err
   280  	}
   281  	return resp, nil
   282  }
   283  
   284  // ListNotificationChannels lists the notification channels that have been created for the project.
   285  func (c *NotificationChannelClient) ListNotificationChannels(ctx context.Context, req *monitoringpb.ListNotificationChannelsRequest, opts ...gax.CallOption) *NotificationChannelIterator {
   286  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   287  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   288  	opts = append(c.CallOptions.ListNotificationChannels[0:len(c.CallOptions.ListNotificationChannels):len(c.CallOptions.ListNotificationChannels)], opts...)
   289  	it := &NotificationChannelIterator{}
   290  	req = proto.Clone(req).(*monitoringpb.ListNotificationChannelsRequest)
   291  	it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.NotificationChannel, string, error) {
   292  		var resp *monitoringpb.ListNotificationChannelsResponse
   293  		req.PageToken = pageToken
   294  		if pageSize > math.MaxInt32 {
   295  			req.PageSize = math.MaxInt32
   296  		} else {
   297  			req.PageSize = int32(pageSize)
   298  		}
   299  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   300  			var err error
   301  			resp, err = c.notificationChannelClient.ListNotificationChannels(ctx, req, settings.GRPC...)
   302  			return err
   303  		}, opts...)
   304  		if err != nil {
   305  			return nil, "", err
   306  		}
   307  
   308  		it.Response = resp
   309  		return resp.NotificationChannels, resp.NextPageToken, nil
   310  	}
   311  	fetch := func(pageSize int, pageToken string) (string, error) {
   312  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   313  		if err != nil {
   314  			return "", err
   315  		}
   316  		it.items = append(it.items, items...)
   317  		return nextPageToken, nil
   318  	}
   319  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   320  	it.pageInfo.MaxSize = int(req.PageSize)
   321  	it.pageInfo.Token = req.PageToken
   322  	return it
   323  }
   324  
   325  // GetNotificationChannel gets a single notification channel. The channel includes the relevant
   326  // configuration details with which the channel was created. However, the
   327  // response may truncate or omit passwords, API keys, or other private key
   328  // matter and thus the response may not be 100% identical to the information
   329  // that was supplied in the call to the create method.
   330  func (c *NotificationChannelClient) GetNotificationChannel(ctx context.Context, req *monitoringpb.GetNotificationChannelRequest, opts ...gax.CallOption) (*monitoringpb.NotificationChannel, error) {
   331  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   332  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   333  	opts = append(c.CallOptions.GetNotificationChannel[0:len(c.CallOptions.GetNotificationChannel):len(c.CallOptions.GetNotificationChannel)], opts...)
   334  	var resp *monitoringpb.NotificationChannel
   335  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   336  		var err error
   337  		resp, err = c.notificationChannelClient.GetNotificationChannel(ctx, req, settings.GRPC...)
   338  		return err
   339  	}, opts...)
   340  	if err != nil {
   341  		return nil, err
   342  	}
   343  	return resp, nil
   344  }
   345  
   346  // CreateNotificationChannel creates a new notification channel, representing a single notification
   347  // endpoint such as an email address, SMS number, or PagerDuty service.
   348  func (c *NotificationChannelClient) CreateNotificationChannel(ctx context.Context, req *monitoringpb.CreateNotificationChannelRequest, opts ...gax.CallOption) (*monitoringpb.NotificationChannel, error) {
   349  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   350  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   351  	opts = append(c.CallOptions.CreateNotificationChannel[0:len(c.CallOptions.CreateNotificationChannel):len(c.CallOptions.CreateNotificationChannel)], opts...)
   352  	var resp *monitoringpb.NotificationChannel
   353  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   354  		var err error
   355  		resp, err = c.notificationChannelClient.CreateNotificationChannel(ctx, req, settings.GRPC...)
   356  		return err
   357  	}, opts...)
   358  	if err != nil {
   359  		return nil, err
   360  	}
   361  	return resp, nil
   362  }
   363  
   364  // UpdateNotificationChannel updates a notification channel. Fields not specified in the field mask
   365  // remain unchanged.
   366  func (c *NotificationChannelClient) UpdateNotificationChannel(ctx context.Context, req *monitoringpb.UpdateNotificationChannelRequest, opts ...gax.CallOption) (*monitoringpb.NotificationChannel, error) {
   367  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "notification_channel.name", url.QueryEscape(req.GetNotificationChannel().GetName())))
   368  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   369  	opts = append(c.CallOptions.UpdateNotificationChannel[0:len(c.CallOptions.UpdateNotificationChannel):len(c.CallOptions.UpdateNotificationChannel)], opts...)
   370  	var resp *monitoringpb.NotificationChannel
   371  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   372  		var err error
   373  		resp, err = c.notificationChannelClient.UpdateNotificationChannel(ctx, req, settings.GRPC...)
   374  		return err
   375  	}, opts...)
   376  	if err != nil {
   377  		return nil, err
   378  	}
   379  	return resp, nil
   380  }
   381  
   382  // DeleteNotificationChannel deletes a notification channel.
   383  func (c *NotificationChannelClient) DeleteNotificationChannel(ctx context.Context, req *monitoringpb.DeleteNotificationChannelRequest, opts ...gax.CallOption) error {
   384  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   385  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   386  	opts = append(c.CallOptions.DeleteNotificationChannel[0:len(c.CallOptions.DeleteNotificationChannel):len(c.CallOptions.DeleteNotificationChannel)], opts...)
   387  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   388  		var err error
   389  		_, err = c.notificationChannelClient.DeleteNotificationChannel(ctx, req, settings.GRPC...)
   390  		return err
   391  	}, opts...)
   392  	return err
   393  }
   394  
   395  // SendNotificationChannelVerificationCode causes a verification code to be delivered to the channel. The code
   396  // can then be supplied in VerifyNotificationChannel to verify the channel.
   397  func (c *NotificationChannelClient) SendNotificationChannelVerificationCode(ctx context.Context, req *monitoringpb.SendNotificationChannelVerificationCodeRequest, opts ...gax.CallOption) error {
   398  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   399  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   400  	opts = append(c.CallOptions.SendNotificationChannelVerificationCode[0:len(c.CallOptions.SendNotificationChannelVerificationCode):len(c.CallOptions.SendNotificationChannelVerificationCode)], opts...)
   401  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   402  		var err error
   403  		_, err = c.notificationChannelClient.SendNotificationChannelVerificationCode(ctx, req, settings.GRPC...)
   404  		return err
   405  	}, opts...)
   406  	return err
   407  }
   408  
   409  // GetNotificationChannelVerificationCode requests a verification code for an already verified channel that can then
   410  // be used in a call to VerifyNotificationChannel() on a different channel
   411  // with an equivalent identity in the same or in a different project. This
   412  // makes it possible to copy a channel between projects without requiring
   413  // manual reverification of the channel. If the channel is not in the
   414  // verified state, this method will fail (in other words, this may only be
   415  // used if the SendNotificationChannelVerificationCode and
   416  // VerifyNotificationChannel paths have already been used to put the given
   417  // channel into the verified state).
   418  //
   419  // There is no guarantee that the verification codes returned by this method
   420  // will be of a similar structure or form as the ones that are delivered
   421  // to the channel via SendNotificationChannelVerificationCode; while
   422  // VerifyNotificationChannel() will recognize both the codes delivered via
   423  // SendNotificationChannelVerificationCode() and returned from
   424  // GetNotificationChannelVerificationCode(), it is typically the case that
   425  // the verification codes delivered via
   426  // SendNotificationChannelVerificationCode() will be shorter and also
   427  // have a shorter expiration (e.g. codes such as “G-123456”) whereas
   428  // GetVerificationCode() will typically return a much longer, websafe base
   429  // 64 encoded string that has a longer expiration time.
   430  func (c *NotificationChannelClient) GetNotificationChannelVerificationCode(ctx context.Context, req *monitoringpb.GetNotificationChannelVerificationCodeRequest, opts ...gax.CallOption) (*monitoringpb.GetNotificationChannelVerificationCodeResponse, error) {
   431  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   432  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   433  	opts = append(c.CallOptions.GetNotificationChannelVerificationCode[0:len(c.CallOptions.GetNotificationChannelVerificationCode):len(c.CallOptions.GetNotificationChannelVerificationCode)], opts...)
   434  	var resp *monitoringpb.GetNotificationChannelVerificationCodeResponse
   435  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   436  		var err error
   437  		resp, err = c.notificationChannelClient.GetNotificationChannelVerificationCode(ctx, req, settings.GRPC...)
   438  		return err
   439  	}, opts...)
   440  	if err != nil {
   441  		return nil, err
   442  	}
   443  	return resp, nil
   444  }
   445  
   446  // VerifyNotificationChannel verifies a NotificationChannel by proving receipt of the code
   447  // delivered to the channel as a result of calling
   448  // SendNotificationChannelVerificationCode.
   449  func (c *NotificationChannelClient) VerifyNotificationChannel(ctx context.Context, req *monitoringpb.VerifyNotificationChannelRequest, opts ...gax.CallOption) (*monitoringpb.NotificationChannel, error) {
   450  	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
   451  	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
   452  	opts = append(c.CallOptions.VerifyNotificationChannel[0:len(c.CallOptions.VerifyNotificationChannel):len(c.CallOptions.VerifyNotificationChannel)], opts...)
   453  	var resp *monitoringpb.NotificationChannel
   454  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   455  		var err error
   456  		resp, err = c.notificationChannelClient.VerifyNotificationChannel(ctx, req, settings.GRPC...)
   457  		return err
   458  	}, opts...)
   459  	if err != nil {
   460  		return nil, err
   461  	}
   462  	return resp, nil
   463  }
   464  
   465  // NotificationChannelDescriptorIterator manages a stream of *monitoringpb.NotificationChannelDescriptor.
   466  type NotificationChannelDescriptorIterator struct {
   467  	items    []*monitoringpb.NotificationChannelDescriptor
   468  	pageInfo *iterator.PageInfo
   469  	nextFunc func() error
   470  
   471  	// Response is the raw response for the current page.
   472  	// It must be cast to the RPC response type.
   473  	// Calling Next() or InternalFetch() updates this value.
   474  	Response interface{}
   475  
   476  	// InternalFetch is for use by the Google Cloud Libraries only.
   477  	// It is not part of the stable interface of this package.
   478  	//
   479  	// InternalFetch returns results from a single call to the underlying RPC.
   480  	// The number of results is no greater than pageSize.
   481  	// If there are no more results, nextPageToken is empty and err is nil.
   482  	InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.NotificationChannelDescriptor, nextPageToken string, err error)
   483  }
   484  
   485  // PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
   486  func (it *NotificationChannelDescriptorIterator) PageInfo() *iterator.PageInfo {
   487  	return it.pageInfo
   488  }
   489  
   490  // Next returns the next result. Its second return value is iterator.Done if there are no more
   491  // results. Once Next returns Done, all subsequent calls will return Done.
   492  func (it *NotificationChannelDescriptorIterator) Next() (*monitoringpb.NotificationChannelDescriptor, error) {
   493  	var item *monitoringpb.NotificationChannelDescriptor
   494  	if err := it.nextFunc(); err != nil {
   495  		return item, err
   496  	}
   497  	item = it.items[0]
   498  	it.items = it.items[1:]
   499  	return item, nil
   500  }
   501  
   502  func (it *NotificationChannelDescriptorIterator) bufLen() int {
   503  	return len(it.items)
   504  }
   505  
   506  func (it *NotificationChannelDescriptorIterator) takeBuf() interface{} {
   507  	b := it.items
   508  	it.items = nil
   509  	return b
   510  }
   511  
   512  // NotificationChannelIterator manages a stream of *monitoringpb.NotificationChannel.
   513  type NotificationChannelIterator struct {
   514  	items    []*monitoringpb.NotificationChannel
   515  	pageInfo *iterator.PageInfo
   516  	nextFunc func() error
   517  
   518  	// Response is the raw response for the current page.
   519  	// It must be cast to the RPC response type.
   520  	// Calling Next() or InternalFetch() updates this value.
   521  	Response interface{}
   522  
   523  	// InternalFetch is for use by the Google Cloud Libraries only.
   524  	// It is not part of the stable interface of this package.
   525  	//
   526  	// InternalFetch returns results from a single call to the underlying RPC.
   527  	// The number of results is no greater than pageSize.
   528  	// If there are no more results, nextPageToken is empty and err is nil.
   529  	InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.NotificationChannel, nextPageToken string, err error)
   530  }
   531  
   532  // PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
   533  func (it *NotificationChannelIterator) PageInfo() *iterator.PageInfo {
   534  	return it.pageInfo
   535  }
   536  
   537  // Next returns the next result. Its second return value is iterator.Done if there are no more
   538  // results. Once Next returns Done, all subsequent calls will return Done.
   539  func (it *NotificationChannelIterator) Next() (*monitoringpb.NotificationChannel, error) {
   540  	var item *monitoringpb.NotificationChannel
   541  	if err := it.nextFunc(); err != nil {
   542  		return item, err
   543  	}
   544  	item = it.items[0]
   545  	it.items = it.items[1:]
   546  	return item, nil
   547  }
   548  
   549  func (it *NotificationChannelIterator) bufLen() int {
   550  	return len(it.items)
   551  }
   552  
   553  func (it *NotificationChannelIterator) takeBuf() interface{} {
   554  	b := it.items
   555  	it.items = nil
   556  	return b
   557  }
   558  

View as plain text