Documentation
¶
Overview ¶
Package api is an auto-generated package for the Maintenance API.
The Maintenance API provides a centralized view of planned disruptive maintenance events across supported Google Cloud products. It offers users visibility into upcoming, ongoing, and completed maintenance, along with controls to manage certain maintenance activities, such as maintenance windows, rescheduling, and on-demand updates.
NOTE: This package is in beta. It is not stable, and may be subject to changes.
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.
// go get cloud.google.com/go/maintenance/api/apiv1@latest
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 := api.NewMaintenanceClient(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, mentioned above.
req := &apipb.GetResourceMaintenanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/maintenance/api/apiv1/apipb#GetResourceMaintenanceRequest.
}
resp, err := c.GetResourceMaintenance(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Use of Context ¶
The ctx passed to NewMaintenanceClient 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.
Index ¶
- func DefaultAuthScopes() []string
- type LocationIterator
- type MaintenanceCallOptions
- type MaintenanceClient
- func (c *MaintenanceClient) Close() error
- func (c *MaintenanceClient) Connection() *grpc.ClientConndeprecated
- func (c *MaintenanceClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, ...) (*locationpb.Location, error)
- func (c *MaintenanceClient) GetResourceMaintenance(ctx context.Context, req *apipb.GetResourceMaintenanceRequest, ...) (*apipb.ResourceMaintenance, error)
- func (c *MaintenanceClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, ...) *LocationIterator
- func (c *MaintenanceClient) ListResourceMaintenances(ctx context.Context, req *apipb.ListResourceMaintenancesRequest, ...) *ResourceMaintenanceIterator
- func (c *MaintenanceClient) SummarizeMaintenances(ctx context.Context, req *apipb.SummarizeMaintenancesRequest, ...) *MaintenanceSummaryIterator
- type MaintenanceSummaryIterator
- type ResourceMaintenanceIterator
Examples ¶
- MaintenanceClient.GetLocation
- MaintenanceClient.GetResourceMaintenance
- MaintenanceClient.ListLocations
- MaintenanceClient.ListLocations (All)
- MaintenanceClient.ListResourceMaintenances
- MaintenanceClient.ListResourceMaintenances (All)
- MaintenanceClient.SummarizeMaintenances
- MaintenanceClient.SummarizeMaintenances (All)
- NewMaintenanceClient
- NewMaintenanceRESTClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type LocationIterator ¶
type LocationIterator struct {
// 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 []*locationpb.Location, nextPageToken string, err error)
// contains filtered or unexported fields
}
LocationIterator manages a stream of *locationpb.Location.
func (*LocationIterator) All ¶
func (it *LocationIterator) All() iter.Seq2[*locationpb.Location, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*LocationIterator) Next ¶
func (it *LocationIterator) Next() (*locationpb.Location, error)
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 (*LocationIterator) PageInfo ¶
func (it *LocationIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type MaintenanceCallOptions ¶
type MaintenanceCallOptions struct {
SummarizeMaintenances []gax.CallOption
ListResourceMaintenances []gax.CallOption
GetResourceMaintenance []gax.CallOption
GetLocation []gax.CallOption
ListLocations []gax.CallOption
}
MaintenanceCallOptions contains the retry settings for each method of MaintenanceClient.
type MaintenanceClient ¶
type MaintenanceClient struct {
// The call options for this service.
CallOptions *MaintenanceCallOptions
// contains filtered or unexported fields
}
MaintenanceClient is a client for interacting with Maintenance API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Unified Maintenance service
func NewMaintenanceClient ¶
func NewMaintenanceClient(ctx context.Context, opts ...option.ClientOption) (*MaintenanceClient, error)
NewMaintenanceClient creates a new maintenance client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Unified Maintenance service
Example ¶
package main
import (
"context"
api "cloud.google.com/go/maintenance/api/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 := api.NewMaintenanceClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewMaintenanceRESTClient ¶
func NewMaintenanceRESTClient(ctx context.Context, opts ...option.ClientOption) (*MaintenanceClient, error)
NewMaintenanceRESTClient creates a new maintenance rest client.
Unified Maintenance service
Example ¶
package main
import (
"context"
api "cloud.google.com/go/maintenance/api/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 := api.NewMaintenanceRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*MaintenanceClient) Close ¶
func (c *MaintenanceClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*MaintenanceClient) Connection
deprecated
func (c *MaintenanceClient) 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 (*MaintenanceClient) GetLocation ¶
func (c *MaintenanceClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error)
GetLocation gets information about a location.
Example ¶
package main
import (
"context"
api "cloud.google.com/go/maintenance/api/apiv1"
locationpb "google.golang.org/genproto/googleapis/cloud/location"
)
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 := api.NewMaintenanceClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &locationpb.GetLocationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
}
resp, err := c.GetLocation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*MaintenanceClient) GetResourceMaintenance ¶
func (c *MaintenanceClient) GetResourceMaintenance(ctx context.Context, req *apipb.GetResourceMaintenanceRequest, opts ...gax.CallOption) (*apipb.ResourceMaintenance, error)
GetResourceMaintenance retrieve a single resource maintenance.
Example ¶
package main
import (
"context"
api "cloud.google.com/go/maintenance/api/apiv1"
apipb "cloud.google.com/go/maintenance/api/apiv1/apipb"
)
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 := api.NewMaintenanceClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apipb.GetResourceMaintenanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/maintenance/api/apiv1/apipb#GetResourceMaintenanceRequest.
}
resp, err := c.GetResourceMaintenance(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*MaintenanceClient) ListLocations ¶
func (c *MaintenanceClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator
ListLocations lists information about the supported locations for this service.
Example ¶
package main
import (
"context"
api "cloud.google.com/go/maintenance/api/apiv1"
"google.golang.org/api/iterator"
locationpb "google.golang.org/genproto/googleapis/cloud/location"
)
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 := api.NewMaintenanceClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &locationpb.ListLocationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
}
it := c.ListLocations(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*locationpb.ListLocationsResponse)
}
}
Example (All) ¶
package main
import (
"context"
api "cloud.google.com/go/maintenance/api/apiv1"
locationpb "google.golang.org/genproto/googleapis/cloud/location"
)
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 := api.NewMaintenanceClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &locationpb.ListLocationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
}
for resp, err := range c.ListLocations(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*MaintenanceClient) ListResourceMaintenances ¶
func (c *MaintenanceClient) ListResourceMaintenances(ctx context.Context, req *apipb.ListResourceMaintenancesRequest, opts ...gax.CallOption) *ResourceMaintenanceIterator
ListResourceMaintenances retrieve a collection of resource maintenances.
Example ¶
package main
import (
"context"
api "cloud.google.com/go/maintenance/api/apiv1"
apipb "cloud.google.com/go/maintenance/api/apiv1/apipb"
"google.golang.org/api/iterator"
)
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 := api.NewMaintenanceClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apipb.ListResourceMaintenancesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/maintenance/api/apiv1/apipb#ListResourceMaintenancesRequest.
}
it := c.ListResourceMaintenances(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*apipb.ListResourceMaintenancesResponse)
}
}
Example (All) ¶
package main
import (
"context"
api "cloud.google.com/go/maintenance/api/apiv1"
apipb "cloud.google.com/go/maintenance/api/apiv1/apipb"
)
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 := api.NewMaintenanceClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apipb.ListResourceMaintenancesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/maintenance/api/apiv1/apipb#ListResourceMaintenancesRequest.
}
for resp, err := range c.ListResourceMaintenances(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*MaintenanceClient) SummarizeMaintenances ¶
func (c *MaintenanceClient) SummarizeMaintenances(ctx context.Context, req *apipb.SummarizeMaintenancesRequest, opts ...gax.CallOption) *MaintenanceSummaryIterator
SummarizeMaintenances retrieves the statistics of a specific maintenance.
Example ¶
package main
import (
"context"
api "cloud.google.com/go/maintenance/api/apiv1"
apipb "cloud.google.com/go/maintenance/api/apiv1/apipb"
"google.golang.org/api/iterator"
)
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 := api.NewMaintenanceClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apipb.SummarizeMaintenancesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/maintenance/api/apiv1/apipb#SummarizeMaintenancesRequest.
}
it := c.SummarizeMaintenances(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*apipb.SummarizeMaintenancesResponse)
}
}
Example (All) ¶
package main
import (
"context"
api "cloud.google.com/go/maintenance/api/apiv1"
apipb "cloud.google.com/go/maintenance/api/apiv1/apipb"
)
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 := api.NewMaintenanceClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apipb.SummarizeMaintenancesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/maintenance/api/apiv1/apipb#SummarizeMaintenancesRequest.
}
for resp, err := range c.SummarizeMaintenances(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
type MaintenanceSummaryIterator ¶
type MaintenanceSummaryIterator struct {
// 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 []*apipb.MaintenanceSummary, nextPageToken string, err error)
// contains filtered or unexported fields
}
MaintenanceSummaryIterator manages a stream of *apipb.MaintenanceSummary.
func (*MaintenanceSummaryIterator) All ¶
func (it *MaintenanceSummaryIterator) All() iter.Seq2[*apipb.MaintenanceSummary, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*MaintenanceSummaryIterator) Next ¶
func (it *MaintenanceSummaryIterator) Next() (*apipb.MaintenanceSummary, error)
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 (*MaintenanceSummaryIterator) PageInfo ¶
func (it *MaintenanceSummaryIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type ResourceMaintenanceIterator ¶
type ResourceMaintenanceIterator struct {
// 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 []*apipb.ResourceMaintenance, nextPageToken string, err error)
// contains filtered or unexported fields
}
ResourceMaintenanceIterator manages a stream of *apipb.ResourceMaintenance.
func (*ResourceMaintenanceIterator) All ¶
func (it *ResourceMaintenanceIterator) All() iter.Seq2[*apipb.ResourceMaintenance, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ResourceMaintenanceIterator) Next ¶
func (it *ResourceMaintenanceIterator) Next() (*apipb.ResourceMaintenance, error)
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 (*ResourceMaintenanceIterator) PageInfo ¶
func (it *ResourceMaintenanceIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.