Documentation
¶
Index ¶
- func HandleRESTRequest(ctx *service.RequestContext, store *Store, locator ServiceLocator) (*service.Response, error)
- type CacheBehavior
- type CachePolicy
- type CloudFrontService
- func (s *CloudFrontService) Actions() []service.Action
- func (s *CloudFrontService) HandleRequest(ctx *service.RequestContext) (*service.Response, error)
- func (s *CloudFrontService) HealthCheck() error
- func (s *CloudFrontService) Name() string
- func (s *CloudFrontService) ResourceSchemas() []schema.ResourceSchema
- func (s *CloudFrontService) SetLocator(locator ServiceLocator)
- type CustomOriginConfig
- type Distribution
- type ForwardedValues
- type Function
- type Invalidation
- type Origin
- type OriginRequestPolicy
- type S3OriginConfig
- type ServiceLocator
- type Store
- func (s *Store) CreateCachePolicy(name, comment string, defaultTTL, maxTTL, minTTL int64, params map[string]any) (*CachePolicy, bool)
- func (s *Store) CreateDistribution(callerRef, comment, defaultRootObject, priceClass string, enabled bool, ...) *Distribution
- func (s *Store) CreateFunction(name, comment, runtime string, code []byte) (*Function, bool)
- func (s *Store) CreateInvalidation(distID, callerRef string, paths []string) (*Invalidation, bool)
- func (s *Store) CreateOriginRequestPolicy(name, comment string, ...) (*OriginRequestPolicy, bool)
- func (s *Store) DeleteCachePolicy(id, ifMatch string) (bool, error)
- func (s *Store) DeleteDistribution(id, ifMatch string) (bool, error)
- func (s *Store) DeleteFunction(name, ifMatch string) (bool, error)
- func (s *Store) DeleteOriginRequestPolicy(id, ifMatch string) (bool, error)
- func (s *Store) FindByCallerReference(callerRef string) (*Distribution, bool)
- func (s *Store) GetCachePolicy(id string) (*CachePolicy, bool)
- func (s *Store) GetDistribution(id string) (*Distribution, bool)
- func (s *Store) GetFunction(name, stage string) (*Function, bool)
- func (s *Store) GetInvalidation(distID, invID string) (*Invalidation, bool)
- func (s *Store) GetOriginRequestPolicy(id string) (*OriginRequestPolicy, bool)
- func (s *Store) ListCachePolicies() []*CachePolicy
- func (s *Store) ListDistributions() []*Distribution
- func (s *Store) ListFunctions(stage string) []*Function
- func (s *Store) ListInvalidations(distID string) ([]*Invalidation, bool)
- func (s *Store) ListOriginRequestPolicies() []*OriginRequestPolicy
- func (s *Store) ListTagsForResource(arn string) (map[string]string, bool)
- func (s *Store) PublishFunction(name, ifMatch string) (*Function, bool, error)
- func (s *Store) TagResource(arn string, tags map[string]string) bool
- func (s *Store) TestFunction(name, stage string, eventObject []byte) (map[string]any, bool)
- func (s *Store) UntagResource(arn string, keys []string) bool
- func (s *Store) UpdateCachePolicy(id, ifMatch, name, comment string, defaultTTL, maxTTL, minTTL int64, ...) (*CachePolicy, bool, error)
- func (s *Store) UpdateDistribution(id, ifMatch, comment, defaultRootObject, priceClass string, enabled *bool, ...) (*Distribution, bool, error)
- func (s *Store) UpdateFunction(name, ifMatch, comment, runtime string, code []byte) (*Function, bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleRESTRequest ¶
func HandleRESTRequest(ctx *service.RequestContext, store *Store, locator ServiceLocator) (*service.Response, error)
HandleRESTRequest routes CloudFront REST-XML requests based on path and method.
Types ¶
type CacheBehavior ¶
type CacheBehavior struct {
PathPattern string
TargetOriginID string
ViewerProtocolPolicy string
AllowedMethods []string
CachedMethods []string
ForwardedValues *ForwardedValues
MinTTL int64
MaxTTL int64
DefaultTTL int64
Compress bool
}
CacheBehavior represents a cache behavior.
type CachePolicy ¶
type CachePolicy struct {
ID string
Name string
Comment string
DefaultTTL int64
MaxTTL int64
MinTTL int64
ParametersInCacheKeyAndForwardedToOrigin map[string]any
ETag string
LastModified time.Time
}
CachePolicy represents a CloudFront cache policy.
type CloudFrontService ¶
type CloudFrontService struct {
// contains filtered or unexported fields
}
CloudFrontService is the cloudmock implementation of the AWS CloudFront API.
func New ¶
func New(accountID, region string) *CloudFrontService
New returns a new CloudFrontService for the given AWS account ID and region.
func NewWithLocator ¶
func NewWithLocator(accountID, region string, locator ServiceLocator) *CloudFrontService
NewWithLocator returns a new CloudFrontService with a service locator for cross-service communication.
func (*CloudFrontService) Actions ¶
func (s *CloudFrontService) Actions() []service.Action
Actions returns the list of CloudFront API actions supported by this service. CloudFront uses REST-XML path-based routing, so these are descriptive only.
func (*CloudFrontService) HandleRequest ¶
func (s *CloudFrontService) HandleRequest(ctx *service.RequestContext) (*service.Response, error)
HandleRequest routes an incoming CloudFront request to the appropriate handler. CloudFront uses REST-XML path-based routing.
func (*CloudFrontService) HealthCheck ¶
func (s *CloudFrontService) HealthCheck() error
HealthCheck always returns nil (no external dependencies).
func (*CloudFrontService) Name ¶
func (s *CloudFrontService) Name() string
Name returns the AWS service name used for routing.
func (*CloudFrontService) ResourceSchemas ¶
func (s *CloudFrontService) ResourceSchemas() []schema.ResourceSchema
ResourceSchemas returns the schema for CloudFront resource types.
func (*CloudFrontService) SetLocator ¶
func (s *CloudFrontService) SetLocator(locator ServiceLocator)
SetLocator sets the service locator for cross-service communication (S3/ELB origin validation).
type CustomOriginConfig ¶
CustomOriginConfig holds custom origin settings.
type Distribution ¶
type Distribution struct {
ID string
ARN string
DomainName string
Status string // Deployed, InProgress
Enabled bool
Comment string
DefaultRootObject string
PriceClass string
Origins []Origin
DefaultCacheBehavior *CacheBehavior
CacheBehaviors []CacheBehavior
CallerReference string
ETag string
LastModified time.Time
Tags map[string]string
Lifecycle *lifecycle.Machine
}
Distribution represents a CloudFront distribution.
type ForwardedValues ¶
type ForwardedValues struct {
QueryString bool
Cookies string // none, whitelist, all
Headers []string
}
ForwardedValues controls what is forwarded to the origin.
type Function ¶
type Function struct {
Name string
Comment string
Runtime string // cloudfront-js-1.0, cloudfront-js-2.0
Stage string // DEVELOPMENT, LIVE
Status string // UNPUBLISHED, DEPLOYED
ARN string
FunctionCode []byte
CreatedAt time.Time
LastModifiedAt time.Time
ETag string
}
Function represents a CloudFront Function.
type Invalidation ¶
type Invalidation struct {
ID string
DistributionID string
Status string // InProgress, Completed
CallerReference string
Paths []string
CreateTime time.Time
Lifecycle *lifecycle.Machine
}
Invalidation represents a CloudFront invalidation.
type Origin ¶
type Origin struct {
ID string
DomainName string
OriginPath string
S3Config *S3OriginConfig
CustomConfig *CustomOriginConfig
}
Origin represents a CloudFront origin.
type OriginRequestPolicy ¶
type OriginRequestPolicy struct {
ID string
Name string
Comment string
HeadersConfig map[string]any
CookiesConfig map[string]any
QueryStringsConfig map[string]any
ETag string
LastModified time.Time
}
OriginRequestPolicy represents a CloudFront origin request policy.
type S3OriginConfig ¶
type S3OriginConfig struct {
OriginAccessIdentity string
}
S3OriginConfig holds S3-specific origin settings.
type ServiceLocator ¶
ServiceLocator provides access to other services for cross-service communication.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages all CloudFront resources.
func (*Store) CreateCachePolicy ¶
func (*Store) CreateDistribution ¶
func (s *Store) CreateDistribution(callerRef, comment, defaultRootObject, priceClass string, enabled bool, origins []Origin, defaultBehavior *CacheBehavior, behaviors []CacheBehavior) *Distribution
func (*Store) CreateFunction ¶
func (*Store) CreateInvalidation ¶
func (s *Store) CreateInvalidation(distID, callerRef string, paths []string) (*Invalidation, bool)
func (*Store) CreateOriginRequestPolicy ¶
func (*Store) DeleteCachePolicy ¶
func (*Store) DeleteDistribution ¶
DeleteDistribution removes a distribution. Returns specific error strings for not-found or not-disabled cases.
func (*Store) DeleteOriginRequestPolicy ¶
func (*Store) FindByCallerReference ¶
func (s *Store) FindByCallerReference(callerRef string) (*Distribution, bool)
FindByCallerReference returns an existing distribution with the same CallerReference, if any.
func (*Store) GetCachePolicy ¶
func (s *Store) GetCachePolicy(id string) (*CachePolicy, bool)
func (*Store) GetDistribution ¶
func (s *Store) GetDistribution(id string) (*Distribution, bool)
func (*Store) GetInvalidation ¶
func (s *Store) GetInvalidation(distID, invID string) (*Invalidation, bool)
func (*Store) GetOriginRequestPolicy ¶
func (s *Store) GetOriginRequestPolicy(id string) (*OriginRequestPolicy, bool)
func (*Store) ListCachePolicies ¶
func (s *Store) ListCachePolicies() []*CachePolicy
func (*Store) ListDistributions ¶
func (s *Store) ListDistributions() []*Distribution
func (*Store) ListFunctions ¶
func (*Store) ListInvalidations ¶
func (s *Store) ListInvalidations(distID string) ([]*Invalidation, bool)
func (*Store) ListOriginRequestPolicies ¶
func (s *Store) ListOriginRequestPolicies() []*OriginRequestPolicy
func (*Store) ListTagsForResource ¶
func (*Store) PublishFunction ¶
func (*Store) TestFunction ¶
TestFunction simulates running a CloudFront function against test event data. Returns computed result (event echo) or error.
func (*Store) UpdateCachePolicy ¶
func (*Store) UpdateDistribution ¶
func (s *Store) UpdateDistribution(id, ifMatch, comment, defaultRootObject, priceClass string, enabled *bool, origins []Origin, defaultBehavior *CacheBehavior, behaviors []CacheBehavior) (*Distribution, bool, error)
UpdateDistribution updates a distribution. Returns (dist, true) on success, (nil, false) if not found, and specific errors for ETag/enabled state issues.