Documentation
¶
Overview ¶
Package cloudsql provides GCP Cloud SQL commitments client
Index ¶
- type BillingService
- type Client
- func (c *Client) GetExistingCommitments(_ context.Context) ([]common.Commitment, error)
- func (c *Client) GetOfferingDetails(ctx context.Context, rec common.Recommendation) (*common.OfferingDetails, error)
- func (c *Client) GetRecommendations(_ context.Context, _ *common.RecommendationParams) ([]common.Recommendation, error)
- func (c *Client) GetRegion() string
- func (c *Client) GetServiceType() common.ServiceType
- func (c *Client) PurchaseCommitment(ctx context.Context, rec common.Recommendation, opts common.PurchaseOptions) (common.PurchaseResult, error)
- func (c *Client) SetBillingService(svc BillingService)
- func (c *Client) SetRecommenderClient(_ RecommenderClient)deprecated
- type RecommenderClientdeprecated
- type RecommenderIteratordeprecated
- type SQLPricing
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 ¶
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) 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.