Documentation
¶
Index ¶
- Variables
- type AppliedValue
- type Association
- type AutoManagement
- type AutoManagementInput
- type AutoManagementView
- type Catalog
- type ExclusionEntry
- 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(c *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) AccountID() string
- func (b *InMemoryBackend) AssociateTemplate(ctx context.Context) error
- func (b *InMemoryBackend) CreateSupportCase(ctx context.Context, requestID string) error
- func (b *InMemoryBackend) DeleteTemplateItem(ctx context.Context, region, serviceCode, quotaCode string) error
- func (b *InMemoryBackend) DisassociateTemplate(ctx context.Context) error
- func (b *InMemoryBackend) GetAutoManagement(ctx context.Context) AutoManagementView
- func (b *InMemoryBackend) GetDefaultQuota(ctx context.Context, serviceCode, quotaCode string) (QuotaView, error)
- func (b *InMemoryBackend) GetReport(ctx context.Context, id, token string, maxResults *int32) (ReportPage, error)
- func (b *InMemoryBackend) GetRequest(ctx context.Context, id string) (RequestView, error)
- func (b *InMemoryBackend) GetServiceQuota(ctx context.Context, serviceCode, quotaCode, contextID string) (QuotaView, error)
- func (b *InMemoryBackend) GetTemplateItem(ctx context.Context, region, serviceCode, quotaCode string) (TemplateView, error)
- func (b *InMemoryBackend) ListDefaultQuotas(ctx context.Context, serviceCode, token string, maxResults *int32) (page.Page[QuotaView], error)
- func (b *InMemoryBackend) ListRequests(ctx context.Context, f RequestFilter, token string, maxResults *int32) (page.Page[RequestView], error)
- func (b *InMemoryBackend) ListServiceQuotas(ctx context.Context, serviceCode, quotaCode, level, token string, ...) (page.Page[QuotaView], error)
- func (b *InMemoryBackend) ListServices(token string, maxResults *int32) (page.Page[ServiceDef], error)
- func (b *InMemoryBackend) ListTagsForResource(ctx context.Context, resource string) (map[string]string, error)
- func (b *InMemoryBackend) ListTemplateItems(ctx context.Context, region, serviceCode, token string, maxResults *int32) (page.Page[TemplateView], error)
- func (b *InMemoryBackend) PutTemplateItem(ctx context.Context, region, serviceCode, quotaCode string, desired *float64) (TemplateView, error)
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) RequestIncrease(ctx context.Context, serviceCode, quotaCode string, desired *float64, ...) (RequestView, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)
- func (b *InMemoryBackend) SetOrgDirectory(d OrgDirectory)
- func (b *InMemoryBackend) SetUsageSource(u UsageSource)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) StartAutoManagement(ctx context.Context, in AutoManagementInput) error
- func (b *InMemoryBackend) StartReport(ctx context.Context) (Report, error)
- func (b *InMemoryBackend) StopAutoManagement(ctx context.Context) error
- func (b *InMemoryBackend) TagResource(ctx context.Context, resource string, add map[string]string) error
- func (b *InMemoryBackend) TemplateAssociation(ctx context.Context) (string, error)
- func (b *InMemoryBackend) UntagResource(ctx context.Context, resource string, keys []string) error
- func (b *InMemoryBackend) UpdateAutoManagement(ctx context.Context, in AutoManagementInput) error
- type OrgDirectory
- type OrgInfo
- type Provider
- type QuotaDef
- type QuotaView
- type Report
- type ReportPage
- type Request
- type RequestFilter
- type RequestView
- type ResourceTags
- type ServiceDef
- type TemplateItem
- type TemplateView
- type UsageMetric
- type UsageSource
- type UtilizationEntry
Constants ¶
This section is empty.
Variables ¶
var ( ErrAccessDenied = errors.New("access denied") ErrAWSServiceAccessNotEnabled = errors.New("service access is not enabled") ErrIllegalArgument = errors.New("illegal argument") ErrInvalidPaginationToken = errors.New("invalid pagination token") ErrInvalidResourceState = errors.New("invalid resource state") ErrNoAvailableOrganization = errors.New("no available organization") ErrNoSuchResource = errors.New("no such resource") ErrOrganizationNotInAllFeaturesMode = errors.New("organization is not in all features mode") ErrQuotaExceeded = errors.New("quota exceeded") ErrResourceAlreadyExists = errors.New("resource already exists") ErrServiceQuotaTemplateNotInUse = errors.New("quota request template is not in use") ErrTooManyTags = errors.New("too many tags") )
Sentinels, one per exception the pinned SDK models that this service raises.
Functions ¶
This section is empty.
Types ¶
type AppliedValue ¶
type AppliedValue struct {
Key string `json:"key"`
Account string `json:"account"`
Region string `json:"region"`
ServiceCode string `json:"serviceCode"`
QuotaCode string `json:"quotaCode"`
Value float64 `json:"value"`
}
AppliedValue overrides a quota's default for one account and Region.
type Association ¶
Association records whether an account's quota request template is associated with its organization.
type AutoManagement ¶
type AutoManagement struct {
Exclusions map[string][]string `json:"exclusions,omitempty"`
Key string `json:"key"`
Account string `json:"account"`
Region string `json:"region"`
OptInLevel string `json:"optInLevel"`
OptInType string `json:"optInType"`
Status string `json:"status"`
NotificationArn string `json:"notificationArn,omitempty"`
}
AutoManagement is the automatic quota management configuration of an account in a Region.
type AutoManagementInput ¶
type AutoManagementInput struct {
Exclusions map[string][]string
NotificationArn *string
OptInLevel string
OptInType string
}
AutoManagementInput carries the editable settings of StartAutoManagement and UpdateAutoManagement.
type AutoManagementView ¶
type AutoManagementView struct {
Exclusions map[string][]ExclusionEntry
Config AutoManagement
}
AutoManagementView is the automatic management configuration with resolved exclusion names.
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog is the set of services and quotas the emulator knows.
func NewCatalog ¶
func NewCatalog(svcs []ServiceDef) *Catalog
NewCatalog builds a catalog from service definitions.
func (*Catalog) Quota ¶
func (c *Catalog) Quota(serviceCode, quotaCode string) (*ServiceDef, *QuotaDef, bool)
Quota looks a quota up by service and quota code.
func (*Catalog) Service ¶
func (c *Catalog) Service(code string) (*ServiceDef, bool)
Service looks a service up by its code.
func (*Catalog) Services ¶
func (c *Catalog) Services() []ServiceDef
Services returns every service in code order.
type ExclusionEntry ¶
type ExclusionEntry struct{ Code, Name string }
ExclusionEntry is an excluded quota with its catalogued name.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
}
Handler serves the Service Quotas awsjson1.1 API.
func (*Handler) ChaosOperations ¶
ChaosOperations lists the fault-injectable operations.
func (*Handler) ChaosRegions ¶
ChaosRegions lists the regions this handler serves.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase service name for fault rules.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name from X-Amz-Target.
func (*Handler) ExtractResource ¶
ExtractResource returns the operation name; the API has no single resource key.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists every routed operation.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the echo handler.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) RouteMatcher ¶
RouteMatcher matches the ServiceQuotasV20190624 X-Amz-Target prefix.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is the Service Quotas state; one coarse lock guards every table.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates an empty backend.
func (*InMemoryBackend) AccountID ¶
func (b *InMemoryBackend) AccountID() string
AccountID returns the default account.
func (*InMemoryBackend) AssociateTemplate ¶
func (b *InMemoryBackend) AssociateTemplate(ctx context.Context) error
AssociateTemplate associates the template with the organization.
func (*InMemoryBackend) CreateSupportCase ¶
func (b *InMemoryBackend) CreateSupportCase(ctx context.Context, requestID string) error
CreateSupportCase opens a support case for a pending request.
func (*InMemoryBackend) DeleteTemplateItem ¶
func (b *InMemoryBackend) DeleteTemplateItem(ctx context.Context, region, serviceCode, quotaCode string) error
DeleteTemplateItem removes one template entry.
func (*InMemoryBackend) DisassociateTemplate ¶
func (b *InMemoryBackend) DisassociateTemplate(ctx context.Context) error
DisassociateTemplate disassociates the template from the organization.
func (*InMemoryBackend) GetAutoManagement ¶
func (b *InMemoryBackend) GetAutoManagement(ctx context.Context) AutoManagementView
GetAutoManagement returns the configuration; a never-started account reports DISABLED.
func (*InMemoryBackend) GetDefaultQuota ¶
func (b *InMemoryBackend) GetDefaultQuota(ctx context.Context, serviceCode, quotaCode string) (QuotaView, error)
GetDefaultQuota returns the AWS default of one quota.
func (*InMemoryBackend) GetReport ¶
func (b *InMemoryBackend) GetReport(ctx context.Context, id, token string, maxResults *int32) (ReportPage, error)
GetReport returns a report and a page of its quotas.
func (*InMemoryBackend) GetRequest ¶
func (b *InMemoryBackend) GetRequest(ctx context.Context, id string) (RequestView, error)
GetRequest returns one request.
func (*InMemoryBackend) GetServiceQuota ¶
func (b *InMemoryBackend) GetServiceQuota( ctx context.Context, serviceCode, quotaCode, contextID string, ) (QuotaView, error)
GetServiceQuota returns the applied value of one quota.
func (*InMemoryBackend) GetTemplateItem ¶
func (b *InMemoryBackend) GetTemplateItem( ctx context.Context, region, serviceCode, quotaCode string, ) (TemplateView, error)
GetTemplateItem returns one template entry.
func (*InMemoryBackend) ListDefaultQuotas ¶
func (b *InMemoryBackend) ListDefaultQuotas( ctx context.Context, serviceCode, token string, maxResults *int32, ) (page.Page[QuotaView], error)
ListDefaultQuotas returns the AWS default quotas of a service.
func (*InMemoryBackend) ListRequests ¶
func (b *InMemoryBackend) ListRequests( ctx context.Context, f RequestFilter, token string, maxResults *int32, ) (page.Page[RequestView], error)
ListRequests returns the request history, oldest first.
func (*InMemoryBackend) ListServiceQuotas ¶
func (b *InMemoryBackend) ListServiceQuotas( ctx context.Context, serviceCode, quotaCode, level, token string, maxResults *int32, ) (page.Page[QuotaView], error)
ListServiceQuotas returns the applied quotas of a service.
func (*InMemoryBackend) ListServices ¶
func (b *InMemoryBackend) ListServices(token string, maxResults *int32) (page.Page[ServiceDef], error)
ListServices returns the services that have quotas.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource(ctx context.Context, resource string) (map[string]string, error)
ListTagsForResource returns the tags of an applied quota.
func (*InMemoryBackend) ListTemplateItems ¶
func (b *InMemoryBackend) ListTemplateItems( ctx context.Context, region, serviceCode, token string, maxResults *int32, ) (page.Page[TemplateView], error)
ListTemplateItems lists template entries, optionally narrowed by Region and service.
func (*InMemoryBackend) PutTemplateItem ¶
func (b *InMemoryBackend) PutTemplateItem( ctx context.Context, region, serviceCode, quotaCode string, desired *float64, ) (TemplateView, error)
PutTemplateItem adds or replaces a quota increase request in the template.
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns the default region.
func (*InMemoryBackend) RequestIncrease ¶
func (b *InMemoryBackend) RequestIncrease( ctx context.Context, serviceCode, quotaCode string, desired *float64, contextID string, caseAllowed *bool, ) (RequestView, error)
RequestIncrease files a quota increase request.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads a snapshot; an incompatible version is discarded.
func (*InMemoryBackend) SetLifecycleDelay ¶
func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)
SetLifecycleDelay overrides the dwell time of each quota request and report stage.
func (*InMemoryBackend) SetOrgDirectory ¶
func (b *InMemoryBackend) SetOrgDirectory(d OrgDirectory)
SetOrgDirectory wires the Organizations lookup used by the quota request template.
func (*InMemoryBackend) SetUsageSource ¶
func (b *InMemoryBackend) SetUsageSource(u UsageSource)
SetUsageSource wires the usage lookup used by utilization reports.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state.
func (*InMemoryBackend) StartAutoManagement ¶
func (b *InMemoryBackend) StartAutoManagement(ctx context.Context, in AutoManagementInput) error
StartAutoManagement opts the account into automatic quota management.
func (*InMemoryBackend) StartReport ¶
func (b *InMemoryBackend) StartReport(ctx context.Context) (Report, error)
StartReport begins generating a utilization report.
func (*InMemoryBackend) StopAutoManagement ¶
func (b *InMemoryBackend) StopAutoManagement(ctx context.Context) error
StopAutoManagement opts the account out of automatic quota management.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(ctx context.Context, resource string, add map[string]string) error
TagResource adds or replaces tags on an applied quota.
func (*InMemoryBackend) TemplateAssociation ¶
func (b *InMemoryBackend) TemplateAssociation(ctx context.Context) (string, error)
TemplateAssociation returns the association status of the template.
func (*InMemoryBackend) UntagResource ¶
UntagResource removes tags by key.
func (*InMemoryBackend) UpdateAutoManagement ¶
func (b *InMemoryBackend) UpdateAutoManagement(ctx context.Context, in AutoManagementInput) error
UpdateAutoManagement changes the settings of an enabled configuration.
type OrgDirectory ¶
OrgDirectory resolves the organization of an account.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Service Quotas.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init builds the backend and handler.
type QuotaDef ¶
type QuotaDef struct {
Usage *UsageMetric `json:"usage,omitempty"`
Code string `json:"code"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Unit string `json:"unit"`
Default float64 `json:"default"`
Adjustable bool `json:"adjustable"`
Global bool `json:"global,omitempty"`
}
QuotaDef is one catalogued quota with its AWS default.
type QuotaView ¶
type QuotaView struct {
Service *ServiceDef
Def *QuotaDef
ARN string
Value float64
Applied bool
}
QuotaView is a catalogued quota with the value that applies to the caller.
type Report ¶
type Report struct {
Created time.Time `json:"created"`
Generated time.Time `json:"generated"`
ID string `json:"id"`
Account string `json:"account"`
Region string `json:"region"`
Status string `json:"status"`
Quotas []UtilizationEntry `json:"quotas,omitempty"`
Seq int64 `json:"seq"`
}
Report is a quota utilization report.
type ReportPage ¶
type ReportPage struct {
Quotas page.Page[UtilizationEntry]
Report Report
Total int
}
ReportPage is a utilization report with one page of its quotas.
type Request ¶
type Request struct {
Created time.Time `json:"created"`
LastUpdated time.Time `json:"lastUpdated"`
CaseOpenedAt time.Time `json:"caseOpenedAt"`
ID string `json:"id"`
Account string `json:"account"`
Region string `json:"region"`
ServiceCode string `json:"serviceCode"`
QuotaCode string `json:"quotaCode"`
CaseID string `json:"caseId,omitempty"`
Status string `json:"status"`
Requester string `json:"requester"`
DesiredValue float64 `json:"desiredValue"`
Seq int64 `json:"seq"`
CaseAllowed bool `json:"caseAllowed"`
}
Request is a quota increase request.
type RequestFilter ¶
RequestFilter narrows a request history listing.
type RequestView ¶
type RequestView struct {
Service *ServiceDef
Def *QuotaDef
ARN string
Request Request
}
RequestView is a quota increase request with the quota it targets.
type ResourceTags ¶
ResourceTags holds the tags of one applied quota.
type ServiceDef ¶
type ServiceDef struct {
Code string `json:"code"`
Name string `json:"name"`
Quotas []QuotaDef `json:"quotas"`
}
ServiceDef is one catalogued service and its quotas.
type TemplateItem ¶
type TemplateItem struct {
Key string `json:"key"`
Account string `json:"account"`
AwsRegion string `json:"awsRegion"`
ServiceCode string `json:"serviceCode"`
QuotaCode string `json:"quotaCode"`
DesiredValue float64 `json:"desiredValue"`
}
TemplateItem is an entry of the quota request template.
type TemplateView ¶
type TemplateView struct {
Service *ServiceDef
Def *QuotaDef
Item TemplateItem
}
TemplateView is a template entry with the quota it targets.
type UsageMetric ¶
type UsageMetric struct {
Dimensions map[string]string `json:"dimensions,omitempty"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Statistic string `json:"statistic"`
}
UsageMetric describes the CloudWatch metric that tracks usage of a quota.
type UsageSource ¶
type UsageSource interface {
QuotaUsage(account, region, serviceCode, quotaCode string) (float64, bool)
}
UsageSource reports current usage of a quota; ok is false when usage is not tracked.
type UtilizationEntry ¶
type UtilizationEntry struct {
ServiceCode string `json:"serviceCode"`
QuotaCode string `json:"quotaCode"`
Namespace string `json:"namespace,omitempty"`
Applied float64 `json:"applied"`
Default float64 `json:"default"`
Utilization float64 `json:"utilization"`
Adjustable bool `json:"adjustable"`
}
UtilizationEntry is one quota line of a utilization report.