Documentation
¶
Index ¶
- Variables
- type AlternateContact
- type ContactInformation
- type ContactType
- type Handler
- 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) AcceptPrimaryEmailUpdate(otp, email string) error
- func (b *InMemoryBackend) DeleteAlternateContact(ct ContactType) error
- func (b *InMemoryBackend) DisableRegion(regionName string) error
- func (b *InMemoryBackend) EnableRegion(regionName string) error
- func (b *InMemoryBackend) GetAccountInformation() (*Info, error)
- func (b *InMemoryBackend) GetAlternateContact(ct ContactType) (*AlternateContact, error)
- func (b *InMemoryBackend) GetContactInformation() (*ContactInformation, error)
- func (b *InMemoryBackend) GetPrimaryEmail() string
- func (b *InMemoryBackend) GetRegionOptStatus(regionName string) (RegionOptStatus, error)
- func (b *InMemoryBackend) ListRegions(statusFilter []RegionOptStatus, maxResults int, nextToken string) ([]*Region, string, error)
- func (b *InMemoryBackend) PutAccountName(name string) error
- func (b *InMemoryBackend) PutAlternateContact(contact *AlternateContact) error
- func (b *InMemoryBackend) PutContactInformation(info *ContactInformation) error
- 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) StartPrimaryEmailUpdate(email string) (string, error)
- type Info
- type Provider
- type Region
- type RegionOptStatus
- type State
- type StorageBackend
Constants ¶
This section is empty.
Variables ¶
var ErrNilAppContext = errors.New("account: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
Functions ¶
This section is empty.
Types ¶
type AlternateContact ¶
type AlternateContact struct {
AlternateContactType ContactType `json:"AlternateContactType"`
EmailAddress string `json:"EmailAddress,omitempty"`
Name string `json:"Name,omitempty"`
PhoneNumber string `json:"PhoneNumber,omitempty"`
Title string `json:"Title,omitempty"`
}
AlternateContact holds alternate contact information.
type ContactInformation ¶
type ContactInformation struct {
AddressLine1 string `json:"AddressLine1"`
AddressLine2 string `json:"AddressLine2,omitempty"`
AddressLine3 string `json:"AddressLine3,omitempty"`
City string `json:"City"`
CompanyName string `json:"CompanyName,omitempty"`
CountryCode string `json:"CountryCode"`
DistrictOrCounty string `json:"DistrictOrCounty,omitempty"`
FullName string `json:"FullName"`
PhoneNumber string `json:"PhoneNumber"`
PostalCode string `json:"PostalCode"`
StateOrRegion string `json:"StateOrRegion,omitempty"`
WebsiteURL string `json:"WebsiteUrl,omitempty"`
}
ContactInformation holds primary contact information for the account.
type ContactType ¶
type ContactType string
ContactType represents the type of alternate contact.
const ( ContactTypeBilling ContactType = "BILLING" ContactTypeOperations ContactType = "OPERATIONS" ContactTypeSecurity ContactType = "SECURITY" )
type Handler ¶
type Handler struct {
Backend StorageBackend
}
Handler implements service.Registerable for the AWS Account Management API.
func NewHandler ¶
func NewHandler(b StorageBackend) *Handler
NewHandler constructs a Handler backed by the given StorageBackend.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name for logging/telemetry.
func (*Handler) ExtractResource ¶
ExtractResource returns a resource identifier for logging.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the operations the handler implements.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the echo handler function.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) RouteMatcher ¶
RouteMatcher identifies account service requests by inspecting the SigV4 service name from the Authorization header and matching one of the fixed operation paths. Every operation is a POST -- Account Management has no GET/PUT/DELETE operations.
func (*Handler) Snapshot ¶
Snapshot implements persistence.Persistable by delegating to the backend. Handler previously had no Snapshot/Restore of its own -- and neither did InMemoryBackend -- so a persistence manager that type-asserts the registered service.Registerable (i.e. the Handler) for a Snapshot/Restore pair never picked Account up at all: dead wiring, with no persistence underneath it either. This delegation (matching the cleanrooms/codecommit pattern) is what wires Account into persistence for the first time.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is an in-memory implementation of StorageBackend.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates a new in-memory backend for the account service.
func (*InMemoryBackend) AcceptPrimaryEmailUpdate ¶
func (b *InMemoryBackend) AcceptPrimaryEmailUpdate(otp, email string) error
AcceptPrimaryEmailUpdate confirms a pending email change using the OTP.
func (*InMemoryBackend) DeleteAlternateContact ¶
func (b *InMemoryBackend) DeleteAlternateContact(ct ContactType) error
DeleteAlternateContact removes an alternate contact by type.
func (*InMemoryBackend) DisableRegion ¶
func (b *InMemoryBackend) DisableRegion(regionName string) error
DisableRegion transitions an opt-in region from ENABLED to DISABLED. ENABLED_BY_DEFAULT regions return a ValidationException per AWS semantics.
func (*InMemoryBackend) EnableRegion ¶
func (b *InMemoryBackend) EnableRegion(regionName string) error
EnableRegion transitions an opt-in region from DISABLED to ENABLED. ENABLED_BY_DEFAULT regions return a ValidationException per AWS semantics.
func (*InMemoryBackend) GetAccountInformation ¶
func (b *InMemoryBackend) GetAccountInformation() (*Info, error)
GetAccountInformation returns the account's ID, display name, creation date, and lifecycle state. AccountState is always ACTIVE: this service has no operation that transitions it (account closure belongs to AWS Organizations -- see services/organizations CloseAccount).
func (*InMemoryBackend) GetAlternateContact ¶
func (b *InMemoryBackend) GetAlternateContact(ct ContactType) (*AlternateContact, error)
GetAlternateContact retrieves an alternate contact by type.
func (*InMemoryBackend) GetContactInformation ¶
func (b *InMemoryBackend) GetContactInformation() (*ContactInformation, error)
GetContactInformation retrieves primary contact information.
func (*InMemoryBackend) GetPrimaryEmail ¶
func (b *InMemoryBackend) GetPrimaryEmail() string
GetPrimaryEmail returns the current primary email address.
func (*InMemoryBackend) GetRegionOptStatus ¶
func (b *InMemoryBackend) GetRegionOptStatus(regionName string) (RegionOptStatus, error)
GetRegionOptStatus returns the current opt-in status for a single region.
func (*InMemoryBackend) ListRegions ¶
func (b *InMemoryBackend) ListRegions( statusFilter []RegionOptStatus, maxResults int, nextToken string, ) ([]*Region, string, error)
ListRegions returns regions filtered by opt-in status, honouring AWS's maxResults/nextToken pagination. nextToken is an opaque cursor (base64 of the exclusive-start RegionName); when maxResults <= 0 the full filtered list is returned.
func (*InMemoryBackend) PutAccountName ¶
func (b *InMemoryBackend) PutAccountName(name string) error
PutAccountName updates the account's display name.
func (*InMemoryBackend) PutAlternateContact ¶
func (b *InMemoryBackend) PutAlternateContact(contact *AlternateContact) error
PutAlternateContact creates or updates an alternate contact.
func (*InMemoryBackend) PutContactInformation ¶
func (b *InMemoryBackend) PutContactInformation(info *ContactInformation) error
PutContactInformation sets primary contact information.
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) StartPrimaryEmailUpdate ¶
func (b *InMemoryBackend) StartPrimaryEmailUpdate(email string) (string, error)
StartPrimaryEmailUpdate initiates a primary email change. Returns a fixed simulation OTP that the caller must pass to AcceptPrimaryEmailUpdate.
type Info ¶
type Info struct {
AccountID string `json:"AccountId"`
AccountName string `json:"AccountName"`
AccountCreatedDate string `json:"AccountCreatedDate"`
AccountState State `json:"AccountState"`
}
Info holds the fields returned by GetAccountInformation.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for AWS Account Management.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the Account Management service backend and handler.
type Region ¶
type Region struct {
RegionName string `json:"RegionName"`
RegionOptStatus RegionOptStatus `json:"RegionOptStatus"`
}
Region represents an AWS region and its opt-in status.
type RegionOptStatus ¶
type RegionOptStatus string
RegionOptStatus represents the opt-in status of an AWS region.
const ( RegionOptStatusEnabled RegionOptStatus = "ENABLED" RegionOptStatusDisabled RegionOptStatus = "DISABLED" RegionOptStatusEnabling RegionOptStatus = "ENABLING" RegionOptStatusDisabling RegionOptStatus = "DISABLING" RegionOptStatusEnabledDefault RegionOptStatus = "ENABLED_BY_DEFAULT" )
type State ¶
type State string
State represents the lifecycle state of an AWS account as reported by GetAccountInformation. Real Account Management never transitions an account to SUSPENDED/CLOSED/PENDING_ACTIVATION from this service -- account closure is an AWS Organizations concept (see the CloseAccount operation already implemented by services/organizations), so this service's backend always reports ACTIVE.
type StorageBackend ¶
type StorageBackend interface {
Reset()
GetAccountInformation() (*Info, error)
ListRegions(statusFilter []RegionOptStatus, maxResults int, nextToken string) ([]*Region, string, error)
EnableRegion(regionName string) error
DisableRegion(regionName string) error
GetRegionOptStatus(regionName string) (RegionOptStatus, error)
GetAlternateContact(ContactType) (*AlternateContact, error)
PutAlternateContact(*AlternateContact) error
DeleteAlternateContact(ContactType) error
GetContactInformation() (*ContactInformation, error)
PutContactInformation(*ContactInformation) error
GetPrimaryEmail() string
StartPrimaryEmailUpdate(email string) (string, error)
AcceptPrimaryEmailUpdate(otp, email string) error
PutAccountName(name string) error
// Snapshot and Restore implement persistence.Persistable. Handler
// delegates to them (see persistence.go) so a persistence manager that
// registers Account can pick it up.
Snapshot(ctx context.Context) []byte
Restore(ctx context.Context, data []byte) error
}
StorageBackend defines the interface for the account service backend.