cloud_sql

package
v1.69.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Domain = "sqladmin.googleapis.com"

	// LoginScope is the OAuth scope a token needs to log into a database as its IAM principal.
	LoginScope = "https://www.googleapis.com/auth/sqlservice.login"
	AdminScope = "https://www.googleapis.com/auth/sqlservice.admin"
)

Variables

This section is empty.

Functions

func DatabaseUsername

func DatabaseUsername(principal string) (string, error)

DatabaseUsername returns the Postgres role Cloud SQL creates for an IAM principal, given as an IAM member (`serviceAccount:x`, `user:x`, `group:x`) or a bare email. A service account's role drops the `.gserviceaccount.com` suffix; every name is lowercase.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client calls the two Cloud SQL Admin API methods a connection needs. Authentication is the caller's: pass an authenticating http.Client through cloud_sql_config.WithFetchOptions.

func NewClient

func NewClient(options ...cloud_sql_config.Option) *Client

func (*Client) GenerateEphemeralCert

func (c *Client) GenerateEphemeralCert(
	ctx context.Context,
	project string,
	instance string,
	publicKeyPem string,
	accessToken string,
	options ...fetch_config.Option,
) (*generate_ephemeral_cert_response.Response, error)

GenerateEphemeralCert has the instance's CA sign publicKeyPem for a client certificate. When accessToken is set, the certificate carries it, and the database accepts it in place of a password for the token's principal.

func (*Client) GetConnectSettings

func (c *Client) GetConnectSettings(ctx context.Context, project string, instance string, options ...fetch_config.Option) (*connect_settings.ConnectSettings, error)

GetConnectSettings returns the instance's server CA, addresses and DNS name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL