Documentation
¶
Overview ¶
Package ce provides an in-memory implementation of the AWS Cost Explorer (Ce) service.
Index ¶
- Constants
- Variables
- type Anomaly
- type AnomalyMonitor
- type AnomalyRootCause
- type AnomalyScore
- type AnomalySubscription
- type BackfillJob
- type CommitmentAnalysis
- type CostAllocationTag
- type CostAllocationTagError
- type CostAllocationTagStatusEntry
- type CostCategory
- type CostCategoryRule
- type CostEntry
- type CostGroup
- type ForecastResult
- type GroupBySpec
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(_ *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type InMemoryBackend
- func (b *InMemoryBackend) AddAnomaly(a Anomaly)
- func (b *InMemoryBackend) CreateAnomalyMonitor(monitorName, monitorType, monitorDimension string, ...) (*AnomalyMonitor, error)
- func (b *InMemoryBackend) CreateAnomalySubscription(subscriptionName, frequency string, monitorARNList []string, ...) (*AnomalySubscription, error)
- func (b *InMemoryBackend) CreateBackfillJob(backfillFrom string) *BackfillJob
- func (b *InMemoryBackend) CreateCommitmentAnalysis() *CommitmentAnalysis
- func (b *InMemoryBackend) CreateCostCategoryDefinition(name, ruleVersion, defaultValue string, rules []CostCategoryRule, ...) (*CostCategory, error)
- func (b *InMemoryBackend) CreateSavingsPlansGeneration() *SavingsPlansGeneration
- func (b *InMemoryBackend) DeleteAnomalyMonitor(monARN string) error
- func (b *InMemoryBackend) DeleteAnomalySubscription(subARN string) error
- func (b *InMemoryBackend) DeleteCostCategoryDefinition(catARN string) (*CostCategory, error)
- func (b *InMemoryBackend) DescribeCostCategoryDefinition(catARN string) (*CostCategory, error)
- func (b *InMemoryBackend) GetAnomalies(monitorARN, feedback, startDate, endDate string, maxResults int, ...) ([]*Anomaly, string)
- func (b *InMemoryBackend) GetAnomalyMonitors(monitorARNList []string, maxResults int, nextPageToken string) ([]*AnomalyMonitor, string, error)
- func (b *InMemoryBackend) GetAnomalySubscriptions(subscriptionARNList []string, monitorARN string, maxResults int, ...) ([]*AnomalySubscription, string, error)
- func (b *InMemoryBackend) GetApproximateUsageRecords(services []string) (string, string, map[string]int64, int64)
- func (b *InMemoryBackend) GetCommitmentAnalysis(analysisID string) (*CommitmentAnalysis, error)
- func (b *InMemoryBackend) GetCostAndUsage(start, end, granularity string, metrics []string, groupBy []GroupBySpec) []ResultByTime
- func (b *InMemoryBackend) GetCostCategories(costCategoryName string) []string
- func (b *InMemoryBackend) GetDimensionValues(dimension string) []string
- func (b *InMemoryBackend) GetForecastByTime(start, end, granularity string, predictionIntervalLevel int) ([]ForecastResult, float64, float64, float64)
- func (b *InMemoryBackend) GetReservationCoverage(start, end, granularity string) []ReservationCoverageByTime
- func (b *InMemoryBackend) GetReservationPurchaseRecommendations(service, lookback, term, payment string) []ReservationRecommendation
- func (b *InMemoryBackend) GetReservationUtilization(start, end, granularity string) []ReservationUtilizationByTime
- func (b *InMemoryBackend) GetRightsizingRecommendations(_ string) []RightsizingRecommendation
- func (b *InMemoryBackend) GetSavingsPlansUtilization(start, end string) *SavingsPlansUtilizationResult
- func (b *InMemoryBackend) GetSavingsPlansUtilizationDetails(start, end string) []SavingsPlansUtilizationDetail
- func (b *InMemoryBackend) GetTagKeys() []string
- func (b *InMemoryBackend) GetTagValues(tagKey string) []string
- func (b *InMemoryBackend) ListBackfillHistory() []*BackfillJob
- func (b *InMemoryBackend) ListCommitmentAnalyses() []*CommitmentAnalysis
- func (b *InMemoryBackend) ListCostAllocationTags(status, tagType string, tagKeys []string) []*CostAllocationTag
- func (b *InMemoryBackend) ListCostCategoryDefinitions(maxResults int, nextPageToken string) ([]*CostCategory, string)
- func (b *InMemoryBackend) ListSavingsPlansGenerations(status string) []*SavingsPlansGeneration
- func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)
- func (b *InMemoryBackend) ProvideAnomalyFeedback(anomalyID, feedback string) error
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) StartJanitor(ctx context.Context, interval time.Duration)
- func (b *InMemoryBackend) TagResource(resourceARN string, resourceTags map[string]string) error
- func (b *InMemoryBackend) UntagResource(resourceARN string, tagKeys []string) error
- func (b *InMemoryBackend) UpdateAnomalyMonitor(monARN, monitorName string) (*AnomalyMonitor, error)
- func (b *InMemoryBackend) UpdateAnomalySubscription(subARN, frequency, subscriptionName string, monitorARNList []string, ...) (*AnomalySubscription, error)
- func (b *InMemoryBackend) UpdateCostAllocationTagsStatus(updates []CostAllocationTagStatusEntry) []CostAllocationTagError
- func (b *InMemoryBackend) UpdateCostCategoryDefinition(catARN, ruleVersion, defaultValue string, rules []CostCategoryRule, ...) (*CostCategory, error)
- type MetricValue
- type Provider
- type ReservationCoverageAgg
- type ReservationCoverageByTime
- type ReservationCoverageCost
- type ReservationCoverageHours
- type ReservationCoverageNormalizedUnits
- type ReservationRecommendation
- type ReservationRecommendationDetail
- type ReservationUtilizationAgg
- type ReservationUtilizationByTime
- type ResultByTime
- type RightsizingCurrentInstance
- type RightsizingModifyDetail
- type RightsizingRecommendation
- type RightsizingTargetInstance
- type RightsizingTerminateDetail
- type SavingsPlansAmortized
- type SavingsPlansGeneration
- type SavingsPlansSavings
- type SavingsPlansUtilizationAgg
- type SavingsPlansUtilizationDetail
- type SavingsPlansUtilizationResult
- type SplitChargeRule
- type Subscriber
Constants ¶
const DefaultAnomalyTTL = 30 * 24 * time.Hour
DefaultAnomalyTTL is the default time-to-live for detected anomalies.
Variables ¶
var ( // ErrNotFound is returned when a requested resource does not exist. ErrNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound) // ErrAlreadyExists is returned when a resource with the same name already exists. ErrAlreadyExists = awserr.New("ServiceQuotaExceededException", awserr.ErrConflict) // ErrValidation is returned when input parameters fail validation. Real AWS CE's // documented common-error type for malformed/missing-required-member requests is // "ValidationError" (confirmed via the CE API reference's CommonErrors page), not a // named per-operation exception -- CE's errors.go typed-exception list (checked // against aws-sdk-go-v2/service/costexplorer/types) has no ValidationException or // InvalidParameterException entry for any operation in this audit. ErrValidation = errors.New("ValidationError") ErrDataUnavailable = awserr.New("DataUnavailableException", awserr.ErrNotFound) // ErrUnknownMonitor is returned when a referenced cost anomaly monitor ARN does not // exist. Real AWS CE returns this (not the generic ResourceNotFoundException) from // every anomaly-monitor op and from any op whose MonitorArnList references a monitor // that doesn't exist. ErrUnknownMonitor = awserr.New("UnknownMonitorException", awserr.ErrNotFound) // ErrUnknownSubscription is returned when a referenced cost anomaly subscription ARN // does not exist. Real AWS CE returns this (not the generic ResourceNotFoundException) // from every anomaly-subscription op. ErrUnknownSubscription = awserr.New("UnknownSubscriptionException", awserr.ErrNotFound) )
Functions ¶
This section is empty.
Types ¶
type Anomaly ¶
type Anomaly struct {
CreationDate time.Time `json:"creationDate"`
AnomalyID string `json:"anomalyID"`
AnomalyStartDate string `json:"anomalyStartDate"`
AnomalyEndDate string `json:"anomalyEndDate"`
DimensionValue string `json:"dimensionValue"`
MonitorARN string `json:"monitorARN"`
SubscriptionARN string `json:"subscriptionARN"`
FeedbackType string `json:"feedbackType"`
RootCauses []AnomalyRootCause `json:"rootCauses,omitempty"`
AnomalyScore AnomalyScore `json:"anomalyScore"`
TotalImpact float64 `json:"totalImpact"`
}
Anomaly represents a detected cost anomaly in AWS CE.
type AnomalyMonitor ¶
type AnomalyMonitor struct {
CreationDate time.Time `json:"creationDate"`
LastUpdatedDate time.Time `json:"lastUpdatedDate"`
Tags map[string]string `json:"tags"`
MonitorARN string `json:"monitorARN"`
MonitorName string `json:"monitorName"`
MonitorType string `json:"monitorType"`
MonitorDimension string `json:"monitorDimension"`
}
AnomalyMonitor represents an in-memory AWS CE anomaly monitor.
type AnomalyRootCause ¶
type AnomalyRootCause struct {
Service string `json:"Service,omitempty"`
Region string `json:"Region,omitempty"`
LinkedAccount string `json:"LinkedAccount,omitempty"`
UsageType string `json:"UsageType,omitempty"`
}
AnomalyRootCause identifies a root cause dimension for an anomaly.
type AnomalyScore ¶
type AnomalyScore struct {
MaxScore float64 `json:"MaxScore"`
CurrentScore float64 `json:"CurrentScore"`
}
AnomalyScore represents the anomaly detection score.
type AnomalySubscription ¶
type AnomalySubscription struct {
CreationDate time.Time `json:"creationDate"`
Tags map[string]string `json:"tags"`
SubscriptionARN string `json:"subscriptionARN"`
SubscriptionName string `json:"subscriptionName"`
AccountID string `json:"accountID"`
Frequency string `json:"frequency"`
MonitorARNList []string `json:"monitorARNList"`
Subscribers []Subscriber `json:"subscribers"`
Threshold float64 `json:"threshold"`
}
AnomalySubscription represents an in-memory AWS CE anomaly subscription.
type BackfillJob ¶
type BackfillJob struct {
BackfillFrom string `json:"backfillFrom"`
RequestedAt string `json:"requestedAt"`
CompletedAt string `json:"completedAt,omitempty"`
BackfillStatus string `json:"backfillStatus"` // SUCCEEDED|PROCESSING|FAILED
LastUpdatedAt string `json:"lastUpdatedAt"`
}
BackfillJob represents a cost allocation tag backfill job.
type CommitmentAnalysis ¶
type CommitmentAnalysis struct {
AnalysisID string `json:"analysisId"`
AnalysisStatus string `json:"analysisStatus"` // SUCCEEDED|PROCESSING|FAILED
AnalysisStartedTime string `json:"analysisStartedTime"`
EstimatedCompletionTime string `json:"estimatedCompletionTime"`
ErrorCode string `json:"errorCode,omitempty"`
}
CommitmentAnalysis represents a commitment purchase analysis.
type CostAllocationTag ¶
type CostAllocationTag struct {
TagKey string `json:"tagKey"`
Status string `json:"status"` // Active | Inactive
Type string `json:"type"` // AWSGenerated | UserDefined
LastUpdatedDate string `json:"lastUpdatedDate"`
}
CostAllocationTag represents an AWS CE cost allocation tag.
type CostAllocationTagError ¶
type CostAllocationTagError struct {
TagKey string `json:"TagKey"`
Code string `json:"Code"`
Message string `json:"Message"`
}
CostAllocationTagError holds an error for a single tag key update.
type CostAllocationTagStatusEntry ¶
type CostAllocationTagStatusEntry struct {
TagKey string `json:"TagKey"`
Status string `json:"Status"`
}
CostAllocationTagStatusEntry is a TagKey+Status pair for UpdateCostAllocationTagsStatus.
type CostCategory ¶
type CostCategory struct {
CreationDate time.Time `json:"creationDate"`
Tags map[string]string `json:"tags"`
ARN string `json:"arn"`
Name string `json:"name"`
RuleVersion string `json:"ruleVersion"`
DefaultValue string `json:"defaultValue"`
EffectiveStart string `json:"effectiveStart"`
Rules []CostCategoryRule `json:"rules"`
SplitChargeRules []SplitChargeRule `json:"splitChargeRules"`
}
CostCategory represents an in-memory AWS Cost Explorer cost category.
type CostCategoryRule ¶
type CostCategoryRule struct {
Value string `json:"value"`
}
CostCategoryRule represents a single cost category rule.
type CostEntry ¶
type CostEntry struct {
Tags map[string]string `json:"tags"`
Date string `json:"date"`
Service string `json:"service"`
Region string `json:"region"`
UsageType string `json:"usageType"`
Account string `json:"account"`
BlendedCost float64 `json:"blendedCost"`
UnblendedCost float64 `json:"unblendedCost"`
UsageQuantity float64 `json:"usageQuantity"`
}
CostEntry is a synthetic cost ledger entry for a single day+service combination.
type CostGroup ¶
type CostGroup struct {
Metrics map[string]MetricValue `json:"Metrics"`
Keys []string `json:"Keys"`
}
CostGroup represents a group in a cost result.
type ForecastResult ¶
type ForecastResult struct {
TimePeriod map[string]string `json:"TimePeriod"`
MeanValue string `json:"MeanValue"`
PredictionIntervalLowerBound string `json:"PredictionIntervalLowerBound,omitempty"`
PredictionIntervalUpperBound string `json:"PredictionIntervalUpperBound,omitempty"`
}
ForecastResult represents a single time-bucket forecast entry.
type GroupBySpec ¶
GroupBySpec represents a single GroupBy dimension spec.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
// contains filtered or unexported fields
}
Handler is the Echo HTTP handler for Cost Explorer (Ce) operations.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a new Cost Explorer handler backed by backend. backend must not be nil.
func (*Handler) ChaosOperations ¶
ChaosOperations returns all operations that can be fault-injected.
func (*Handler) ChaosRegions ¶
ChaosRegions returns all regions this handler instance handles.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase AWS service name for fault rule matching.
func (*Handler) ExtractOperation ¶
ExtractOperation extracts the Cost Explorer action from the X-Amz-Target header.
func (*Handler) ExtractResource ¶
ExtractResource extracts the resource identifier from the request (not used for Ce).
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns the list of supported operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function for Cost Explorer requests.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) Reset ¶
func (h *Handler) Reset()
Reset implements service.Resettable by delegating to the backend.
func (*Handler) RouteMatcher ¶
RouteMatcher returns a function that matches Cost Explorer requests.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is a thread-safe in-memory store for Cost Explorer resources.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates a new backend for the given account and region.
func (*InMemoryBackend) AddAnomaly ¶
func (b *InMemoryBackend) AddAnomaly(a Anomaly)
AddAnomaly inserts an anomaly into the backend. It is intended for testing.
func (*InMemoryBackend) CreateAnomalyMonitor ¶
func (b *InMemoryBackend) CreateAnomalyMonitor( monitorName, monitorType, monitorDimension string, resourceTags map[string]string, ) (*AnomalyMonitor, error)
CreateAnomalyMonitor creates a new anomaly monitor.
func (*InMemoryBackend) CreateAnomalySubscription ¶
func (b *InMemoryBackend) CreateAnomalySubscription( subscriptionName, frequency string, monitorARNList []string, subscribers []Subscriber, threshold float64, resourceTags map[string]string, ) (*AnomalySubscription, error)
CreateAnomalySubscription creates a new anomaly subscription.
func (*InMemoryBackend) CreateBackfillJob ¶
func (b *InMemoryBackend) CreateBackfillJob(backfillFrom string) *BackfillJob
CreateBackfillJob creates a new cost allocation tag backfill job.
func (*InMemoryBackend) CreateCommitmentAnalysis ¶
func (b *InMemoryBackend) CreateCommitmentAnalysis() *CommitmentAnalysis
CreateCommitmentAnalysis starts a new commitment purchase analysis.
func (*InMemoryBackend) CreateCostCategoryDefinition ¶
func (b *InMemoryBackend) CreateCostCategoryDefinition( name, ruleVersion, defaultValue string, rules []CostCategoryRule, resourceTags map[string]string, ) (*CostCategory, error)
CreateCostCategoryDefinition creates a new cost category and returns it.
func (*InMemoryBackend) CreateSavingsPlansGeneration ¶ added in v1.2.0
func (b *InMemoryBackend) CreateSavingsPlansGeneration() *SavingsPlansGeneration
CreateSavingsPlansGeneration starts a new Savings Plans purchase recommendation generation job and persists it, mirroring the CommitmentAnalysis start/persist/list/get pattern used elsewhere in this backend.
func (*InMemoryBackend) DeleteAnomalyMonitor ¶
func (b *InMemoryBackend) DeleteAnomalyMonitor(monARN string) error
DeleteAnomalyMonitor removes an anomaly monitor by ARN.
func (*InMemoryBackend) DeleteAnomalySubscription ¶
func (b *InMemoryBackend) DeleteAnomalySubscription(subARN string) error
DeleteAnomalySubscription removes an anomaly subscription by ARN.
func (*InMemoryBackend) DeleteCostCategoryDefinition ¶
func (b *InMemoryBackend) DeleteCostCategoryDefinition(catARN string) (*CostCategory, error)
DeleteCostCategoryDefinition removes a cost category by ARN.
func (*InMemoryBackend) DescribeCostCategoryDefinition ¶
func (b *InMemoryBackend) DescribeCostCategoryDefinition(catARN string) (*CostCategory, error)
DescribeCostCategoryDefinition returns a cost category by ARN.
func (*InMemoryBackend) GetAnomalies ¶
func (b *InMemoryBackend) GetAnomalies( monitorARN, feedback, startDate, endDate string, maxResults int, nextPageToken string, ) ([]*Anomaly, string)
GetAnomalies returns detected anomalies, optionally filtered by monitor ARN, feedback type, and date interval. maxResults and nextPageToken implement opaque-cursor pagination.
func (*InMemoryBackend) GetAnomalyMonitors ¶
func (b *InMemoryBackend) GetAnomalyMonitors( monitorARNList []string, maxResults int, nextPageToken string, ) ([]*AnomalyMonitor, string, error)
GetAnomalyMonitors returns anomaly monitors, optionally filtered by ARNs, sorted by MonitorARN. maxResults and nextPageToken implement opaque-cursor pagination (real AWS behaviour). If monitorARNList references an ARN that doesn't exist, it returns ErrUnknownMonitor, matching real AWS.
func (*InMemoryBackend) GetAnomalySubscriptions ¶
func (b *InMemoryBackend) GetAnomalySubscriptions( subscriptionARNList []string, monitorARN string, maxResults int, nextPageToken string, ) ([]*AnomalySubscription, string, error)
GetAnomalySubscriptions returns anomaly subscriptions, optionally filtered by ARNs or monitor ARN, sorted by SubscriptionARN. maxResults and nextPageToken implement opaque-cursor pagination. If subscriptionARNList references an ARN that doesn't exist, it returns ErrUnknownSubscription, matching real AWS. monitorARN is a simple filter (real AWS does not require it to reference an existing monitor).
func (*InMemoryBackend) GetApproximateUsageRecords ¶ added in v1.2.0
func (b *InMemoryBackend) GetApproximateUsageRecords( services []string, ) (string, string, map[string]int64, int64)
GetApproximateUsageRecords returns estimated per-service usage record counts derived from the cost ledger's UsageQuantity over the trailing daysPerMonth-day lookback window, optionally filtered to services. Matches real AWS's GetApproximateUsageRecords shape: LookbackPeriod + per-service counts + a grand total.
func (*InMemoryBackend) GetCommitmentAnalysis ¶
func (b *InMemoryBackend) GetCommitmentAnalysis(analysisID string) (*CommitmentAnalysis, error)
GetCommitmentAnalysis retrieves a commitment analysis by ID.
func (*InMemoryBackend) GetCostAndUsage ¶
func (b *InMemoryBackend) GetCostAndUsage( start, end, granularity string, metrics []string, groupBy []GroupBySpec, ) []ResultByTime
GetCostAndUsage aggregates cost ledger entries by granularity, applying optional GroupBy.
func (*InMemoryBackend) GetCostCategories ¶
func (b *InMemoryBackend) GetCostCategories(costCategoryName string) []string
GetCostCategories returns the distinct cost category values stored in the backend, optionally filtered by cost category name. Values are sorted alphabetically.
func (*InMemoryBackend) GetDimensionValues ¶
func (b *InMemoryBackend) GetDimensionValues(dimension string) []string
GetDimensionValues returns unique values for the given dimension from the cost ledger.
func (*InMemoryBackend) GetForecastByTime ¶
func (b *InMemoryBackend) GetForecastByTime( start, end, granularity string, predictionIntervalLevel int, ) ([]ForecastResult, float64, float64, float64)
GetForecastByTime returns per-bucket cost forecasts for a time range.
func (*InMemoryBackend) GetReservationCoverage ¶
func (b *InMemoryBackend) GetReservationCoverage( start, end, granularity string, ) []ReservationCoverageByTime
GetReservationCoverage returns synthetic RI coverage by time.
func (*InMemoryBackend) GetReservationPurchaseRecommendations ¶
func (b *InMemoryBackend) GetReservationPurchaseRecommendations( service, lookback, term, payment string, ) []ReservationRecommendation
GetReservationPurchaseRecommendations returns synthetic RI purchase recommendations.
func (*InMemoryBackend) GetReservationUtilization ¶
func (b *InMemoryBackend) GetReservationUtilization( start, end, granularity string, ) []ReservationUtilizationByTime
GetReservationUtilization returns synthetic RI utilization by time.
func (*InMemoryBackend) GetRightsizingRecommendations ¶
func (b *InMemoryBackend) GetRightsizingRecommendations( _ string, ) []RightsizingRecommendation
GetRightsizingRecommendations returns synthetic rightsizing recommendations.
func (*InMemoryBackend) GetSavingsPlansUtilization ¶
func (b *InMemoryBackend) GetSavingsPlansUtilization( start, end string, ) *SavingsPlansUtilizationResult
GetSavingsPlansUtilization returns a synthetic savings-plans utilization aggregate.
func (*InMemoryBackend) GetSavingsPlansUtilizationDetails ¶
func (b *InMemoryBackend) GetSavingsPlansUtilizationDetails( start, end string, ) []SavingsPlansUtilizationDetail
GetSavingsPlansUtilizationDetails returns per-plan utilization details.
func (*InMemoryBackend) GetTagKeys ¶
func (b *InMemoryBackend) GetTagKeys() []string
GetTagKeys returns all distinct tag keys used across the cost ledger.
func (*InMemoryBackend) GetTagValues ¶
func (b *InMemoryBackend) GetTagValues(tagKey string) []string
GetTagValues returns distinct values for a tag key.
func (*InMemoryBackend) ListBackfillHistory ¶
func (b *InMemoryBackend) ListBackfillHistory() []*BackfillJob
ListBackfillHistory returns backfill jobs sorted by RequestedAt descending.
func (*InMemoryBackend) ListCommitmentAnalyses ¶
func (b *InMemoryBackend) ListCommitmentAnalyses() []*CommitmentAnalysis
ListCommitmentAnalyses returns all commitment analyses sorted by AnalysisStartedTime.
func (*InMemoryBackend) ListCostAllocationTags ¶
func (b *InMemoryBackend) ListCostAllocationTags( status, tagType string, tagKeys []string, ) []*CostAllocationTag
ListCostAllocationTags returns cost allocation tags, optionally filtered.
func (*InMemoryBackend) ListCostCategoryDefinitions ¶
func (b *InMemoryBackend) ListCostCategoryDefinitions(maxResults int, nextPageToken string) ([]*CostCategory, string)
ListCostCategoryDefinitions returns cost categories sorted by name with opaque pagination.
func (*InMemoryBackend) ListSavingsPlansGenerations ¶ added in v1.2.0
func (b *InMemoryBackend) ListSavingsPlansGenerations(status string) []*SavingsPlansGeneration
ListSavingsPlansGenerations returns generation jobs, optionally filtered by GenerationStatus, most recently started first.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)
ListTagsForResource returns the tags for a CE resource by ARN.
func (*InMemoryBackend) ProvideAnomalyFeedback ¶
func (b *InMemoryBackend) ProvideAnomalyFeedback(anomalyID, feedback string) error
ProvideAnomalyFeedback persists feedback for an anomaly.
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns the region for this backend instance.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state to JSON. It implements persistence.Persistable.
func (*InMemoryBackend) StartJanitor ¶
func (b *InMemoryBackend) StartJanitor(ctx context.Context, interval time.Duration)
StartJanitor launches a background goroutine that evicts anomalies older than the backend's TTL. It stops when ctx is cancelled.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(resourceARN string, resourceTags map[string]string) error
TagResource adds or updates tags on a CE resource.
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource(resourceARN string, tagKeys []string) error
UntagResource removes tags from a CE resource.
func (*InMemoryBackend) UpdateAnomalyMonitor ¶
func (b *InMemoryBackend) UpdateAnomalyMonitor( monARN, monitorName string, ) (*AnomalyMonitor, error)
UpdateAnomalyMonitor updates the name of an anomaly monitor.
func (*InMemoryBackend) UpdateAnomalySubscription ¶
func (b *InMemoryBackend) UpdateAnomalySubscription( subARN, frequency, subscriptionName string, monitorARNList []string, subscribers []Subscriber, threshold float64, ) (*AnomalySubscription, error)
UpdateAnomalySubscription updates a CE anomaly subscription.
func (*InMemoryBackend) UpdateCostAllocationTagsStatus ¶
func (b *InMemoryBackend) UpdateCostAllocationTagsStatus( updates []CostAllocationTagStatusEntry, ) []CostAllocationTagError
UpdateCostAllocationTagsStatus updates the Active/Inactive status of cost allocation tags. Returns a list of errors for tags that could not be updated.
func (*InMemoryBackend) UpdateCostCategoryDefinition ¶
func (b *InMemoryBackend) UpdateCostCategoryDefinition( catARN, ruleVersion, defaultValue string, rules []CostCategoryRule, splitChargeRules []SplitChargeRule, ) (*CostCategory, error)
UpdateCostCategoryDefinition updates an existing cost category.
type MetricValue ¶
MetricValue holds Amount+Unit for a cost metric.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for the Cost Explorer (Ce) service.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the Cost Explorer service.
type ReservationCoverageAgg ¶
type ReservationCoverageAgg struct {
CoverageHours ReservationCoverageHours `json:"CoverageHours"`
CoverageNormalizedUnits ReservationCoverageNormalizedUnits `json:"CoverageNormalizedUnits"`
CoverageCost ReservationCoverageCost `json:"CoverageCost"`
}
ReservationCoverageAgg holds RI coverage aggregates.
type ReservationCoverageByTime ¶
type ReservationCoverageByTime struct {
TimePeriod map[string]string `json:"TimePeriod"`
Total ReservationCoverageAgg `json:"Total"`
Groups []any `json:"Groups"`
}
ReservationCoverageByTime holds RI coverage for a time period.
type ReservationCoverageCost ¶
type ReservationCoverageCost struct {
OnDemandCost string `json:"OnDemandCost"`
}
ReservationCoverageCost holds cost-based RI coverage.
type ReservationCoverageHours ¶
type ReservationCoverageHours struct {
OnDemandHours string `json:"OnDemandHours"`
ReservedHours string `json:"ReservedHours"`
TotalRunningHours string `json:"TotalRunningHours"`
CoverageHoursPercentage string `json:"CoverageHoursPercentage"`
}
ReservationCoverageHours holds hourly RI coverage data.
type ReservationCoverageNormalizedUnits ¶
type ReservationCoverageNormalizedUnits struct {
OnDemandNormalizedUnits string `json:"OnDemandNormalizedUnits"`
ReservedNormalizedUnits string `json:"ReservedNormalizedUnits"`
TotalRunningNormalizedUnits string `json:"TotalRunningNormalizedUnits"`
CoverageNormalizedUnitsPercentage string `json:"CoverageNormalizedUnitsPercentage"`
}
ReservationCoverageNormalizedUnits holds normalized unit coverage.
type ReservationRecommendation ¶
type ReservationRecommendation struct {
ServiceSpecification map[string]any `json:"ServiceSpecification,omitempty"`
RecommendationSummary map[string]string `json:"RecommendationSummary,omitempty"`
AccountScope string `json:"AccountScope,omitempty"`
LookbackPeriodInDays string `json:"LookbackPeriodInDays,omitempty"`
TermInYears string `json:"TermInYears,omitempty"`
PaymentOption string `json:"PaymentOption,omitempty"`
RecommendationDetails []ReservationRecommendationDetail `json:"RecommendationDetails"`
}
ReservationRecommendation holds a single RI recommendation group.
type ReservationRecommendationDetail ¶
type ReservationRecommendationDetail struct {
AccountID string `json:"AccountId,omitempty"`
InstanceDetails map[string]any `json:"InstanceDetails,omitempty"`
RecommendedNumberOfInstancesToPurchase string `json:"RecommendedNumberOfInstancesToPurchase"`
RecommendedNormalizedUnitsToPurchase string `json:"RecommendedNormalizedUnitsToPurchase"`
MinimumNumberOfInstancesUsedPerHour string `json:"MinimumNumberOfInstancesUsedPerHour"`
MinimumNormalizedUnitsUsedPerHour string `json:"MinimumNormalizedUnitsUsedPerHour"`
MaximumNumberOfInstancesUsedPerHour string `json:"MaximumNumberOfInstancesUsedPerHour"`
MaximumNormalizedUnitsUsedPerHour string `json:"MaximumNormalizedUnitsUsedPerHour"`
AverageNumberOfInstancesUsedPerHour string `json:"AverageNumberOfInstancesUsedPerHour"`
AverageNormalizedUnitsUsedPerHour string `json:"AverageNormalizedUnitsUsedPerHour"`
AverageUtilization string `json:"AverageUtilization"`
EstimatedBreakEvenInMonths string `json:"EstimatedBreakEvenInMonths"`
CurrencyCode string `json:"CurrencyCode"`
EstimatedMonthlySavingsAmount string `json:"EstimatedMonthlySavingsAmount"`
EstimatedMonthlySavingsPercentage string `json:"EstimatedMonthlySavingsPercentage"`
EstimatedMonthlyOnDemandCost string `json:"EstimatedMonthlyOnDemandCost"`
EstimatedReservationCostForLookbackPeriod string `json:"EstimatedReservationCostForLookbackPeriod"`
UpfrontCost string `json:"UpfrontCost"`
RecurringStandardMonthlyCost string `json:"RecurringStandardMonthlyCost"`
}
ReservationRecommendationDetail is one RI recommendation.
type ReservationUtilizationAgg ¶
type ReservationUtilizationAgg struct {
UtilizationPercentage string `json:"UtilizationPercentage"`
PurchasedHours string `json:"PurchasedHours"`
TotalActualHours string `json:"TotalActualHours"`
UnusedHours string `json:"UnusedHours"`
OnDemandCostOfRIHoursUsed string `json:"OnDemandCostOfRIHoursUsed"`
NetRISavings string `json:"NetRISavings"`
TotalPotentialRISavings string `json:"TotalPotentialRISavings"`
AmortizedUpfrontFee string `json:"AmortizedUpfrontFee"`
AmortizedRecurringFee string `json:"AmortizedRecurringFee"`
TotalAmortizedFee string `json:"TotalAmortizedFee"`
RICostForUnusedHours string `json:"RICostForUnusedHours"`
RealizedSavings string `json:"RealizedSavings"`
UnrealizedSavings string `json:"UnrealizedSavings"`
}
ReservationUtilizationAgg holds RI utilization aggregates.
type ReservationUtilizationByTime ¶
type ReservationUtilizationByTime struct {
TimePeriod map[string]string `json:"TimePeriod"`
Total ReservationUtilizationAgg `json:"Total"`
Groups []any `json:"Groups"`
}
ReservationUtilizationByTime holds RI utilization for a time period.
type ResultByTime ¶
type ResultByTime struct {
TimePeriod map[string]string `json:"TimePeriod"`
Total map[string]MetricValue `json:"Total"`
Groups []CostGroup `json:"Groups"`
Estimated bool `json:"Estimated"`
}
ResultByTime represents a single time period in GetCostAndUsage.
type RightsizingCurrentInstance ¶
type RightsizingCurrentInstance struct {
ResourceID string `json:"ResourceId"`
InstanceType string `json:"InstanceType,omitempty"`
MonthlyCost string `json:"MonthlyCost,omitempty"`
CurrencyCode string `json:"CurrencyCode,omitempty"`
}
RightsizingCurrentInstance holds details about the current instance.
type RightsizingModifyDetail ¶
type RightsizingModifyDetail struct {
TargetInstances []RightsizingTargetInstance `json:"TargetInstances"`
}
RightsizingModifyDetail holds modification target options.
type RightsizingRecommendation ¶
type RightsizingRecommendation struct {
ModifyRecommendationDetail *RightsizingModifyDetail `json:"ModifyRecommendationDetail,omitempty"`
TerminateRecommendationDetail *RightsizingTerminateDetail `json:"TerminateRecommendationDetail,omitempty"`
CurrentInstance RightsizingCurrentInstance `json:"CurrentInstance"`
AccountID string `json:"AccountId"`
RightsizingType string `json:"RightsizingType"`
}
RightsizingRecommendation is a single rightsizing recommendation.
type RightsizingTargetInstance ¶
type RightsizingTargetInstance struct {
ResourceDetails map[string]any `json:"ResourceDetails,omitempty"`
EstimatedMonthlyCost string `json:"EstimatedMonthlyCost"`
EstimatedMonthlySavings string `json:"EstimatedMonthlySavings"`
EstimatedSavingsPercentage string `json:"EstimatedSavingsPercentage"`
CurrencyCode string `json:"CurrencyCode"`
DefaultTargetInstance bool `json:"DefaultTargetInstance"`
}
RightsizingTargetInstance is a recommended replacement instance.
type RightsizingTerminateDetail ¶
type RightsizingTerminateDetail struct {
EstimatedMonthlySavings string `json:"EstimatedMonthlySavings,omitempty"`
CurrencyCode string `json:"CurrencyCode,omitempty"`
}
RightsizingTerminateDetail holds termination savings estimate.
type SavingsPlansAmortized ¶
type SavingsPlansAmortized struct {
AmortizedRecurringCommitment string `json:"AmortizedRecurringCommitment"`
AmortizedUpfrontCommitment string `json:"AmortizedUpfrontCommitment"`
TotalAmortizedCommitment string `json:"TotalAmortizedCommitment"`
}
SavingsPlansAmortized holds amortized commitment.
type SavingsPlansGeneration ¶ added in v1.2.0
type SavingsPlansGeneration struct {
RecommendationID string `json:"recommendationId"`
GenerationStatus string `json:"generationStatus"` // PROCESSING|SUCCEEDED|FAILED
GenerationStartedTime string `json:"generationStartedTime"`
GenerationCompletionTime string `json:"generationCompletionTime,omitempty"`
EstimatedCompletionTime string `json:"estimatedCompletionTime"`
}
SavingsPlansGeneration represents a Savings Plans purchase recommendation generation job, matching real AWS CE's GenerationSummary shape (RecommendationId, not GenerationId -- see api_op_StartSavingsPlansPurchaseRecommendationGeneration.go).
type SavingsPlansSavings ¶
type SavingsPlansSavings struct {
NetSavings string `json:"NetSavings"`
OnDemandCostEquivalent string `json:"OnDemandCostEquivalent"`
}
SavingsPlansSavings holds SP savings.
type SavingsPlansUtilizationAgg ¶
type SavingsPlansUtilizationAgg struct {
TotalCommitment string `json:"TotalCommitment"`
UsedCommitment string `json:"UsedCommitment"`
UnusedCommitment string `json:"UnusedCommitment"`
UtilizationPercentage string `json:"UtilizationPercentage"`
}
SavingsPlansUtilizationAgg holds SP utilization aggregates.
type SavingsPlansUtilizationDetail ¶
type SavingsPlansUtilizationDetail struct {
Attributes map[string]string `json:"Attributes,omitempty"`
Utilization SavingsPlansUtilizationAgg `json:"Utilization"`
AmortizedCommitment SavingsPlansAmortized `json:"AmortizedCommitment"`
Savings SavingsPlansSavings `json:"Savings"`
SavingsPlanARN string `json:"SavingsPlanArn"`
}
SavingsPlansUtilizationDetail is a per-plan utilization entry.
type SavingsPlansUtilizationResult ¶
type SavingsPlansUtilizationResult struct {
Utilization SavingsPlansUtilizationAgg `json:"Utilization"`
Savings SavingsPlansSavings `json:"Savings"`
AmortizedCommitment SavingsPlansAmortized `json:"AmortizedCommitment"`
}
SavingsPlansUtilizationResult is the total savings plans utilization.
type SplitChargeRule ¶
type SplitChargeRule struct {
Source string `json:"source"`
Method string `json:"method"`
Targets []string `json:"targets"`
}
SplitChargeRule represents a cost category split charge rule.
type Subscriber ¶
type Subscriber struct {
Address string `json:"address"`
Type string `json:"type"`
Status string `json:"status"`
}
Subscriber represents a CE anomaly subscription notification target.
Source Files
¶
- anomalies.go
- commitment_purchase_analysis.go
- cost_allocation_tags.go
- cost_categories.go
- cost_usage.go
- errors.go
- handler.go
- handler_anomalies.go
- handler_commitment_purchase_analysis.go
- handler_cost_allocation_tags.go
- handler_cost_categories.go
- handler_cost_usage.go
- handler_reservations.go
- handler_savings_plans.go
- handler_tags.go
- models.go
- persistence.go
- provider.go
- reservations.go
- savings_plans.go
- store.go
- store_setup.go
- tags.go