Package metricsscope is an auto-generated package for the Cloud Monitoring API.
Manages your Cloud Monitoring data and configurations. Most projects must be associated with a Workspace, with a few exceptions as noted on the individual method pages. The table entries below are presented in alphabetical order, not in order of common use. For explanations of the concepts found in the table entries, read the Cloud Monitoring documentation (at https://cloud.google.com/monitoring/docs).
General documentation
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage
To get started with this package, create a client.
ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := metricsscope.NewMetricsScopesClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close()
The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.
Using the Client
The following is an example of making an API call with the newly created client.
ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := metricsscope.NewMetricsScopesClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &metricsscopepb.CreateMonitoredProjectRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb#CreateMonitoredProjectRequest. } op, err := c.CreateMonitoredProject(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context
The ctx passed to NewMetricsScopesClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
Functions
func DefaultAuthScopes
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
CreateMonitoredProjectOperation
type CreateMonitoredProjectOperation struct {
// contains filtered or unexported fields
}
CreateMonitoredProjectOperation manages a long-running operation from CreateMonitoredProject.
func (*CreateMonitoredProjectOperation) Done
func (op *CreateMonitoredProjectOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*CreateMonitoredProjectOperation) Metadata
func (op *CreateMonitoredProjectOperation) Metadata() (*metricsscopepb.OperationMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*CreateMonitoredProjectOperation) Name
func (op *CreateMonitoredProjectOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*CreateMonitoredProjectOperation) Poll
func (op *CreateMonitoredProjectOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*metricsscopepb.MonitoredProject, error)
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*CreateMonitoredProjectOperation) Wait
func (op *CreateMonitoredProjectOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*metricsscopepb.MonitoredProject, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
DeleteMonitoredProjectOperation
type DeleteMonitoredProjectOperation struct {
// contains filtered or unexported fields
}
DeleteMonitoredProjectOperation manages a long-running operation from DeleteMonitoredProject.
func (*DeleteMonitoredProjectOperation) Done
func (op *DeleteMonitoredProjectOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*DeleteMonitoredProjectOperation) Metadata
func (op *DeleteMonitoredProjectOperation) Metadata() (*metricsscopepb.OperationMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*DeleteMonitoredProjectOperation) Name
func (op *DeleteMonitoredProjectOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*DeleteMonitoredProjectOperation) Poll
func (op *DeleteMonitoredProjectOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*DeleteMonitoredProjectOperation) Wait
func (op *DeleteMonitoredProjectOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
MetricsScopesCallOptions
type MetricsScopesCallOptions struct {
GetMetricsScope []gax.CallOption
ListMetricsScopesByMonitoredProject []gax.CallOption
CreateMonitoredProject []gax.CallOption
DeleteMonitoredProject []gax.CallOption
}
MetricsScopesCallOptions contains the retry settings for each method of MetricsScopesClient.
MetricsScopesClient
type MetricsScopesClient struct {
// The call options for this service.
CallOptions *MetricsScopesCallOptions
// LROClient is used internally to handle long-running operations.
// It is exposed so that its CallOptions can be modified if required.
// Users should not Close this client.
LROClient *lroauto.OperationsClient
// contains filtered or unexported fields
}
MetricsScopesClient 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.
Manages Cloud Monitoring Metrics Scopes, and the monitoring of Google Cloud projects and AWS accounts.
func NewMetricsScopesClient
func NewMetricsScopesClient(ctx context.Context, opts ...option.ClientOption) (*MetricsScopesClient, error)
NewMetricsScopesClient creates a new metrics scopes client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Manages Cloud Monitoring Metrics Scopes, and the monitoring of Google Cloud projects and AWS accounts.
Example
package main
import (
"context"
metricsscope "cloud.google.com/go/monitoring/metricsscope/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := metricsscope.NewMetricsScopesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*MetricsScopesClient) Close
func (c *MetricsScopesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*MetricsScopesClient) Connection (deprecated)
func (c *MetricsScopesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*MetricsScopesClient) CreateMonitoredProject
func (c *MetricsScopesClient) CreateMonitoredProject(ctx context.Context, req *metricsscopepb.CreateMonitoredProjectRequest, opts ...gax.CallOption) (*CreateMonitoredProjectOperation, error)
CreateMonitoredProject adds a MonitoredProject with the given project ID to the specified Metrics Scope.
Example
package main
import (
"context"
metricsscope "cloud.google.com/go/monitoring/metricsscope/apiv1"
metricsscopepb "cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := metricsscope.NewMetricsScopesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &metricsscopepb.CreateMonitoredProjectRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb#CreateMonitoredProjectRequest.
}
op, err := c.CreateMonitoredProject(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*MetricsScopesClient) CreateMonitoredProjectOperation
func (c *MetricsScopesClient) CreateMonitoredProjectOperation(name string) *CreateMonitoredProjectOperation
CreateMonitoredProjectOperation returns a new CreateMonitoredProjectOperation from a given name. The name must be that of a previously created CreateMonitoredProjectOperation, possibly from a different process.
func (*MetricsScopesClient) DeleteMonitoredProject
func (c *MetricsScopesClient) DeleteMonitoredProject(ctx context.Context, req *metricsscopepb.DeleteMonitoredProjectRequest, opts ...gax.CallOption) (*DeleteMonitoredProjectOperation, error)
DeleteMonitoredProject deletes a MonitoredProject from the specified Metrics Scope.
Example
package main
import (
"context"
metricsscope "cloud.google.com/go/monitoring/metricsscope/apiv1"
metricsscopepb "cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := metricsscope.NewMetricsScopesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &metricsscopepb.DeleteMonitoredProjectRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb#DeleteMonitoredProjectRequest.
}
op, err := c.DeleteMonitoredProject(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*MetricsScopesClient) DeleteMonitoredProjectOperation
func (c *MetricsScopesClient) DeleteMonitoredProjectOperation(name string) *DeleteMonitoredProjectOperation
DeleteMonitoredProjectOperation returns a new DeleteMonitoredProjectOperation from a given name. The name must be that of a previously created DeleteMonitoredProjectOperation, possibly from a different process.
func (*MetricsScopesClient) GetMetricsScope
func (c *MetricsScopesClient) GetMetricsScope(ctx context.Context, req *metricsscopepb.GetMetricsScopeRequest, opts ...gax.CallOption) (*metricsscopepb.MetricsScope, error)
GetMetricsScope returns a specific Metrics Scope.
Example
package main
import (
"context"
metricsscope "cloud.google.com/go/monitoring/metricsscope/apiv1"
metricsscopepb "cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := metricsscope.NewMetricsScopesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &metricsscopepb.GetMetricsScopeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb#GetMetricsScopeRequest.
}
resp, err := c.GetMetricsScope(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*MetricsScopesClient) ListMetricsScopesByMonitoredProject
func (c *MetricsScopesClient) ListMetricsScopesByMonitoredProject(ctx context.Context, req *metricsscopepb.ListMetricsScopesByMonitoredProjectRequest, opts ...gax.CallOption) (*metricsscopepb.ListMetricsScopesByMonitoredProjectResponse, error)
ListMetricsScopesByMonitoredProject returns a list of every Metrics Scope that a specific MonitoredProject has been added to. The metrics scope representing the specified monitored project will always be the first entry in the response.
Example
package main
import (
"context"
metricsscope "cloud.google.com/go/monitoring/metricsscope/apiv1"
metricsscopepb "cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := metricsscope.NewMetricsScopesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &metricsscopepb.ListMetricsScopesByMonitoredProjectRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb#ListMetricsScopesByMonitoredProjectRequest.
}
resp, err := c.ListMetricsScopesByMonitoredProject(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}