Source File
group_client.go
Belonging Package
cloud.google.com/go/monitoring/apiv3
package monitoring
import (
gax
gtransport
monitoredrespb
monitoringpb
)
var newGroupClientHook clientHook
type GroupCallOptions struct {
ListGroups []gax.CallOption
GetGroup []gax.CallOption
CreateGroup []gax.CallOption
UpdateGroup []gax.CallOption
DeleteGroup []gax.CallOption
ListGroupMembers []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 () *GroupCallOptions {
return &GroupCallOptions{
ListGroups: []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,
})
}),
},
GetGroup: []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,
})
}),
},
CreateGroup: []gax.CallOption{},
UpdateGroup: []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,
})
}),
},
DeleteGroup: []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,
})
}),
},
ListGroupMembers: []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,
})
}),
},
}
}
func ( context.Context, ...option.ClientOption) (*GroupClient, error) {
:= defaultGroupClientOptions()
if newGroupClientHook != nil {
, := newGroupClientHook(, clientHookParams{})
if != nil {
return nil,
}
= append(, ...)
}
, := gtransport.DialPool(, append(, ...)...)
if != nil {
return nil,
}
:= &GroupClient{
connPool: ,
CallOptions: defaultGroupCallOptions(),
groupClient: monitoringpb.NewGroupServiceClient(),
}
.setGoogleClientInfo()
return , nil
}
func ( *GroupClient) () *grpc.ClientConn {
return .connPool.Conn()
}
func ( *GroupClient) () error {
return .connPool.Close()
}
func ( *GroupClient) ( ...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 ( *GroupClient) ( context.Context, *monitoringpb.ListGroupsRequest, ...gax.CallOption) *GroupIterator {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.ListGroups[0:len(.CallOptions.ListGroups):len(.CallOptions.ListGroups)], ...)
:= &GroupIterator{}
= proto.Clone().(*monitoringpb.ListGroupsRequest)
.InternalFetch = func( int, string) ([]*monitoringpb.Group, string, error) {
var *monitoringpb.ListGroupsResponse
.PageToken =
if > math.MaxInt32 {
.PageSize = math.MaxInt32
} else {
.PageSize = int32()
}
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .groupClient.ListGroups(, , .GRPC...)
return
}, ...)
if != nil {
return nil, "",
}
.Response =
return .Group, .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 ( *GroupClient) ( context.Context, *monitoringpb.GetGroupRequest, ...gax.CallOption) (*monitoringpb.Group, error) {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.GetGroup[0:len(.CallOptions.GetGroup):len(.CallOptions.GetGroup)], ...)
var *monitoringpb.Group
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .groupClient.GetGroup(, , .GRPC...)
return
}, ...)
if != nil {
return nil,
}
return , nil
}
func ( *GroupClient) ( context.Context, *monitoringpb.CreateGroupRequest, ...gax.CallOption) (*monitoringpb.Group, error) {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.CreateGroup[0:len(.CallOptions.CreateGroup):len(.CallOptions.CreateGroup)], ...)
var *monitoringpb.Group
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .groupClient.CreateGroup(, , .GRPC...)
return
}, ...)
if != nil {
return nil,
}
return , nil
}
func ( *GroupClient) ( context.Context, *monitoringpb.UpdateGroupRequest, ...gax.CallOption) (*monitoringpb.Group, error) {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "group.name", url.QueryEscape(.GetGroup().GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.UpdateGroup[0:len(.CallOptions.UpdateGroup):len(.CallOptions.UpdateGroup)], ...)
var *monitoringpb.Group
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .groupClient.UpdateGroup(, , .GRPC...)
return
}, ...)
if != nil {
return nil,
}
return , nil
}
func ( *GroupClient) ( context.Context, *monitoringpb.DeleteGroupRequest, ...gax.CallOption) error {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.DeleteGroup[0:len(.CallOptions.DeleteGroup):len(.CallOptions.DeleteGroup)], ...)
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
_, = .groupClient.DeleteGroup(, , .GRPC...)
return
}, ...)
return
}
func ( *GroupClient) ( context.Context, *monitoringpb.ListGroupMembersRequest, ...gax.CallOption) *MonitoredResourceIterator {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.ListGroupMembers[0:len(.CallOptions.ListGroupMembers):len(.CallOptions.ListGroupMembers)], ...)
:= &MonitoredResourceIterator{}
= proto.Clone().(*monitoringpb.ListGroupMembersRequest)
.InternalFetch = func( int, string) ([]*monitoredrespb.MonitoredResource, string, error) {
var *monitoringpb.ListGroupMembersResponse
.PageToken =
if > math.MaxInt32 {
.PageSize = math.MaxInt32
} else {
.PageSize = int32()
}
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .groupClient.ListGroupMembers(, , .GRPC...)
return
}, ...)
if != nil {
return nil, "",
}
.Response =
return .Members, .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
}
type GroupIterator struct {
items []*monitoringpb.Group
pageInfo *iterator.PageInfo
nextFunc func() error
Response interface{}
InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.Group, nextPageToken string, err error)
}
func ( *GroupIterator) () *iterator.PageInfo {
return .pageInfo
}
func ( *GroupIterator) () (*monitoringpb.Group, error) {
var *monitoringpb.Group
if := .nextFunc(); != nil {
return ,
}
= .items[0]
.items = .items[1:]
return , nil
}
func ( *GroupIterator) () int {
return len(.items)
}
func ( *GroupIterator) () interface{} {
:= .items
.items = nil
return
}
type MonitoredResourceIterator struct {
items []*monitoredrespb.MonitoredResource
pageInfo *iterator.PageInfo
nextFunc func() error
Response interface{}
InternalFetch func(pageSize int, pageToken string) (results []*monitoredrespb.MonitoredResource, nextPageToken string, err error)
}
func ( *MonitoredResourceIterator) () *iterator.PageInfo {
return .pageInfo
}
func ( *MonitoredResourceIterator) () (*monitoredrespb.MonitoredResource, error) {
var *monitoredrespb.MonitoredResource
if := .nextFunc(); != nil {
return ,
}
= .items[0]
.items = .items[1:]
return , nil
}
func ( *MonitoredResourceIterator) () int {
return len(.items)
}
func ( *MonitoredResourceIterator) () 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. |