Copyright 2020 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Code generated by protoc-gen-go_gapic. DO NOT EDIT.

package monitoring

import (
	
	
	
	
	

	
	gax 
	
	
	gtransport 
	monitoringpb 
	
	
	
)

var newAlertPolicyClientHook clientHook
AlertPolicyCallOptions contains the retry settings for each method of AlertPolicyClient.
type AlertPolicyCallOptions struct {
	ListAlertPolicies []gax.CallOption
	GetAlertPolicy    []gax.CallOption
	CreateAlertPolicy []gax.CallOption
	DeleteAlertPolicy []gax.CallOption
	UpdateAlertPolicy []gax.CallOption
}

func () []option.ClientOption {
	return []option.ClientOption{
		option.WithEndpoint("monitoring.googleapis.com:443"),
		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
		option.WithScopes(DefaultAuthScopes()...),
		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
	}
}

func () *AlertPolicyCallOptions {
	return &AlertPolicyCallOptions{
		ListAlertPolicies: []gax.CallOption{
			gax.WithRetry(func() gax.Retryer {
				return gax.OnCodes([]codes.Code{
					codes.DeadlineExceeded,
					codes.Unavailable,
				}, gax.Backoff{
					Initial:    100 * time.Millisecond,
					Max:        30000 * time.Millisecond,
					Multiplier: 1.30,
				})
			}),
		},
		GetAlertPolicy: []gax.CallOption{
			gax.WithRetry(func() gax.Retryer {
				return gax.OnCodes([]codes.Code{
					codes.DeadlineExceeded,
					codes.Unavailable,
				}, gax.Backoff{
					Initial:    100 * time.Millisecond,
					Max:        30000 * time.Millisecond,
					Multiplier: 1.30,
				})
			}),
		},
		CreateAlertPolicy: []gax.CallOption{},
		DeleteAlertPolicy: []gax.CallOption{
			gax.WithRetry(func() gax.Retryer {
				return gax.OnCodes([]codes.Code{
					codes.DeadlineExceeded,
					codes.Unavailable,
				}, gax.Backoff{
					Initial:    100 * time.Millisecond,
					Max:        30000 * time.Millisecond,
					Multiplier: 1.30,
				})
			}),
		},
		UpdateAlertPolicy: []gax.CallOption{},
	}
}
AlertPolicyClient is a client for interacting with Cloud Monitoring API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Connection pool of gRPC connections to the service.
The call options for this service.
The x-goog-* metadata to be sent with each request.
NewAlertPolicyClient creates a new alert policy service client. The AlertPolicyService API is used to manage (list, create, delete, edit) alert policies in Stackdriver Monitoring. An alerting policy is a description of the conditions under which some aspect of your system is considered to be “unhealthy” and the ways to notify people or services about this state. In addition to using this API, alert policies can also be managed through Stackdriver Monitoring (at https://cloud.google.com/monitoring/docs/), which can be reached by clicking the “Monitoring” tab in Cloud Console (at https://console.cloud.google.com/).
func ( context.Context,  ...option.ClientOption) (*AlertPolicyClient, error) {
	 := defaultAlertPolicyClientOptions()

	if newAlertPolicyClientHook != nil {
		,  := newAlertPolicyClientHook(, clientHookParams{})
		if  != nil {
			return nil, 
		}
		 = append(, ...)
	}

	,  := gtransport.DialPool(, append(, ...)...)
	if  != nil {
		return nil, 
	}
	 := &AlertPolicyClient{
		connPool:    ,
		CallOptions: defaultAlertPolicyCallOptions(),

		alertPolicyClient: monitoringpb.NewAlertPolicyServiceClient(),
	}
	.setGoogleClientInfo()

	return , nil
}
Connection returns a connection to the API service. Deprecated.
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func ( *AlertPolicyClient) () error {
	return .connPool.Close()
}
setGoogleClientInfo sets the name and version of the application in the `x-goog-api-client` header passed on each request. Intended for use by Google-written clients.
func ( *AlertPolicyClient) ( ...string) {
	 := append([]string{"gl-go", versionGo()}, ...)
	 = append(, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
	.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(...))
}
ListAlertPolicies lists the existing alerting policies for the project.
func ( *AlertPolicyClient) ( context.Context,  *monitoringpb.ListAlertPoliciesRequest,  ...gax.CallOption) *AlertPolicyIterator {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.ListAlertPolicies[0:len(.CallOptions.ListAlertPolicies):len(.CallOptions.ListAlertPolicies)], ...)
	 := &AlertPolicyIterator{}
	 = proto.Clone().(*monitoringpb.ListAlertPoliciesRequest)
	.InternalFetch = func( int,  string) ([]*monitoringpb.AlertPolicy, string, error) {
		var  *monitoringpb.ListAlertPoliciesResponse
		.PageToken = 
		if  > math.MaxInt32 {
			.PageSize = math.MaxInt32
		} else {
			.PageSize = int32()
		}
		 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
			var  error
			,  = .alertPolicyClient.ListAlertPolicies(, , .GRPC...)
			return 
		}, ...)
		if  != nil {
			return nil, "", 
		}

		.Response = 
		return .AlertPolicies, .NextPageToken, nil
	}
	 := func( int,  string) (string, error) {
		, ,  := .InternalFetch(, )
		if  != nil {
			return "", 
		}
		.items = append(.items, ...)
		return , nil
	}
	.pageInfo, .nextFunc = iterator.NewPageInfo(, .bufLen, .takeBuf)
	.pageInfo.MaxSize = int(.PageSize)
	.pageInfo.Token = .PageToken
	return 
}
GetAlertPolicy gets a single alerting policy.
func ( *AlertPolicyClient) ( context.Context,  *monitoringpb.GetAlertPolicyRequest,  ...gax.CallOption) (*monitoringpb.AlertPolicy, error) {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.GetAlertPolicy[0:len(.CallOptions.GetAlertPolicy):len(.CallOptions.GetAlertPolicy)], ...)
	var  *monitoringpb.AlertPolicy
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .alertPolicyClient.GetAlertPolicy(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
CreateAlertPolicy creates a new alerting policy.
func ( *AlertPolicyClient) ( context.Context,  *monitoringpb.CreateAlertPolicyRequest,  ...gax.CallOption) (*monitoringpb.AlertPolicy, error) {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.CreateAlertPolicy[0:len(.CallOptions.CreateAlertPolicy):len(.CallOptions.CreateAlertPolicy)], ...)
	var  *monitoringpb.AlertPolicy
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .alertPolicyClient.CreateAlertPolicy(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
DeleteAlertPolicy deletes an alerting policy.
func ( *AlertPolicyClient) ( context.Context,  *monitoringpb.DeleteAlertPolicyRequest,  ...gax.CallOption) error {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.DeleteAlertPolicy[0:len(.CallOptions.DeleteAlertPolicy):len(.CallOptions.DeleteAlertPolicy)], ...)
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		_,  = .alertPolicyClient.DeleteAlertPolicy(, , .GRPC...)
		return 
	}, ...)
	return 
}
UpdateAlertPolicy updates an alerting policy. You can either replace the entire policy with a new one or replace only certain fields in the current alerting policy by specifying the fields to be updated via updateMask. Returns the updated alerting policy.
func ( *AlertPolicyClient) ( context.Context,  *monitoringpb.UpdateAlertPolicyRequest,  ...gax.CallOption) (*monitoringpb.AlertPolicy, error) {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "alert_policy.name", url.QueryEscape(.GetAlertPolicy().GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.UpdateAlertPolicy[0:len(.CallOptions.UpdateAlertPolicy):len(.CallOptions.UpdateAlertPolicy)], ...)
	var  *monitoringpb.AlertPolicy
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .alertPolicyClient.UpdateAlertPolicy(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
AlertPolicyIterator manages a stream of *monitoringpb.AlertPolicy.
Response is the raw response for the current page. It must be cast to the RPC response type. Calling Next() or InternalFetch() updates this value.
	Response interface{}
InternalFetch is for use by the Google Cloud Libraries only. It is not part of the stable interface of this package. InternalFetch returns results from a single call to the underlying RPC. The number of results is no greater than pageSize. If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.AlertPolicy, nextPageToken string, err error)
}
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func ( *AlertPolicyIterator) () (*monitoringpb.AlertPolicy, error) {
	var  *monitoringpb.AlertPolicy
	if  := .nextFunc();  != nil {
		return , 
	}
	 = .items[0]
	.items = .items[1:]
	return , nil
}

func ( *AlertPolicyIterator) () int {
	return len(.items)
}

func ( *AlertPolicyIterator) () interface{} {
	 := .items
	.items = nil
	return