Source File
alert_policy_client.go
Belonging Package
cloud.google.com/go/monitoring/apiv3
package monitoring
import (
gax
gtransport
monitoringpb
)
var newAlertPolicyClientHook clientHook
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{},
}
}
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
}
func ( *AlertPolicyClient) () *grpc.ClientConn {
return .connPool.Conn()
}
func ( *AlertPolicyClient) () error {
return .connPool.Close()
}
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(...))
}
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
}
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
}
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
}
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
}
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
}
type AlertPolicyIterator struct {
items []*monitoringpb.AlertPolicy
pageInfo *iterator.PageInfo
nextFunc func() error
Response interface{}
InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.AlertPolicy, nextPageToken string, err error)
}
func ( *AlertPolicyIterator) () *iterator.PageInfo {
return .pageInfo
}
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
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |