mediastore

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 22 Imported by: 0

README

MediaStore

Parity grade: B · SDK aws-sdk-go-v2/service/mediastore@v1.29.23 · last audited 2026-07-13 (dfd2cb83)

Coverage

Metric Value
Operations audited 21 (21 ok)
Feature families 6 (6 ok)
Known gaps 3
Deferred items 0
Resource leaks clean
Known gaps
  • MetricPolicyRule.ObjectGroup/ObjectGroupName character-set and length limits (900/30 chars) not enforced server-side -- unreachable via a real SDK client (client-side validators.go only requires non-nil), so low value; only affects raw-HTTP callers that bypass the SDK. (bd: none filed, low priority)
  • CorsPolicy rule-count limit (AWS allows up to 100 rules) not enforced. Same reasoning: no observed client-visible impact. (bd: none filed, low priority)
  • Container lifecycle is instantaneous (CREATING/DELETING transient states are never observed -- CreateContainer returns ACTIVE immediately, DeleteContainer removes synchronously). This is strictly more convenient for callers/waiters than real AWS's async transition and never causes a hang or wrong terminal state, so left as-is; noted here so a future auditor doesn't mistake it for the "stuck in CREATING" bug class.

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrContainerNotFound is returned when a container does not exist.
	ErrContainerNotFound = awserr.New(
		"container not found",
		awserr.ErrNotFound,
	)
	// ErrContainerAlreadyExists is returned when a container already exists.
	ErrContainerAlreadyExists = awserr.New(
		"container already exists",
		awserr.ErrAlreadyExists,
	)
	// ErrPolicyNotFound is returned when no container policy has been set.
	ErrPolicyNotFound = awserr.New(
		"no policy found for container",
		awserr.ErrNotFound,
	)
	// ErrCorsPolicyNotFound is returned when no CORS policy has been set.
	ErrCorsPolicyNotFound = awserr.New(
		"no CORS policy found for container",
		awserr.ErrNotFound,
	)
	// ErrLifecyclePolicyNotFound is returned when no lifecycle policy has been set.
	ErrLifecyclePolicyNotFound = awserr.New(
		"no lifecycle policy found for container",
		awserr.ErrNotFound,
	)
	// ErrMetricPolicyNotFound is returned when no metric policy has been set.
	ErrMetricPolicyNotFound = awserr.New(
		"no metric policy found for container",
		awserr.ErrNotFound,
	)
	// ErrMissingContainerName is returned when the container name is missing.
	ErrMissingContainerName = errors.New("ContainerName is required")
	// ErrInvalidContainerName is returned when the container name is invalid.
	//
	// The message intentionally does NOT repeat the "ValidationException:" type
	// prefix: writeBackendError already carries that in the response envelope's
	// __type field (see JSONErrorResponse), so baking it into the message text
	// too would double it up on the wire (e.g. "ValidationException:
	// ValidationException: ...", as every AWS SDK formats client-visible errors
	// as "api error <Type>: <message>").
	ErrInvalidContainerName = errors.New(
		"container name must be 1-255 characters" +
			" and contain only letters, numbers, hyphens, and underscores",
	)
	// ErrInvalidPolicy is returned when a policy string is not valid JSON.
	ErrInvalidPolicy = errors.New("policy must be valid JSON")
	// ErrCorsRuleInvalid is returned when a CORS rule is missing required fields.
	ErrCorsRuleInvalid = errors.New(
		"each CORS rule must have at least one AllowedOrigin and one AllowedHeader",
	)
	// ErrInvalidMetricPolicy is returned when ContainerLevelMetrics has an invalid value.
	ErrInvalidMetricPolicy = errors.New(
		"ContainerLevelMetrics must be ENABLED or DISABLED",
	)
	// ErrTooManyMetricRules is returned when more than 5 metric policy rules are provided.
	ErrTooManyMetricRules = errors.New(
		"metric policy may have at most 5 rules",
	)
	// ErrEmptyTagKey is returned when a tag with an empty key is provided.
	ErrEmptyTagKey = errors.New("tag key must not be empty")
)

Functions

This section is empty.

Types

type Container

type Container struct {
	CreationTime         *time.Time
	Tags                 map[string]string
	MetricPolicy         *MetricPolicy // cached parsed policy; nil means not set
	ARN                  string
	ContainerPolicy      string
	LifecyclePolicy      string
	Endpoint             string
	Name                 string
	Status               string
	CorsPolicy           []*CorsRule // cached parsed rules; nil means not set
	AccessLoggingEnabled bool
}

Container represents an AWS Elemental MediaStore container.

type CorsRule

