sns

package
v1.1.1 Latest Latest
Warning

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

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

README

SNS

Parity grade: B · SDK aws-sdk-go-v2/service/sns@v1.41.0 · last audited 2026-07-11 (3d4de4f9)

Coverage

Metric Value
Operations audited 27 (26 ok, 1 other)
Feature families 6 (6 ok)
Known gaps 3
Deferred items 2
Resource leaks clean
Known gaps
  • ArchivePolicy/ReplayPolicy are accepted on any topic and fan out to any protocol (HTTP/email/sms/application); real AWS restricts message archiving/replay to FIFO topics with SQS/Lambda/Firehose subscribers only. Not fixed this pass — no doc access to confirm the exact restriction text/error code, and existing tests exercise HTTP replay deliberately. (bd: gopherstack-bz6)
  • Subscribe does not validate that an 'sqs' protocol endpoint is a well-formed SQS queue ARN (any string is accepted); AWS rejects malformed endpoint ARNs per-protocol. Low value — SDK-driven callers always pass valid ARNs. (bd: gopherstack-bz6)
  • SignatureVersion topic/subscription attribute is accepted and stored (isKnownTopicAttribute) but delivery always signs with SHA-256 (AWS 'SignatureVersion 2'); a topic explicitly set to SignatureVersion=1 should sign with SHA-1 instead. Not fixed — no consumer in this codebase verifies signatures, so behavior is unobservable, and getting this wrong is worse than leaving it (bd: gopherstack-bz6)
