Package sql is an auto-generated package for the Cloud SQL Admin API.
Cloud SQL Admin API
NOTE: This package is in beta. It is not stable, and may be subject to changes.
General documentation
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage
To get started with this package, create a client.
// go get cloud.google.com/go/sql/apiv1beta4@latest ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := sql.NewSqlBackupRunsClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close()
The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.
Using the Client
The following is an example of making an API call with the newly created client, mentioned above.
req := &sqlpb.SqlBackupRunsDeleteRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlBackupRunsDeleteRequest. } resp, err := c.Delete(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context
The ctx passed to NewSqlBackupRunsClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
Functions
func DefaultAuthScopes
func DefaultAuthScopes() []stringDefaultAuthScopes reports the default set of authentication scopes to use with this package.
ApiWarningIterator
type ApiWarningIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*sqlpb.ApiWarning, nextPageToken string, err error)
// contains filtered or unexported fields
}ApiWarningIterator manages a stream of *sqlpb.ApiWarning.
func (*ApiWarningIterator) All
func (it *ApiWarningIterator) All() iter.Seq2[*sqlpb.ApiWarning, error]All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ApiWarningIterator) Next
func (it *ApiWarningIterator) Next() (*sqlpb.ApiWarning, error)Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ApiWarningIterator) PageInfo
func (it *ApiWarningIterator) PageInfo() *iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
BackupIterator
type BackupIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*sqlpb.Backup, nextPageToken string, err error)
// contains filtered or unexported fields
}BackupIterator manages a stream of *sqlpb.Backup.
func (*BackupIterator) All
func (it *BackupIterator) All() iter.Seq2[*sqlpb.Backup, error]All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*BackupIterator) Next
func (it *BackupIterator) Next() (*sqlpb.Backup, error)Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*BackupIterator) PageInfo
func (it *BackupIterator) PageInfo() *iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
BackupRunIterator
type BackupRunIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*sqlpb.BackupRun, nextPageToken string, err error)
// contains filtered or unexported fields
}BackupRunIterator manages a stream of *sqlpb.BackupRun.
func (*BackupRunIterator) All
func (it *BackupRunIterator) All() iter.Seq2[*sqlpb.BackupRun, error]All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*BackupRunIterator) Next
func (it *BackupRunIterator) Next() (*sqlpb.BackupRun, error)Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*BackupRunIterator) PageInfo
func (it *BackupRunIterator) PageInfo() *iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
OperationIterator
type OperationIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*sqlpb.Operation, nextPageToken string, err error)
// contains filtered or unexported fields
}OperationIterator manages a stream of *sqlpb.Operation.
func (*OperationIterator) All
func (it *OperationIterator) All() iter.Seq2[*sqlpb.Operation, error]All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*OperationIterator) Next
func (it *OperationIterator) Next() (*sqlpb.Operation, error)Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*OperationIterator) PageInfo
func (it *OperationIterator) PageInfo() *iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
SqlBackupRunsCallOptions
type SqlBackupRunsCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
}SqlBackupRunsCallOptions contains the retry settings for each method of SqlBackupRunsClient.
SqlBackupRunsClient
type SqlBackupRunsClient struct {
// The call options for this service.
CallOptions *SqlBackupRunsCallOptions
// contains filtered or unexported fields
}SqlBackupRunsClient is a client for interacting with Cloud SQL Admin API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
func NewSqlBackupRunsClient
func NewSqlBackupRunsClient(ctx context.Context, opts ...option.ClientOption) (*SqlBackupRunsClient, error)NewSqlBackupRunsClient creates a new sql backup runs service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupRunsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewSqlBackupRunsRESTClient
func NewSqlBackupRunsRESTClient(ctx context.Context, opts ...option.ClientOption) (*SqlBackupRunsClient, error)NewSqlBackupRunsRESTClient creates a new sql backup runs service rest client.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupRunsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*SqlBackupRunsClient) Close
func (c *SqlBackupRunsClient) Close() errorClose closes the connection to the API service. Always call Close() when the client is no longer required.
func (*SqlBackupRunsClient) Connection (deprecated)
func (c *SqlBackupRunsClient) Connection() *grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SqlBackupRunsClient) Delete
func (c *SqlBackupRunsClient) Delete(ctx context.Context, req *sqlpb.SqlBackupRunsDeleteRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Delete deletes the backup taken by a backup run.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupRunsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlBackupRunsDeleteRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlBackupRunsDeleteRequest.
}
resp, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlBackupRunsClient) Get
func (c *SqlBackupRunsClient) Get(ctx context.Context, req *sqlpb.SqlBackupRunsGetRequest, opts ...gax.CallOption) (*sqlpb.BackupRun, error)Get retrieves a resource containing information about a backup run.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupRunsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlBackupRunsGetRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlBackupRunsGetRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlBackupRunsClient) Insert
func (c *SqlBackupRunsClient) Insert(ctx context.Context, req *sqlpb.SqlBackupRunsInsertRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Insert creates a new backup run on demand.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupRunsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlBackupRunsInsertRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlBackupRunsInsertRequest.
}
resp, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlBackupRunsClient) List
func (c *SqlBackupRunsClient) List(ctx context.Context, req *sqlpb.SqlBackupRunsListRequest, opts ...gax.CallOption) *BackupRunIteratorList lists all backup runs associated with the project or a given instance and configuration in the reverse chronological order of the backup initiation time.
Examples
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupRunsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlBackupRunsListRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlBackupRunsListRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*sqlpb.BackupRunsListResponse)
}
}
all
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupRunsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlBackupRunsListRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlBackupRunsListRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
SqlBackupsCallOptions
type SqlBackupsCallOptions struct {
CreateBackup []gax.CallOption
GetBackup []gax.CallOption
ListBackups []gax.CallOption
UpdateBackup []gax.CallOption
DeleteBackup []gax.CallOption
}SqlBackupsCallOptions contains the retry settings for each method of SqlBackupsClient.
SqlBackupsClient
type SqlBackupsClient struct {
// The call options for this service.
CallOptions *SqlBackupsCallOptions
// contains filtered or unexported fields
}SqlBackupsClient is a client for interacting with Cloud SQL Admin API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
func NewSqlBackupsClient
func NewSqlBackupsClient(ctx context.Context, opts ...option.ClientOption) (*SqlBackupsClient, error)NewSqlBackupsClient creates a new sql backups service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewSqlBackupsRESTClient
func NewSqlBackupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*SqlBackupsClient, error)NewSqlBackupsRESTClient creates a new sql backups service rest client.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*SqlBackupsClient) Close
func (c *SqlBackupsClient) Close() errorClose closes the connection to the API service. Always call Close() when the client is no longer required.
func (*SqlBackupsClient) Connection (deprecated)
func (c *SqlBackupsClient) Connection() *grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SqlBackupsClient) CreateBackup
func (c *SqlBackupsClient) CreateBackup(ctx context.Context, req *sqlpb.CreateBackupRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)CreateBackup creates a backup for a Cloud SQL instance. This API can be used only to create on-demand backups.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.CreateBackupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#CreateBackupRequest.
}
resp, err := c.CreateBackup(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlBackupsClient) DeleteBackup
func (c *SqlBackupsClient) DeleteBackup(ctx context.Context, req *sqlpb.DeleteBackupRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)DeleteBackup deletes the backup.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.DeleteBackupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#DeleteBackupRequest.
}
resp, err := c.DeleteBackup(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlBackupsClient) GetBackup
func (c *SqlBackupsClient) GetBackup(ctx context.Context, req *sqlpb.GetBackupRequest, opts ...gax.CallOption) (*sqlpb.Backup, error)GetBackup retrieves a resource containing information about a backup.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.GetBackupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#GetBackupRequest.
}
resp, err := c.GetBackup(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlBackupsClient) ListBackups
func (c *SqlBackupsClient) ListBackups(ctx context.Context, req *sqlpb.ListBackupsRequest, opts ...gax.CallOption) *BackupIteratorListBackups lists all backups associated with the project.
Examples
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.ListBackupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#ListBackupsRequest.
}
it := c.ListBackups(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*sqlpb.ListBackupsResponse)
}
}
all
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.ListBackupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#ListBackupsRequest.
}
for resp, err := range c.ListBackups(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*SqlBackupsClient) UpdateBackup
func (c *SqlBackupsClient) UpdateBackup(ctx context.Context, req *sqlpb.UpdateBackupRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)UpdateBackup updates the retention period and the description of the backup. You can use this API to update final backups only.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlBackupsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.UpdateBackupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#UpdateBackupRequest.
}
resp, err := c.UpdateBackup(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
SqlConnectCallOptions
type SqlConnectCallOptions struct {
GetConnectSettings []gax.CallOption
ResolveConnectSettings []gax.CallOption
GenerateEphemeralCert []gax.CallOption
}SqlConnectCallOptions contains the retry settings for each method of SqlConnectClient.
SqlConnectClient
type SqlConnectClient struct {
// The call options for this service.
CallOptions *SqlConnectCallOptions
// contains filtered or unexported fields
}SqlConnectClient is a client for interacting with Cloud SQL Admin API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Cloud SQL connect service.
func NewSqlConnectClient
func NewSqlConnectClient(ctx context.Context, opts ...option.ClientOption) (*SqlConnectClient, error)NewSqlConnectClient creates a new sql connect service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Cloud SQL connect service.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlConnectClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewSqlConnectRESTClient
func NewSqlConnectRESTClient(ctx context.Context, opts ...option.ClientOption) (*SqlConnectClient, error)NewSqlConnectRESTClient creates a new sql connect service rest client.
Cloud SQL connect service.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlConnectRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*SqlConnectClient) Close
func (c *SqlConnectClient) Close() errorClose closes the connection to the API service. Always call Close() when the client is no longer required.
func (*SqlConnectClient) Connection (deprecated)
func (c *SqlConnectClient) Connection() *grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SqlConnectClient) GenerateEphemeralCert
func (c *SqlConnectClient) GenerateEphemeralCert(ctx context.Context, req *sqlpb.GenerateEphemeralCertRequest, opts ...gax.CallOption) (*sqlpb.GenerateEphemeralCertResponse, error)GenerateEphemeralCert generates a short-lived X509 certificate containing the provided public key and signed by a private key specific to the target instance. Users may use the certificate to authenticate as themselves when connecting to the database.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlConnectClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.GenerateEphemeralCertRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#GenerateEphemeralCertRequest.
}
resp, err := c.GenerateEphemeralCert(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlConnectClient) GetConnectSettings
func (c *SqlConnectClient) GetConnectSettings(ctx context.Context, req *sqlpb.GetConnectSettingsRequest, opts ...gax.CallOption) (*sqlpb.ConnectSettings, error)GetConnectSettings retrieves connect settings about a Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlConnectClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.GetConnectSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#GetConnectSettingsRequest.
}
resp, err := c.GetConnectSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlConnectClient) ResolveConnectSettings
func (c *SqlConnectClient) ResolveConnectSettings(ctx context.Context, req *sqlpb.ResolveConnectSettingsRequest, opts ...gax.CallOption) (*sqlpb.ConnectSettings, error)ResolveConnectSettings retrieves connect settings about a Cloud SQL instance using the instance DNS name.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlConnectClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.ResolveConnectSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#ResolveConnectSettingsRequest.
}
resp, err := c.ResolveConnectSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
SqlDataCallOptions
type SqlDataCallOptions struct {
StreamSqlData []gax.CallOption
}SqlDataCallOptions contains the retry settings for each method of SqlDataClient.
SqlDataClient
type SqlDataClient struct {
// The call options for this service.
CallOptions *SqlDataCallOptions
// contains filtered or unexported fields
}SqlDataClient is a client for interacting with Cloud SQL Admin API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for streaming data to and from Cloud SQL instances.
func NewSqlDataClient
func NewSqlDataClient(ctx context.Context, opts ...option.ClientOption) (*SqlDataClient, error)NewSqlDataClient creates a new sql data service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for streaming data to and from Cloud SQL instances.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlDataClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*SqlDataClient) Close
func (c *SqlDataClient) Close() errorClose closes the connection to the API service. Always call Close() when the client is no longer required.
func (*SqlDataClient) Connection (deprecated)
func (c *SqlDataClient) Connection() *grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SqlDataClient) StreamSqlData
func (c *SqlDataClient) StreamSqlData(ctx context.Context, opts ...gax.CallOption) (sqlpb.SqlDataService_StreamSqlDataClient, error)StreamSqlData StreamSqlData establishes a bidirectional stream to a Cloud SQL instance, and then streams data to and from the instance.
The first message from the client MUST be a StreamSqlDataRequest request with configuration settings, including required values for the connection_settings field. Subsequent messages from the client may contain the payload field.
Messages from the server may contain the payload field.
The payload fields of the request and response streams contain the raw data of the database’s native wire protocol (e.g., PostgreSQL wire protocol). The database client is responsible for generating and parsing this data.
Any errors on initial connection (e.g., connection failure, authorization issues, network problems) will result in the stream being terminated with an appropriate RPC status exception.
After a successful connection is made, if an error occurs, then the server terminates connection and returns the appropriate RPC status exception.
Add the request params headers to the request to ensure that the streaming request is routed to the correct service for your database.
Use this format for the request params header:
location_path is locations/{location_name} instance_path is projects/{project_name}/instances/{instance_name}
for example: x-goog-request-params: location_id=locations/us-central1&instance_id=projects/myproject/instances/instancename
Example
package main
import (
"context"
"io"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlDataClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
stream, err := c.StreamSqlData(ctx)
if err != nil {
// TODO: Handle error.
}
go func() {
reqs := []*sqlpb.StreamSqlDataRequest{
// TODO: Create requests.
}
for _, req := range reqs {
if err := stream.Send(req); err != nil {
// TODO: Handle error.
}
}
stream.CloseSend()
}()
for {
resp, err := stream.Recv()
if err == io.EOF {
break
}
if err != nil {
// TODO: handle error.
}
// TODO: Use resp.
_ = resp
}
}
SqlDatabasesCallOptions
type SqlDatabasesCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
Update []gax.CallOption
}SqlDatabasesCallOptions contains the retry settings for each method of SqlDatabasesClient.
SqlDatabasesClient
type SqlDatabasesClient struct {
// The call options for this service.
CallOptions *SqlDatabasesCallOptions
// contains filtered or unexported fields
}SqlDatabasesClient is a client for interacting with Cloud SQL Admin API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
func NewSqlDatabasesClient
func NewSqlDatabasesClient(ctx context.Context, opts ...option.ClientOption) (*SqlDatabasesClient, error)NewSqlDatabasesClient creates a new sql databases service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlDatabasesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewSqlDatabasesRESTClient
func NewSqlDatabasesRESTClient(ctx context.Context, opts ...option.ClientOption) (*SqlDatabasesClient, error)NewSqlDatabasesRESTClient creates a new sql databases service rest client.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlDatabasesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*SqlDatabasesClient) Close
func (c *SqlDatabasesClient) Close() errorClose closes the connection to the API service. Always call Close() when the client is no longer required.
func (*SqlDatabasesClient) Connection (deprecated)
func (c *SqlDatabasesClient) Connection() *grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SqlDatabasesClient) Delete
func (c *SqlDatabasesClient) Delete(ctx context.Context, req *sqlpb.SqlDatabasesDeleteRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Delete deletes a database from a Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlDatabasesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlDatabasesDeleteRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlDatabasesDeleteRequest.
}
resp, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlDatabasesClient) Get
func (c *SqlDatabasesClient) Get(ctx context.Context, req *sqlpb.SqlDatabasesGetRequest, opts ...gax.CallOption) (*sqlpb.Database, error)Get retrieves a resource containing information about a database inside a Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlDatabasesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlDatabasesGetRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlDatabasesGetRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlDatabasesClient) Insert
func (c *SqlDatabasesClient) Insert(ctx context.Context, req *sqlpb.SqlDatabasesInsertRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Insert inserts a resource containing information about a database inside a Cloud SQL instance.
Note: You can’t modify the default character set and collation.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlDatabasesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlDatabasesInsertRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlDatabasesInsertRequest.
}
resp, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlDatabasesClient) List
func (c *SqlDatabasesClient) List(ctx context.Context, req *sqlpb.SqlDatabasesListRequest, opts ...gax.CallOption) (*sqlpb.DatabasesListResponse, error)List lists databases in the specified Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlDatabasesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlDatabasesListRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlDatabasesListRequest.
}
resp, err := c.List(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlDatabasesClient) Patch
func (c *SqlDatabasesClient) Patch(ctx context.Context, req *sqlpb.SqlDatabasesUpdateRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Patch partially updates a resource containing information about a database inside a Cloud SQL instance. This method supports patch semantics.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlDatabasesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlDatabasesUpdateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlDatabasesUpdateRequest.
}
resp, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlDatabasesClient) Update
func (c *SqlDatabasesClient) Update(ctx context.Context, req *sqlpb.SqlDatabasesUpdateRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Update updates a resource containing information about a database inside a Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlDatabasesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlDatabasesUpdateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlDatabasesUpdateRequest.
}
resp, err := c.Update(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
SqlFlagsCallOptions
type SqlFlagsCallOptions struct {
List []gax.CallOption
}SqlFlagsCallOptions contains the retry settings for each method of SqlFlagsClient.
SqlFlagsClient
type SqlFlagsClient struct {
// The call options for this service.
CallOptions *SqlFlagsCallOptions
// contains filtered or unexported fields
}SqlFlagsClient is a client for interacting with Cloud SQL Admin API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
func NewSqlFlagsClient
func NewSqlFlagsClient(ctx context.Context, opts ...option.ClientOption) (*SqlFlagsClient, error)NewSqlFlagsClient creates a new sql flags service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlFlagsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewSqlFlagsRESTClient
func NewSqlFlagsRESTClient(ctx context.Context, opts ...option.ClientOption) (*SqlFlagsClient, error)NewSqlFlagsRESTClient creates a new sql flags service rest client.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlFlagsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*SqlFlagsClient) Close
func (c *SqlFlagsClient) Close() errorClose closes the connection to the API service. Always call Close() when the client is no longer required.
func (*SqlFlagsClient) Connection (deprecated)
func (c *SqlFlagsClient) Connection() *grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SqlFlagsClient) List
func (c *SqlFlagsClient) List(ctx context.Context, req *sqlpb.SqlFlagsListRequest, opts ...gax.CallOption) (*sqlpb.FlagsListResponse, error)List lists all available database flags for Cloud SQL instances.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlFlagsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlFlagsListRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlFlagsListRequest.
}
resp, err := c.List(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
SqlInstancesCallOptions
type SqlInstancesCallOptions struct {
AddServerCa []gax.CallOption
AddServerCertificate []gax.CallOption
AddEntraIdCertificate []gax.CallOption
Clone []gax.CallOption
Delete []gax.CallOption
DemoteMaster []gax.CallOption
Demote []gax.CallOption
Export []gax.CallOption
Failover []gax.CallOption
Reencrypt []gax.CallOption
Get []gax.CallOption
Import []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
ListServerCas []gax.CallOption
ListServerCertificates []gax.CallOption
ListEntraIdCertificates []gax.CallOption
Patch []gax.CallOption
PromoteReplica []gax.CallOption
Switchover []gax.CallOption
ResetSslConfig []gax.CallOption
Restart []gax.CallOption
RestoreBackup []gax.CallOption
RotateServerCa []gax.CallOption
RotateServerCertificate []gax.CallOption
RotateEntraIdCertificate []gax.CallOption
StartReplica []gax.CallOption
StopReplica []gax.CallOption
TruncateLog []gax.CallOption
Update []gax.CallOption
CreateEphemeral []gax.CallOption
RescheduleMaintenance []gax.CallOption
VerifyExternalSyncSettings []gax.CallOption
StartExternalSync []gax.CallOption
PerformDiskShrink []gax.CallOption
GetDiskShrinkConfig []gax.CallOption
ResetReplicaSize []gax.CallOption
GetLatestRecoveryTime []gax.CallOption
ExecuteSql []gax.CallOption
AcquireSsrsLease []gax.CallOption
ReleaseSsrsLease []gax.CallOption
PreCheckMajorVersionUpgrade []gax.CallOption
PointInTimeRestore []gax.CallOption
}SqlInstancesCallOptions contains the retry settings for each method of SqlInstancesClient.
SqlInstancesClient
type SqlInstancesClient struct {
// The call options for this service.
CallOptions *SqlInstancesCallOptions
// contains filtered or unexported fields
}SqlInstancesClient is a client for interacting with Cloud SQL Admin API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
func NewSqlInstancesClient
func NewSqlInstancesClient(ctx context.Context, opts ...option.ClientOption) (*SqlInstancesClient, error)NewSqlInstancesClient creates a new sql instances service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewSqlInstancesRESTClient
func NewSqlInstancesRESTClient(ctx context.Context, opts ...option.ClientOption) (*SqlInstancesClient, error)NewSqlInstancesRESTClient creates a new sql instances service rest client.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*SqlInstancesClient) AcquireSsrsLease
func (c *SqlInstancesClient) AcquireSsrsLease(ctx context.Context, req *sqlpb.SqlInstancesAcquireSsrsLeaseRequest, opts ...gax.CallOption) (*sqlpb.SqlInstancesAcquireSsrsLeaseResponse, error)AcquireSsrsLease acquire a lease for the setup of SQL Server Reporting Services (SSRS).
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesAcquireSsrsLeaseRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesAcquireSsrsLeaseRequest.
}
resp, err := c.AcquireSsrsLease(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) AddEntraIdCertificate
func (c *SqlInstancesClient) AddEntraIdCertificate(ctx context.Context, req *sqlpb.SqlInstancesAddEntraIdCertificateRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)AddEntraIdCertificate adds a new Entra ID certificate for the specified instance. If an Entra ID certificate was previously added but never used in a certificate rotation, this operation replaces that version.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesAddEntraIdCertificateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesAddEntraIdCertificateRequest.
}
resp, err := c.AddEntraIdCertificate(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) AddServerCa
func (c *SqlInstancesClient) AddServerCa(ctx context.Context, req *sqlpb.SqlInstancesAddServerCaRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)AddServerCa add a new trusted Certificate Authority (CA) version for the specified instance. Required to prepare for a certificate rotation. If a CA version was previously added but never used in a certificate rotation, this operation replaces that version. There cannot be more than one CA version waiting to be rotated in. For instances that have enabled Certificate Authority Service (CAS) based server CA, use AddServerCertificate to add a new server certificate.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesAddServerCaRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesAddServerCaRequest.
}
resp, err := c.AddServerCa(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) AddServerCertificate
func (c *SqlInstancesClient) AddServerCertificate(ctx context.Context, req *sqlpb.SqlInstancesAddServerCertificateRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)AddServerCertificate add a new trusted server certificate version for the specified instance using Certificate Authority Service (CAS) server CA. Required to prepare for a certificate rotation. If a server certificate version was previously added but never used in a certificate rotation, this operation replaces that version. There cannot be more than one certificate version waiting to be rotated in. For instances not using CAS server CA, use AddServerCa instead.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesAddServerCertificateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesAddServerCertificateRequest.
}
resp, err := c.AddServerCertificate(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Clone
func (c *SqlInstancesClient) Clone(ctx context.Context, req *sqlpb.SqlInstancesCloneRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Clone creates a Cloud SQL instance as a clone of the source instance. Using this operation might cause your instance to restart.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesCloneRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesCloneRequest.
}
resp, err := c.Clone(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Close
func (c *SqlInstancesClient) Close() errorClose closes the connection to the API service. Always call Close() when the client is no longer required.
func (*SqlInstancesClient) Connection (deprecated)
func (c *SqlInstancesClient) Connection() *grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SqlInstancesClient) CreateEphemeral
func (c *SqlInstancesClient) CreateEphemeral(ctx context.Context, req *sqlpb.SqlInstancesCreateEphemeralCertRequest, opts ...gax.CallOption) (*sqlpb.SslCert, error)CreateEphemeral generates a short-lived X509 certificate containing the provided public key and signed by a private key specific to the target instance. Users may use the certificate to authenticate as themselves when connecting to the database.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesCreateEphemeralCertRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesCreateEphemeralCertRequest.
}
resp, err := c.CreateEphemeral(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Delete
func (c *SqlInstancesClient) Delete(ctx context.Context, req *sqlpb.SqlInstancesDeleteRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Delete deletes a Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesDeleteRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesDeleteRequest.
}
resp, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Demote
func (c *SqlInstancesClient) Demote(ctx context.Context, req *sqlpb.SqlInstancesDemoteRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Demote demotes an existing standalone instance to be a Cloud SQL read replica for an external database server.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesDemoteRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesDemoteRequest.
}
resp, err := c.Demote(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) DemoteMaster
func (c *SqlInstancesClient) DemoteMaster(ctx context.Context, req *sqlpb.SqlInstancesDemoteMasterRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)DemoteMaster demotes the stand-alone instance to be a Cloud SQL read replica for an external database server.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesDemoteMasterRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesDemoteMasterRequest.
}
resp, err := c.DemoteMaster(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) ExecuteSql
func (c *SqlInstancesClient) ExecuteSql(ctx context.Context, req *sqlpb.SqlInstancesExecuteSqlRequest, opts ...gax.CallOption) (*sqlpb.SqlInstancesExecuteSqlResponse, error)ExecuteSql execute SQL statements.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesExecuteSqlRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesExecuteSqlRequest.
}
resp, err := c.ExecuteSql(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Export
func (c *SqlInstancesClient) Export(ctx context.Context, req *sqlpb.SqlInstancesExportRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Export exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL dump or CSV file.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesExportRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesExportRequest.
}
resp, err := c.Export(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Failover
func (c *SqlInstancesClient) Failover(ctx context.Context, req *sqlpb.SqlInstancesFailoverRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Failover initiates a manual failover of a high availability (HA) primary instance to a standby instance, which becomes the primary instance. Users are then rerouted to the new primary. For more information, see the Overview of high availability (at https://cloud.google.com/sql/docs/mysql/high-availability) page in the Cloud SQL documentation. If using Legacy HA (MySQL only), this causes the instance to failover to its failover replica instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesFailoverRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesFailoverRequest.
}
resp, err := c.Failover(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Get
func (c *SqlInstancesClient) Get(ctx context.Context, req *sqlpb.SqlInstancesGetRequest, opts ...gax.CallOption) (*sqlpb.DatabaseInstance, error)Get retrieves a resource containing information about a Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesGetRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesGetRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) GetDiskShrinkConfig
func (c *SqlInstancesClient) GetDiskShrinkConfig(ctx context.Context, req *sqlpb.SqlInstancesGetDiskShrinkConfigRequest, opts ...gax.CallOption) (*sqlpb.SqlInstancesGetDiskShrinkConfigResponse, error)GetDiskShrinkConfig get Disk Shrink Config for a given instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesGetDiskShrinkConfigRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesGetDiskShrinkConfigRequest.
}
resp, err := c.GetDiskShrinkConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) GetLatestRecoveryTime
func (c *SqlInstancesClient) GetLatestRecoveryTime(ctx context.Context, req *sqlpb.SqlInstancesGetLatestRecoveryTimeRequest, opts ...gax.CallOption) (*sqlpb.SqlInstancesGetLatestRecoveryTimeResponse, error)GetLatestRecoveryTime get Latest Recovery Time for a given instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesGetLatestRecoveryTimeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesGetLatestRecoveryTimeRequest.
}
resp, err := c.GetLatestRecoveryTime(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Import
func (c *SqlInstancesClient) Import(ctx context.Context, req *sqlpb.SqlInstancesImportRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Import imports data into a Cloud SQL instance from a SQL dump or CSV file in Cloud Storage.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesImportRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesImportRequest.
}
resp, err := c.Import(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Insert
func (c *SqlInstancesClient) Insert(ctx context.Context, req *sqlpb.SqlInstancesInsertRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Insert creates a new Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesInsertRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesInsertRequest.
}
resp, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) List
func (c *SqlInstancesClient) List(ctx context.Context, req *sqlpb.SqlInstancesListRequest, opts ...gax.CallOption) *ApiWarningIteratorList lists instances under a given project.
Examples
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesListRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesListRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*sqlpb.InstancesListResponse)
}
}
all
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesListRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesListRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*SqlInstancesClient) ListEntraIdCertificates
func (c *SqlInstancesClient) ListEntraIdCertificates(ctx context.Context, req *sqlpb.SqlInstancesListEntraIdCertificatesRequest, opts ...gax.CallOption) (*sqlpb.InstancesListEntraIdCertificatesResponse, error)ListEntraIdCertificates lists all versions of EntraID certificates for the specified instance. There can be up to three sets of certificates listed: the certificate that is currently in use, a future that has been added but not yet used to sign a certificate, and a certificate that has been rotated out.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesListEntraIdCertificatesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesListEntraIdCertificatesRequest.
}
resp, err := c.ListEntraIdCertificates(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) ListServerCas
func (c *SqlInstancesClient) ListServerCas(ctx context.Context, req *sqlpb.SqlInstancesListServerCasRequest, opts ...gax.CallOption) (*sqlpb.InstancesListServerCasResponse, error)ListServerCas lists all of the trusted Certificate Authorities (CAs) for the specified instance. There can be up to three CAs listed: the CA that was used to sign the certificate that is currently in use, a CA that has been added but not yet used to sign a certificate, and a CA used to sign a certificate that has previously rotated out.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesListServerCasRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesListServerCasRequest.
}
resp, err := c.ListServerCas(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) ListServerCertificates
func (c *SqlInstancesClient) ListServerCertificates(ctx context.Context, req *sqlpb.SqlInstancesListServerCertificatesRequest, opts ...gax.CallOption) (*sqlpb.InstancesListServerCertificatesResponse, error)ListServerCertificates lists all versions of server certificates and certificate authorities (CAs) for the specified instance. There can be up to three sets of certs listed: the certificate that is currently in use, a future that has been added but not yet used to sign a certificate, and a certificate that has been rotated out. For instances not using Certificate Authority Service (CAS) server CA, use ListServerCas instead.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesListServerCertificatesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesListServerCertificatesRequest.
}
resp, err := c.ListServerCertificates(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Patch
func (c *SqlInstancesClient) Patch(ctx context.Context, req *sqlpb.SqlInstancesPatchRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Patch partially updates settings of a Cloud SQL instance by merging the request with the current configuration. This method supports patch semantics.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesPatchRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesPatchRequest.
}
resp, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) PerformDiskShrink
func (c *SqlInstancesClient) PerformDiskShrink(ctx context.Context, req *sqlpb.SqlInstancesPerformDiskShrinkRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)PerformDiskShrink perform Disk Shrink on primary instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesPerformDiskShrinkRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesPerformDiskShrinkRequest.
}
resp, err := c.PerformDiskShrink(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) PointInTimeRestore
func (c *SqlInstancesClient) PointInTimeRestore(ctx context.Context, req *sqlpb.SqlInstancesPointInTimeRestoreRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)PointInTimeRestore point in time restore for an instance managed by Google Cloud Backup and Disaster Recovery.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesPointInTimeRestoreRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesPointInTimeRestoreRequest.
}
resp, err := c.PointInTimeRestore(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) PreCheckMajorVersionUpgrade
func (c *SqlInstancesClient) PreCheckMajorVersionUpgrade(ctx context.Context, req *sqlpb.SqlInstancesPreCheckMajorVersionUpgradeRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)PreCheckMajorVersionUpgrade execute MVU Pre-checks
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesPreCheckMajorVersionUpgradeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesPreCheckMajorVersionUpgradeRequest.
}
resp, err := c.PreCheckMajorVersionUpgrade(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) PromoteReplica
func (c *SqlInstancesClient) PromoteReplica(ctx context.Context, req *sqlpb.SqlInstancesPromoteReplicaRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)PromoteReplica promotes the read replica instance to be an independent Cloud SQL primary instance. Using this operation might cause your instance to restart.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesPromoteReplicaRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesPromoteReplicaRequest.
}
resp, err := c.PromoteReplica(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Reencrypt
func (c *SqlInstancesClient) Reencrypt(ctx context.Context, req *sqlpb.SqlInstancesReencryptRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Reencrypt reencrypt CMEK instance with latest key version.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesReencryptRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesReencryptRequest.
}
resp, err := c.Reencrypt(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) ReleaseSsrsLease
func (c *SqlInstancesClient) ReleaseSsrsLease(ctx context.Context, req *sqlpb.SqlInstancesReleaseSsrsLeaseRequest, opts ...gax.CallOption) (*sqlpb.SqlInstancesReleaseSsrsLeaseResponse, error)ReleaseSsrsLease release a lease for the setup of SQL Server Reporting Services (SSRS).
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesReleaseSsrsLeaseRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesReleaseSsrsLeaseRequest.
}
resp, err := c.ReleaseSsrsLease(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) RescheduleMaintenance
func (c *SqlInstancesClient) RescheduleMaintenance(ctx context.Context, req *sqlpb.SqlInstancesRescheduleMaintenanceRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)RescheduleMaintenance reschedules the maintenance on the given instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesRescheduleMaintenanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesRescheduleMaintenanceRequest.
}
resp, err := c.RescheduleMaintenance(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) ResetReplicaSize
func (c *SqlInstancesClient) ResetReplicaSize(ctx context.Context, req *sqlpb.SqlInstancesResetReplicaSizeRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)ResetReplicaSize reset Replica Size to primary instance disk size.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesResetReplicaSizeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesResetReplicaSizeRequest.
}
resp, err := c.ResetReplicaSize(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) ResetSslConfig
func (c *SqlInstancesClient) ResetSslConfig(ctx context.Context, req *sqlpb.SqlInstancesResetSslConfigRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)ResetSslConfig deletes all client certificates and generates a new server SSL certificate for the instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesResetSslConfigRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesResetSslConfigRequest.
}
resp, err := c.ResetSslConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Restart
func (c *SqlInstancesClient) Restart(ctx context.Context, req *sqlpb.SqlInstancesRestartRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Restart restarts a Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesRestartRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesRestartRequest.
}
resp, err := c.Restart(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) RestoreBackup
func (c *SqlInstancesClient) RestoreBackup(ctx context.Context, req *sqlpb.SqlInstancesRestoreBackupRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)RestoreBackup restores a backup of a Cloud SQL instance. Using this operation might cause your instance to restart.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesRestoreBackupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesRestoreBackupRequest.
}
resp, err := c.RestoreBackup(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) RotateEntraIdCertificate
func (c *SqlInstancesClient) RotateEntraIdCertificate(ctx context.Context, req *sqlpb.SqlInstancesRotateEntraIdCertificateRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)RotateEntraIdCertificate rotates the Entra Id certificate version to one previously added with the addEntraIdCertificate method.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesRotateEntraIdCertificateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesRotateEntraIdCertificateRequest.
}
resp, err := c.RotateEntraIdCertificate(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) RotateServerCa
func (c *SqlInstancesClient) RotateServerCa(ctx context.Context, req *sqlpb.SqlInstancesRotateServerCaRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)RotateServerCa rotates the server certificate to one signed by the Certificate Authority (CA) version previously added with the addServerCA method. For instances that have enabled Certificate Authority Service (CAS) based server CA, use RotateServerCertificate to rotate the server certificate.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesRotateServerCaRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesRotateServerCaRequest.
}
resp, err := c.RotateServerCa(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) RotateServerCertificate
func (c *SqlInstancesClient) RotateServerCertificate(ctx context.Context, req *sqlpb.SqlInstancesRotateServerCertificateRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)RotateServerCertificate rotates the server certificate version to one previously added with the addServerCertificate method. For instances not using Certificate Authority Service (CAS) server CA, use RotateServerCa instead.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesRotateServerCertificateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesRotateServerCertificateRequest.
}
resp, err := c.RotateServerCertificate(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) StartExternalSync
func (c *SqlInstancesClient) StartExternalSync(ctx context.Context, req *sqlpb.SqlInstancesStartExternalSyncRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)StartExternalSync start External primary instance migration.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesStartExternalSyncRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesStartExternalSyncRequest.
}
resp, err := c.StartExternalSync(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) StartReplica
func (c *SqlInstancesClient) StartReplica(ctx context.Context, req *sqlpb.SqlInstancesStartReplicaRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)StartReplica starts the replication in the read replica instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesStartReplicaRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesStartReplicaRequest.
}
resp, err := c.StartReplica(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) StopReplica
func (c *SqlInstancesClient) StopReplica(ctx context.Context, req *sqlpb.SqlInstancesStopReplicaRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)StopReplica stops the replication in the read replica instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesStopReplicaRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesStopReplicaRequest.
}
resp, err := c.StopReplica(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Switchover
func (c *SqlInstancesClient) Switchover(ctx context.Context, req *sqlpb.SqlInstancesSwitchoverRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Switchover switches over from the primary instance to the DR replica instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesSwitchoverRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesSwitchoverRequest.
}
resp, err := c.Switchover(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) TruncateLog
func (c *SqlInstancesClient) TruncateLog(ctx context.Context, req *sqlpb.SqlInstancesTruncateLogRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)TruncateLog truncate MySQL general and slow query log tables MySQL only.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesTruncateLogRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesTruncateLogRequest.
}
resp, err := c.TruncateLog(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) Update
func (c *SqlInstancesClient) Update(ctx context.Context, req *sqlpb.SqlInstancesUpdateRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Update updates settings of a Cloud SQL instance. Using this operation might cause your instance to restart.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesUpdateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesUpdateRequest.
}
resp, err := c.Update(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlInstancesClient) VerifyExternalSyncSettings
func (c *SqlInstancesClient) VerifyExternalSyncSettings(ctx context.Context, req *sqlpb.SqlInstancesVerifyExternalSyncSettingsRequest, opts ...gax.CallOption) (*sqlpb.SqlInstancesVerifyExternalSyncSettingsResponse, error)VerifyExternalSyncSettings verify External primary instance external sync settings.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlInstancesClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlInstancesVerifyExternalSyncSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlInstancesVerifyExternalSyncSettingsRequest.
}
resp, err := c.VerifyExternalSyncSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
SqlOperationsCallOptions
type SqlOperationsCallOptions struct {
Get []gax.CallOption
List []gax.CallOption
Cancel []gax.CallOption
}SqlOperationsCallOptions contains the retry settings for each method of SqlOperationsClient.
SqlOperationsClient
type SqlOperationsClient struct {
// The call options for this service.
CallOptions *SqlOperationsCallOptions
// contains filtered or unexported fields
}SqlOperationsClient is a client for interacting with Cloud SQL Admin API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
func NewSqlOperationsClient
func NewSqlOperationsClient(ctx context.Context, opts ...option.ClientOption) (*SqlOperationsClient, error)NewSqlOperationsClient creates a new sql operations service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlOperationsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewSqlOperationsRESTClient
func NewSqlOperationsRESTClient(ctx context.Context, opts ...option.ClientOption) (*SqlOperationsClient, error)NewSqlOperationsRESTClient creates a new sql operations service rest client.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*SqlOperationsClient) Cancel
func (c *SqlOperationsClient) Cancel(ctx context.Context, req *sqlpb.SqlOperationsCancelRequest, opts ...gax.CallOption) errorCancel cancels an instance operation that has been performed on an instance. Ordinarily, this method name should be CancelSqlOperation.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlOperationsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlOperationsCancelRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlOperationsCancelRequest.
}
err = c.Cancel(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*SqlOperationsClient) Close
func (c *SqlOperationsClient) Close() errorClose closes the connection to the API service. Always call Close() when the client is no longer required.
func (*SqlOperationsClient) Connection (deprecated)
func (c *SqlOperationsClient) Connection() *grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SqlOperationsClient) Get
func (c *SqlOperationsClient) Get(ctx context.Context, req *sqlpb.SqlOperationsGetRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Get retrieves an instance operation that has been performed on an instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlOperationsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlOperationsGetRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlOperationsGetRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlOperationsClient) List
func (c *SqlOperationsClient) List(ctx context.Context, req *sqlpb.SqlOperationsListRequest, opts ...gax.CallOption) *OperationIteratorList lists all instance operations that have been performed on the given Cloud SQL instance in the reverse chronological order of the start time.
Examples
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlOperationsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlOperationsListRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlOperationsListRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*sqlpb.OperationsListResponse)
}
}
all
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlOperationsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlOperationsListRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlOperationsListRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
SqlSslCertsCallOptions
type SqlSslCertsCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
}SqlSslCertsCallOptions contains the retry settings for each method of SqlSslCertsClient.
SqlSslCertsClient
type SqlSslCertsClient struct {
// The call options for this service.
CallOptions *SqlSslCertsCallOptions
// contains filtered or unexported fields
}SqlSslCertsClient is a client for interacting with Cloud SQL Admin API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
func NewSqlSslCertsClient
func NewSqlSslCertsClient(ctx context.Context, opts ...option.ClientOption) (*SqlSslCertsClient, error)NewSqlSslCertsClient creates a new sql ssl certs service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlSslCertsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewSqlSslCertsRESTClient
func NewSqlSslCertsRESTClient(ctx context.Context, opts ...option.ClientOption) (*SqlSslCertsClient, error)NewSqlSslCertsRESTClient creates a new sql ssl certs service rest client.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlSslCertsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*SqlSslCertsClient) Close
func (c *SqlSslCertsClient) Close() errorClose closes the connection to the API service. Always call Close() when the client is no longer required.
func (*SqlSslCertsClient) Connection (deprecated)
func (c *SqlSslCertsClient) Connection() *grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SqlSslCertsClient) Delete
func (c *SqlSslCertsClient) Delete(ctx context.Context, req *sqlpb.SqlSslCertsDeleteRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Delete deletes the SSL certificate. For First Generation instances, the certificate remains valid until the instance is restarted.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlSslCertsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlSslCertsDeleteRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlSslCertsDeleteRequest.
}
resp, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlSslCertsClient) Get
func (c *SqlSslCertsClient) Get(ctx context.Context, req *sqlpb.SqlSslCertsGetRequest, opts ...gax.CallOption) (*sqlpb.SslCert, error)Get retrieves a particular SSL certificate. Does not include the private key (required for usage). The private key must be saved from the response to initial creation.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlSslCertsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlSslCertsGetRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlSslCertsGetRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlSslCertsClient) Insert
func (c *SqlSslCertsClient) Insert(ctx context.Context, req *sqlpb.SqlSslCertsInsertRequest, opts ...gax.CallOption) (*sqlpb.SslCertsInsertResponse, error)Insert creates an SSL certificate and returns it along with the private key and server certificate authority. The new certificate will not be usable until the instance is restarted.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlSslCertsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlSslCertsInsertRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlSslCertsInsertRequest.
}
resp, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlSslCertsClient) List
func (c *SqlSslCertsClient) List(ctx context.Context, req *sqlpb.SqlSslCertsListRequest, opts ...gax.CallOption) (*sqlpb.SslCertsListResponse, error)List lists all of the current SSL certificates for the instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlSslCertsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlSslCertsListRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlSslCertsListRequest.
}
resp, err := c.List(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
SqlTiersCallOptions
type SqlTiersCallOptions struct {
List []gax.CallOption
}SqlTiersCallOptions contains the retry settings for each method of SqlTiersClient.
SqlTiersClient
type SqlTiersClient struct {
// The call options for this service.
CallOptions *SqlTiersCallOptions
// contains filtered or unexported fields
}SqlTiersClient is a client for interacting with Cloud SQL Admin API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for providing machine types (tiers) for Cloud SQL.
func NewSqlTiersClient
func NewSqlTiersClient(ctx context.Context, opts ...option.ClientOption) (*SqlTiersClient, error)NewSqlTiersClient creates a new sql tiers service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for providing machine types (tiers) for Cloud SQL.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlTiersClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewSqlTiersRESTClient
func NewSqlTiersRESTClient(ctx context.Context, opts ...option.ClientOption) (*SqlTiersClient, error)NewSqlTiersRESTClient creates a new sql tiers service rest client.
Service for providing machine types (tiers) for Cloud SQL.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlTiersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*SqlTiersClient) Close
func (c *SqlTiersClient) Close() errorClose closes the connection to the API service. Always call Close() when the client is no longer required.
func (*SqlTiersClient) Connection (deprecated)
func (c *SqlTiersClient) Connection() *grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SqlTiersClient) List
func (c *SqlTiersClient) List(ctx context.Context, req *sqlpb.SqlTiersListRequest, opts ...gax.CallOption) (*sqlpb.TiersListResponse, error)List lists all available machine types (tiers) for Cloud SQL, for example, db-custom-1-3840. For related information, see Pricing (at /sql/pricing).
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlTiersClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlTiersListRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlTiersListRequest.
}
resp, err := c.List(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
SqlUsersCallOptions
type SqlUsersCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Update []gax.CallOption
}SqlUsersCallOptions contains the retry settings for each method of SqlUsersClient.
SqlUsersClient
type SqlUsersClient struct {
// The call options for this service.
CallOptions *SqlUsersCallOptions
// contains filtered or unexported fields
}SqlUsersClient is a client for interacting with Cloud SQL Admin API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
func NewSqlUsersClient
func NewSqlUsersClient(ctx context.Context, opts ...option.ClientOption) (*SqlUsersClient, error)NewSqlUsersClient creates a new sql users service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlUsersClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewSqlUsersRESTClient
func NewSqlUsersRESTClient(ctx context.Context, opts ...option.ClientOption) (*SqlUsersClient, error)NewSqlUsersRESTClient creates a new sql users service rest client.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlUsersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*SqlUsersClient) Close
func (c *SqlUsersClient) Close() errorClose closes the connection to the API service. Always call Close() when the client is no longer required.
func (*SqlUsersClient) Connection (deprecated)
func (c *SqlUsersClient) Connection() *grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SqlUsersClient) Delete
func (c *SqlUsersClient) Delete(ctx context.Context, req *sqlpb.SqlUsersDeleteRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Delete deletes a user from a Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlUsersClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlUsersDeleteRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlUsersDeleteRequest.
}
resp, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlUsersClient) Get
func (c *SqlUsersClient) Get(ctx context.Context, req *sqlpb.SqlUsersGetRequest, opts ...gax.CallOption) (*sqlpb.User, error)Get retrieves a resource containing information about a user.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlUsersClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlUsersGetRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlUsersGetRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlUsersClient) Insert
func (c *SqlUsersClient) Insert(ctx context.Context, req *sqlpb.SqlUsersInsertRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Insert creates a new user in a Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlUsersClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlUsersInsertRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlUsersInsertRequest.
}
resp, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlUsersClient) List
func (c *SqlUsersClient) List(ctx context.Context, req *sqlpb.SqlUsersListRequest, opts ...gax.CallOption) (*sqlpb.UsersListResponse, error)List lists users in the specified Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlUsersClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlUsersListRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlUsersListRequest.
}
resp, err := c.List(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SqlUsersClient) Update
func (c *SqlUsersClient) Update(ctx context.Context, req *sqlpb.SqlUsersUpdateRequest, opts ...gax.CallOption) (*sqlpb.Operation, error)Update updates an existing user in a Cloud SQL instance.
Example
package main
import (
"context"
sql "cloud.google.com/go/sql/apiv1beta4"
sqlpb "cloud.google.com/go/sql/apiv1beta4/sqlpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := sql.NewSqlUsersClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &sqlpb.SqlUsersUpdateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/sql/apiv1beta4/sqlpb#SqlUsersUpdateRequest.
}
resp, err := c.Update(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}