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(ctx context.Context, p *common.RecommendationParams) ([]common.Recommendation, error)
- func (c *Client) GetRegion() string
- func (c *Client) GetServiceType() common.ServiceType
- func (c *Client) GetValidResourceTypes(ctx context.Context) ([]string, error)
- 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(client RecommenderClient)
- func (c *Client) SetSQLAdminService(svc SQLAdminService)
- func (c *Client) ValidateOffering(ctx context.Context, rec common.Recommendation) error
- type RecommenderClient
- type RecommenderIterator
- type SQLAdminService
- type SQLPricing
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BillingService ¶
type BillingService interface {
ListSKUs(serviceID string) (*cloudbilling.ListSkusResponse, error)
}
BillingService interface for billing operations (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(ctx context.Context, p *common.RecommendationParams) ([]common.Recommendation, error)
GetRecommendations gets Cloud SQL recommendations from GCP Recommender API.
func (*Client) GetServiceType ¶
func (c *Client) GetServiceType() common.ServiceType
GetServiceType returns the service type.
func (*Client) GetValidResourceTypes ¶
GetValidResourceTypes returns valid Cloud SQL tiers.
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 ¶
func (c *Client) SetRecommenderClient(client RecommenderClient)
SetRecommenderClient sets the recommender client (for testing).
func (*Client) SetSQLAdminService ¶
func (c *Client) SetSQLAdminService(svc SQLAdminService)
SetSQLAdminService sets the SQL admin service (for testing).
func (*Client) ValidateOffering ¶
ValidateOffering validates that a Cloud SQL tier exists.
type RecommenderClient ¶
type RecommenderClient interface {
ListRecommendations(ctx context.Context, req *recommenderpb.ListRecommendationsRequest) RecommenderIterator
Close() error
}
RecommenderClient interface for recommender operations (enables mocking).
type RecommenderIterator ¶
type RecommenderIterator interface {
Next() (*recommenderpb.Recommendation, error)
}
RecommenderIterator interface for recommender iteration (enables mocking).
type SQLAdminService ¶
type SQLAdminService interface {
ListInstances(projectID string) (*sqladmin.InstancesListResponse, error)
InsertInstance(projectID string, instance *sqladmin.DatabaseInstance) (*sqladmin.Operation, error)
ListTiers(projectID string) (*sqladmin.TiersListResponse, error)
}
SQLAdminService interface for SQL admin operations (enables mocking).