cloudsql

package
v0.0.0-...-36f5383 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: OSL-3.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cloudsql provides GCP Cloud SQL commitments client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BillingService

type BillingService = skulist.BillingService

BillingService lists SKUs of one Cloud Billing service (enables mocking).

type Client

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

Client handles GCP Cloud SQL commitments.

func NewClient

func NewClient(ctx context.Context, projectID, region string, opts ...option.ClientOption) (*Client, error)

NewClient creates a new GCP Cloud SQL client.

func (*Client) GetExistingCommitments

func (c *Client) GetExistingCommitments(_ context.Context) ([]common.Commitment, error)

GetExistingCommitments returns an empty slice for Cloud SQL. Cloud SQL spend-based CUDs are purchased via the Cloud Billing console / Cloud Commerce Consumer Procurement API, not exposed through the sqladmin API. The legacy PricingPlan "PACKAGE" is a per-instance billing mode (non-commitment, deprecated) -- treating it as a commitment caused double-counting against real spend-based CUDs (10-L3). Return empty until a proper commitment- detection path is available.

func (*Client) GetOfferingDetails

func (c *Client) GetOfferingDetails(ctx context.Context, rec common.Recommendation) (*common.OfferingDetails, error)

GetOfferingDetails retrieves Cloud SQL offering details from GCP Billing API.

func (*Client) GetRecommendations

func (c *Client) GetRecommendations(_ context.Context, _ *common.RecommendationParams) ([]common.Recommendation, error)

GetRecommendations always returns an error (issue #294). Cloud SQL CUDs are spend-based, and Google recommends them only at Cloud Billing account scope (google.cloudbilling.commitment.SpendBasedCommitmentRecommender); the project-scoped google.cloudsql.instance.PerformanceRecommender gives per-instance tuning advice, not commitments, so its output must not be relabeled as a CUD. The billing-scoped path is designed in docs/design/gcp-spend-commitments.md. The error is explicit so callers do not read an empty result as "nothing to buy".

func (*Client) GetRegion

func (c *Client) GetRegion() string

GetRegion returns the region.

func (*Client) GetServiceType

func (c *Client) GetServiceType() common.ServiceType

GetServiceType returns the service type.

func (*Client) PurchaseCommitment

func (c *Client) PurchaseCommitment(ctx context.Context, rec common.Recommendation, opts common.PurchaseOptions) (common.PurchaseResult, error)

PurchaseCommitment is intentionally a no-op for Cloud SQL: GCP exposes no programmatic API to buy a Cloud SQL committed-use discount. CUD purchases are spend-based and bought via the Cloud Billing console / Cloud Commerce Consumer Procurement API, not via sqladmin.Instances.Insert. The previous implementation created a brand-new billable SQL instance (the legacy PricingPlan "PACKAGE" is a per-instance billing mode, not a commitment), so a "purchase" silently spun up a new database that kept billing. Cloud SQL recommendations are therefore advisory only; this returns a clear not-supported error and never calls any resource-creation API (issue #640).

func (*Client) SetBillingService

func (c *Client) SetBillingService(svc BillingService)

SetBillingService sets the billing service (for testing).

func (*Client) SetRecommenderClient deprecated

func (c *Client) SetRecommenderClient(_ RecommenderClient)

SetRecommenderClient ignores the supplied client and does not close it.

Deprecated: Cloud SQL has no project-scoped commitment recommender (issue #294).

type RecommenderClient deprecated

type RecommenderClient interface {
	ListRecommendations(ctx context.Context, req *recommenderpb.ListRecommendationsRequest) RecommenderIterator
	Close() error
}

RecommenderClient preserves the legacy injection API for source compatibility.

Deprecated: Cloud SQL has no project-scoped commitment recommender (issue #294).

type RecommenderIterator deprecated

type RecommenderIterator interface {
	Next() (*recommenderpb.Recommendation, error)
}

RecommenderIterator preserves the legacy iteration API for source compatibility.

Deprecated: Cloud SQL has no project-scoped commitment recommender (issue #294).

type SQLPricing

type SQLPricing = catalogprice.Term

SQLPricing contains pricing information for Cloud SQL.

Jump to

Keyboard shortcuts

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