Documentation
¶
Overview ¶
Package computeengine provides GCP Compute Engine Committed Use Discounts client
Index ¶
- type BillingService
- type CommitmentRequest
- type CommitmentsIterator
- type CommitmentsOperation
- type CommitmentsService
- type ComputeEngineClient
- func (c *ComputeEngineClient) GetExistingCommitments(ctx context.Context) ([]common.Commitment, error)
- func (c *ComputeEngineClient) GetOfferingDetails(ctx context.Context, rec common.Recommendation) (*common.OfferingDetails, error)
- func (c *ComputeEngineClient) GetRecommendations(ctx context.Context, p *common.RecommendationParams) ([]common.Recommendation, error)
- func (c *ComputeEngineClient) GetRegion() string
- func (c *ComputeEngineClient) GetServiceType() common.ServiceType
- func (c *ComputeEngineClient) GetValidResourceTypes(ctx context.Context) ([]string, error)
- func (c *ComputeEngineClient) PurchaseCommitment(ctx context.Context, rec common.Recommendation, opts common.PurchaseOptions) (common.PurchaseResult, error)
- func (c *ComputeEngineClient) SetBillingService(svc BillingService)
- func (c *ComputeEngineClient) SetCommitmentsService(svc CommitmentsService)
- func (c *ComputeEngineClient) SetMachineTypesService(svc MachineTypesService)
- func (c *ComputeEngineClient) SetRecommenderClient(client RecommenderClient)
- func (c *ComputeEngineClient) ValidateOffering(ctx context.Context, rec common.Recommendation) error
- type ComputePricing
- type MachineTypesIterator
- type MachineTypesService
- type RecommenderClient
- type RecommenderIterator
- type ResourceCommitment
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 CommitmentRequest ¶
type CommitmentRequest struct {
Name string // unique per region+project
Plan string // "TWELVE_MONTH" or "THIRTY_SIX_MONTH"
Region string
Resources []ResourceCommitment
}
CommitmentRequest represents a single GCP commitment to create.
func GroupCommitments ¶
func GroupCommitments(recs []common.Recommendation) []CommitmentRequest
GroupCommitments groups recommendations by project+region+term into CommitmentRequests. GCP requires both a VCPU and a MEMORY resource (memory Amount in MB) in a single commitments.insert call. Each recommendation's Count is treated as vCPU count; the memory Amount is read from ComputeDetails.MemoryGB (populated by extractMemoryMBFromRecommendation). Recommendations with an unrecognized term or missing memory are skipped with a log warning so a bad rec never contaminates an otherwise valid group.
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)
Close() error
}
CommitmentsService interface for commitments operations (enables mocking)
type ComputeEngineClient ¶
type ComputeEngineClient struct {
// contains filtered or unexported fields
}
ComputeEngineClient handles GCP Compute Engine Committed Use Discounts
func NewClient ¶
func NewClient(ctx context.Context, projectID, region string, opts ...option.ClientOption) (*ComputeEngineClient, error)
NewClient creates a new GCP Compute Engine client
func (*ComputeEngineClient) GetExistingCommitments ¶
func (c *ComputeEngineClient) GetExistingCommitments(ctx context.Context) ([]common.Commitment, error)
GetExistingCommitments retrieves existing Compute Engine CUDs
func (*ComputeEngineClient) GetOfferingDetails ¶
func (c *ComputeEngineClient) GetOfferingDetails(ctx context.Context, rec common.Recommendation) (*common.OfferingDetails, error)
GetOfferingDetails retrieves CUD offering details from GCP Billing API
func (*ComputeEngineClient) GetRecommendations ¶
func (c *ComputeEngineClient) GetRecommendations(ctx context.Context, p *common.RecommendationParams) ([]common.Recommendation, error)
GetRecommendations gets CUD recommendations from GCP Recommender API
func (*ComputeEngineClient) GetRegion ¶
func (c *ComputeEngineClient) GetRegion() string
GetRegion returns the region
func (*ComputeEngineClient) GetServiceType ¶
func (c *ComputeEngineClient) GetServiceType() common.ServiceType
GetServiceType returns the service type
func (*ComputeEngineClient) GetValidResourceTypes ¶
func (c *ComputeEngineClient) GetValidResourceTypes(ctx context.Context) ([]string, error)
GetValidResourceTypes returns valid machine types from GCP Compute API
func (*ComputeEngineClient) PurchaseCommitment ¶
func (c *ComputeEngineClient) PurchaseCommitment(ctx context.Context, rec common.Recommendation, opts common.PurchaseOptions) (common.PurchaseResult, error)
PurchaseCommitment purchases a Compute Engine CUD
func (*ComputeEngineClient) SetBillingService ¶
func (c *ComputeEngineClient) SetBillingService(svc BillingService)
SetBillingService sets the billing service (for testing)
func (*ComputeEngineClient) SetCommitmentsService ¶
func (c *ComputeEngineClient) SetCommitmentsService(svc CommitmentsService)
SetCommitmentsService sets the commitments service (for testing)
func (*ComputeEngineClient) SetMachineTypesService ¶
func (c *ComputeEngineClient) SetMachineTypesService(svc MachineTypesService)
SetMachineTypesService sets the machine types service (for testing)
func (*ComputeEngineClient) SetRecommenderClient ¶
func (c *ComputeEngineClient) SetRecommenderClient(client RecommenderClient)
SetRecommenderClient sets the recommender client (for testing)
func (*ComputeEngineClient) ValidateOffering ¶
func (c *ComputeEngineClient) ValidateOffering(ctx context.Context, rec common.Recommendation) error
ValidateOffering validates that a machine type exists
type ComputePricing ¶
type ComputePricing struct {
HourlyRate float64
CommitmentPrice float64
OnDemandPrice float64
Currency string
SavingsPercentage float64
}
ComputePricing contains pricing information for Compute Engine
type MachineTypesIterator ¶
type MachineTypesIterator interface {
Next() (*computepb.MachineType, error)
}
MachineTypesIterator interface for machine types iteration (enables mocking)
type MachineTypesService ¶
type MachineTypesService interface {
List(ctx context.Context, req *computepb.ListMachineTypesRequest) MachineTypesIterator
Close() error
}
MachineTypesService interface for machine types operations (enables mocking)
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 ResourceCommitment ¶
type ResourceCommitment struct {
Amount int64 // number of vCPUs or memory in MB
Type string // GCP ResourceCommitment.Type enum: "VCPU" or "MEMORY"
}
ResourceCommitment represents a single resource within a GCP commitment.