forecast

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 21 Imported by: 0

README

Forecast

Parity grade: A · SDK aws-sdk-go-v2/service/forecast@v1.42.0 · last audited 2026-07-23 (80757023)

Coverage

Metric Value
Operations audited 20 (20 ok)
Feature families 7 (7 ok)
Known gaps 3
Deferred items 0
Resource leaks clean
Known gaps
    • CreatePredictor's InputDataConfig.DatasetGroupArn and CreateAutoPredictor's DataConfig.DatasetGroupArn are nested FK references (not top-level fields) and are not existence-validated -- a Predictor can be created against a DatasetGroupArn that was never created. Every other required ARN reference in the API (DatasetImportJob.DatasetArn, Forecast.PredictorArn, ForecastExportJob.ForecastArn, PredictorBacktestExportJob.PredictorArn, Explainability.ResourceArn, ExplainabilityExport.ExplainabilityArn, Monitor.ResourceArn, WhatIfAnalysis.ForecastArn, WhatIfForecast.WhatIfAnalysisArn, WhatIfForecastExport.WhatIfForecastArns) is now FK-validated (see ops table) -- this is the one deliberately out-of-scope exception, called out explicitly rather than silently skipped (see validation.go's package doc comment).
    • CreateDatasetGroup's (and UpdateDatasetGroup's) DatasetArns list is not existence-validated -- a DatasetGroup can reference DatasetArns that were never created. Out of scope this pass (not one of the three named gap/deferred items from the prior audit).
    • Delete* never returns ResourceInUseException for a resource that still has dependents (e.g. deleting a Predictor that still has Forecasts). This is DELIBERATE, not an oversight: the real Amazon Forecast SDK doc comments for every Delete* op (DeletePredictor, DeleteDatasetGroup, DeleteForecast, ...) describe the ResourceInUseException precondition purely in terms of the target resource's OWN status ("you can delete only predictor that have a status of ACTIVE or CREATE_FAILED"), never in terms of dependents -- DeleteDatasetGroup's doc comment explicitly says "This operation deletes only the dataset group, not the datasets in the group" with no blocking behavior. The PRIOR audit's framing of this gap ("Delete* never returns ResourceInUseException for a resource that still has dependents") does not match the real API and has been corrected: what real AWS actually models is a self-status precondition, which this pass implemented (see validateDeletableLocked in validation.go and the Delete* ops table above).

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a requested Forecast resource is absent.
	ErrNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound)
	// ErrAlreadyExists is returned when a Forecast resource name already exists.
	ErrAlreadyExists = awserr.New("ResourceAlreadyExistsException", awserr.ErrConflict)
	// ErrValidation is returned when a Forecast request is invalid.
	ErrValidation = awserr.New("InvalidInputException", awserr.ErrInvalidParameter)
	// ErrInvalidNextToken is returned when a List* NextToken cannot be decoded.
	// Real Amazon Forecast models InvalidNextTokenException on every List operation.
	ErrInvalidNextToken = awserr.New("InvalidNextTokenException", awserr.ErrInvalidParameter)
	// ErrResourceInUse is returned when a Delete* operation targets a resource
	// that is not yet in a deletable state (e.g. still CREATE_PENDING). Real
	// Amazon Forecast models ResourceInUseException on every Delete operation
	// (e.g. "You can delete only predictor that have a status of ACTIVE or
	// CREATE_FAILED", per the DeletePredictor API doc).
	ErrResourceInUse = awserr.New("ResourceInUseException", awserr.ErrConflict)
)
View Source
var ErrNilAppContext = errors.New("forecast: nil AppContext")

ErrNilAppContext is returned when Init receives nil context.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Backend *InMemoryBackend
	// contains filtered or unexported fields
}

Handler serves Amazon Forecast JSON protocol operations.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates Forecast HTTP handler.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations returns supported fault injection operations.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns regions handled by instance.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns fault injection service identifier.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation extracts operation from Forecast target.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(_ *echo.Context) string

