account

package
v1.8.2 Latest Latest
Warning

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

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

README

Account

Parity grade: A · SDK aws-sdk-go-v2/service/account@v1.35.4 · last audited 2026-10-10 (4cfa01673)

Coverage

Metric Value
PARITY entries audited 16 (16 ok)
Feature families 1 (1 ok)
Known gaps none
Structural gaps (can't be emulated) 3
Deferred items 1
Resource leaks clean
Structural gaps

These do not block an A grade — no implementation could produce real data here because the underlying data source cannot exist in an emulator.

  • AccountId targeting of org member accounts: the optional AccountId/StandardAccountId is accepted but the single-account backend ignores it; member-account state and org management/delegated-admin membership live in services/organizations and need cross-service wiring.
  • AccessDeniedException/TooManyRequestsException are classified but never raised: no per-request IAM evaluation or throttling exists for this service.
  • ConflictException for an email in use by a different AWS account (StartPrimaryEmailUpdate): only this account's own email is known; no second account's email exists to collide with.
Deferred
  • none (every routed op audited this pass)

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

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

ExtractOperation returns the operation name for logging/telemetry.

func (*Handler) ExtractResource

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

ExtractResource returns a resource identifier for logging.

func (*Handler) GetSupportedOperations

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

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

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) Reset

func (h *Handler) Reset()

Reset delegates to the backend.

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 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) Shutdown

func (h *Handler) Shutdown(_ context.Context)

Shutdown stops the backend's transition timers.

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 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 backend whose timers are rooted at context.Background().

func NewInMemoryBackendWithContext

func NewInMemoryBackendWithContext(ctx context.Context, accountID, region string) *InMemoryBackend

NewInMemoryBackendWithContext creates a backend whose async transitions run on a worker.Group rooted at ctx.

func (*InMemoryBackend) AcceptPrimaryEmailUpdate

func (b *InMemoryBackend) AcceptPrimaryEmailUpdate(otp, email string) error

AcceptPrimaryEmailUpdate confirms a pending email change using the OTP. The status is ACCEPTED immediately and settles to COMPLETED after regionTransitionDelay.

func (*InMemoryBackend) Close

func (b *InMemoryBackend) Close()

Close stops pending transition timers. Safe to call more than once.

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 starts an opt-in region's ENABLED -> DISABLING -> DISABLED transition. ENABLED_BY_DEFAULT regions return a ValidationException; a region still ENABLING returns a ConflictException.

func (*InMemoryBackend) EnableRegion

func (b *InMemoryBackend) EnableRegion(regionName string) error

EnableRegion starts an opt-in region's DISABLED -> ENABLING -> ENABLED transition. ENABLED_BY_DEFAULT regions return a ValidationException; a region still DISABLING returns a ConflictException.

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) GetGovCloudAccountInformation added in v1.3.1

func (b *InMemoryBackend) GetGovCloudAccountInformation() (string, State, error)

GetGovCloudAccountInformation returns the GovCloud account linked to this account. This backend models a single, standalone (non-organization-member) account -- see the AccountId-targeting gap in PARITY.md -- so no account it simulates ever has a linked GovCloud pair; matches real AWS's documented ResourceNotFoundException for that case.

func (*InMemoryBackend) GetPrimaryEmail

func (b *InMemoryBackend) GetPrimaryEmail() string

GetPrimaryEmail returns the current primary email address.

func (*InMemoryBackend) GetPrimaryEmailUpdateStatus added in v1.3.1

func (b *InMemoryBackend) GetPrimaryEmailUpdateStatus() (PrimaryEmailUpdateStatus, time.Time, error)

GetPrimaryEmailUpdateStatus returns the status of the most recent primary email update request and when it last changed.

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) Reset

func (b *InMemoryBackend) Reset()

Reset clears all in-memory state.

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) SetLifecycleDelay

func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)

SetLifecycleDelay sets how long opt-in regions stay ENABLING/DISABLING and a primary email update stays ACCEPTED. The default is 100ms; a negative value is ignored.

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. Rejects a target email already in use by this account (ConflictException; see errPrimaryEmailInUse).

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 PrimaryEmailUpdateStatus added in v1.3.1

type PrimaryEmailUpdateStatus string

PrimaryEmailUpdateStatus represents the status of the most recent primary email update request, as reported by GetPrimaryEmailUpdateStatus.

const (
	PrimaryEmailUpdateStatusPending   PrimaryEmailUpdateStatus = "PENDING"
	PrimaryEmailUpdateStatusAccepted  PrimaryEmailUpdateStatus = "ACCEPTED"
	PrimaryEmailUpdateStatusCompleted PrimaryEmailUpdateStatus = "COMPLETED"
	PrimaryEmailUpdateStatusFailed    PrimaryEmailUpdateStatus = "FAILED"
)

type Provider

type Provider struct{}

Provider implements service.Provider for AWS Account Management.

func (*Provider) Init

Init initializes the Account Management service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

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.

const (
	StateActive            State = "ACTIVE"
	StatePendingActivation State = "PENDING_ACTIVATION"
	StateSuspended         State = "SUSPENDED"
	StateClosed            State = "CLOSED"
)

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
	GetPrimaryEmailUpdateStatus() (PrimaryEmailUpdateStatus, time.Time, error)
	PutAccountName(name string) error
	GetGovCloudAccountInformation() (string, State, 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.

Jump to

Keyboard shortcuts

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