blob: e891f38f309d3081f032d85ec99e45eb3eab5416 [file] [log] [blame]
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
package alloydb
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"math"
"net/http"
"net/url"
"time"
alloydbpb "cloud.google.com/go/alloydb/apiv1alpha/alloydbpb"
"cloud.google.com/go/longrunning"
lroauto "cloud.google.com/go/longrunning/autogen"
"cloud.google.com/go/longrunning/autogen/longrunningpb"
gax "github.com/googleapis/gax-go/v2"
"google.golang.org/api/googleapi"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
"google.golang.org/api/option/internaloption"
gtransport "google.golang.org/api/transport/grpc"
httptransport "google.golang.org/api/transport/http"
locationpb "google.golang.org/genproto/googleapis/cloud/location"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
var newAlloyDBAdminClientHook clientHook
// AlloyDBAdminCallOptions contains the retry settings for each method of AlloyDBAdminClient.
type AlloyDBAdminCallOptions struct {
ListClusters []gax.CallOption
GetCluster []gax.CallOption
CreateCluster []gax.CallOption
UpdateCluster []gax.CallOption
DeleteCluster []gax.CallOption
PromoteCluster []gax.CallOption
RestoreCluster []gax.CallOption
CreateSecondaryCluster []gax.CallOption
ListInstances []gax.CallOption
GetInstance []gax.CallOption
CreateInstance []gax.CallOption
CreateSecondaryInstance []gax.CallOption
BatchCreateInstances []gax.CallOption
UpdateInstance []gax.CallOption
DeleteInstance []gax.CallOption
FailoverInstance []gax.CallOption
RestartInstance []gax.CallOption
ListBackups []gax.CallOption
GetBackup []gax.CallOption
CreateBackup []gax.CallOption
UpdateBackup []gax.CallOption
DeleteBackup []gax.CallOption
ListSupportedDatabaseFlags []gax.CallOption
GenerateClientCertificate []gax.CallOption
GetConnectionInfo []gax.CallOption
GetLocation []gax.CallOption
ListLocations []gax.CallOption
CancelOperation []gax.CallOption
DeleteOperation []gax.CallOption
GetOperation []gax.CallOption
ListOperations []gax.CallOption
}
func defaultAlloyDBAdminGRPCClientOptions() []option.ClientOption {
return []option.ClientOption{
internaloption.WithDefaultEndpoint("alloydb.googleapis.com:443"),
internaloption.WithDefaultMTLSEndpoint("alloydb.mtls.googleapis.com:443"),
internaloption.WithDefaultAudience("https://alloydb.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
internaloption.EnableJwtWithScope(),
option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(math.MaxInt32))),
}
}
func defaultAlloyDBAdminCallOptions() *AlloyDBAdminCallOptions {
return &AlloyDBAdminCallOptions{
ListClusters: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
}, gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
GetCluster: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
}, gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
CreateCluster: []gax.CallOption{},
UpdateCluster: []gax.CallOption{},
DeleteCluster: []gax.CallOption{},
PromoteCluster: []gax.CallOption{},
RestoreCluster: []gax.CallOption{},
CreateSecondaryCluster: []gax.CallOption{},
ListInstances: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
}, gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
GetInstance: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
}, gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
CreateInstance: []gax.CallOption{},
CreateSecondaryInstance: []gax.CallOption{},
BatchCreateInstances: []gax.CallOption{},
UpdateInstance: []gax.CallOption{},
DeleteInstance: []gax.CallOption{},
FailoverInstance: []gax.CallOption{},
RestartInstance: []gax.CallOption{},
ListBackups: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
}, gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
GetBackup: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
}, gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
CreateBackup: []gax.CallOption{},
UpdateBackup: []gax.CallOption{},
DeleteBackup: []gax.CallOption{},
ListSupportedDatabaseFlags: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
}, gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
GenerateClientCertificate: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
}, gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
GetConnectionInfo: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
}, gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
GetLocation: []gax.CallOption{},
ListLocations: []gax.CallOption{},
CancelOperation: []gax.CallOption{},
DeleteOperation: []gax.CallOption{},
GetOperation: []gax.CallOption{},
ListOperations: []gax.CallOption{},
}
}
func defaultAlloyDBAdminRESTCallOptions() *AlloyDBAdminCallOptions {
return &AlloyDBAdminCallOptions{
ListClusters: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusServiceUnavailable)
}),
},
GetCluster: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusServiceUnavailable)
}),
},
CreateCluster: []gax.CallOption{},
UpdateCluster: []gax.CallOption{},
DeleteCluster: []gax.CallOption{},
PromoteCluster: []gax.CallOption{},
RestoreCluster: []gax.CallOption{},
CreateSecondaryCluster: []gax.CallOption{},
ListInstances: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusServiceUnavailable)
}),
},
GetInstance: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusServiceUnavailable)
}),
},
CreateInstance: []gax.CallOption{},
CreateSecondaryInstance: []gax.CallOption{},
BatchCreateInstances: []gax.CallOption{},
UpdateInstance: []gax.CallOption{},
DeleteInstance: []gax.CallOption{},
FailoverInstance: []gax.CallOption{},
RestartInstance: []gax.CallOption{},
ListBackups: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusServiceUnavailable)
}),
},
GetBackup: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusServiceUnavailable)
}),
},
CreateBackup: []gax.CallOption{},
UpdateBackup: []gax.CallOption{},
DeleteBackup: []gax.CallOption{},
ListSupportedDatabaseFlags: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusServiceUnavailable)
}),
},
GenerateClientCertificate: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusServiceUnavailable)
}),
},
GetConnectionInfo: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 1000 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusServiceUnavailable)
}),
},
GetLocation: []gax.CallOption{},
ListLocations: []gax.CallOption{},
CancelOperation: []gax.CallOption{},
DeleteOperation: []gax.CallOption{},
GetOperation: []gax.CallOption{},
ListOperations: []gax.CallOption{},
}
}
// internalAlloyDBAdminClient is an interface that defines the methods available from AlloyDB API.
type internalAlloyDBAdminClient interface {
Close() error
setGoogleClientInfo(...string)
Connection() *grpc.ClientConn
ListClusters(context.Context, *alloydbpb.ListClustersRequest, ...gax.CallOption) *ClusterIterator
GetCluster(context.Context, *alloydbpb.GetClusterRequest, ...gax.CallOption) (*alloydbpb.Cluster, error)
CreateCluster(context.Context, *alloydbpb.CreateClusterRequest, ...gax.CallOption) (*CreateClusterOperation, error)
CreateClusterOperation(name string) *CreateClusterOperation
UpdateCluster(context.Context, *alloydbpb.UpdateClusterRequest, ...gax.CallOption) (*UpdateClusterOperation, error)
UpdateClusterOperation(name string) *UpdateClusterOperation
DeleteCluster(context.Context, *alloydbpb.DeleteClusterRequest, ...gax.CallOption) (*DeleteClusterOperation, error)
DeleteClusterOperation(name string) *DeleteClusterOperation
PromoteCluster(context.Context, *alloydbpb.PromoteClusterRequest, ...gax.CallOption) (*PromoteClusterOperation, error)
PromoteClusterOperation(name string) *PromoteClusterOperation
RestoreCluster(context.Context, *alloydbpb.RestoreClusterRequest, ...gax.CallOption) (*RestoreClusterOperation, error)
RestoreClusterOperation(name string) *RestoreClusterOperation
CreateSecondaryCluster(context.Context, *alloydbpb.CreateSecondaryClusterRequest, ...gax.CallOption) (*CreateSecondaryClusterOperation, error)
CreateSecondaryClusterOperation(name string) *CreateSecondaryClusterOperation
ListInstances(context.Context, *alloydbpb.ListInstancesRequest, ...gax.CallOption) *InstanceIterator
GetInstance(context.Context, *alloydbpb.GetInstanceRequest, ...gax.CallOption) (*alloydbpb.Instance, error)
CreateInstance(context.Context, *alloydbpb.CreateInstanceRequest, ...gax.CallOption) (*CreateInstanceOperation, error)
CreateInstanceOperation(name string) *CreateInstanceOperation
CreateSecondaryInstance(context.Context, *alloydbpb.CreateSecondaryInstanceRequest, ...gax.CallOption) (*CreateSecondaryInstanceOperation, error)
CreateSecondaryInstanceOperation(name string) *CreateSecondaryInstanceOperation
BatchCreateInstances(context.Context, *alloydbpb.BatchCreateInstancesRequest, ...gax.CallOption) (*BatchCreateInstancesOperation, error)
BatchCreateInstancesOperation(name string) *BatchCreateInstancesOperation
UpdateInstance(context.Context, *alloydbpb.UpdateInstanceRequest, ...gax.CallOption) (*UpdateInstanceOperation, error)
UpdateInstanceOperation(name string) *UpdateInstanceOperation
DeleteInstance(context.Context, *alloydbpb.DeleteInstanceRequest, ...gax.CallOption) (*DeleteInstanceOperation, error)
DeleteInstanceOperation(name string) *DeleteInstanceOperation
FailoverInstance(context.Context, *alloydbpb.FailoverInstanceRequest, ...gax.CallOption) (*FailoverInstanceOperation, error)
FailoverInstanceOperation(name string) *FailoverInstanceOperation
RestartInstance(context.Context, *alloydbpb.RestartInstanceRequest, ...gax.CallOption) (*RestartInstanceOperation, error)
RestartInstanceOperation(name string) *RestartInstanceOperation
ListBackups(context.Context, *alloydbpb.ListBackupsRequest, ...gax.CallOption) *BackupIterator
GetBackup(context.Context, *alloydbpb.GetBackupRequest, ...gax.CallOption) (*alloydbpb.Backup, error)
CreateBackup(context.Context, *alloydbpb.CreateBackupRequest, ...gax.CallOption) (*CreateBackupOperation, error)
CreateBackupOperation(name string) *CreateBackupOperation
UpdateBackup(context.Context, *alloydbpb.UpdateBackupRequest, ...gax.CallOption) (*UpdateBackupOperation, error)
UpdateBackupOperation(name string) *UpdateBackupOperation
DeleteBackup(context.Context, *alloydbpb.DeleteBackupRequest, ...gax.CallOption) (*DeleteBackupOperation, error)
DeleteBackupOperation(name string) *DeleteBackupOperation
ListSupportedDatabaseFlags(context.Context, *alloydbpb.ListSupportedDatabaseFlagsRequest, ...gax.CallOption) *SupportedDatabaseFlagIterator
GenerateClientCertificate(context.Context, *alloydbpb.GenerateClientCertificateRequest, ...gax.CallOption) (*alloydbpb.GenerateClientCertificateResponse, error)
GetConnectionInfo(context.Context, *alloydbpb.GetConnectionInfoRequest, ...gax.CallOption) (*alloydbpb.ConnectionInfo, error)
GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
}
// AlloyDBAdminClient is a client for interacting with AlloyDB API.
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
//
// Service describing handlers for resources
type AlloyDBAdminClient struct {
// The internal transport-dependent client.
internalClient internalAlloyDBAdminClient
// The call options for this service.
CallOptions *AlloyDBAdminCallOptions
// 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
}
// Wrapper methods routed to the internal client.
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *AlloyDBAdminClient) Close() error {
return c.internalClient.Close()
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *AlloyDBAdminClient) setGoogleClientInfo(keyval ...string) {
c.internalClient.setGoogleClientInfo(keyval...)
}
// Connection returns a connection to the API service.
//
// Deprecated: Connections are now pooled so this method does not always
// return the same resource.
func (c *AlloyDBAdminClient) Connection() *grpc.ClientConn {
return c.internalClient.Connection()
}
// ListClusters lists Clusters in a given project and location.
func (c *AlloyDBAdminClient) ListClusters(ctx context.Context, req *alloydbpb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator {
return c.internalClient.ListClusters(ctx, req, opts...)
}
// GetCluster gets details of a single Cluster.
func (c *AlloyDBAdminClient) GetCluster(ctx context.Context, req *alloydbpb.GetClusterRequest, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
return c.internalClient.GetCluster(ctx, req, opts...)
}
// CreateCluster creates a new Cluster in a given project and location.
func (c *AlloyDBAdminClient) CreateCluster(ctx context.Context, req *alloydbpb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error) {
return c.internalClient.CreateCluster(ctx, req, opts...)
}
// CreateClusterOperation returns a new CreateClusterOperation from a given name.
// The name must be that of a previously created CreateClusterOperation, possibly from a different process.
func (c *AlloyDBAdminClient) CreateClusterOperation(name string) *CreateClusterOperation {
return c.internalClient.CreateClusterOperation(name)
}
// UpdateCluster updates the parameters of a single Cluster.
func (c *AlloyDBAdminClient) UpdateCluster(ctx context.Context, req *alloydbpb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error) {
return c.internalClient.UpdateCluster(ctx, req, opts...)
}
// UpdateClusterOperation returns a new UpdateClusterOperation from a given name.
// The name must be that of a previously created UpdateClusterOperation, possibly from a different process.
func (c *AlloyDBAdminClient) UpdateClusterOperation(name string) *UpdateClusterOperation {
return c.internalClient.UpdateClusterOperation(name)
}
// DeleteCluster deletes a single Cluster.
func (c *AlloyDBAdminClient) DeleteCluster(ctx context.Context, req *alloydbpb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error) {
return c.internalClient.DeleteCluster(ctx, req, opts...)
}
// DeleteClusterOperation returns a new DeleteClusterOperation from a given name.
// The name must be that of a previously created DeleteClusterOperation, possibly from a different process.
func (c *AlloyDBAdminClient) DeleteClusterOperation(name string) *DeleteClusterOperation {
return c.internalClient.DeleteClusterOperation(name)
}
// PromoteCluster promotes a SECONDARY cluster. This turns down replication
// from the PRIMARY cluster and promotes a secondary cluster
// into its own standalone cluster.
// Imperative only.
func (c *AlloyDBAdminClient) PromoteCluster(ctx context.Context, req *alloydbpb.PromoteClusterRequest, opts ...gax.CallOption) (*PromoteClusterOperation, error) {
return c.internalClient.PromoteCluster(ctx, req, opts...)
}
// PromoteClusterOperation returns a new PromoteClusterOperation from a given name.
// The name must be that of a previously created PromoteClusterOperation, possibly from a different process.
func (c *AlloyDBAdminClient) PromoteClusterOperation(name string) *PromoteClusterOperation {
return c.internalClient.PromoteClusterOperation(name)
}
// RestoreCluster creates a new Cluster in a given project and location, with a volume
// restored from the provided source, either a backup ID or a point-in-time
// and a source cluster.
func (c *AlloyDBAdminClient) RestoreCluster(ctx context.Context, req *alloydbpb.RestoreClusterRequest, opts ...gax.CallOption) (*RestoreClusterOperation, error) {
return c.internalClient.RestoreCluster(ctx, req, opts...)
}
// RestoreClusterOperation returns a new RestoreClusterOperation from a given name.
// The name must be that of a previously created RestoreClusterOperation, possibly from a different process.
func (c *AlloyDBAdminClient) RestoreClusterOperation(name string) *RestoreClusterOperation {
return c.internalClient.RestoreClusterOperation(name)
}
// CreateSecondaryCluster creates a cluster of type SECONDARY in the given location using
// the primary cluster as the source.
func (c *AlloyDBAdminClient) CreateSecondaryCluster(ctx context.Context, req *alloydbpb.CreateSecondaryClusterRequest, opts ...gax.CallOption) (*CreateSecondaryClusterOperation, error) {
return c.internalClient.CreateSecondaryCluster(ctx, req, opts...)
}
// CreateSecondaryClusterOperation returns a new CreateSecondaryClusterOperation from a given name.
// The name must be that of a previously created CreateSecondaryClusterOperation, possibly from a different process.
func (c *AlloyDBAdminClient) CreateSecondaryClusterOperation(name string) *CreateSecondaryClusterOperation {
return c.internalClient.CreateSecondaryClusterOperation(name)
}
// ListInstances lists Instances in a given project and location.
func (c *AlloyDBAdminClient) ListInstances(ctx context.Context, req *alloydbpb.ListInstancesRequest, opts ...gax.CallOption) *InstanceIterator {
return c.internalClient.ListInstances(ctx, req, opts...)
}
// GetInstance gets details of a single Instance.
func (c *AlloyDBAdminClient) GetInstance(ctx context.Context, req *alloydbpb.GetInstanceRequest, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
return c.internalClient.GetInstance(ctx, req, opts...)
}
// CreateInstance creates a new Instance in a given project and location.
func (c *AlloyDBAdminClient) CreateInstance(ctx context.Context, req *alloydbpb.CreateInstanceRequest, opts ...gax.CallOption) (*CreateInstanceOperation, error) {
return c.internalClient.CreateInstance(ctx, req, opts...)
}
// CreateInstanceOperation returns a new CreateInstanceOperation from a given name.
// The name must be that of a previously created CreateInstanceOperation, possibly from a different process.
func (c *AlloyDBAdminClient) CreateInstanceOperation(name string) *CreateInstanceOperation {
return c.internalClient.CreateInstanceOperation(name)
}
// CreateSecondaryInstance creates a new SECONDARY Instance in a given project and location.
func (c *AlloyDBAdminClient) CreateSecondaryInstance(ctx context.Context, req *alloydbpb.CreateSecondaryInstanceRequest, opts ...gax.CallOption) (*CreateSecondaryInstanceOperation, error) {
return c.internalClient.CreateSecondaryInstance(ctx, req, opts...)
}
// CreateSecondaryInstanceOperation returns a new CreateSecondaryInstanceOperation from a given name.
// The name must be that of a previously created CreateSecondaryInstanceOperation, possibly from a different process.
func (c *AlloyDBAdminClient) CreateSecondaryInstanceOperation(name string) *CreateSecondaryInstanceOperation {
return c.internalClient.CreateSecondaryInstanceOperation(name)
}
// BatchCreateInstances creates new instances under the given project, location and cluster.
// There can be only one primary instance in a cluster. If the primary
// instance exists in the cluster as well as this request, then API will
// throw an error.
// The primary instance should exist before any read pool instance is
// created. If the primary instance is a part of the request payload, then
// the API will take care of creating instances in the correct order.
// This method is here to support Google-internal use cases, and is not meant
// for external customers to consume. Please do not start relying on it; its
// behavior is subject to change without notice.
func (c *AlloyDBAdminClient) BatchCreateInstances(ctx context.Context, req *alloydbpb.BatchCreateInstancesRequest, opts ...gax.CallOption) (*BatchCreateInstancesOperation, error) {
return c.internalClient.BatchCreateInstances(ctx, req, opts...)
}
// BatchCreateInstancesOperation returns a new BatchCreateInstancesOperation from a given name.
// The name must be that of a previously created BatchCreateInstancesOperation, possibly from a different process.
func (c *AlloyDBAdminClient) BatchCreateInstancesOperation(name string) *BatchCreateInstancesOperation {
return c.internalClient.BatchCreateInstancesOperation(name)
}
// UpdateInstance updates the parameters of a single Instance.
func (c *AlloyDBAdminClient) UpdateInstance(ctx context.Context, req *alloydbpb.UpdateInstanceRequest, opts ...gax.CallOption) (*UpdateInstanceOperation, error) {
return c.internalClient.UpdateInstance(ctx, req, opts...)
}
// UpdateInstanceOperation returns a new UpdateInstanceOperation from a given name.
// The name must be that of a previously created UpdateInstanceOperation, possibly from a different process.
func (c *AlloyDBAdminClient) UpdateInstanceOperation(name string) *UpdateInstanceOperation {
return c.internalClient.UpdateInstanceOperation(name)
}
// DeleteInstance deletes a single Instance.
func (c *AlloyDBAdminClient) DeleteInstance(ctx context.Context, req *alloydbpb.DeleteInstanceRequest, opts ...gax.CallOption) (*DeleteInstanceOperation, error) {
return c.internalClient.DeleteInstance(ctx, req, opts...)
}
// DeleteInstanceOperation returns a new DeleteInstanceOperation from a given name.
// The name must be that of a previously created DeleteInstanceOperation, possibly from a different process.
func (c *AlloyDBAdminClient) DeleteInstanceOperation(name string) *DeleteInstanceOperation {
return c.internalClient.DeleteInstanceOperation(name)
}
// FailoverInstance forces a Failover for a highly available instance.
// Failover promotes the HA standby instance as the new primary.
// Imperative only.
func (c *AlloyDBAdminClient) FailoverInstance(ctx context.Context, req *alloydbpb.FailoverInstanceRequest, opts ...gax.CallOption) (*FailoverInstanceOperation, error) {
return c.internalClient.FailoverInstance(ctx, req, opts...)
}
// FailoverInstanceOperation returns a new FailoverInstanceOperation from a given name.
// The name must be that of a previously created FailoverInstanceOperation, possibly from a different process.
func (c *AlloyDBAdminClient) FailoverInstanceOperation(name string) *FailoverInstanceOperation {
return c.internalClient.FailoverInstanceOperation(name)
}
// RestartInstance restart an Instance in a cluster.
// Imperative only.
func (c *AlloyDBAdminClient) RestartInstance(ctx context.Context, req *alloydbpb.RestartInstanceRequest, opts ...gax.CallOption) (*RestartInstanceOperation, error) {
return c.internalClient.RestartInstance(ctx, req, opts...)
}
// RestartInstanceOperation returns a new RestartInstanceOperation from a given name.
// The name must be that of a previously created RestartInstanceOperation, possibly from a different process.
func (c *AlloyDBAdminClient) RestartInstanceOperation(name string) *RestartInstanceOperation {
return c.internalClient.RestartInstanceOperation(name)
}
// ListBackups lists Backups in a given project and location.
func (c *AlloyDBAdminClient) ListBackups(ctx context.Context, req *alloydbpb.ListBackupsRequest, opts ...gax.CallOption) *BackupIterator {
return c.internalClient.ListBackups(ctx, req, opts...)
}
// GetBackup gets details of a single Backup.
func (c *AlloyDBAdminClient) GetBackup(ctx context.Context, req *alloydbpb.GetBackupRequest, opts ...gax.CallOption) (*alloydbpb.Backup, error) {
return c.internalClient.GetBackup(ctx, req, opts...)
}
// CreateBackup creates a new Backup in a given project and location.
func (c *AlloyDBAdminClient) CreateBackup(ctx context.Context, req *alloydbpb.CreateBackupRequest, opts ...gax.CallOption) (*CreateBackupOperation, error) {
return c.internalClient.CreateBackup(ctx, req, opts...)
}
// CreateBackupOperation returns a new CreateBackupOperation from a given name.
// The name must be that of a previously created CreateBackupOperation, possibly from a different process.
func (c *AlloyDBAdminClient) CreateBackupOperation(name string) *CreateBackupOperation {
return c.internalClient.CreateBackupOperation(name)
}
// UpdateBackup updates the parameters of a single Backup.
func (c *AlloyDBAdminClient) UpdateBackup(ctx context.Context, req *alloydbpb.UpdateBackupRequest, opts ...gax.CallOption) (*UpdateBackupOperation, error) {
return c.internalClient.UpdateBackup(ctx, req, opts...)
}
// UpdateBackupOperation returns a new UpdateBackupOperation from a given name.
// The name must be that of a previously created UpdateBackupOperation, possibly from a different process.
func (c *AlloyDBAdminClient) UpdateBackupOperation(name string) *UpdateBackupOperation {
return c.internalClient.UpdateBackupOperation(name)
}
// DeleteBackup deletes a single Backup.
func (c *AlloyDBAdminClient) DeleteBackup(ctx context.Context, req *alloydbpb.DeleteBackupRequest, opts ...gax.CallOption) (*DeleteBackupOperation, error) {
return c.internalClient.DeleteBackup(ctx, req, opts...)
}
// DeleteBackupOperation returns a new DeleteBackupOperation from a given name.
// The name must be that of a previously created DeleteBackupOperation, possibly from a different process.
func (c *AlloyDBAdminClient) DeleteBackupOperation(name string) *DeleteBackupOperation {
return c.internalClient.DeleteBackupOperation(name)
}
// ListSupportedDatabaseFlags lists SupportedDatabaseFlags for a given project and location.
func (c *AlloyDBAdminClient) ListSupportedDatabaseFlags(ctx context.Context, req *alloydbpb.ListSupportedDatabaseFlagsRequest, opts ...gax.CallOption) *SupportedDatabaseFlagIterator {
return c.internalClient.ListSupportedDatabaseFlags(ctx, req, opts...)
}
// GenerateClientCertificate generate a client certificate signed by a Cluster CA.
// The sole purpose of this endpoint is to support the Auth Proxy client and
// the endpoint’s behavior is subject to change without notice, so do not rely
// on its behavior remaining constant. Future changes will not break the Auth
// Proxy client.
func (c *AlloyDBAdminClient) GenerateClientCertificate(ctx context.Context, req *alloydbpb.GenerateClientCertificateRequest, opts ...gax.CallOption) (*alloydbpb.GenerateClientCertificateResponse, error) {
return c.internalClient.GenerateClientCertificate(ctx, req, opts...)
}
// GetConnectionInfo get instance metadata used for a connection.
func (c *AlloyDBAdminClient) GetConnectionInfo(ctx context.Context, req *alloydbpb.GetConnectionInfoRequest, opts ...gax.CallOption) (*alloydbpb.ConnectionInfo, error) {
return c.internalClient.GetConnectionInfo(ctx, req, opts...)
}
// GetLocation gets information about a location.
func (c *AlloyDBAdminClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
return c.internalClient.GetLocation(ctx, req, opts...)
}
// ListLocations lists information about the supported locations for this service.
func (c *AlloyDBAdminClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
return c.internalClient.ListLocations(ctx, req, opts...)
}
// CancelOperation is a utility method from google.longrunning.Operations.
func (c *AlloyDBAdminClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
return c.internalClient.CancelOperation(ctx, req, opts...)
}
// DeleteOperation is a utility method from google.longrunning.Operations.
func (c *AlloyDBAdminClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
return c.internalClient.DeleteOperation(ctx, req, opts...)
}
// GetOperation is a utility method from google.longrunning.Operations.
func (c *AlloyDBAdminClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
return c.internalClient.GetOperation(ctx, req, opts...)
}
// ListOperations is a utility method from google.longrunning.Operations.
func (c *AlloyDBAdminClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
return c.internalClient.ListOperations(ctx, req, opts...)
}
// alloyDBAdminGRPCClient is a client for interacting with AlloyDB API over gRPC transport.
//
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type alloyDBAdminGRPCClient struct {
// Connection pool of gRPC connections to the service.
connPool gtransport.ConnPool
// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
disableDeadlines bool
// Points back to the CallOptions field of the containing AlloyDBAdminClient
CallOptions **AlloyDBAdminCallOptions
// The gRPC API client.
alloyDBAdminClient alloydbpb.AlloyDBAdminClient
// 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
operationsClient longrunningpb.OperationsClient
locationsClient locationpb.LocationsClient
// The x-goog-* metadata to be sent with each request.
xGoogMetadata metadata.MD
}
// NewAlloyDBAdminClient creates a new alloydb admin client based on gRPC.
// The returned client must be Closed when it is done being used to clean up its underlying connections.
//
// Service describing handlers for resources
func NewAlloyDBAdminClient(ctx context.Context, opts ...option.ClientOption) (*AlloyDBAdminClient, error) {
clientOpts := defaultAlloyDBAdminGRPCClientOptions()
if newAlloyDBAdminClientHook != nil {
hookOpts, err := newAlloyDBAdminClientHook(ctx, clientHookParams{})
if err != nil {
return nil, err
}
clientOpts = append(clientOpts, hookOpts...)
}
disableDeadlines, err := checkDisableDeadlines()
if err != nil {
return nil, err
}
connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
if err != nil {
return nil, err
}
client := AlloyDBAdminClient{CallOptions: defaultAlloyDBAdminCallOptions()}
c := &alloyDBAdminGRPCClient{
connPool: connPool,
disableDeadlines: disableDeadlines,
alloyDBAdminClient: alloydbpb.NewAlloyDBAdminClient(connPool),
CallOptions: &client.CallOptions,
operationsClient: longrunningpb.NewOperationsClient(connPool),
locationsClient: locationpb.NewLocationsClient(connPool),
}
c.setGoogleClientInfo()
client.internalClient = c
client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
if err != nil {
// This error "should not happen", since we are just reusing old connection pool
// and never actually need to dial.
// If this does happen, we could leak connp. However, we cannot close conn:
// If the user invoked the constructor with option.WithGRPCConn,
// we would close a connection that's still in use.
// TODO: investigate error conditions.
return nil, err
}
c.LROClient = &client.LROClient
return &client, nil
}
// Connection returns a connection to the API service.
//
// Deprecated: Connections are now pooled so this method does not always
// return the same resource.
func (c *alloyDBAdminGRPCClient) Connection() *grpc.ClientConn {
return c.connPool.Conn()
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *alloyDBAdminGRPCClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", versionGo()}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
}
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *alloyDBAdminGRPCClient) Close() error {
return c.connPool.Close()
}
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type alloyDBAdminRESTClient struct {
// The http endpoint to connect to.
endpoint string
// The http client.
httpClient *http.Client
// 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
// The x-goog-* metadata to be sent with each request.
xGoogMetadata metadata.MD
// Points back to the CallOptions field of the containing AlloyDBAdminClient
CallOptions **AlloyDBAdminCallOptions
}
// NewAlloyDBAdminRESTClient creates a new alloydb admin rest client.
//
// Service describing handlers for resources
func NewAlloyDBAdminRESTClient(ctx context.Context, opts ...option.ClientOption) (*AlloyDBAdminClient, error) {
clientOpts := append(defaultAlloyDBAdminRESTClientOptions(), opts...)
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
if err != nil {
return nil, err
}
callOpts := defaultAlloyDBAdminRESTCallOptions()
c := &alloyDBAdminRESTClient{
endpoint: endpoint,
httpClient: httpClient,
CallOptions: &callOpts,
}
c.setGoogleClientInfo()
lroOpts := []option.ClientOption{
option.WithHTTPClient(httpClient),
option.WithEndpoint(endpoint),
}
opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
if err != nil {
return nil, err
}
c.LROClient = &opClient
return &AlloyDBAdminClient{internalClient: c, CallOptions: callOpts}, nil
}
func defaultAlloyDBAdminRESTClientOptions() []option.ClientOption {
return []option.ClientOption{
internaloption.WithDefaultEndpoint("https://alloydb.googleapis.com"),
internaloption.WithDefaultMTLSEndpoint("https://alloydb.mtls.googleapis.com"),
internaloption.WithDefaultAudience("https://alloydb.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
}
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *alloyDBAdminRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", versionGo()}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
}
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *alloyDBAdminRESTClient) Close() error {
// Replace httpClient with nil to force cleanup.
c.httpClient = nil
return nil
}
// Connection returns a connection to the API service.
//
// Deprecated: This method always returns nil.
func (c *alloyDBAdminRESTClient) Connection() *grpc.ClientConn {
return nil
}
func (c *alloyDBAdminGRPCClient) ListClusters(ctx context.Context, req *alloydbpb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).ListClusters[0:len((*c.CallOptions).ListClusters):len((*c.CallOptions).ListClusters)], opts...)
it := &ClusterIterator{}
req = proto.Clone(req).(*alloydbpb.ListClustersRequest)
it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Cluster, string, error) {
resp := &alloydbpb.ListClustersResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.ListClusters(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, "", err
}
it.Response = resp
return resp.GetClusters(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
func (c *alloyDBAdminGRPCClient) GetCluster(ctx context.Context, req *alloydbpb.GetClusterRequest, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).GetCluster[0:len((*c.CallOptions).GetCluster):len((*c.CallOptions).GetCluster)], opts...)
var resp *alloydbpb.Cluster
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.GetCluster(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *alloyDBAdminGRPCClient) CreateCluster(ctx context.Context, req *alloydbpb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).CreateCluster[0:len((*c.CallOptions).CreateCluster):len((*c.CallOptions).CreateCluster)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.CreateCluster(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &CreateClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) UpdateCluster(ctx context.Context, req *alloydbpb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "cluster.name", url.QueryEscape(req.GetCluster().GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).UpdateCluster[0:len((*c.CallOptions).UpdateCluster):len((*c.CallOptions).UpdateCluster)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.UpdateCluster(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &UpdateClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) DeleteCluster(ctx context.Context, req *alloydbpb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).DeleteCluster[0:len((*c.CallOptions).DeleteCluster):len((*c.CallOptions).DeleteCluster)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.DeleteCluster(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &DeleteClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) PromoteCluster(ctx context.Context, req *alloydbpb.PromoteClusterRequest, opts ...gax.CallOption) (*PromoteClusterOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).PromoteCluster[0:len((*c.CallOptions).PromoteCluster):len((*c.CallOptions).PromoteCluster)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.PromoteCluster(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &PromoteClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) RestoreCluster(ctx context.Context, req *alloydbpb.RestoreClusterRequest, opts ...gax.CallOption) (*RestoreClusterOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).RestoreCluster[0:len((*c.CallOptions).RestoreCluster):len((*c.CallOptions).RestoreCluster)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.RestoreCluster(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &RestoreClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) CreateSecondaryCluster(ctx context.Context, req *alloydbpb.CreateSecondaryClusterRequest, opts ...gax.CallOption) (*CreateSecondaryClusterOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).CreateSecondaryCluster[0:len((*c.CallOptions).CreateSecondaryCluster):len((*c.CallOptions).CreateSecondaryCluster)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.CreateSecondaryCluster(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &CreateSecondaryClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) ListInstances(ctx context.Context, req *alloydbpb.ListInstancesRequest, opts ...gax.CallOption) *InstanceIterator {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).ListInstances[0:len((*c.CallOptions).ListInstances):len((*c.CallOptions).ListInstances)], opts...)
it := &InstanceIterator{}
req = proto.Clone(req).(*alloydbpb.ListInstancesRequest)
it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Instance, string, error) {
resp := &alloydbpb.ListInstancesResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.ListInstances(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, "", err
}
it.Response = resp
return resp.GetInstances(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
func (c *alloyDBAdminGRPCClient) GetInstance(ctx context.Context, req *alloydbpb.GetInstanceRequest, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).GetInstance[0:len((*c.CallOptions).GetInstance):len((*c.CallOptions).GetInstance)], opts...)
var resp *alloydbpb.Instance
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.GetInstance(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *alloyDBAdminGRPCClient) CreateInstance(ctx context.Context, req *alloydbpb.CreateInstanceRequest, opts ...gax.CallOption) (*CreateInstanceOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).CreateInstance[0:len((*c.CallOptions).CreateInstance):len((*c.CallOptions).CreateInstance)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.CreateInstance(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &CreateInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) CreateSecondaryInstance(ctx context.Context, req *alloydbpb.CreateSecondaryInstanceRequest, opts ...gax.CallOption) (*CreateSecondaryInstanceOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).CreateSecondaryInstance[0:len((*c.CallOptions).CreateSecondaryInstance):len((*c.CallOptions).CreateSecondaryInstance)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.CreateSecondaryInstance(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &CreateSecondaryInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) BatchCreateInstances(ctx context.Context, req *alloydbpb.BatchCreateInstancesRequest, opts ...gax.CallOption) (*BatchCreateInstancesOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).BatchCreateInstances[0:len((*c.CallOptions).BatchCreateInstances):len((*c.CallOptions).BatchCreateInstances)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.BatchCreateInstances(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &BatchCreateInstancesOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) UpdateInstance(ctx context.Context, req *alloydbpb.UpdateInstanceRequest, opts ...gax.CallOption) (*UpdateInstanceOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "instance.name", url.QueryEscape(req.GetInstance().GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).UpdateInstance[0:len((*c.CallOptions).UpdateInstance):len((*c.CallOptions).UpdateInstance)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.UpdateInstance(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &UpdateInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) DeleteInstance(ctx context.Context, req *alloydbpb.DeleteInstanceRequest, opts ...gax.CallOption) (*DeleteInstanceOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).DeleteInstance[0:len((*c.CallOptions).DeleteInstance):len((*c.CallOptions).DeleteInstance)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.DeleteInstance(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &DeleteInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) FailoverInstance(ctx context.Context, req *alloydbpb.FailoverInstanceRequest, opts ...gax.CallOption) (*FailoverInstanceOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).FailoverInstance[0:len((*c.CallOptions).FailoverInstance):len((*c.CallOptions).FailoverInstance)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.FailoverInstance(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &FailoverInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) RestartInstance(ctx context.Context, req *alloydbpb.RestartInstanceRequest, opts ...gax.CallOption) (*RestartInstanceOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).RestartInstance[0:len((*c.CallOptions).RestartInstance):len((*c.CallOptions).RestartInstance)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.RestartInstance(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &RestartInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) ListBackups(ctx context.Context, req *alloydbpb.ListBackupsRequest, opts ...gax.CallOption) *BackupIterator {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).ListBackups[0:len((*c.CallOptions).ListBackups):len((*c.CallOptions).ListBackups)], opts...)
it := &BackupIterator{}
req = proto.Clone(req).(*alloydbpb.ListBackupsRequest)
it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Backup, string, error) {
resp := &alloydbpb.ListBackupsResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.ListBackups(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, "", err
}
it.Response = resp
return resp.GetBackups(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
func (c *alloyDBAdminGRPCClient) GetBackup(ctx context.Context, req *alloydbpb.GetBackupRequest, opts ...gax.CallOption) (*alloydbpb.Backup, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).GetBackup[0:len((*c.CallOptions).GetBackup):len((*c.CallOptions).GetBackup)], opts...)
var resp *alloydbpb.Backup
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.GetBackup(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *alloyDBAdminGRPCClient) CreateBackup(ctx context.Context, req *alloydbpb.CreateBackupRequest, opts ...gax.CallOption) (*CreateBackupOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).CreateBackup[0:len((*c.CallOptions).CreateBackup):len((*c.CallOptions).CreateBackup)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.CreateBackup(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &CreateBackupOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) UpdateBackup(ctx context.Context, req *alloydbpb.UpdateBackupRequest, opts ...gax.CallOption) (*UpdateBackupOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "backup.name", url.QueryEscape(req.GetBackup().GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).UpdateBackup[0:len((*c.CallOptions).UpdateBackup):len((*c.CallOptions).UpdateBackup)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.UpdateBackup(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &UpdateBackupOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) DeleteBackup(ctx context.Context, req *alloydbpb.DeleteBackupRequest, opts ...gax.CallOption) (*DeleteBackupOperation, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).DeleteBackup[0:len((*c.CallOptions).DeleteBackup):len((*c.CallOptions).DeleteBackup)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.DeleteBackup(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &DeleteBackupOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *alloyDBAdminGRPCClient) ListSupportedDatabaseFlags(ctx context.Context, req *alloydbpb.ListSupportedDatabaseFlagsRequest, opts ...gax.CallOption) *SupportedDatabaseFlagIterator {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).ListSupportedDatabaseFlags[0:len((*c.CallOptions).ListSupportedDatabaseFlags):len((*c.CallOptions).ListSupportedDatabaseFlags)], opts...)
it := &SupportedDatabaseFlagIterator{}
req = proto.Clone(req).(*alloydbpb.ListSupportedDatabaseFlagsRequest)
it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.SupportedDatabaseFlag, string, error) {
resp := &alloydbpb.ListSupportedDatabaseFlagsResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.ListSupportedDatabaseFlags(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, "", err
}
it.Response = resp
return resp.GetSupportedDatabaseFlags(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
func (c *alloyDBAdminGRPCClient) GenerateClientCertificate(ctx context.Context, req *alloydbpb.GenerateClientCertificateRequest, opts ...gax.CallOption) (*alloydbpb.GenerateClientCertificateResponse, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).GenerateClientCertificate[0:len((*c.CallOptions).GenerateClientCertificate):len((*c.CallOptions).GenerateClientCertificate)], opts...)
var resp *alloydbpb.GenerateClientCertificateResponse
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.GenerateClientCertificate(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *alloyDBAdminGRPCClient) GetConnectionInfo(ctx context.Context, req *alloydbpb.GetConnectionInfoRequest, opts ...gax.CallOption) (*alloydbpb.ConnectionInfo, error) {
if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
defer cancel()
ctx = cctx
}
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).GetConnectionInfo[0:len((*c.CallOptions).GetConnectionInfo):len((*c.CallOptions).GetConnectionInfo)], opts...)
var resp *alloydbpb.ConnectionInfo
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.alloyDBAdminClient.GetConnectionInfo(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *alloyDBAdminGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
var resp *locationpb.Location
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.locationsClient.GetLocation(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *alloyDBAdminGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
it := &LocationIterator{}
req = proto.Clone(req).(*locationpb.ListLocationsRequest)
it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
resp := &locationpb.ListLocationsResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.locationsClient.ListLocations(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, "", err
}
it.Response = resp
return resp.GetLocations(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
func (c *alloyDBAdminGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
_, err = c.operationsClient.CancelOperation(ctx, req, settings.GRPC...)
return err
}, opts...)
return err
}
func (c *alloyDBAdminGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
_, err = c.operationsClient.DeleteOperation(ctx, req, settings.GRPC...)
return err
}, opts...)
return err
}
func (c *alloyDBAdminGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.operationsClient.GetOperation(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *alloyDBAdminGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
it := &OperationIterator{}
req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
resp := &longrunningpb.ListOperationsResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.operationsClient.ListOperations(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, "", err
}
it.Response = resp
return resp.GetOperations(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
// ListClusters lists Clusters in a given project and location.
func (c *alloyDBAdminRESTClient) ListClusters(ctx context.Context, req *alloydbpb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator {
it := &ClusterIterator{}
req = proto.Clone(req).(*alloydbpb.ListClustersRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Cluster, string, error) {
resp := &alloydbpb.ListClustersResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, "", err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/clusters", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetFilter() != "" {
params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
}
if req.GetOrderBy() != "" {
params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
}
if req.GetPageSize() != 0 {
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
}
if req.GetPageToken() != "" {
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json"))
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, "", e
}
it.Response = resp
return resp.GetClusters(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
// GetCluster gets details of a single Cluster.
func (c *alloyDBAdminRESTClient) GetCluster(ctx context.Context, req *alloydbpb.GetClusterRequest, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
opts = append((*c.CallOptions).GetCluster[0:len((*c.CallOptions).GetCluster):len((*c.CallOptions).GetCluster)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &alloydbpb.Cluster{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// CreateCluster creates a new Cluster in a given project and location.
func (c *alloyDBAdminRESTClient) CreateCluster(ctx context.Context, req *alloydbpb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
body := req.GetCluster()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/clusters", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
params.Add("clusterId", fmt.Sprintf("%v", req.GetClusterId()))
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &CreateClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// UpdateCluster updates the parameters of a single Cluster.
func (c *alloyDBAdminRESTClient) UpdateCluster(ctx context.Context, req *alloydbpb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
body := req.GetCluster()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v", req.GetCluster().GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetAllowMissing() {
params.Add("allowMissing", fmt.Sprintf("%v", req.GetAllowMissing()))
}
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req.GetUpdateMask() != nil {
updateMask, err := protojson.Marshal(req.GetUpdateMask())
if err != nil {
return nil, err
}
params.Add("updateMask", string(updateMask))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "cluster.name", url.QueryEscape(req.GetCluster().GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &UpdateClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// DeleteCluster deletes a single Cluster.
func (c *alloyDBAdminRESTClient) DeleteCluster(ctx context.Context, req *alloydbpb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetEtag() != "" {
params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
}
if req.GetForce() {
params.Add("force", fmt.Sprintf("%v", req.GetForce()))
}
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &DeleteClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// PromoteCluster promotes a SECONDARY cluster. This turns down replication
// from the PRIMARY cluster and promotes a secondary cluster
// into its own standalone cluster.
// Imperative only.
func (c *alloyDBAdminRESTClient) PromoteCluster(ctx context.Context, req *alloydbpb.PromoteClusterRequest, opts ...gax.CallOption) (*PromoteClusterOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v:promote", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &PromoteClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// RestoreCluster creates a new Cluster in a given project and location, with a volume
// restored from the provided source, either a backup ID or a point-in-time
// and a source cluster.
func (c *alloyDBAdminRESTClient) RestoreCluster(ctx context.Context, req *alloydbpb.RestoreClusterRequest, opts ...gax.CallOption) (*RestoreClusterOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/clusters:restore", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &RestoreClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// CreateSecondaryCluster creates a cluster of type SECONDARY in the given location using
// the primary cluster as the source.
func (c *alloyDBAdminRESTClient) CreateSecondaryCluster(ctx context.Context, req *alloydbpb.CreateSecondaryClusterRequest, opts ...gax.CallOption) (*CreateSecondaryClusterOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
body := req.GetCluster()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/clusters:createsecondary", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
params.Add("clusterId", fmt.Sprintf("%v", req.GetClusterId()))
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &CreateSecondaryClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// ListInstances lists Instances in a given project and location.
func (c *alloyDBAdminRESTClient) ListInstances(ctx context.Context, req *alloydbpb.ListInstancesRequest, opts ...gax.CallOption) *InstanceIterator {
it := &InstanceIterator{}
req = proto.Clone(req).(*alloydbpb.ListInstancesRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Instance, string, error) {
resp := &alloydbpb.ListInstancesResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, "", err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/instances", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetFilter() != "" {
params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
}
if req.GetOrderBy() != "" {
params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
}
if req.GetPageSize() != 0 {
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
}
if req.GetPageToken() != "" {
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json"))
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, "", e
}
it.Response = resp
return resp.GetInstances(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
// GetInstance gets details of a single Instance.
func (c *alloyDBAdminRESTClient) GetInstance(ctx context.Context, req *alloydbpb.GetInstanceRequest, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetView() != 0 {
params.Add("view", fmt.Sprintf("%v", req.GetView()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
opts = append((*c.CallOptions).GetInstance[0:len((*c.CallOptions).GetInstance):len((*c.CallOptions).GetInstance)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &alloydbpb.Instance{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// CreateInstance creates a new Instance in a given project and location.
func (c *alloyDBAdminRESTClient) CreateInstance(ctx context.Context, req *alloydbpb.CreateInstanceRequest, opts ...gax.CallOption) (*CreateInstanceOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
body := req.GetInstance()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/instances", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
params.Add("instanceId", fmt.Sprintf("%v", req.GetInstanceId()))
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &CreateInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// CreateSecondaryInstance creates a new SECONDARY Instance in a given project and location.
func (c *alloyDBAdminRESTClient) CreateSecondaryInstance(ctx context.Context, req *alloydbpb.CreateSecondaryInstanceRequest, opts ...gax.CallOption) (*CreateSecondaryInstanceOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
body := req.GetInstance()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/instances:createsecondary", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
params.Add("instanceId", fmt.Sprintf("%v", req.GetInstanceId()))
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &CreateSecondaryInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// BatchCreateInstances creates new instances under the given project, location and cluster.
// There can be only one primary instance in a cluster. If the primary
// instance exists in the cluster as well as this request, then API will
// throw an error.
// The primary instance should exist before any read pool instance is
// created. If the primary instance is a part of the request payload, then
// the API will take care of creating instances in the correct order.
// This method is here to support Google-internal use cases, and is not meant
// for external customers to consume. Please do not start relying on it; its
// behavior is subject to change without notice.
func (c *alloyDBAdminRESTClient) BatchCreateInstances(ctx context.Context, req *alloydbpb.BatchCreateInstancesRequest, opts ...gax.CallOption) (*BatchCreateInstancesOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
body := req.GetRequests()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/instances:batchCreate", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &BatchCreateInstancesOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// UpdateInstance updates the parameters of a single Instance.
func (c *alloyDBAdminRESTClient) UpdateInstance(ctx context.Context, req *alloydbpb.UpdateInstanceRequest, opts ...gax.CallOption) (*UpdateInstanceOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
body := req.GetInstance()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v", req.GetInstance().GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetAllowMissing() {
params.Add("allowMissing", fmt.Sprintf("%v", req.GetAllowMissing()))
}
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req.GetUpdateMask() != nil {
updateMask, err := protojson.Marshal(req.GetUpdateMask())
if err != nil {
return nil, err
}
params.Add("updateMask", string(updateMask))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "instance.name", url.QueryEscape(req.GetInstance().GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &UpdateInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// DeleteInstance deletes a single Instance.
func (c *alloyDBAdminRESTClient) DeleteInstance(ctx context.Context, req *alloydbpb.DeleteInstanceRequest, opts ...gax.CallOption) (*DeleteInstanceOperation, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetEtag() != "" {
params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
}
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &DeleteInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// FailoverInstance forces a Failover for a highly available instance.
// Failover promotes the HA standby instance as the new primary.
// Imperative only.
func (c *alloyDBAdminRESTClient) FailoverInstance(ctx context.Context, req *alloydbpb.FailoverInstanceRequest, opts ...gax.CallOption) (*FailoverInstanceOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v:failover", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &FailoverInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// RestartInstance restart an Instance in a cluster.
// Imperative only.
func (c *alloyDBAdminRESTClient) RestartInstance(ctx context.Context, req *alloydbpb.RestartInstanceRequest, opts ...gax.CallOption) (*RestartInstanceOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v:restart", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &RestartInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// ListBackups lists Backups in a given project and location.
func (c *alloyDBAdminRESTClient) ListBackups(ctx context.Context, req *alloydbpb.ListBackupsRequest, opts ...gax.CallOption) *BackupIterator {
it := &BackupIterator{}
req = proto.Clone(req).(*alloydbpb.ListBackupsRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Backup, string, error) {
resp := &alloydbpb.ListBackupsResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, "", err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/backups", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetFilter() != "" {
params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
}
if req.GetOrderBy() != "" {
params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
}
if req.GetPageSize() != 0 {
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
}
if req.GetPageToken() != "" {
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json"))
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, "", e
}
it.Response = resp
return resp.GetBackups(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
// GetBackup gets details of a single Backup.
func (c *alloyDBAdminRESTClient) GetBackup(ctx context.Context, req *alloydbpb.GetBackupRequest, opts ...gax.CallOption) (*alloydbpb.Backup, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
opts = append((*c.CallOptions).GetBackup[0:len((*c.CallOptions).GetBackup):len((*c.CallOptions).GetBackup)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &alloydbpb.Backup{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// CreateBackup creates a new Backup in a given project and location.
func (c *alloyDBAdminRESTClient) CreateBackup(ctx context.Context, req *alloydbpb.CreateBackupRequest, opts ...gax.CallOption) (*CreateBackupOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
body := req.GetBackup()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/backups", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
params.Add("backupId", fmt.Sprintf("%v", req.GetBackupId()))
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &CreateBackupOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// UpdateBackup updates the parameters of a single Backup.
func (c *alloyDBAdminRESTClient) UpdateBackup(ctx context.Context, req *alloydbpb.UpdateBackupRequest, opts ...gax.CallOption) (*UpdateBackupOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
body := req.GetBackup()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v", req.GetBackup().GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetAllowMissing() {
params.Add("allowMissing", fmt.Sprintf("%v", req.GetAllowMissing()))
}
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req.GetUpdateMask() != nil {
updateMask, err := protojson.Marshal(req.GetUpdateMask())
if err != nil {
return nil, err
}
params.Add("updateMask", string(updateMask))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "backup.name", url.QueryEscape(req.GetBackup().GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &UpdateBackupOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// DeleteBackup deletes a single Backup.
func (c *alloyDBAdminRESTClient) DeleteBackup(ctx context.Context, req *alloydbpb.DeleteBackupRequest, opts ...gax.CallOption) (*DeleteBackupOperation, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetEtag() != "" {
params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
}
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
override := fmt.Sprintf("/v1alpha/%s", resp.GetName())
return &DeleteBackupOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// ListSupportedDatabaseFlags lists SupportedDatabaseFlags for a given project and location.
func (c *alloyDBAdminRESTClient) ListSupportedDatabaseFlags(ctx context.Context, req *alloydbpb.ListSupportedDatabaseFlagsRequest, opts ...gax.CallOption) *SupportedDatabaseFlagIterator {
it := &SupportedDatabaseFlagIterator{}
req = proto.Clone(req).(*alloydbpb.ListSupportedDatabaseFlagsRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.SupportedDatabaseFlag, string, error) {
resp := &alloydbpb.ListSupportedDatabaseFlagsResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, "", err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/supportedDatabaseFlags", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetPageSize() != 0 {
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
}
if req.GetPageToken() != "" {
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json"))
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, "", e
}
it.Response = resp
return resp.GetSupportedDatabaseFlags(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
// GenerateClientCertificate generate a client certificate signed by a Cluster CA.
// The sole purpose of this endpoint is to support the Auth Proxy client and
// the endpoint’s behavior is subject to change without notice, so do not rely
// on its behavior remaining constant. Future changes will not break the Auth
// Proxy client.
func (c *alloyDBAdminRESTClient) GenerateClientCertificate(ctx context.Context, req *alloydbpb.GenerateClientCertificateRequest, opts ...gax.CallOption) (*alloydbpb.GenerateClientCertificateResponse, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v:generateClientCertificate", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
opts = append((*c.CallOptions).GenerateClientCertificate[0:len((*c.CallOptions).GenerateClientCertificate):len((*c.CallOptions).GenerateClientCertificate)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &alloydbpb.GenerateClientCertificateResponse{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// GetConnectionInfo get instance metadata used for a connection.
func (c *alloyDBAdminRESTClient) GetConnectionInfo(ctx context.Context, req *alloydbpb.GetConnectionInfoRequest, opts ...gax.CallOption) (*alloydbpb.ConnectionInfo, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/connectionInfo", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetRequestId() != "" {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
opts = append((*c.CallOptions).GetConnectionInfo[0:len((*c.CallOptions).GetConnectionInfo):len((*c.CallOptions).GetConnectionInfo)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &alloydbpb.ConnectionInfo{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// GetLocation gets information about a location.
func (c *alloyDBAdminRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &locationpb.Location{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// ListLocations lists information about the supported locations for this service.
func (c *alloyDBAdminRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
it := &LocationIterator{}
req = proto.Clone(req).(*locationpb.ListLocationsRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
resp := &locationpb.ListLocationsResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, "", err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/locations", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetFilter() != "" {
params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
}
if req.GetPageSize() != 0 {
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
}
if req.GetPageToken() != "" {
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json"))
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, "", e
}
it.Response = resp
return resp.GetLocations(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
// CancelOperation is a utility method from google.longrunning.Operations.
func (c *alloyDBAdminRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v:cancel", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
// Returns nil if there is no error, otherwise wraps
// the response code and body into a non-nil error
return googleapi.CheckResponse(httpRsp)
}, opts...)
}
// DeleteOperation is a utility method from google.longrunning.Operations.
func (c *alloyDBAdminRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
// Returns nil if there is no error, otherwise wraps
// the response code and body into a non-nil error
return googleapi.CheckResponse(httpRsp)
}, opts...)
}
// GetOperation is a utility method from google.longrunning.Operations.
func (c *alloyDBAdminRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))
opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// ListOperations is a utility method from google.longrunning.Operations.
func (c *alloyDBAdminRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
it := &OperationIterator{}
req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
resp := &longrunningpb.ListOperationsResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, "", err
}
baseUrl.Path += fmt.Sprintf("/v1alpha/%v/operations", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetFilter() != "" {
params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
}
if req.GetPageSize() != 0 {
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
}
if req.GetPageToken() != "" {
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json"))
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq.Header = headers
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return maybeUnknownEnum(err)
}
return nil
}, opts...)
if e != nil {
return nil, "", e
}
it.Response = resp
return resp.GetOperations(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
// BatchCreateInstancesOperation manages a long-running operation from BatchCreateInstances.
type BatchCreateInstancesOperation struct {
lro *longrunning.Operation
pollPath string
}
// BatchCreateInstancesOperation returns a new BatchCreateInstancesOperation from a given name.
// The name must be that of a previously created BatchCreateInstancesOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) BatchCreateInstancesOperation(name string) *BatchCreateInstancesOperation {
return &BatchCreateInstancesOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// BatchCreateInstancesOperation returns a new BatchCreateInstancesOperation from a given name.
// The name must be that of a previously created BatchCreateInstancesOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) BatchCreateInstancesOperation(name string) *BatchCreateInstancesOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &BatchCreateInstancesOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *BatchCreateInstancesOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.BatchCreateInstancesResponse, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.BatchCreateInstancesResponse
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *BatchCreateInstancesOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.BatchCreateInstancesResponse, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.BatchCreateInstancesResponse
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *BatchCreateInstancesOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *BatchCreateInstancesOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *BatchCreateInstancesOperation) Name() string {
return op.lro.Name()
}
// CreateBackupOperation manages a long-running operation from CreateBackup.
type CreateBackupOperation struct {
lro *longrunning.Operation
pollPath string
}
// CreateBackupOperation returns a new CreateBackupOperation from a given name.
// The name must be that of a previously created CreateBackupOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) CreateBackupOperation(name string) *CreateBackupOperation {
return &CreateBackupOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// CreateBackupOperation returns a new CreateBackupOperation from a given name.
// The name must be that of a previously created CreateBackupOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) CreateBackupOperation(name string) *CreateBackupOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &CreateBackupOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *CreateBackupOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Backup, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Backup
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *CreateBackupOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Backup, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Backup
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *CreateBackupOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *CreateBackupOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *CreateBackupOperation) Name() string {
return op.lro.Name()
}
// CreateClusterOperation manages a long-running operation from CreateCluster.
type CreateClusterOperation struct {
lro *longrunning.Operation
pollPath string
}
// CreateClusterOperation returns a new CreateClusterOperation from a given name.
// The name must be that of a previously created CreateClusterOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) CreateClusterOperation(name string) *CreateClusterOperation {
return &CreateClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// CreateClusterOperation returns a new CreateClusterOperation from a given name.
// The name must be that of a previously created CreateClusterOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) CreateClusterOperation(name string) *CreateClusterOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &CreateClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *CreateClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Cluster
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *CreateClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Cluster
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *CreateClusterOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *CreateClusterOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *CreateClusterOperation) Name() string {
return op.lro.Name()
}
// CreateInstanceOperation manages a long-running operation from CreateInstance.
type CreateInstanceOperation struct {
lro *longrunning.Operation
pollPath string
}
// CreateInstanceOperation returns a new CreateInstanceOperation from a given name.
// The name must be that of a previously created CreateInstanceOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) CreateInstanceOperation(name string) *CreateInstanceOperation {
return &CreateInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// CreateInstanceOperation returns a new CreateInstanceOperation from a given name.
// The name must be that of a previously created CreateInstanceOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) CreateInstanceOperation(name string) *CreateInstanceOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &CreateInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *CreateInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Instance
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *CreateInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Instance
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *CreateInstanceOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *CreateInstanceOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *CreateInstanceOperation) Name() string {
return op.lro.Name()
}
// CreateSecondaryClusterOperation manages a long-running operation from CreateSecondaryCluster.
type CreateSecondaryClusterOperation struct {
lro *longrunning.Operation
pollPath string
}
// CreateSecondaryClusterOperation returns a new CreateSecondaryClusterOperation from a given name.
// The name must be that of a previously created CreateSecondaryClusterOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) CreateSecondaryClusterOperation(name string) *CreateSecondaryClusterOperation {
return &CreateSecondaryClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// CreateSecondaryClusterOperation returns a new CreateSecondaryClusterOperation from a given name.
// The name must be that of a previously created CreateSecondaryClusterOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) CreateSecondaryClusterOperation(name string) *CreateSecondaryClusterOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &CreateSecondaryClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *CreateSecondaryClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Cluster
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *CreateSecondaryClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Cluster
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *CreateSecondaryClusterOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *CreateSecondaryClusterOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *CreateSecondaryClusterOperation) Name() string {
return op.lro.Name()
}
// CreateSecondaryInstanceOperation manages a long-running operation from CreateSecondaryInstance.
type CreateSecondaryInstanceOperation struct {
lro *longrunning.Operation
pollPath string
}
// CreateSecondaryInstanceOperation returns a new CreateSecondaryInstanceOperation from a given name.
// The name must be that of a previously created CreateSecondaryInstanceOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) CreateSecondaryInstanceOperation(name string) *CreateSecondaryInstanceOperation {
return &CreateSecondaryInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// CreateSecondaryInstanceOperation returns a new CreateSecondaryInstanceOperation from a given name.
// The name must be that of a previously created CreateSecondaryInstanceOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) CreateSecondaryInstanceOperation(name string) *CreateSecondaryInstanceOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &CreateSecondaryInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *CreateSecondaryInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Instance
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *CreateSecondaryInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Instance
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *CreateSecondaryInstanceOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *CreateSecondaryInstanceOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *CreateSecondaryInstanceOperation) Name() string {
return op.lro.Name()
}
// DeleteBackupOperation manages a long-running operation from DeleteBackup.
type DeleteBackupOperation struct {
lro *longrunning.Operation
pollPath string
}
// DeleteBackupOperation returns a new DeleteBackupOperation from a given name.
// The name must be that of a previously created DeleteBackupOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) DeleteBackupOperation(name string) *DeleteBackupOperation {
return &DeleteBackupOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// DeleteBackupOperation returns a new DeleteBackupOperation from a given name.
// The name must be that of a previously created DeleteBackupOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) DeleteBackupOperation(name string) *DeleteBackupOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &DeleteBackupOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *DeleteBackupOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
}
// 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 (op *DeleteBackupOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
return op.lro.Poll(ctx, nil, opts...)
}
// 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 (op *DeleteBackupOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *DeleteBackupOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *DeleteBackupOperation) Name() string {
return op.lro.Name()
}
// DeleteClusterOperation manages a long-running operation from DeleteCluster.
type DeleteClusterOperation struct {
lro *longrunning.Operation
pollPath string
}
// DeleteClusterOperation returns a new DeleteClusterOperation from a given name.
// The name must be that of a previously created DeleteClusterOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) DeleteClusterOperation(name string) *DeleteClusterOperation {
return &DeleteClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// DeleteClusterOperation returns a new DeleteClusterOperation from a given name.
// The name must be that of a previously created DeleteClusterOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) DeleteClusterOperation(name string) *DeleteClusterOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &DeleteClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *DeleteClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
}
// 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 (op *DeleteClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
return op.lro.Poll(ctx, nil, opts...)
}
// 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 (op *DeleteClusterOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *DeleteClusterOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *DeleteClusterOperation) Name() string {
return op.lro.Name()
}
// DeleteInstanceOperation manages a long-running operation from DeleteInstance.
type DeleteInstanceOperation struct {
lro *longrunning.Operation
pollPath string
}
// DeleteInstanceOperation returns a new DeleteInstanceOperation from a given name.
// The name must be that of a previously created DeleteInstanceOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) DeleteInstanceOperation(name string) *DeleteInstanceOperation {
return &DeleteInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// DeleteInstanceOperation returns a new DeleteInstanceOperation from a given name.
// The name must be that of a previously created DeleteInstanceOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) DeleteInstanceOperation(name string) *DeleteInstanceOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &DeleteInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *DeleteInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
}
// 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 (op *DeleteInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
return op.lro.Poll(ctx, nil, opts...)
}
// 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 (op *DeleteInstanceOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *DeleteInstanceOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *DeleteInstanceOperation) Name() string {
return op.lro.Name()
}
// FailoverInstanceOperation manages a long-running operation from FailoverInstance.
type FailoverInstanceOperation struct {
lro *longrunning.Operation
pollPath string
}
// FailoverInstanceOperation returns a new FailoverInstanceOperation from a given name.
// The name must be that of a previously created FailoverInstanceOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) FailoverInstanceOperation(name string) *FailoverInstanceOperation {
return &FailoverInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// FailoverInstanceOperation returns a new FailoverInstanceOperation from a given name.
// The name must be that of a previously created FailoverInstanceOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) FailoverInstanceOperation(name string) *FailoverInstanceOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &FailoverInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *FailoverInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Instance
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *FailoverInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Instance
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *FailoverInstanceOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *FailoverInstanceOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *FailoverInstanceOperation) Name() string {
return op.lro.Name()
}
// PromoteClusterOperation manages a long-running operation from PromoteCluster.
type PromoteClusterOperation struct {
lro *longrunning.Operation
pollPath string
}
// PromoteClusterOperation returns a new PromoteClusterOperation from a given name.
// The name must be that of a previously created PromoteClusterOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) PromoteClusterOperation(name string) *PromoteClusterOperation {
return &PromoteClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// PromoteClusterOperation returns a new PromoteClusterOperation from a given name.
// The name must be that of a previously created PromoteClusterOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) PromoteClusterOperation(name string) *PromoteClusterOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &PromoteClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *PromoteClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Cluster
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *PromoteClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Cluster
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *PromoteClusterOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *PromoteClusterOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *PromoteClusterOperation) Name() string {
return op.lro.Name()
}
// RestartInstanceOperation manages a long-running operation from RestartInstance.
type RestartInstanceOperation struct {
lro *longrunning.Operation
pollPath string
}
// RestartInstanceOperation returns a new RestartInstanceOperation from a given name.
// The name must be that of a previously created RestartInstanceOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) RestartInstanceOperation(name string) *RestartInstanceOperation {
return &RestartInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// RestartInstanceOperation returns a new RestartInstanceOperation from a given name.
// The name must be that of a previously created RestartInstanceOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) RestartInstanceOperation(name string) *RestartInstanceOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &RestartInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *RestartInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Instance
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *RestartInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Instance
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *RestartInstanceOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *RestartInstanceOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *RestartInstanceOperation) Name() string {
return op.lro.Name()
}
// RestoreClusterOperation manages a long-running operation from RestoreCluster.
type RestoreClusterOperation struct {
lro *longrunning.Operation
pollPath string
}
// RestoreClusterOperation returns a new RestoreClusterOperation from a given name.
// The name must be that of a previously created RestoreClusterOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) RestoreClusterOperation(name string) *RestoreClusterOperation {
return &RestoreClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// RestoreClusterOperation returns a new RestoreClusterOperation from a given name.
// The name must be that of a previously created RestoreClusterOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) RestoreClusterOperation(name string) *RestoreClusterOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &RestoreClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *RestoreClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Cluster
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *RestoreClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Cluster
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *RestoreClusterOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *RestoreClusterOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *RestoreClusterOperation) Name() string {
return op.lro.Name()
}
// UpdateBackupOperation manages a long-running operation from UpdateBackup.
type UpdateBackupOperation struct {
lro *longrunning.Operation
pollPath string
}
// UpdateBackupOperation returns a new UpdateBackupOperation from a given name.
// The name must be that of a previously created UpdateBackupOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) UpdateBackupOperation(name string) *UpdateBackupOperation {
return &UpdateBackupOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// UpdateBackupOperation returns a new UpdateBackupOperation from a given name.
// The name must be that of a previously created UpdateBackupOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) UpdateBackupOperation(name string) *UpdateBackupOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &UpdateBackupOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *UpdateBackupOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Backup, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Backup
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *UpdateBackupOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Backup, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Backup
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *UpdateBackupOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *UpdateBackupOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *UpdateBackupOperation) Name() string {
return op.lro.Name()
}
// UpdateClusterOperation manages a long-running operation from UpdateCluster.
type UpdateClusterOperation struct {
lro *longrunning.Operation
pollPath string
}
// UpdateClusterOperation returns a new UpdateClusterOperation from a given name.
// The name must be that of a previously created UpdateClusterOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) UpdateClusterOperation(name string) *UpdateClusterOperation {
return &UpdateClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// UpdateClusterOperation returns a new UpdateClusterOperation from a given name.
// The name must be that of a previously created UpdateClusterOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) UpdateClusterOperation(name string) *UpdateClusterOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &UpdateClusterOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *UpdateClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Cluster
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *UpdateClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Cluster
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *UpdateClusterOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *UpdateClusterOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *UpdateClusterOperation) Name() string {
return op.lro.Name()
}
// UpdateInstanceOperation manages a long-running operation from UpdateInstance.
type UpdateInstanceOperation struct {
lro *longrunning.Operation
pollPath string
}
// UpdateInstanceOperation returns a new UpdateInstanceOperation from a given name.
// The name must be that of a previously created UpdateInstanceOperation, possibly from a different process.
func (c *alloyDBAdminGRPCClient) UpdateInstanceOperation(name string) *UpdateInstanceOperation {
return &UpdateInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// UpdateInstanceOperation returns a new UpdateInstanceOperation from a given name.
// The name must be that of a previously created UpdateInstanceOperation, possibly from a different process.
func (c *alloyDBAdminRESTClient) UpdateInstanceOperation(name string) *UpdateInstanceOperation {
override := fmt.Sprintf("/v1alpha/%s", name)
return &UpdateInstanceOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *UpdateInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Instance
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// 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 (op *UpdateInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp alloydbpb.Instance
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// 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 (op *UpdateInstanceOperation) Metadata() (*alloydbpb.OperationMetadata, error) {
var meta alloydbpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *UpdateInstanceOperation) Done() bool {
return op.lro.Done()
}
// 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 (op *UpdateInstanceOperation) Name() string {
return op.lro.Name()
}
// BackupIterator manages a stream of *alloydbpb.Backup.
type BackupIterator struct {
items []*alloydbpb.Backup
pageInfo *iterator.PageInfo
nextFunc func() error
// 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 []*alloydbpb.Backup, nextPageToken string, err error)
}
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func (it *BackupIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// 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 (it *BackupIterator) Next() (*alloydbpb.Backup, error) {
var item *alloydbpb.Backup
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *BackupIterator) bufLen() int {
return len(it.items)
}
func (it *BackupIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}
// ClusterIterator manages a stream of *alloydbpb.Cluster.
type ClusterIterator struct {
items []*alloydbpb.Cluster
pageInfo *iterator.PageInfo
nextFunc func() error
// 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 []*alloydbpb.Cluster, nextPageToken string, err error)
}
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func (it *ClusterIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// 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 (it *ClusterIterator) Next() (*alloydbpb.Cluster, error) {
var item *alloydbpb.Cluster
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *ClusterIterator) bufLen() int {
return len(it.items)
}
func (it *ClusterIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}
// InstanceIterator manages a stream of *alloydbpb.Instance.
type InstanceIterator struct {
items []*alloydbpb.Instance
pageInfo *iterator.PageInfo
nextFunc func() error
// 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 []*alloydbpb.Instance, nextPageToken string, err error)
}
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func (it *InstanceIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// 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 (it *InstanceIterator) Next() (*alloydbpb.Instance, error) {
var item *alloydbpb.Instance
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *InstanceIterator) bufLen() int {
return len(it.items)
}
func (it *InstanceIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}
// LocationIterator manages a stream of *locationpb.Location.
type LocationIterator struct {
items []*locationpb.Location
pageInfo *iterator.PageInfo
nextFunc func() error
// 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)
}
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func (it *LocationIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// 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 (it *LocationIterator) Next() (*locationpb.Location, error) {
var item *locationpb.Location
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *LocationIterator) bufLen() int {
return len(it.items)
}
func (it *LocationIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}
// OperationIterator manages a stream of *longrunningpb.Operation.
type OperationIterator struct {
items []*longrunningpb.Operation
pageInfo *iterator.PageInfo
nextFunc func() error
// 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 []*longrunningpb.Operation, nextPageToken string, err error)
}
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func (it *OperationIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// 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 (it *OperationIterator) Next() (*longrunningpb.Operation, error) {
var item *longrunningpb.Operation
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *OperationIterator) bufLen() int {
return len(it.items)
}
func (it *OperationIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}
// SupportedDatabaseFlagIterator manages a stream of *alloydbpb.SupportedDatabaseFlag.
type SupportedDatabaseFlagIterator struct {
items []*alloydbpb.SupportedDatabaseFlag
pageInfo *iterator.PageInfo
nextFunc func() error
// 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 []*alloydbpb.SupportedDatabaseFlag, nextPageToken string, err error)
}
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func (it *SupportedDatabaseFlagIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// 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 (it *SupportedDatabaseFlagIterator) Next() (*alloydbpb.SupportedDatabaseFlag, error) {
var item *alloydbpb.SupportedDatabaseFlag
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *SupportedDatabaseFlagIterator) bufLen() int {
return len(it.items)
}
func (it *SupportedDatabaseFlagIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}