type CorsRule struct {
	AllowedHeaders []string `json:"AllowedHeaders"`
	AllowedMethods []string `json:"AllowedMethods,omitempty"`
	AllowedOrigins []string `json:"AllowedOrigins"`
	ExposeHeaders  []string `json:"ExposeHeaders,omitempty"`
	MaxAgeSeconds  int      `json:"MaxAgeSeconds,omitempty"`
}

CorsRule represents a single CORS rule.

type ExportedContainer

type ExportedContainer = Container

ExportedContainer is a compatibility alias used by the dashboard package.

type Handler

type Handler struct {
	Backend       StorageBackend
	AccountID     string
	DefaultRegion string
}

Handler is the HTTP handler for the AWS Elemental MediaStore JSON 1.1 API.

func NewHandler

func NewHandler(backend StorageBackend) *Handler

NewHandler creates a new MediaStore handler.

func (*Handler) ChaosOperations

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

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

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

ChaosRegions returns all regions this handler handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

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

ExtractOperation extracts the operation name from the X-Amz-Target header.

func (*Handler) ExtractResource

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

ExtractResource extracts the container name from the request body.

func (*Handler) GetSupportedOperations

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

GetSupportedOperations returns the list of supported MediaStore operations.

func (*Handler) Handler

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

Handler returns the Echo handler function for MediaStore requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

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 returns a function that matches MediaStore JSON 1.1 API requests.

func (*Handler) Snapshot

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

Snapshot implements persistence.Persistable by delegating to the backend. MediaStore had no persistence at all before Phase 3.3 -- neither Handler nor InMemoryBackend implemented Snapshot/Restore, so cli.go's generic setupPersistence (which type-asserts the registered service.Registerable, i.e. the Handler, for a Snapshot/Restore pair) never picked MediaStore up: dead wiring, with no persistence underneath it either. This delegation (matching the codecommit/cleanrooms pattern) wires MediaStore into persistence for the first time.

type InMemoryBackend

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

InMemoryBackend is the in-memory implementation of StorageBackend.

State is partitioned by region: containers[region] gives the store.Table of containers stored within that region (see store_setup.go for why this is a per-region map rather than a single flat table).

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates a new in-memory MediaStore backend.

func (*InMemoryBackend) CreateContainer

func (b *InMemoryBackend) CreateContainer(
	ctx context.Context,
	accountID, name string,
	tags map[string]string,
) (*Container, error)

CreateContainer creates a new MediaStore container in the ctx region.

func (*InMemoryBackend) DeleteContainer

func (b *InMemoryBackend) DeleteContainer(ctx context.Context, name string) error

DeleteContainer removes a container from the ctx region.

func (*InMemoryBackend) DeleteContainerPolicy

func (b *InMemoryBackend) DeleteContainerPolicy(ctx context.Context, name string) error

DeleteContainerPolicy removes the container access policy.

func (*InMemoryBackend) DeleteCorsPolicy

func (b *InMemoryBackend) DeleteCorsPolicy(ctx context.Context, name string) error

DeleteCorsPolicy removes the CORS policy from a container.

func (*InMemoryBackend) DeleteLifecyclePolicy

func (b *InMemoryBackend) DeleteLifecyclePolicy(ctx context.Context, name string) error

DeleteLifecyclePolicy removes the lifecycle policy from a container.

func (*InMemoryBackend) DeleteMetricPolicy

func (b *InMemoryBackend) DeleteMetricPolicy(ctx context.Context, name string) error

DeleteMetricPolicy removes the metric policy from a container.

func (*InMemoryBackend) DescribeContainer

func (b *InMemoryBackend) DescribeContainer(ctx context.Context, name string) (*Container, error)

DescribeContainer returns details about a container in the ctx region.

func (*InMemoryBackend) GetContainerPolicy

func (b *InMemoryBackend) GetContainerPolicy(ctx context.Context, name string) (string, error)

GetContainerPolicy retrieves the container access policy.

func (*InMemoryBackend) GetCorsPolicy

func (b *InMemoryBackend) GetCorsPolicy(ctx context.Context, name string) ([]CorsRule, error)

GetCorsPolicy retrieves the CORS policy for a container.

func (*InMemoryBackend) GetLifecyclePolicy

func (b *InMemoryBackend) GetLifecyclePolicy(ctx context.Context, name string) (string, error)

GetLifecyclePolicy retrieves the lifecycle policy for a container.

func (*InMemoryBackend) GetMetricPolicy

func (b *InMemoryBackend) GetMetricPolicy(ctx context.Context, name string) (MetricPolicy, error)

