Source File
service_monitoring_client.go
Belonging Package
cloud.google.com/go/monitoring/apiv3
package monitoring
import (
gax
gtransport
monitoringpb
)
var newServiceMonitoringClientHook clientHook
type ServiceMonitoringCallOptions struct {
CreateService []gax.CallOption
GetService []gax.CallOption
ListServices []gax.CallOption
UpdateService []gax.CallOption
DeleteService []gax.CallOption
CreateServiceLevelObjective []gax.CallOption
GetServiceLevelObjective []gax.CallOption
ListServiceLevelObjectives []gax.CallOption
UpdateServiceLevelObjective []gax.CallOption
DeleteServiceLevelObjective []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 () *ServiceMonitoringCallOptions {
return &ServiceMonitoringCallOptions{
CreateService: []gax.CallOption{},
GetService: []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,
})
}),
},
ListServices: []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,
})
}),
},
UpdateService: []gax.CallOption{},
DeleteService: []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,
})
}),
},
CreateServiceLevelObjective: []gax.CallOption{},
GetServiceLevelObjective: []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,
})
}),
},
ListServiceLevelObjectives: []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,
})
}),
},
UpdateServiceLevelObjective: []gax.CallOption{},
DeleteServiceLevelObjective: []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) (*ServiceMonitoringClient, error) {
:= defaultServiceMonitoringClientOptions()
if newServiceMonitoringClientHook != nil {
, := newServiceMonitoringClientHook(, clientHookParams{})
if != nil {
return nil,
}
= append(, ...)
}
, := gtransport.DialPool(, append(, ...)...)
if != nil {
return nil,
}
:= &ServiceMonitoringClient{
connPool: ,
CallOptions: defaultServiceMonitoringCallOptions(),
serviceMonitoringClient: monitoringpb.NewServiceMonitoringServiceClient(),
}
.setGoogleClientInfo()
return , nil
}
func ( *ServiceMonitoringClient) () *grpc.ClientConn {
return .connPool.Conn()
}
func ( *ServiceMonitoringClient) () error {
return .connPool.Close()
}
func ( *ServiceMonitoringClient) ( ...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 ( *ServiceMonitoringClient) ( context.Context, *monitoringpb.CreateServiceRequest, ...gax.CallOption) (*monitoringpb.Service, error) {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(.GetParent())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.CreateService[0:len(.CallOptions.CreateService):len(.CallOptions.CreateService)], ...)
var *monitoringpb.Service
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .serviceMonitoringClient.CreateService(, , .GRPC...)
return
}, ...)
if != nil {
return nil,
}
return , nil
}
func ( *ServiceMonitoringClient) ( context.Context, *monitoringpb.GetServiceRequest, ...gax.CallOption) (*monitoringpb.Service, error) {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.GetService[0:len(.CallOptions.GetService):len(.CallOptions.GetService)], ...)
var *monitoringpb.Service
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .serviceMonitoringClient.GetService(, , .GRPC...)
return
}, ...)
if != nil {
return nil,
}
return , nil
}
func ( *ServiceMonitoringClient) ( context.Context, *monitoringpb.ListServicesRequest, ...gax.CallOption) *ServiceIterator {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(.GetParent())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.ListServices[0:len(.CallOptions.ListServices):len(.CallOptions.ListServices)], ...)
:= &ServiceIterator{}
= proto.Clone().(*monitoringpb.ListServicesRequest)
.InternalFetch = func( int, string) ([]*monitoringpb.Service, string, error) {
var *monitoringpb.ListServicesResponse
.PageToken =
if > math.MaxInt32 {
.PageSize = math.MaxInt32
} else {
.PageSize = int32()
}
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .serviceMonitoringClient.ListServices(, , .GRPC...)
return
}, ...)
if != nil {
return nil, "",
}
.Response =
return .Services, .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 ( *ServiceMonitoringClient) ( context.Context, *monitoringpb.UpdateServiceRequest, ...gax.CallOption) (*monitoringpb.Service, error) {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service.name", url.QueryEscape(.GetService().GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.UpdateService[0:len(.CallOptions.UpdateService):len(.CallOptions.UpdateService)], ...)
var *monitoringpb.Service
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .serviceMonitoringClient.UpdateService(, , .GRPC...)
return
}, ...)
if != nil {
return nil,
}
return , nil
}
func ( *ServiceMonitoringClient) ( context.Context, *monitoringpb.DeleteServiceRequest, ...gax.CallOption) error {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.DeleteService[0:len(.CallOptions.DeleteService):len(.CallOptions.DeleteService)], ...)
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
_, = .serviceMonitoringClient.DeleteService(, , .GRPC...)
return
}, ...)
return
}
func ( *ServiceMonitoringClient) ( context.Context, *monitoringpb.CreateServiceLevelObjectiveRequest, ...gax.CallOption) (*monitoringpb.ServiceLevelObjective, error) {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(.GetParent())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.CreateServiceLevelObjective[0:len(.CallOptions.CreateServiceLevelObjective):len(.CallOptions.CreateServiceLevelObjective)], ...)
var *monitoringpb.ServiceLevelObjective
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .serviceMonitoringClient.CreateServiceLevelObjective(, , .GRPC...)
return
}, ...)
if != nil {
return nil,
}
return , nil
}
func ( *ServiceMonitoringClient) ( context.Context, *monitoringpb.GetServiceLevelObjectiveRequest, ...gax.CallOption) (*monitoringpb.ServiceLevelObjective, error) {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.GetServiceLevelObjective[0:len(.CallOptions.GetServiceLevelObjective):len(.CallOptions.GetServiceLevelObjective)], ...)
var *monitoringpb.ServiceLevelObjective
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .serviceMonitoringClient.GetServiceLevelObjective(, , .GRPC...)
return
}, ...)
if != nil {
return nil,
}
return , nil
}
func ( *ServiceMonitoringClient) ( context.Context, *monitoringpb.ListServiceLevelObjectivesRequest, ...gax.CallOption) *ServiceLevelObjectiveIterator {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(.GetParent())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.ListServiceLevelObjectives[0:len(.CallOptions.ListServiceLevelObjectives):len(.CallOptions.ListServiceLevelObjectives)], ...)
:= &ServiceLevelObjectiveIterator{}
= proto.Clone().(*monitoringpb.ListServiceLevelObjectivesRequest)
.InternalFetch = func( int, string) ([]*monitoringpb.ServiceLevelObjective, string, error) {
var *monitoringpb.ListServiceLevelObjectivesResponse
.PageToken =
if > math.MaxInt32 {
.PageSize = math.MaxInt32
} else {
.PageSize = int32()
}
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .serviceMonitoringClient.ListServiceLevelObjectives(, , .GRPC...)
return
}, ...)
if != nil {
return nil, "",
}
.Response =
return .ServiceLevelObjectives, .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 ( *ServiceMonitoringClient) ( context.Context, *monitoringpb.UpdateServiceLevelObjectiveRequest, ...gax.CallOption) (*monitoringpb.ServiceLevelObjective, error) {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_level_objective.name", url.QueryEscape(.GetServiceLevelObjective().GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.UpdateServiceLevelObjective[0:len(.CallOptions.UpdateServiceLevelObjective):len(.CallOptions.UpdateServiceLevelObjective)], ...)
var *monitoringpb.ServiceLevelObjective
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .serviceMonitoringClient.UpdateServiceLevelObjective(, , .GRPC...)
return
}, ...)
if != nil {
return nil,
}
return , nil
}
func ( *ServiceMonitoringClient) ( context.Context, *monitoringpb.DeleteServiceLevelObjectiveRequest, ...gax.CallOption) error {
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.DeleteServiceLevelObjective[0:len(.CallOptions.DeleteServiceLevelObjective):len(.CallOptions.DeleteServiceLevelObjective)], ...)
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
_, = .serviceMonitoringClient.DeleteServiceLevelObjective(, , .GRPC...)
return
}, ...)
return
}
type ServiceIterator struct {
items []*monitoringpb.Service
pageInfo *iterator.PageInfo
nextFunc func() error
Response interface{}
InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.Service, nextPageToken string, err error)
}
func ( *ServiceIterator) () *iterator.PageInfo {
return .pageInfo
}
func ( *ServiceIterator) () (*monitoringpb.Service, error) {
var *monitoringpb.Service
if := .nextFunc(); != nil {
return ,
}
= .items[0]
.items = .items[1:]
return , nil
}
func ( *ServiceIterator) () int {
return len(.items)
}
func ( *ServiceIterator) () interface{} {
:= .items
.items = nil
return
}
type ServiceLevelObjectiveIterator struct {
items []*monitoringpb.ServiceLevelObjective
pageInfo *iterator.PageInfo
nextFunc func() error
Response interface{}
InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.ServiceLevelObjective, nextPageToken string, err error)
}
func ( *ServiceLevelObjectiveIterator) () *iterator.PageInfo {
return .pageInfo
}
func ( *ServiceLevelObjectiveIterator) () (*monitoringpb.ServiceLevelObjective, error) {
var *monitoringpb.ServiceLevelObjective
if := .nextFunc(); != nil {
return ,
}
= .items[0]
.items = .items[1:]
return , nil
}
func ( *ServiceLevelObjectiveIterator) () int {
return len(.items)
}
func ( *ServiceLevelObjectiveIterator) () 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. |