ExtractResource returns no generic resource identifier.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations reports implemented Amazon Forecast operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns Echo handler.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns Forecast header match priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns service registry name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all backend state for the /_gopherstack/reset test hook.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher matches Forecast target requests.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend. Handler previously had no Snapshot/Restore of its own -- and neither did InMemoryBackend -- so cli.go's generic setupPersistence never picked Forecast up at all: dead wiring, with no persistence underneath it either. This delegation (matching the cleanrooms/codecommit/codepipeline/emr/ workmail pattern) is what wires Forecast into persistence for the first time.

type InMemoryBackend

type InMemoryBackend struct {
	// contains filtered or unexported fields
}

InMemoryBackend stores Amazon Forecast state with concurrency-safe transitions.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend returns a stateful Amazon Forecast backend.

func (*InMemoryBackend) AccountID

func (b *InMemoryBackend) AccountID() string

AccountID returns backend account.

func (*InMemoryBackend) DeleteResourceTree

func (b *InMemoryBackend) DeleteResourceTree(targetARN string) error

DeleteResourceTree deletes a resource and all dependent child resources transitively, mirroring AWS Forecast behavior.

func (*InMemoryBackend) GetAccuracyMetrics

func (b *InMemoryBackend) GetAccuracyMetrics(predictorArn string) (map[string]any, error)

GetAccuracyMetrics returns deterministic backtest accuracy metrics for a predictor, modeled on the AWS Forecast GetAccuracyMetrics response shape (PredictorEvaluationResults -> TestWindows -> Metrics with RMSE, weighted quantile losses, and WAPE/MAPE/MASE error metrics). Values are derived from a stable hash of the predictor ARN so repeated calls return identical numbers, which is what a Terraform/SDK client comparing state expects. This exceeds LocalStack, which returns no evaluation results at all.

func (*InMemoryBackend) ListTagsForResource

func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)

ListTagsForResource lists tags for a resource. Real Amazon Forecast returns ResourceNotFoundException when resourceARN does not identify an existing resource.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns backend region.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all in-memory Forecast state. It supports the /_gopherstack/reset test hook so suites start from a clean slate.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore deserializes backend state from a snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serializes the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(resourceARN string, tags map[string]string) error

TagResource adds tags to a resource. Real Amazon Forecast returns ResourceNotFoundException when resourceARN does not identify an existing resource -- TagResource does not silently create tag state for ARNs no resource ever owned.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(resourceARN string, tagKeys []string) error

UntagResource removes tags from a resource. Real Amazon Forecast returns ResourceNotFoundException when resourceARN does not identify an existing resource.

func (*InMemoryBackend) UpdateResourceStatus

func (b *InMemoryBackend) UpdateResourceStatus(resourceARN, newStatus string) error

UpdateResourceStatus handles StopResource and ResumeResource.

type MonitorEvaluation

type MonitorEvaluation struct {
	CreationTime    time.Time `json:"CreationTime"`
	EvaluationTime  time.Time `json:"EvaluationTime"`
	PredictorEvent  any       `json:"PredictorEvent,omitempty"`
	Message         string    `json:"Message,omitempty"`
	MonitorArn      string    `json:"MonitorArn"`
	MonitorName     string    `json:"MonitorName"`
	ResourceArn     string    `json:"ResourceArn,omitempty"`
	Status          string    `json:"Status"`
	EvaluationState string    `json:"EvaluationState"`
	MetricResults   []any     `json:"MetricResults"`
}

MonitorEvaluation represents one completed evaluation emitted by a predictor monitor.

type Provider

type Provider struct{}

Provider initializes Amazon Forecast.

func (*Provider) Init

Init initializes Amazon Forecast backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns provider name.

type Resource

type Resource struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	Data      map[string]any
	ARN       string
	Name      string
	Status    string
	Kind      resourceKind
}

Resource stores one Forecast API object with AWS response-shaped attributes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL