Documentation
¶
Overview ¶
Package redshift provides AWS Redshift Reserved Nodes client
Index ¶
- type API
- type Client
- 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(_ context.Context, _ *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) SetRedshiftAPI(api API)
- func (c *Client) SetSTSAPI(api STSAPI)
- func (c *Client) ValidateOffering(ctx context.Context, rec common.Recommendation) error
- type STSAPI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface {
PurchaseReservedNodeOffering(ctx context.Context, params *redshift.PurchaseReservedNodeOfferingInput, optFns ...func(*redshift.Options)) (*redshift.PurchaseReservedNodeOfferingOutput, error)
DescribeReservedNodeOfferings(ctx context.Context, params *redshift.DescribeReservedNodeOfferingsInput, optFns ...func(*redshift.Options)) (*redshift.DescribeReservedNodeOfferingsOutput, error)
DescribeReservedNodes(ctx context.Context, params *redshift.DescribeReservedNodesInput, optFns ...func(*redshift.Options)) (*redshift.DescribeReservedNodesOutput, error)
CreateTags(ctx context.Context, params *redshift.CreateTagsInput, optFns ...func(*redshift.Options)) (*redshift.CreateTagsOutput, error)
DescribeTags(ctx context.Context, params *redshift.DescribeTagsInput, optFns ...func(*redshift.Options)) (*redshift.DescribeTagsOutput, error)
}
API defines the interface for Redshift operations (enables mocking).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles AWS Redshift Reserved Nodes.
func NewClient ¶
NewClient creates a new Redshift client with purchase-path retry/timeout settings. See purchasecfg for rationale.
func (*Client) GetExistingCommitments ¶
GetExistingCommitments retrieves existing Redshift Reserved Nodes.
func (*Client) GetOfferingDetails ¶
func (c *Client) GetOfferingDetails(ctx context.Context, rec common.Recommendation) (*common.OfferingDetails, error)
GetOfferingDetails retrieves offering details. All prices are per ONE reservation (callers multiply by rec.Count): UpfrontCost is FixedPrice, RecurringCost the hourly rate, TotalCost upfront plus hourly over the offering duration.
func (*Client) GetRecommendations ¶
func (c *Client) GetRecommendations(_ context.Context, _ *common.RecommendationParams) ([]common.Recommendation, error)
GetRecommendations returns empty as Redshift uses centralized Cost Explorer recommendations.
func (*Client) GetServiceType ¶
func (c *Client) GetServiceType() common.ServiceType
GetServiceType returns the service type.
func (*Client) GetValidResourceTypes ¶
GetValidResourceTypes returns valid Redshift node types by querying the API.
func (*Client) PurchaseCommitment ¶
func (c *Client) PurchaseCommitment(ctx context.Context, rec common.Recommendation, opts common.PurchaseOptions) (common.PurchaseResult, error)
PurchaseCommitment purchases a Redshift Reserved Node.
PurchaseReservedNodeOfferingInput has no Tags field — tagging happens post-purchase via redshift:CreateTags, which requires a full ARN (arn:aws:redshift:<region>:<account>:reservednode:<id>). The account ID is resolved lazily on first tag call via sts:GetCallerIdentity and cached for the lifetime of the client. Tagging failure is logged but does NOT fail the purchase — the reserved node is already bought.
func (*Client) SetRedshiftAPI ¶
SetRedshiftAPI sets a custom Redshift API client (for testing).
func (*Client) ValidateOffering ¶
ValidateOffering checks if an offering exists without purchasing.
type STSAPI ¶
type STSAPI interface {
GetCallerIdentity(ctx context.Context, params *sts.GetCallerIdentityInput, optFns ...func(*sts.Options)) (*sts.GetCallerIdentityOutput, error)
}
STSAPI is the subset of STS this client calls to resolve the caller's account ID for ARN construction. Declared at package level so tests can substitute a fake.