Documentation
¶
Overview ¶
Package computeengine provides GCP Compute Engine Committed Use Discounts client
Index ¶
- func CheckPaymentOption(payment string) error
- func IsRateLimited(err error) bool
- type BillingService
- type Client
- func (c *Client) FilterRecommendationsForRecentCommitments(recs []common.Recommendation, existing []common.Commitment) (passed, filtered []common.Recommendation, err error)
- func (c *Client) GetExistingCommitments(ctx 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) PurchaseCommitment(ctx context.Context, rec common.Recommendation, opts common.PurchaseOptions) (common.PurchaseResult, error)
- func (c *Client) SetBillingService(svc BillingService)
- func (c *Client) SetCommitmentsService(svc CommitmentsService)
- func (c *Client) SetRecommenderClient(client RecommenderClient)
- type CommitmentsIterator
- type CommitmentsOperation
- type CommitmentsService
- type ComputePricing
- type RecommenderClient
- type RecommenderIterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPaymentOption ¶
CheckPaymentOption accepts the spellings callers send for a known option and rejects anything else, so a typo is not mistaken for a monthly request.
func IsRateLimited ¶
IsRateLimited reports whether err is a throttle worth retrying after a backoff: HTTP 429, gRPC RESOURCE_EXHAUSTED, or a Compute 403 with a rate-limit reason.
Types ¶
type BillingService ¶
type BillingService interface {
ListSKUs(ctx context.Context, 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 Compute Engine Committed Use Discounts.
func NewClient ¶
func NewClient(projectID, region string, opts ...option.ClientOption) (*Client, error)
NewClient creates a new GCP Compute Engine client.
func (*Client) FilterRecommendationsForRecentCommitments ¶
func (c *Client) FilterRecommendationsForRecentCommitments(recs []common.Recommendation, existing []common.Commitment) (passed, filtered []common.Recommendation, err error)
FilterRecommendationsForRecentCommitments defers the whole family: scalar vCPU subtraction cannot safely resize the independently committed memory amount.
func (*Client) GetExistingCommitments ¶
GetExistingCommitments retrieves existing Compute Engine CUDs.
func (*Client) GetOfferingDetails ¶
func (c *Client) GetOfferingDetails(ctx context.Context, rec common.Recommendation) (*common.OfferingDetails, error)
GetOfferingDetails retrieves CUD offering details from GCP Billing API.
func (*Client) GetRecommendations ¶
func (c *Client) GetRecommendations(ctx context.Context, p *common.RecommendationParams) ([]common.Recommendation, error)
GetRecommendations gets CUD recommendations from GCP Recommender API.
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 purchases a Compute Engine CUD.
func (*Client) SetBillingService ¶
func (c *Client) SetBillingService(svc BillingService)
SetBillingService sets the billing service (for testing).
func (*Client) SetCommitmentsService ¶
func (c *Client) SetCommitmentsService(svc CommitmentsService)
SetCommitmentsService sets the commitments service (for testing). An injected service is NOT page-capped (the cap lives in realCommitmentsService.List), so test doubles must bound themselves.
func (*Client) SetRecommenderClient ¶
func (c *Client) SetRecommenderClient(client RecommenderClient)
SetRecommenderClient sets the recommender client (for testing).
type CommitmentsIterator ¶
type CommitmentsIterator interface {
Next() (*computepb.Commitment, error)
}
CommitmentsIterator interface for commitments iteration (enables mocking).
type CommitmentsOperation ¶
type CommitmentsOperation interface {
Wait(ctx context.Context, opts ...gax.CallOption) error
}
CommitmentsOperation interface for commitment operations (enables mocking).
type CommitmentsService ¶
type CommitmentsService interface {
List(ctx context.Context, req *computepb.ListRegionCommitmentsRequest) CommitmentsIterator
Insert(ctx context.Context, req *computepb.InsertRegionCommitmentRequest) (CommitmentsOperation, error)
Get(ctx context.Context, req *computepb.GetRegionCommitmentRequest) (*computepb.Commitment, error)
Close() error
}
CommitmentsService interface for commitments operations (enables mocking).
type ComputePricing ¶
type ComputePricing struct {
Currency string
// HourlyRate is the committed price per hour for the whole resource set.
HourlyRate float64
// CommitmentPrice is the committed price over the whole term.
CommitmentPrice float64
// OnDemandPrice is the on-demand price of the same resources over the term.
OnDemandPrice float64
SavingsPercentage float64
}
ComputePricing is the price of a commitment's resources, for one term.
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).