Deferred
  • GetDataProtectionPolicy/PutDataProtectionPolicy: not verified against the real data-identifier grammar (e.g. built-in identifiers like 'Name', 'Address'); only checked that the policy round-trips as an opaque JSON string
  • Cross-service integration (test/integration/*_parity_test.go) was not run this pass — see parity-principles.md note that unit tests are not parity proof; recommend running the SDK-driven integration suite in a follow-up

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTopicNotFound                    = errors.New("NotFound")
	ErrTopicAlreadyExists               = errors.New("TopicAlreadyExists")
	ErrSubscriptionNotFound             = errors.New("NotFound")
	ErrPlatformApplicationNotFound      = errors.New("NotFound")
	ErrPlatformApplicationAlreadyExists = errors.New("PlatformApplicationAlreadyExists")
	ErrEndpointNotFound                 = errors.New("NotFound")
	ErrEndpointDisabled                 = errors.New("EndpointDisabled")
	ErrInvalidParameter                 = errors.New("InvalidParameter")
	ErrPhoneNumberNotFound              = errors.New("ResourceNotFound")
	ErrSandboxPhoneAlreadyExists        = errors.New("AlreadyExists")
	ErrPermissionLabelExists            = errors.New("AuthorizationError")
	ErrPermissionLabelNotFound          = errors.New("AuthorizationError")
	ErrSandboxPhoneNotVerified          = errors.New("InvalidParameter")
	// ErrOptedOut maps to the SNS "OptedOut" error code (see errorCode in handler.go).
	// The sentinel's own message must describe the actual condition, since %w-wrapping
	// embeds it verbatim into the API error message returned to the caller: it
	// previously read "KMSOptInRequired", an unrelated KMS error string that leaked
	// into every opted-out-SMS error message.
	ErrOptedOut   = errors.New("OptedOut")
	ErrHTTPStatus = errors.New("HTTP status")
)
View Source
var ErrNilAppContext = errors.New("sns: nil app context")

ErrNilAppContext is returned when Init is called with a nil AppContext.

Functions

This section is empty.

Types

type AddPermissionResponse

type AddPermissionResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ AddPermissionResponse"`
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

AddPermissionResponse is the XML response for AddPermission.

type ApplicationDelivery

type ApplicationDelivery struct {
	// EndpointARN is the target platform endpoint ARN.
	EndpointARN string
	// Message is the (per-protocol resolved) message body.
	Message string
	// MessageID is the generated message ID for the delivery.
	MessageID string
}

ApplicationDelivery records a single message delivered to an application-protocol (mobile push platform endpoint) subscription during a topic publish. AWS delivers these to a platform endpoint; gopherstack records the delivery here and exposes it via DrainApplicationDeliveries for inspection/testing.

type ArchivedMessage

type ArchivedMessage struct {
	Attributes map[string]MessageAttribute
	Timestamp  time.Time
	MessageID  string
	Message    string
	Subject    string
}

ArchivedMessage stores a published message in the per-topic archive. Messages are archived when the topic has an ArchivePolicy attribute set. They are replayed to subscriptions that have a ReplayPolicy set.

type CheckIfPhoneNumberIsOptedOutResponse

type CheckIfPhoneNumberIsOptedOutResponse struct {
	XMLName                            xml.Name                           `xml:"https://sns.amazonaws.com/doc/2010-03-31/ CheckIfPhoneNumberIsOptedOutResponse"` //nolint:lll // XML namespace.
	ResponseMetadata                   ResponseMetadata                   `xml:"ResponseMetadata"`
	CheckIfPhoneNumberIsOptedOutResult CheckIfPhoneNumberIsOptedOutResult `xml:"CheckIfPhoneNumberIsOptedOutResult"`
}

CheckIfPhoneNumberIsOptedOutResponse is the XML response for CheckIfPhoneNumberIsOptedOut.

type CheckIfPhoneNumberIsOptedOutResult

type CheckIfPhoneNumberIsOptedOutResult struct {
	IsOptedOut bool `xml:"isOptedOut"`
}

CheckIfPhoneNumberIsOptedOutResult holds the result of CheckIfPhoneNumberIsOptedOut.

type ConfirmSubscriptionResponse

type ConfirmSubscriptionResponse struct {
	XMLName                   xml.Name                  `xml:"https://sns.amazonaws.com/doc/2010-03-31/ ConfirmSubscriptionResponse"` //nolint:lll // XML namespace makes this line long.
	ConfirmSubscriptionResult ConfirmSubscriptionResult `xml:"ConfirmSubscriptionResult"`
	ResponseMetadata          ResponseMetadata          `xml:"ResponseMetadata"`
}

ConfirmSubscriptionResponse is the XML response for ConfirmSubscription.

type ConfirmSubscriptionResult

type ConfirmSubscriptionResult struct {
	SubscriptionArn string `xml:"SubscriptionArn"`
}

ConfirmSubscriptionResult holds the subscription ARN after confirmation.

type CreatePlatformApplicationResponse

type CreatePlatformApplicationResponse struct {
	XMLName                         xml.Name                        `xml:"https://sns.amazonaws.com/doc/2010-03-31/ CreatePlatformApplicationResponse"` //nolint:lll // XML namespace makes this line long.
	CreatePlatformApplicationResult CreatePlatformApplicationResult `xml:"CreatePlatformApplicationResult"`
	ResponseMetadata                ResponseMetadata                `xml:"ResponseMetadata"`
}

CreatePlatformApplicationResponse is the XML response for CreatePlatformApplication.

type CreatePlatformApplicationResult

type CreatePlatformApplicationResult struct {
	PlatformApplicationArn string `xml:"PlatformApplicationArn"`
}

CreatePlatformApplicationResult holds the result of a CreatePlatformApplication operation.

type CreatePlatformEndpointResponse

type CreatePlatformEndpointResponse struct {
	XMLName                      xml.Name                     `xml:"https://sns.amazonaws.com/doc/2010-03-31/ CreatePlatformEndpointResponse"` //nolint:lll // XML namespace makes this line long.
	CreatePlatformEndpointResult CreatePlatformEndpointResult `xml:"CreatePlatformEndpointResult"`
	ResponseMetadata             ResponseMetadata             `xml:"ResponseMetadata"`
}

CreatePlatformEndpointResponse is the XML response for CreatePlatformEndpoint.

type CreatePlatformEndpointResult

type CreatePlatformEndpointResult struct {
	EndpointArn string `xml:"EndpointArn"`
}

CreatePlatformEndpointResult holds the result of CreatePlatformEndpoint.

type CreateSMSSandboxPhoneNumberResponse

type CreateSMSSandboxPhoneNumberResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ CreateSMSSandboxPhoneNumberResponse"` //nolint:lll // XML namespace.
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

CreateSMSSandboxPhoneNumberResponse is the XML response for CreateSMSSandboxPhoneNumber.

type CreateTopicResponse

type CreateTopicResponse struct {
	XMLName           xml.Name          `xml:"https://sns.amazonaws.com/doc/2010-03-31/ CreateTopicResponse"`
	CreateTopicResult CreateTopicResult `xml:"CreateTopicResult"`
	ResponseMetadata  ResponseMetadata  `xml:"ResponseMetadata"`
}

CreateTopicResponse is the XML response for CreateTopic.

type CreateTopicResult

type CreateTopicResult struct {
	TopicArn string `xml:"TopicArn"`
}

CreateTopicResult holds the result of a CreateTopic operation.

type DeleteEndpointResponse

type DeleteEndpointResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ DeleteEndpointResponse"`
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

DeleteEndpointResponse is the XML response for DeleteEndpoint.

type DeletePlatformApplicationResponse

type DeletePlatformApplicationResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ DeletePlatformApplicationResponse"` //nolint:lll // XML namespace makes this line long.
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

DeletePlatformApplicationResponse is the XML response for DeletePlatformApplication.

type DeleteSMSSandboxPhoneNumberResponse

type DeleteSMSSandboxPhoneNumberResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ DeleteSMSSandboxPhoneNumberResponse"` //nolint:lll // XML namespace.
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

DeleteSMSSandboxPhoneNumberResponse is the XML response for DeleteSMSSandboxPhoneNumber.

type DeleteTopicResponse

type DeleteTopicResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ DeleteTopicResponse"`
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

DeleteTopicResponse is the XML response for DeleteTopic.

type EmailDelivery

type EmailDelivery struct {
	// EndpointEmail is the subscriber's email address.
	EndpointEmail string
	// Protocol is "email" or "email-json".
	Protocol string
	// Subject is the optional message subject.
	Subject string
	// Message is the (per-protocol resolved) message body.
	Message string
	// MessageID is the publish MessageId.
	MessageID string
	// TopicARN is the originating topic.
	TopicARN string
}

EmailDelivery records a single message delivered to an email or email-json subscription. AWS sends these to a mailbox; gopherstack has no SMTP sink, so the delivery is recorded here and exposed via DrainEmailDeliveries for inspection/testing — the simulator equivalent of "the email was sent".

type Error

type Error struct {
	Type    string `xml:"Type"`
	Code    string `xml:"Code"`
	Message string `xml:"Message"`
}

Error contains the error details within an ErrorResponse.

type ErrorResponse

type ErrorResponse struct {
	XMLName   xml.Name `xml:"ErrorResponse"`
	Error     Error    `xml:"Error"`
	RequestID string   `xml:"RequestId"`
}

ErrorResponse represents an SNS XML error response.

type FirehosePutter

type FirehosePutter interface {
	// PutRecordBatch delivers a batch of records to the named delivery stream.
	PutRecordBatch(streamName string, records [][]byte) (int, error)
}

FirehosePutter can put records to a Kinesis Firehose stream for SNS subscription delivery.

type GetDataProtectionPolicyResponse

type GetDataProtectionPolicyResponse struct {
	XMLName                       xml.Name                      `xml:"https://sns.amazonaws.com/doc/2010-03-31/ GetDataProtectionPolicyResponse"` //nolint:lll // XML namespace.
	GetDataProtectionPolicyResult GetDataProtectionPolicyResult `xml:"GetDataProtectionPolicyResult"`
	ResponseMetadata              ResponseMetadata              `xml:"ResponseMetadata"`
}

GetDataProtectionPolicyResponse is the XML response for GetDataProtectionPolicy.

type GetDataProtectionPolicyResult

type GetDataProtectionPolicyResult struct {
	DataProtectionPolicy string `xml:"DataProtectionPolicy"`
}

GetDataProtectionPolicyResult holds the result of GetDataProtectionPolicy.

type GetEndpointAttributesResponse

type GetEndpointAttributesResponse struct {
	XMLName                     xml.Name                    `xml:"https://sns.amazonaws.com/doc/2010-03-31/ GetEndpointAttributesResponse"` //nolint:lll // XML namespace makes this line long.
	ResponseMetadata            ResponseMetadata            `xml:"ResponseMetadata"`
	GetEndpointAttributesResult GetEndpointAttributesResult `xml:"GetEndpointAttributesResult"`
}

GetEndpointAttributesResponse is the XML response for GetEndpointAttributes.

type GetEndpointAttributesResult

type GetEndpointAttributesResult struct {
	Attributes []XMLAttributeEntry `xml:"Attributes>entry"`
}

GetEndpointAttributesResult holds the result of GetEndpointAttributes.

type GetPlatformApplicationAttributesResponse

type GetPlatformApplicationAttributesResponse struct {
	XMLName                                xml.Name                               `xml:"https://sns.amazonaws.com/doc/2010-03-31/ GetPlatformApplicationAttributesResponse"` //nolint:lll // XML namespace makes this line long.
	ResponseMetadata                       ResponseMetadata                       `xml:"ResponseMetadata"`
	GetPlatformApplicationAttributesResult GetPlatformApplicationAttributesResult `xml:"GetPlatformApplicationAttributesResult"` //nolint:lll // Long type name.
}

GetPlatformApplicationAttributesResponse is the XML response for GetPlatformApplicationAttributes.

type GetPlatformApplicationAttributesResult

type GetPlatformApplicationAttributesResult struct {
	Attributes []XMLAttributeEntry `xml:"Attributes>entry"`
}

GetPlatformApplicationAttributesResult holds the result of GetPlatformApplicationAttributes.

type GetSMSAttributesResponse

type GetSMSAttributesResponse struct {
	XMLName                xml.Name               `xml:"https://sns.amazonaws.com/doc/2010-03-31/ GetSMSAttributesResponse"` //nolint:lll // XML namespace.
	ResponseMetadata       ResponseMetadata       `xml:"ResponseMetadata"`
	GetSMSAttributesResult GetSMSAttributesResult `xml:"GetSMSAttributesResult"`
}

GetSMSAttributesResponse is the XML response for GetSMSAttributes.

type GetSMSAttributesResult

type GetSMSAttributesResult struct {
	Attributes []XMLAttributeEntry `xml:"attributes>entry"`
}

GetSMSAttributesResult holds the result of GetSMSAttributes.

type GetSMSSandboxAccountStatusResponse

type GetSMSSandboxAccountStatusResponse struct {
	XMLName                          xml.Name                         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ GetSMSSandboxAccountStatusResponse"` //nolint:lll // XML namespace.
	ResponseMetadata                 ResponseMetadata                 `xml:"ResponseMetadata"`
	GetSMSSandboxAccountStatusResult GetSMSSandboxAccountStatusResult `xml:"GetSMSSandboxAccountStatusResult"`
}

GetSMSSandboxAccountStatusResponse is the XML response for GetSMSSandboxAccountStatus.

type GetSMSSandboxAccountStatusResult

type GetSMSSandboxAccountStatusResult struct {
	IsInSandbox bool `xml:"IsInSandbox"`
}

GetSMSSandboxAccountStatusResult holds the result of GetSMSSandboxAccountStatus.

type GetSubscriptionAttributesResponse

type GetSubscriptionAttributesResponse struct {
	XMLName                         xml.Name                        `xml:"https://sns.amazonaws.com/doc/2010-03-31/ GetSubscriptionAttributesResponse"` //nolint:lll // XML namespace
	ResponseMetadata                ResponseMetadata                `xml:"ResponseMetadata"`
	GetSubscriptionAttributesResult GetSubscriptionAttributesResult `xml:"GetSubscriptionAttributesResult"`
}

GetSubscriptionAttributesResponse is the XML response for GetSubscriptionAttributes.

type GetSubscriptionAttributesResult

type GetSubscriptionAttributesResult struct {
	Attributes []XMLAttributeEntry `xml:"Attributes>entry"`
}

GetSubscriptionAttributesResult holds the attributes of a subscription.

type GetTopicAttributesResponse

type GetTopicAttributesResponse struct {
	XMLName                  xml.Name                 `xml:"https://sns.amazonaws.com/doc/2010-03-31/ GetTopicAttributesResponse"` //nolint:lll // XML namespace makes this line long.
	ResponseMetadata         ResponseMetadata         `xml:"ResponseMetadata"`
	GetTopicAttributesResult GetTopicAttributesResult `xml:"GetTopicAttributesResult"`
}

GetTopicAttributesResponse is the XML response for GetTopicAttributes.

type GetTopicAttributesResult

type GetTopicAttributesResult struct {
	Attributes []XMLAttributeEntry `xml:"Attributes>entry"`
}

GetTopicAttributesResult holds the result of a GetTopicAttributes operation.

type Handler

type Handler struct {
	Backend StorageBackend

	// DefaultRegion is the fallback region used when region cannot be extracted from the request.
	DefaultRegion string
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(backend StorageBackend) *Handler

NewHandler creates a new SNS Handler with the given backend and logger.

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 SNS instance 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 SNS action from the request form.

func (*Handler) ExtractResource

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

ExtractResource extracts the primary resource (TopicArn or Name) from the request form.

func (*Handler) GetSupportedOperations

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

GetSupportedOperations returns the list of supported SNS operations.

func (*Handler) Handler

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

Handler returns the Echo HandlerFunc for SNS requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority for the SNS handler.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Purge

func (h *Handler) Purge(ctx context.Context, cutoff time.Time)

Purge implements service.Purgeable by deleting resources older than cutoff.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all in-memory state from the backend. It is used by the POST /_gopherstack/reset endpoint for CI pipelines and rapid local development.

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 SNS requests by Content-Type and body version. It also matches GET requests for the SNS signing certificate PEM file so that HTTP/HTTPS subscribers can verify notification signatures without contacting AWS.

func (*Handler) Shutdown

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

Shutdown implements service.Shutdowner. It waits for all in-flight HTTP/HTTPS delivery goroutines to finish. If ctx expires before all goroutines complete, Shutdown returns immediately so that process shutdown is not blocked.

func (*Handler) Snapshot

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

Snapshot implements persistence.Persistable by delegating to the backend.

type InMemoryBackend

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

InMemoryBackend implements StorageBackend using an in-memory concurrency-safe store.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates a new empty InMemoryBackend with default account/region.

func NewInMemoryBackendWithConfig

func NewInMemoryBackendWithConfig(accountID, region string) *InMemoryBackend

NewInMemoryBackendWithConfig creates a new InMemoryBackend with the given account ID and region. Use NewInMemoryBackendWithContext to bind it to a parent service context instead.

func NewInMemoryBackendWithContext

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

NewInMemoryBackendWithContext creates a new InMemoryBackend bound to the given parent context. The context is used when emitting SNS publish events (e.g. to SQS delivery) so that event delivery is cancelled if the service is shut down. If svcCtx is nil, context.Background is used.

func (*InMemoryBackend) AddPermission

func (b *InMemoryBackend) AddPermission(topicArn, label string, accounts, actions []string) error

AddPermission adds a permission statement to an SNS topic's access policy. Duplicate labels are rejected with ErrPermissionLabelExists. Labels must be non-empty, at most 80 characters, and consist only of alphanumeric characters or hyphens; invalid labels are rejected with ErrInvalidParameter.

func (*InMemoryBackend) CheckIfPhoneNumberIsOptedOut

func (b *InMemoryBackend) CheckIfPhoneNumberIsOptedOut(phoneNumber string) (bool, error)

CheckIfPhoneNumberIsOptedOut returns whether a phone number has opted out of SMS messages.

func (*InMemoryBackend) ConfirmSubscription

func (b *InMemoryBackend) ConfirmSubscription(topicArn, token string) (*Subscription, error)

ConfirmSubscription "confirms" a pending subscription. In the mock, any non-empty token is accepted. The subscription must belong to the given topicArn; if found and pending, PendingConfirmation is cleared and the subscription ARN is returned.

func (*InMemoryBackend) CreatePlatformApplication

func (b *InMemoryBackend) CreatePlatformApplication(
	name, platform string,
	attributes map[string]string,
) (*PlatformApplication, error)

CreatePlatformApplication creates a new SNS platform application using the backend's default region.

func (*InMemoryBackend) CreatePlatformApplicationInRegion

func (b *InMemoryBackend) CreatePlatformApplicationInRegion(
	name, platform, region string,
	attributes map[string]string,
) (*PlatformApplication, error)

CreatePlatformApplicationInRegion creates a new SNS platform application (e.g. GCM, APNS) with the ARN scoped to the specified region.

func (*InMemoryBackend) CreatePlatformEndpoint

func (b *InMemoryBackend) CreatePlatformEndpoint(
	platformApplicationArn, token string,
	attributes map[string]string,
) (*PlatformEndpoint, error)

CreatePlatformEndpoint registers a device token as an endpoint for a platform application. AWS deduplication behaviour: if an endpoint with the same token already exists under this platform application, the existing endpoint ARN is returned instead of creating a new one. After creation, an EventEndpointCreated event is fired to the platform application's configured event topic, if any.

func (*InMemoryBackend) CreateSMSSandboxPhoneNumber

func (b *InMemoryBackend) CreateSMSSandboxPhoneNumber(phoneNumber, languageCode string) error

CreateSMSSandboxPhoneNumber adds a phone number to the SMS sandbox. The phone number must be in E.164 format. Numbers start with status "Pending" and must be verified via VerifySMSSandboxPhoneNumber before they can receive SMS.

func (*InMemoryBackend) CreateTopic

func (b *InMemoryBackend) CreateTopic(name string, attributes map[string]string) (*Topic, error)

CreateTopic creates a new SNS topic using the backend's default region.

func (*InMemoryBackend) CreateTopicInRegion

func (b *InMemoryBackend) CreateTopicInRegion(
	name, region string,
	attributes map[string]string,
) (*Topic, error)

CreateTopicInRegion creates a new SNS topic in the specified region. If region is empty, the backend's default region is used.

func (*InMemoryBackend) DeleteEndpoint

func (b *InMemoryBackend) DeleteEndpoint(endpointArn string) error

DeleteEndpoint removes a platform endpoint by ARN. After deletion, an EventEndpointDeleted event is fired to the platform application's configured event topic, if any.

func (*InMemoryBackend) DeletePlatformApplication

func (b *InMemoryBackend) DeletePlatformApplication(platformApplicationArn string) error

DeletePlatformApplication removes a platform application and its endpoints by ARN.

func (*InMemoryBackend) DeleteSMSSandboxPhoneNumber

func (b *InMemoryBackend) DeleteSMSSandboxPhoneNumber(phoneNumber string) error

DeleteSMSSandboxPhoneNumber removes a phone number from the SMS sandbox. The phone number must be in E.164 format.

func (*InMemoryBackend) DeleteTopic

func (b *InMemoryBackend) DeleteTopic(topicArn string) error

DeleteTopic removes a topic by ARN.

func (*InMemoryBackend) DrainApplicationDeliveries

func (b *InMemoryBackend) DrainApplicationDeliveries() []ApplicationDelivery

DrainApplicationDeliveries returns and clears all recorded application-protocol deliveries. These are recorded when a topic publish fans out to application (mobile push endpoint) subscriptions so tests can assert delivery without a real push network.

func (*InMemoryBackend) DrainEmailDeliveries

func (b *InMemoryBackend) DrainEmailDeliveries() []EmailDelivery

DrainEmailDeliveries returns and clears all recorded email/email-json deliveries. AWS delivers these to a mailbox; gopherstack records them here so tests and the dashboard can confirm the message was delivered.

func (*InMemoryBackend) DrainSMSDeliveries

func (b *InMemoryBackend) DrainSMSDeliveries() []SMSDelivery

DrainSMSDeliveries returns and clears all recorded SMS deliveries. This is intended for test assertions to verify SMS messages sent via PublishSMS.

func (*InMemoryBackend) GetArchivedMessages

func (b *InMemoryBackend) GetArchivedMessages(topicArn string) []ArchivedMessage

GetArchivedMessages returns a snapshot of all messages archived for the given topic ARN. Returns nil when no messages have been archived (ArchivePolicy not set or no messages published yet). Intended for test assertions.

func (*InMemoryBackend) GetDataProtectionPolicy

func (b *InMemoryBackend) GetDataProtectionPolicy(resourceArn string) (string, error)

GetDataProtectionPolicy returns the data protection policy JSON for the given topic ARN. The policy is stored as the "DataProtectionPolicy" attribute on the topic.

func (*InMemoryBackend) GetEndpointAttributes

func (b *InMemoryBackend) GetEndpointAttributes(endpointArn string) (map[string]string, error)

GetEndpointAttributes returns the attributes of a platform endpoint.

func (*InMemoryBackend) GetPlatformApplicationAttributes

func (b *InMemoryBackend) GetPlatformApplicationAttributes(
	platformApplicationArn string,
) (map[string]string, error)

GetPlatformApplicationAttributes returns the attributes of a platform application. In addition to stored attributes, computed statistics are returned:

  • Enabled: always "true" for the application itself (not to be confused with endpoint Enabled).
  • EndpointActive: the number of enabled platform endpoints for this application.
  • EndpointDisabled: the number of disabled platform endpoints.

func (*InMemoryBackend) GetSMSAttributes

func (b *InMemoryBackend) GetSMSAttributes(names []string) (map[string]string, error)

GetSMSAttributes returns the current SMS account attributes, optionally filtered by name. If names is empty all attributes are returned.

func (*InMemoryBackend) GetSMSSandboxAccountStatus

func (b *InMemoryBackend) GetSMSSandboxAccountStatus() (bool, error)

GetSMSSandboxAccountStatus returns whether the account is in SMS sandbox mode. Defaults to true (sandbox mode active) matching the AWS default for new accounts.

func (*InMemoryBackend) GetSubscriptionAttributes

func (b *InMemoryBackend) GetSubscriptionAttributes(
	subscriptionArn string,
) (map[string]string, error)

GetSubscriptionAttributes returns the attributes of a subscription.

func (*InMemoryBackend) GetTopicAttributes

func (b *InMemoryBackend) GetTopicAttributes(topicArn string) (map[string]string, error)

GetTopicAttributes returns the attributes of a topic.

func (*InMemoryBackend) GetTopicTags

func (b *InMemoryBackend) GetTopicTags(arn string) map[string]string

GetTopicTags returns tags for the given topic ARN.

func (*InMemoryBackend) ListAllPlatformApplications

func (b *InMemoryBackend) ListAllPlatformApplications() []PlatformApplication

ListAllPlatformApplications returns all platform applications sorted by ARN.

func (*InMemoryBackend) ListAllSubscriptions

func (b *InMemoryBackend) ListAllSubscriptions() []Subscription

ListAllSubscriptions returns all subscriptions sorted by ARN.

func (*InMemoryBackend) ListAllTopics

func (b *InMemoryBackend) ListAllTopics() []Topic

ListAllTopics returns all topics sorted by ARN.

func (*InMemoryBackend) ListEndpointsByPlatformApplication

func (b *InMemoryBackend) ListEndpointsByPlatformApplication(
	platformApplicationArn, nextToken string,
) ([]PlatformEndpoint, string, error)

ListEndpointsByPlatformApplication returns a page of endpoints for a platform application.

func (*InMemoryBackend) ListOriginationNumbers

func (b *InMemoryBackend) ListOriginationNumbers(
	nextToken string,
	maxResults int,
) ([]XMLOriginationPhone, string, error)

ListOriginationNumbers returns a paginated list of origination phone numbers for the backend's region, a next-page token (empty when the last page is reached), and any error. maxResults controls the page size; 0 means the default (30). Values exceeding 30 are clamped, matching AWS SNS limits for this operation.

AWS SNS exposes no public "create origination number" API: origination numbers are provisioned by buying phone numbers through Pinpoint / AWS End User Messaging. A fresh account therefore legitimately has none, so an empty list is AWS-accurate. State is populated internally via InMemoryBackend.SeedOriginationNumber (used by tests).

func (*InMemoryBackend) ListPhoneNumbersOptedOut

func (b *InMemoryBackend) ListPhoneNumbersOptedOut(
	nextToken string,
	maxResults int,
) ([]string, string, error)

ListPhoneNumbersOptedOut returns a paginated list of phone numbers opted out of SMS, a next-page token (empty when the last page is reached), and any error. maxResults controls the page size; 0 means the default (100). Values exceeding 100 are clamped.

func (*InMemoryBackend) ListPlatformApplications

func (b *InMemoryBackend) ListPlatformApplications(
	nextToken string,
) ([]PlatformApplication, string, error)

ListPlatformApplications returns a page of platform applications and the next pagination token.

func (*InMemoryBackend) ListSMSSandboxPhoneNumbers

func (b *InMemoryBackend) ListSMSSandboxPhoneNumbers(
	nextToken string,
	maxResults int,
) ([]SandboxPhoneNumber, string, error)

ListSMSSandboxPhoneNumbers returns a paginated list of SMS sandbox phone numbers, a next-page token (empty when the last page is reached), and any error. maxResults controls the page size; 0 means the default (100). Values exceeding 100 are clamped.

func (*InMemoryBackend) ListSubscriptions

func (b *InMemoryBackend) ListSubscriptions(nextToken string) ([]Subscription, string, error)

ListSubscriptions returns a page of subscriptions and the next pagination token.

func (*InMemoryBackend) ListSubscriptionsByTopic

func (b *InMemoryBackend) ListSubscriptionsByTopic(
	topicArn, nextToken string,
) ([]Subscription, string, error)

ListSubscriptionsByTopic returns a page of subscriptions for a topic and the next pagination token.

func (*InMemoryBackend) ListTopics

func (b *InMemoryBackend) ListTopics(nextToken string) ([]Topic, string, error)

ListTopics returns a page of topics across all regions, ordered by ARN. This preserves backward compatibility for callers that don't need region filtering.

func (*InMemoryBackend) ListTopicsInRegion

func (b *InMemoryBackend) ListTopicsInRegion(region, nextToken string) ([]Topic, string, error)

ListTopicsInRegion returns a page of topics belonging to region and the next pagination token. AWS SNS ListTopics only returns topics in the caller's region.

func (*InMemoryBackend) OptInPhoneNumber

func (b *InMemoryBackend) OptInPhoneNumber(phoneNumber string) error

OptInPhoneNumber removes a phone number from the opt-out list so it can receive SMS messages. The phone number must be in E.164 format.

func (*InMemoryBackend) Publish

func (b *InMemoryBackend) Publish(
	topicArn, message, subject, messageStructure string, attrs map[string]MessageAttribute,
) (string, error)

Publish delivers a message to all subscriptions of topicArn. HTTP/HTTPS subscriptions each receive an asynchronous best-effort delivery goroutine after the read lock is released to avoid lock starvation. Goroutines wait for a concurrency slot (up to snsMaxConcurrentDeliveries concurrent HTTP calls) or exit early if the backend is shutting down. All subscriptions are also broadcast via the publish emitter (e.g. to SQS).

func (*InMemoryBackend) PublishSMS

func (b *InMemoryBackend) PublishSMS(phoneNumber, message string) (string, error)

PublishSMS publishes a message directly to a phone number via SMS. The delivery is recorded in smsDeliveries so tests can assert on it via DrainSMSDeliveries. Returns ErrOptedOut when the destination number has opted out of SMS messages. Returns ErrSandboxPhoneNotVerified when the number is in the SMS sandbox but not yet verified.

func (*InMemoryBackend) PublishToTargetArn

func (b *InMemoryBackend) PublishToTargetArn(
	targetArn, _, _ string,
	_ map[string]MessageAttribute,
) (string, error)

PublishToTargetArn publishes a message directly to a platform endpoint ARN. Returns ErrEndpointDisabled when the endpoint has Enabled=false, matching the AWS EndpointDisabled error that triggers automatic endpoint disabling. In the mock, no actual push delivery occurs beyond generating the message ID.

func (*InMemoryBackend) Purge

func (b *InMemoryBackend) Purge(ctx context.Context, cutoff time.Time)

Purge removes all SNS resources created before the given cutoff time.

func (*InMemoryBackend) PutDataProtectionPolicy

func (b *InMemoryBackend) PutDataProtectionPolicy(resourceArn, policy string) error

PutDataProtectionPolicy stores a data protection policy JSON string on the given topic ARN. The policy must be valid JSON; invalid JSON is rejected with ErrInvalidParameter.

func (*InMemoryBackend) RemovePermission

func (b *InMemoryBackend) RemovePermission(topicArn, label string) error

RemovePermission removes a permission statement (identified by label) from an SNS topic.

func (*InMemoryBackend) RemoveTopicTags

func (b *InMemoryBackend) RemoveTopicTags(arn string, keys []string)

RemoveTopicTags removes specified tag keys for the given topic ARN.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all in-memory state from the database. It is used by the POST /_gopherstack/reset endpoint for CI pipelines and rapid local development.

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. The event emitter is not restored — it is re-wired by the CLI after restore.

func (*InMemoryBackend) SeedOriginationNumber

func (b *InMemoryBackend) SeedOriginationNumber(num XMLOriginationPhone)

SeedOriginationNumber populates an origination phone number for the backend's region. It exists because AWS SNS provides no public API to create origination numbers (they are provisioned via Pinpoint / AWS End User Messaging); this internal helper lets tests and fixtures populate state that InMemoryBackend.ListOriginationNumbers then returns honestly.

func (*InMemoryBackend) SetEndpointAttributes

func (b *InMemoryBackend) SetEndpointAttributes(
	endpointArn string,
	attributes map[string]string,
) error

SetEndpointAttributes updates attributes on a platform endpoint. After the update, an EventEndpointUpdated event is fired to the platform application's configured event topic, if any.

func (*InMemoryBackend) SetFirehoseBackend

func (b *InMemoryBackend) SetFirehoseBackend(firehose FirehosePutter)

SetFirehoseBackend wires the Firehose backend for SNS → Firehose subscription delivery.

func (*InMemoryBackend) SetHTTPDeliveryClient

func (b *InMemoryBackend) SetHTTPDeliveryClient(c *http.Client)

SetHTTPDeliveryClient configures the HTTP client used for HTTP/HTTPS subscription delivery. If not set, a dedicated client with a 5-second timeout is used.

func (*InMemoryBackend) SetLambdaBackend

func (b *InMemoryBackend) SetLambdaBackend(lambda LambdaInvoker)

SetLambdaBackend wires the Lambda backend for SNS → Lambda subscription delivery.

func (*InMemoryBackend) SetPlatformApplicationAttributes

func (b *InMemoryBackend) SetPlatformApplicationAttributes(
	platformApplicationArn string,
	attributes map[string]string,
) error

SetPlatformApplicationAttributes updates attributes on a platform application.

func (*InMemoryBackend) SetPublishEmitter

func (b *InMemoryBackend) SetPublishEmitter(
	emitter events.EventEmitter[*events.SNSPublishedEvent],
)

SetPublishEmitter registers an event emitter that fires when a message is published. This is used to wire SNS→SQS delivery at startup.

func (*InMemoryBackend) SetSMSAttributes

func (b *InMemoryBackend) SetSMSAttributes(attributes map[string]string) error

SetSMSAttributes stores global SMS account attributes. Existing attribute keys are updated; unspecified keys are left unchanged. Only known AWS attribute names are accepted; unknown names are rejected with ErrInvalidParameter.

func (*InMemoryBackend) SetSMSSandboxMode

func (b *InMemoryBackend) SetSMSSandboxMode(enabled bool)

SetSMSSandboxMode configures sandbox mode. AWS does not expose an API for this — use this method in tests or operator tooling to simulate production mode.

func (*InMemoryBackend) SetSQSChecker

func (b *InMemoryBackend) SetSQSChecker(checker SQSQueueChecker)

SetSQSChecker wires the SQS queue checker used to verify deadLetterTargetArn existence during SetSubscriptionAttributes. When nil, the existence check is skipped.

func (*InMemoryBackend) SetSQSSender

func (b *InMemoryBackend) SetSQSSender(sender SQSSender)

SetSQSSender wires the SQS sender used to deliver failed messages to a subscription DLQ.

func (*InMemoryBackend) SetSigningCertBaseURL

func (b *InMemoryBackend) SetSigningCertBaseURL(baseURL string)

SetSigningCertBaseURL configures the URL embedded in the SigningCertURL field of HTTP/HTTPS notification envelopes. Call this once the server address is known so that subscribers can retrieve the verification certificate. The URL should point to the mock server's /SimpleNotificationService.pem path.

func (*InMemoryBackend) SetSubscriptionAttributes

func (b *InMemoryBackend) SetSubscriptionAttributes(
	subscriptionArn, attrName, attrValue string,
) error

SetSubscriptionAttributes sets a single attribute on a subscription. When ReplayPolicy is set to a non-empty value, archived messages from the topic (published at or after replayFromTimestamp) are asynchronously delivered to this subscription. This mirrors AWS SNS archive replay behaviour.

func (*InMemoryBackend) SetTopicAttributes

func (b *InMemoryBackend) SetTopicAttributes(topicArn, attrName, attrValue string) error

SetTopicAttributes sets a single attribute on a topic.

func (*InMemoryBackend) SetTopicTags

func (b *InMemoryBackend) SetTopicTags(arn string, kv *svcTags.Tags)

SetTopicTags stores tags for the given topic ARN.

func (*InMemoryBackend) SigningCertPEM

func (b *InMemoryBackend) SigningCertPEM() []byte

SigningCertPEM returns the PEM-encoded self-signed certificate used to verify HTTP/HTTPS notification signatures. Tests can call this to verify that a notification's Signature field is a valid RSA-SHA1 signature over the canonical notification string.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) Subscribe

func (b *InMemoryBackend) Subscribe(
	topicArn, protocol, endpoint, filterPolicy string,
) (*Subscription, error)

Subscribe creates a new subscription for the given topic, protocol, and endpoint. If a confirmed subscription for the same topic+protocol+endpoint already exists, the existing subscription ARN is returned (matching AWS deduplication behaviour).

func (*InMemoryBackend) TagTopicByARN

func (b *InMemoryBackend) TagTopicByARN(topicARN string, newTags map[string]string) error

TagTopicByARN applies tags to the SNS topic identified by its ARN.

func (*InMemoryBackend) TaggedTopics

func (b *InMemoryBackend) TaggedTopics() []TaggedTopicInfo

TaggedTopics returns a snapshot of all SNS topics with their tags. Intended for use by the Resource Groups Tagging API provider.

func (*InMemoryBackend) Unsubscribe

func (b *InMemoryBackend) Unsubscribe(subscriptionArn string) error

Unsubscribe removes a subscription by ARN.

func (*InMemoryBackend) UntagTopicByARN

func (b *InMemoryBackend) UntagTopicByARN(topicARN string, tagKeys []string) error

UntagTopicByARN removes the specified tag keys from the SNS topic identified by its ARN.

func (*InMemoryBackend) VerifySMSSandboxPhoneNumber

func (b *InMemoryBackend) VerifySMSSandboxPhoneNumber(phoneNumber, oneTimePassword string) error

VerifySMSSandboxPhoneNumber marks a sandbox phone number as Verified. In the mock backend, any non-empty one-time password is accepted.

func (*InMemoryBackend) WaitDeliveries

func (b *InMemoryBackend) WaitDeliveries()

WaitDeliveries stops accepting new HTTP/HTTPS delivery goroutines and blocks until all currently in-flight delivery goroutines have finished. It is called during graceful shutdown by Handler.Shutdown.

Goroutines that were already launched (before WaitDeliveries is called) always complete their delivery. Subsequent calls are safe (idempotent via closing flag).

type LambdaInvoker

type LambdaInvoker interface {
	InvokeFunction(
		ctx context.Context,
		name, invocationType string,
		payload []byte,
	) ([]byte, int, error)
}

LambdaInvoker can invoke a Lambda function for SNS subscription delivery.

type ListEndpointsByPlatformApplicationResponse

type ListEndpointsByPlatformApplicationResponse struct {
	XMLName                                  xml.Name                                 `xml:"https://sns.amazonaws.com/doc/2010-03-31/ ListEndpointsByPlatformApplicationResponse"` //nolint:lll // XML namespace makes this line long.
	ResponseMetadata                         ResponseMetadata                         `xml:"ResponseMetadata"`
	ListEndpointsByPlatformApplicationResult ListEndpointsByPlatformApplicationResult `xml:"ListEndpointsByPlatformApplicationResult"` //nolint:lll // Long type name.
}

ListEndpointsByPlatformApplicationResponse is the XML response for ListEndpointsByPlatformApplication.

type ListEndpointsByPlatformApplicationResult

type ListEndpointsByPlatformApplicationResult struct {
	NextToken string                `xml:"NextToken,omitempty"`
	Endpoints []XMLPlatformEndpoint `xml:"Endpoints>member"`
}

ListEndpointsByPlatformApplicationResult holds the result of ListEndpointsByPlatformApplication.

type ListOriginationNumbersResponse

type ListOriginationNumbersResponse struct {
	XMLName                      xml.Name                     `xml:"https://sns.amazonaws.com/doc/2010-03-31/ ListOriginationNumbersResponse"` //nolint:lll // XML namespace.
	ResponseMetadata             ResponseMetadata             `xml:"ResponseMetadata"`
	ListOriginationNumbersResult ListOriginationNumbersResult `xml:"ListOriginationNumbersResult"`
}

ListOriginationNumbersResponse is the XML response for ListOriginationNumbers.

type ListOriginationNumbersResult

type ListOriginationNumbersResult struct {
	NextToken    string                `xml:"NextToken,omitempty"`
	PhoneNumbers []XMLOriginationPhone `xml:"PhoneNumbers>member"`
}

ListOriginationNumbersResult holds the result of ListOriginationNumbers.

type ListPhoneNumbersOptedOutResponse

type ListPhoneNumbersOptedOutResponse struct {
	XMLName                        xml.Name                       `xml:"https://sns.amazonaws.com/doc/2010-03-31/ ListPhoneNumbersOptedOutResponse"` //nolint:lll // XML namespace.
	ResponseMetadata               ResponseMetadata               `xml:"ResponseMetadata"`
	ListPhoneNumbersOptedOutResult ListPhoneNumbersOptedOutResult `xml:"ListPhoneNumbersOptedOutResult"`
}

ListPhoneNumbersOptedOutResponse is the XML response for ListPhoneNumbersOptedOut.

type ListPhoneNumbersOptedOutResult

type ListPhoneNumbersOptedOutResult struct {
	NextToken    string   `xml:"nextToken,omitempty"`
	PhoneNumbers []string `xml:"phoneNumbers>member"`
}

ListPhoneNumbersOptedOutResult holds the result of ListPhoneNumbersOptedOut.

type ListPlatformApplicationsResponse

type ListPlatformApplicationsResponse struct {
	XMLName                        xml.Name                       `xml:"https://sns.amazonaws.com/doc/2010-03-31/ ListPlatformApplicationsResponse"` //nolint:lll // XML namespace makes this line long.
	ResponseMetadata               ResponseMetadata               `xml:"ResponseMetadata"`
	ListPlatformApplicationsResult ListPlatformApplicationsResult `xml:"ListPlatformApplicationsResult"`
}

ListPlatformApplicationsResponse is the XML response for ListPlatformApplications.

type ListPlatformApplicationsResult

type ListPlatformApplicationsResult struct {
	NextToken            string                   `xml:"NextToken,omitempty"`
	PlatformApplications []XMLPlatformApplication `xml:"PlatformApplications>member"`
}

ListPlatformApplicationsResult holds the result of ListPlatformApplications.

type ListSMSSandboxPhoneNumbersResponse

type ListSMSSandboxPhoneNumbersResponse struct {
	XMLName                          xml.Name                         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ ListSMSSandboxPhoneNumbersResponse"` //nolint:lll // XML namespace.
	ResponseMetadata                 ResponseMetadata                 `xml:"ResponseMetadata"`
	ListSMSSandboxPhoneNumbersResult ListSMSSandboxPhoneNumbersResult `xml:"ListSMSSandboxPhoneNumbersResult"`
}

ListSMSSandboxPhoneNumbersResponse is the XML response for ListSMSSandboxPhoneNumbers.

type ListSMSSandboxPhoneNumbersResult

type ListSMSSandboxPhoneNumbersResult struct {
	NextToken    string                  `xml:"NextToken,omitempty"`
	PhoneNumbers []XMLSandboxPhoneNumber `xml:"PhoneNumbers>member"`
}

ListSMSSandboxPhoneNumbersResult holds the result of ListSMSSandboxPhoneNumbers.

type ListSubscriptionsByTopicResponse

type ListSubscriptionsByTopicResponse struct {
	XMLName                        xml.Name                       `xml:"https://sns.amazonaws.com/doc/2010-03-31/ ListSubscriptionsByTopicResponse"` //nolint:lll // XML namespace makes this line long.
	ResponseMetadata               ResponseMetadata               `xml:"ResponseMetadata"`
	ListSubscriptionsByTopicResult ListSubscriptionsByTopicResult `xml:"ListSubscriptionsByTopicResult"`
}

ListSubscriptionsByTopicResponse is the XML response for ListSubscriptionsByTopic.

type ListSubscriptionsByTopicResult

type ListSubscriptionsByTopicResult struct {
	NextToken     string            `xml:"NextToken,omitempty"`
	Subscriptions []XMLSubscription `xml:"Subscriptions>member"`
}

ListSubscriptionsByTopicResult holds the result of a ListSubscriptionsByTopic operation.

type ListSubscriptionsResponse

type ListSubscriptionsResponse struct {
	XMLName                 xml.Name                `xml:"https://sns.amazonaws.com/doc/2010-03-31/ ListSubscriptionsResponse"` //nolint:lll // XML namespace makes this line long.
	ResponseMetadata        ResponseMetadata        `xml:"ResponseMetadata"`
	ListSubscriptionsResult ListSubscriptionsResult `xml:"ListSubscriptionsResult"`
}

ListSubscriptionsResponse is the XML response for ListSubscriptions.

type ListSubscriptionsResult

type ListSubscriptionsResult struct {
	NextToken     string            `xml:"NextToken,omitempty"`
	Subscriptions []XMLSubscription `xml:"Subscriptions>member"`
}

ListSubscriptionsResult holds the result of a ListSubscriptions operation.

type ListTopicsResponse

type ListTopicsResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ ListTopicsResponse"`
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
	ListTopicsResult ListTopicsResult `xml:"ListTopicsResult"`
}

ListTopicsResponse is the XML response for ListTopics.

type ListTopicsResult

type ListTopicsResult struct {
	NextToken string     `xml:"NextToken,omitempty"`
	Topics    []XMLTopic `xml:"Topics>member"`
}

ListTopicsResult holds the result of a ListTopics operation.

type Message

type Message struct {
	Attributes map[string]MessageAttribute
	MessageID  string
	Body       string
	Subject    string
	TopicArn   string
}

Message represents a published SNS message.

type MessageAttribute

type MessageAttribute struct {
	DataType    string
	StringValue string
}

MessageAttribute represents a single message attribute value.

type OptInPhoneNumberResponse

type OptInPhoneNumberResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ OptInPhoneNumberResponse"`
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

OptInPhoneNumberResponse is the XML response for OptInPhoneNumber.

type PlatformApplication

type PlatformApplication struct {
	CreationTimestamp      time.Time         `json:"creationTimestamp"`
	Attributes             map[string]string `json:"attributes,omitempty"`
	PlatformApplicationArn string            `json:"platformApplicationArn"`
}

PlatformApplication represents an SNS platform application for mobile push.

type PlatformEndpoint

type PlatformEndpoint struct {
	CreationTimestamp      time.Time         `json:"creationTimestamp"`
	Attributes             map[string]string `json:"attributes,omitempty"`
	EndpointArn            string            `json:"endpointArn"`
	PlatformApplicationArn string            `json:"platformApplicationArn"`
}

PlatformEndpoint represents an SNS platform endpoint (device token registration).

type Provider

type Provider struct{}

Provider implements service.Provider for the SNS service.

func (*Provider) Init

Init initializes the SNS service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the logical name of the provider.

type PublishBatchResponse

type PublishBatchResponse struct {
	XMLName            xml.Name           `xml:"https://sns.amazonaws.com/doc/2010-03-31/ PublishBatchResponse"`
	ResponseMetadata   ResponseMetadata   `xml:"ResponseMetadata"`
	PublishBatchResult PublishBatchResult `xml:"PublishBatchResult"`
}

PublishBatchResponse is the XML response for PublishBatch.

type PublishBatchResult

type PublishBatchResult struct {
	Successful []XMLPublishBatchSuccessEntry `xml:"Successful>member"`
	Failed     []XMLPublishBatchFailEntry    `xml:"Failed>member"`
}

PublishBatchResult holds the result of a PublishBatch operation.

type PublishResponse

type PublishResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ PublishResponse"`
	PublishResult    PublishResult    `xml:"PublishResult"`
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

PublishResponse is the XML response for Publish.

type PublishResult

type PublishResult struct {
	MessageID      string `xml:"MessageId"`
	SequenceNumber string `xml:"SequenceNumber,omitempty"`
}

PublishResult holds the result of a Publish operation. SequenceNumber is only populated for FIFO topics; it is a monotonically increasing 20-digit zero-padded integer unique within the topic.

type PutDataProtectionPolicyResponse

type PutDataProtectionPolicyResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ PutDataProtectionPolicyResponse"` //nolint:lll // XML namespace.
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

PutDataProtectionPolicyResponse is the XML response for PutDataProtectionPolicy.

type RemovePermissionResponse

type RemovePermissionResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ RemovePermissionResponse"`
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

RemovePermissionResponse is the XML response for RemovePermission.

type ResponseMetadata

type ResponseMetadata struct {
	RequestID string `xml:"RequestId"`
}

ResponseMetadata is included in all SNS XML responses.

type SMSDelivery

type SMSDelivery struct {
	PhoneNumber string
	Message     string
	MessageID   string
}

SMSDelivery records a single SMS message sent via PublishSMS.

type SQSQueueChecker

type SQSQueueChecker interface {
	QueueExists(ctx context.Context, queueARN string) (bool, error)
}

SQSQueueChecker can verify whether an SQS queue identified by ARN exists. Used to validate RedrivePolicy.deadLetterTargetArn during SetSubscriptionAttributes.

type SQSSender

type SQSSender interface {
	SendMessageToQueue(ctx context.Context, queueARN, messageBody string) error
}

SQSSender can send a message to an SQS queue identified by ARN, used for DLQ delivery.

type SandboxPhoneNumber

type SandboxPhoneNumber struct {
	CreationTimestamp time.Time `json:"creationTimestamp"`
	PhoneNumber       string    `json:"phoneNumber"`
	LanguageCode      string    `json:"languageCode,omitempty"`
	Status            string    `json:"status"` // "Pending" or "Verified"
}

SandboxPhoneNumber represents a phone number registered in the SMS sandbox.

type SetEndpointAttributesResponse

type SetEndpointAttributesResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ SetEndpointAttributesResponse"` //nolint:lll // XML namespace makes this line long.
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

SetEndpointAttributesResponse is the XML response for SetEndpointAttributes.

type SetPlatformApplicationAttributesResponse

type SetPlatformApplicationAttributesResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ SetPlatformApplicationAttributesResponse"` //nolint:lll // XML namespace makes this line long.
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

SetPlatformApplicationAttributesResponse is the XML response for SetPlatformApplicationAttributes.

type SetSMSAttributesResponse

type SetSMSAttributesResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ SetSMSAttributesResponse"`
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

SetSMSAttributesResponse is the XML response for SetSMSAttributes.

type SetSubscriptionAttributesResponse

type SetSubscriptionAttributesResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ SetSubscriptionAttributesResponse"`
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

SetSubscriptionAttributesResponse is the XML response for SetSubscriptionAttributes.

type SetTopicAttributesResponse

type SetTopicAttributesResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ SetTopicAttributesResponse"`
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

SetTopicAttributesResponse is the XML response for SetTopicAttributes.

type StorageBackend

type StorageBackend interface {
	CreateTopic(name string, attributes map[string]string) (*Topic, error)
	CreateTopicInRegion(name, region string, attributes map[string]string) (*Topic, error)
	DeleteTopic(topicArn string) error
	ListTopics(nextToken string) ([]Topic, string, error)
	ListTopicsInRegion(region, nextToken string) ([]Topic, string, error)
	GetTopicAttributes(topicArn string) (map[string]string, error)
	SetTopicAttributes(topicArn, attrName, attrValue string) error
	Subscribe(topicArn, protocol, endpoint, filterPolicy string) (*Subscription, error)
	ConfirmSubscription(topicArn, token string) (*Subscription, error)
	Unsubscribe(subscriptionArn string) error
	ListSubscriptions(nextToken string) ([]Subscription, string, error)
	ListSubscriptionsByTopic(topicArn, nextToken string) ([]Subscription, string, error)
	GetSubscriptionAttributes(subscriptionArn string) (map[string]string, error)
	SetSubscriptionAttributes(subscriptionArn, attrName, attrValue string) error
	Publish(
		topicArn, message, subject, messageStructure string,
		attrs map[string]MessageAttribute,
	) (string, error)
	// PublishToTargetArn publishes directly to a platform endpoint ARN.
	// In the mock, this generates and returns a unique message ID without real delivery.
	PublishToTargetArn(
		targetArn, message, subject string,
		attrs map[string]MessageAttribute,
	) (string, error)
	// PublishSMS publishes directly to a phone number via SMS.
	// In the mock, this generates and returns a unique message ID without real delivery.
	PublishSMS(phoneNumber, message string) (string, error)
	ListAllTopics() []Topic
	ListAllSubscriptions() []Subscription
	ListAllPlatformApplications() []PlatformApplication
	GetTopicTags(arn string) map[string]string
	SetTopicTags(arn string, kv *svcTags.Tags)
	RemoveTopicTags(arn string, keys []string)
	// Platform application operations.
	CreatePlatformApplication(
		name, platform string,
		attributes map[string]string,
	) (*PlatformApplication, error)
	CreatePlatformApplicationInRegion(
		name, platform, region string,
		attributes map[string]string,
	) (*PlatformApplication, error)
	GetPlatformApplicationAttributes(platformApplicationArn string) (map[string]string, error)
	SetPlatformApplicationAttributes(
		platformApplicationArn string,
		attributes map[string]string,
	) error
	ListPlatformApplications(nextToken string) ([]PlatformApplication, string, error)
	DeletePlatformApplication(platformApplicationArn string) error
	// Platform endpoint operations.
	CreatePlatformEndpoint(
		platformApplicationArn, token string,
		attributes map[string]string,
	) (*PlatformEndpoint, error)
	GetEndpointAttributes(endpointArn string) (map[string]string, error)
	SetEndpointAttributes(endpointArn string, attributes map[string]string) error
	ListEndpointsByPlatformApplication(
		platformApplicationArn, nextToken string,
	) ([]PlatformEndpoint, string, error)
	DeleteEndpoint(endpointArn string) error
	// Permission operations.
	AddPermission(topicArn, label string, accounts, actions []string) error
	RemovePermission(topicArn, label string) error
	// SMS Sandbox operations.
	GetSMSSandboxAccountStatus() (bool, error)
	CreateSMSSandboxPhoneNumber(phoneNumber, languageCode string) error
	DeleteSMSSandboxPhoneNumber(phoneNumber string) error
	ListSMSSandboxPhoneNumbers(
		nextToken string,
		maxResults int,
	) ([]SandboxPhoneNumber, string, error)
	VerifySMSSandboxPhoneNumber(phoneNumber, oneTimePassword string) error
	// SMS opt-out operations.
	CheckIfPhoneNumberIsOptedOut(phoneNumber string) (bool, error)
	ListPhoneNumbersOptedOut(nextToken string, maxResults int) ([]string, string, error)
	OptInPhoneNumber(phoneNumber string) error
	// SMS attribute operations.
	GetSMSAttributes(names []string) (map[string]string, error)
	SetSMSAttributes(attributes map[string]string) error
	// Data protection policy operations.
	GetDataProtectionPolicy(resourceArn string) (string, error)
	PutDataProtectionPolicy(resourceArn, policy string) error
	// Origination number operations.
	ListOriginationNumbers(nextToken string, maxResults int) ([]XMLOriginationPhone, string, error)
}

StorageBackend defines the interface for an SNS storage backend.

type SubscribeResponse

type SubscribeResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ SubscribeResponse"`
	SubscribeResult  SubscribeResult  `xml:"SubscribeResult"`
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

SubscribeResponse is the XML response for Subscribe.

type SubscribeResult

type SubscribeResult struct {
	SubscriptionArn string `xml:"SubscriptionArn"`
}

SubscribeResult holds the result of a Subscribe operation.

type Subscription

type Subscription struct {
	CreationTimestamp time.Time `json:"creationTimestamp"`

	RedrivePolicy       string `json:"redrivePolicy,omitempty"`
	DeliveryPolicy      string `json:"deliveryPolicy,omitempty"`
	ReplayPolicy        string `json:"replayPolicy,omitempty"`
	Endpoint            string `json:"endpoint"`
	Owner               string `json:"owner"`
	TopicArn            string `json:"topicArn"`
	Protocol            string `json:"protocol"`
	SubscriptionRoleArn string `json:"subscriptionRoleArn,omitempty"`
	FilterPolicyScope   string `json:"filterPolicyScope,omitempty"`
	SubscriptionArn     string `json:"subscriptionArn"`
	FilterPolicy        string `json:"filterPolicy,omitempty"`
	RawMessageDelivery  bool   `json:"rawMessageDelivery,omitempty"`
	PendingConfirmation bool   `json:"pendingConfirmation"`
	// contains filtered or unexported fields
}

Subscription represents an SNS subscription.

type TaggedTopicInfo

type TaggedTopicInfo struct {
	Tags map[string]string
	ARN  string
}

TaggedTopicInfo contains a topic's ARN and tag snapshot. Used by the Resource Groups Tagging API cross-service listing.

type Topic

type Topic struct {
	CreationTimestamp time.Time                   `json:"creationTimestamp"`
	Attributes        map[string]string           `json:"attributes,omitempty"`
	Permissions       map[string]*TopicPermission `json:"permissions,omitempty"`
	TopicArn          string                      `json:"topicArn"`
}

Topic represents an SNS topic.

type TopicPermission

type TopicPermission struct {
	Label      string   `json:"label"`
	AWSAccount []string `json:"awsAccount"`
	Actions    []string `json:"actions"`
}

TopicPermission represents a single permission (statement) added to an SNS topic policy.

type UnsubscribeResponse

type UnsubscribeResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ UnsubscribeResponse"`
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

UnsubscribeResponse is the XML response for Unsubscribe.

type VerifySMSSandboxPhoneNumberResponse

type VerifySMSSandboxPhoneNumberResponse struct {
	XMLName          xml.Name         `xml:"https://sns.amazonaws.com/doc/2010-03-31/ VerifySMSSandboxPhoneNumberResponse"` //nolint:lll // XML namespace.
	ResponseMetadata ResponseMetadata `xml:"ResponseMetadata"`
}

VerifySMSSandboxPhoneNumberResponse is the XML response for VerifySMSSandboxPhoneNumber.

type XMLAttributeEntry

type XMLAttributeEntry struct {
	Key   string `xml:"key"`
	Value string `xml:"value"`
}

XMLAttributeEntry is a key-value attribute pair in XML attribute maps.

type XMLOriginationPhone

type XMLOriginationPhone struct {
	PhoneNumber        string   `xml:"PhoneNumber"`
	Iso2CountryCode    string   `xml:"Iso2CountryCode"`
	RouteType          string   `xml:"RouteType"`
	NumberCapabilities []string `xml:"NumberCapabilities>member"`
}

XMLOriginationPhone is the XML representation of an origination phone number.

type XMLPlatformApplication

type XMLPlatformApplication struct {
	PlatformApplicationArn string              `xml:"PlatformApplicationArn"`
	Attributes             []XMLAttributeEntry `xml:"Attributes>entry"`
}

XMLPlatformApplication is the XML representation of a platform application in list responses.

type XMLPlatformEndpoint

type XMLPlatformEndpoint struct {
	EndpointArn string              `xml:"EndpointArn"`
	Attributes  []XMLAttributeEntry `xml:"Attributes>entry"`
}

XMLPlatformEndpoint is the XML representation of a platform endpoint in list responses.

type XMLPublishBatchFailEntry

type XMLPublishBatchFailEntry struct {
	ID          string `xml:"Id"`
	Code        string `xml:"Code"`
	Message     string `xml:"Message"`
	SenderFault bool   `xml:"SenderFault"`
}

XMLPublishBatchFailEntry represents a failed batch entry.

type XMLPublishBatchSuccessEntry

type XMLPublishBatchSuccessEntry struct {
	MessageID      string `xml:"MessageId"`
	SequenceNumber string `xml:"SequenceNumber,omitempty"`
	ID             string `xml:"Id"`
}

XMLPublishBatchSuccessEntry represents a successfully published batch entry. SequenceNumber is only populated for FIFO topic batch entries.

type XMLSandboxPhoneNumber

type XMLSandboxPhoneNumber struct {
	PhoneNumber  string `xml:"PhoneNumber"`
	LanguageCode string `xml:"LanguageCode,omitempty"`
	Status       string `xml:"Status"`
}

XMLSandboxPhoneNumber is the XML representation of a sandbox phone number entry.

type XMLSubscription

type XMLSubscription struct {
	TopicArn        string `xml:"TopicArn"`
	Protocol        string `xml:"Protocol"`
	SubscriptionArn string `xml:"SubscriptionArn"`
	Owner           string `xml:"Owner"`
	Endpoint        string `xml:"Endpoint"`
}

XMLSubscription is the XML representation of a subscription in list responses.

type XMLTopic

type XMLTopic struct {
	TopicArn string `xml:"TopicArn"`
}

XMLTopic is the XML representation of a topic in list responses.

Jump to

Keyboard shortcuts

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