GetMetricPolicy retrieves the metric policy for a container.

func (*InMemoryBackend) ListContainers

func (b *InMemoryBackend) ListContainers(
	ctx context.Context,
	nextToken string,
	maxResults int,
) ([]*Container, string, error)

ListContainers returns paginated containers in the ctx region sorted by name.

func (*InMemoryBackend) ListTagsForResource

func (b *InMemoryBackend) ListTagsForResource(
	ctx context.Context,
	resourceARN string,
) (map[string]string, error)

ListTagsForResource returns tags for a container identified by ARN.

func (*InMemoryBackend) PutContainerPolicy

func (b *InMemoryBackend) PutContainerPolicy(ctx context.Context, name, policy string) error

PutContainerPolicy stores a container access policy.

func (*InMemoryBackend) PutCorsPolicy

func (b *InMemoryBackend) PutCorsPolicy(ctx context.Context, name string, rules []CorsRule) error

PutCorsPolicy stores a CORS policy for a container.

func (*InMemoryBackend) PutLifecyclePolicy

func (b *InMemoryBackend) PutLifecyclePolicy(ctx context.Context, name, policy string) error

PutLifecyclePolicy stores a lifecycle policy for a container.

func (*InMemoryBackend) PutMetricPolicy

func (b *InMemoryBackend) PutMetricPolicy(ctx context.Context, name string, policy MetricPolicy) error

PutMetricPolicy stores a metric policy for a container.

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 serializes the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) StartAccessLogging

func (b *InMemoryBackend) StartAccessLogging(ctx context.Context, name string) error

StartAccessLogging enables access logging for a container.

func (*InMemoryBackend) StopAccessLogging

func (b *InMemoryBackend) StopAccessLogging(ctx context.Context, name string) error

StopAccessLogging disables access logging for a container.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(ctx context.Context, resourceARN string, tags map[string]string) error

TagResource adds or updates tags on a container identified by ARN.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error

UntagResource removes tags from a container identified by ARN.

type MetricPolicy

type MetricPolicy struct {
	ContainerLevelMetrics string             `json:"ContainerLevelMetrics"`
	MetricPolicyRules     []MetricPolicyRule `json:"MetricPolicyRules,omitempty"`
}

MetricPolicy represents a metric policy.

type MetricPolicyRule

type MetricPolicyRule struct {
	ObjectGroup     string `json:"ObjectGroup"`
	ObjectGroupName string `json:"ObjectGroupName"`
}

MetricPolicyRule represents a metric policy rule.

type Provider

type Provider struct{}

Provider implements service.Provider for the MediaStore service.

func (*Provider) Init

Init initializes the MediaStore service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type StorageBackend

type StorageBackend interface {
	// Snapshot and Restore implement persistence.Persistable. Handler
	// delegates to them (see persistence.go) so cli.go's generic
	// setupPersistence picks MediaStore up.
	Snapshot(ctx context.Context) []byte
	Restore(ctx context.Context, data []byte) error

	CreateContainer(ctx context.Context, accountID, name string, tags map[string]string) (*Container, error)
	DeleteContainer(ctx context.Context, name string) error
	DescribeContainer(ctx context.Context, name string) (*Container, error)
	ListContainers(ctx context.Context, nextToken string, maxResults int) ([]*Container, string, error)
	PutContainerPolicy(ctx context.Context, name, policy string) error
	GetContainerPolicy(ctx context.Context, name string) (string, error)
	DeleteContainerPolicy(ctx context.Context, name string) error
	PutCorsPolicy(ctx context.Context, name string, rules []CorsRule) error
	GetCorsPolicy(ctx context.Context, name string) ([]CorsRule, error)
	DeleteCorsPolicy(ctx context.Context, name string) error
	PutLifecyclePolicy(ctx context.Context, name, policy string) error
	GetLifecyclePolicy(ctx context.Context, name string) (string, error)
	DeleteLifecyclePolicy(ctx context.Context, name string) error
	PutMetricPolicy(ctx context.Context, name string, policy MetricPolicy) error
	GetMetricPolicy(ctx context.Context, name string) (MetricPolicy, error)
	DeleteMetricPolicy(ctx context.Context, name string) error
	StartAccessLogging(ctx context.Context, name string) error
	StopAccessLogging(ctx context.Context, name string) error
	TagResource(ctx context.Context, resourceARN string, tags map[string]string) error
	UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error
	ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)
}

StorageBackend is the interface for the MediaStore in-memory backend.

All methods take a context.Context whose resolved AWS region (stored under regionContextKey) partitions state: containers created in one region are invisible to every other region.

Jump to

Keyboard shortcuts

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