-
Notifications
You must be signed in to change notification settings - Fork 16
/
sns.aws.txt
291 lines (255 loc) · 18.7 KB
/
sns.aws.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
SNS
TODO:
- revisit CloudWatch logs MASK_POLICY, since it seems to be a subset of SNS's
SNS ==> #Version from 2014-07-10
GOAL ==> #Like SQS, but forwards as email, AJAX request, SQS, SMS or mobile push notifications.
MESSAGE/TOPIC ==> #Similar to SQS message/queue, but:
# - 1-n readers, not just 1
# - reading ("subscribe"), done via different protocols.
# - no polling
# - can push different message according to protocol
# - uses message titles ("Subject")
# - Must confirm subscriptions within 3 days.
/=+===============================+=\
/ : : \
)==: PROTOCOLS :==(
\ :_______________________________: /
\=+===============================+=/
HTTP[S] ==> # - Endpoint is URL
# - POST request
# - Must respond with 2xx, 3xx or 4xx (otherwise it will retry, see below)
# - Sends:
# - SubscriptionConfirmation: after Subscribe(). Must use ConfirmSubscription() with Token sent
# - Notification: message sent
# - UnsubscribeConfirmation: afterUnsubscribe()
# - Headers:
# - x-amz-sns-message-type [C]
# - x-amz-sns-message-id [C]
# - x-amz-sns-message-topic-arn [C]
# - x-amz-sns-message-subscription-arn [C]
# - User-Agent: Amazon Simple Notification Service Agent
# - Body is either:
# - OBJ:
# - Type "SubscriptionConfirmation|Notification|UnsubscribeConfirmation"
# - MessageId
# - TopicArn
# - Subject STR
# - Message STR
# - Timestamp DATE_STR
# - Signature STR
# - SigningCertURL PEM_FILE_URL
# - Token STR: To useConfirmSubscription()
# - [Un]subscribeURL: URL with Action "[Un]subscribe" to this topic
# - message as is, if SetSubscriptionAttributes() RawMessageDelivery true or
# MessageStructure not "json"
# - will add x-amz-sns-rawdelivery: true [C]
# - Supports SNI
# - Can put user:password@ in URL (Basic and Digest Authentication)
# - DeliveryPolicy: JSON_STR specifying how to retry. Can be set up by:
# - publisher, with SetTopicAttributes():
# - http:
# - healthyRetryPolicy:
# - numNoDelayRetries NUM (def: 0): after this number of retries with Delay == 0
# (beginning), starts delaying with minDelay (but no backoffFunction)
# - min|maxDelayTarget NUM (def: 20|20)
# - numMinDelayRetries NUM (def: 0): after this number of retries with
# Delay == minDelay, starts using backOffFunction
# - numRetries NUM (def: 3): number of retries between minDelay and maxDelay
# - backoffFunction "linear|arithmetic|geometric|exponential" (def: "linear")
# - numMaxDelayRetries NUM (def: 0): after this number of retries with
# Delay == maxDelay, stops
# - defaultThrottlePolicy: maxReceivesPerSecond NUM (def: null):
# - max number of messages per second.
# - above it: messages are pending for max one hour
# - disableSubscriptionOverrides BOOL (def: false)
# - subscriber, with SetSubscriptionAttributes(): same but:
# - no http, nor disableSubscriptionOverrides
# - defaultThrottlePolicy -> throttlePolicy
# - security:
# - should use HTTPS
# - should verify signature
EMAIL-JSON ==> #Like HTTP[S] but:
# - Endpoint is email address
# - Sent from [email protected], which appears as DisplayName
# (def: "AWS Notifications")
# - def. Subject is "AWS Notification Message"
# - no RawMessageDelivery nor metadata
EMAIL ==> #Like email-json, but sends messages raw, not JSON (unless MessageStructure "json")
SQS ==> #SendMessage():
# - Endpoint is SQS_QUEUE_ARN
# - Message is same JSON as HTTP[S]
# - Must give permission:
# - Action "sqs:SendMessage"
# - Resource SQS_QUEUE_ARN
# - Principal "*"
# - Condition: { ArnEquals: { "aws:SourceArn": TOPIC_ARN }}
SMS ==> # - Endpoint is phone number (only in US) [:digit:] only
# - Topics must be in REGION us-east
# - must use DisplayName: will use first 10 chars uppercased as start of the SMS body, followed
# by ">"
# - If Subject, uses it instead of Message as the message body
# - max 140 ASCII or 70 Unicode
# - Uses phone number 303-04.
# - Ask for confirmation first (must send SMS back "Yes DISPLAYNAME")
# - Can unsubscribe by SMS responding with "Stop"
PUSH NOTIFICATION ==> # - Endpoint is PLATFORM_ENDPOINT_ARN
# - Messages are JSON_STR:
# - ADM|APNS[_SANDBOX]|GCM|Baidu|MPNS|WNS:
# - data: message STR, url STR
# - time_to_live NUM: after this, if not delivered, drops it (def: 4 weeks)
# - collapse_key "deals"
# - Steps:
# - first CreatePlatformApplication(): for all users. Must supply app credentials.
# - then CreatePlatformEndpoint(): for given device. Must supply device-sent Token.
# - CustomUserData: arbitraty user data (max 2KB)
# - Support:
# - iOS: "APNS[_SANDBOX]", Apple Push Notification Service
# - PlatformCredential "private key", PlatformPrincipal "SSL certificate"
# - Android (not China), and Chrome apps/extensions: "GCM", Google Cloud Messaging for Android
# - PlatformCredential "API key"
# - Android (China): "Baidu", Baidu Cloud Push
# - PlatformCredential "API key", "client secret"
# - Windows Phone: "MPNS", Microsoft Push Notification Service for Windows Phone
# - PlatformCredential "private key", PlatformPrincipal "SSL certificate"
# - Windows 8: "WNS", Windows Push Notification Services
# - PlatformCredential "client secret", PlatformPrincipal "client id"
# - Kindle: "ADM", Amazon Device Messaging
# - PlatformCredential "client secret", PlatformPrincipal "client id"
/=+===============================+=\
/ : : \
)==: API :==(
\ :_______________________________: /
\=+===============================+=/
CLOUDWATCH ==> #METRIC:
# - NumberOfMessagesPublished NUM
# - PublishSize NUM
# - NumberOfNotificationsDelivered|Failed NUM
#Dimensions: Application, Platform, TopicName
API ==> # - ARR.member.NUM (REST API) -> ARR (SDKs)
ARN ==> #Like SQS, use resource-based permissions (on Topics) and Add|RemovePermission(), but:
# - default policy: allow everyone to do all actions, providing AWS:SourceOwner == ACCOUNT_ID,
# where ACCOUNT_ID is Topic creator (so allows only creator to do anything)
# - ARN is arn:aws:sns:REGION:ACCOUNT_ID:TOPIC_NAME
# - COND_KEYs:
# - sns:Endpoint STR
# - sns:Protocol STR
PAGINATION ==> # - Request parameters: NextToken STR
# - Response body: NextToken STR
/=+===============================+=\
/ : : \
)==: METHODS GENERAL :==(
\ :_______________________________: /
\=+===============================+=/
CreateTopic() #Request parameters: Name STR
#Response body: TopicArn STR
DeleteTopic() #Request parameters: TopicArn STR
ListTopics() #Response body: Topics OBJ_ARR: TopicArn STR
#Paginates
SetTopicAttributes() #Request parameters:
# - AttributeName "Policy|DisplayName|DeliveryPolicy"
# - AttributeValue STR
# - TopicArn
GetTopicAttributes() #Request parameters: TopicArn STR
#Response body: Attributes OBJ:
# - TopicArn STR
# - Owner ACCOUNT_ID
# - Policy JSON_STR
# - DisplayName STR
# - SubscriptionsPending|Confirmed|Deleted NUM
# - [Effective]DeliveryPolicy JSON_STR
Publish() #Request parameters:
# - Message STR or JSON_STR, with OBJ.default|email|sqs|sms|http[s] STR
# - MessageAttributes METADATA:
# - VAR:
# - DataType "String|Binary[.CUSTOM]"
# - BinaryValue BUFFER|TYPEDARRAY|BLOB
# - StringValue STR
# - MessageStructure "json" (optional)
# - Subject STR
# - TopicArn TOPIC_ARN
# - TargetArn ENDPOINT_ARN
#Response body: MessageId STR
Subscribe() #Request parameters:
# - TopicArn STR
# - Protocol "http[s]|email[-json]|sms|sqs|application"
# - EndpointUrl URL
#Response body: SubscriptionArn STR
Unsubscribe() #Request parameters: SubscriptionArn STR
ConfirmSubscription() #Request parameters:
# - TopicArn STR
# - Token STR
# - AuthenticateOnUnsubscribe "true" (optional): only topic or subscription owner can
# Unsubscribe()
#Response body: SubscriptionArn STR
ListSubscriptions() #Response body: Subscriptions SUBSCRIPTION_ARR:
# - TopicArn STR
# - Protocol STR
# - Endpoint URL
# - Owner STR
# - SubscriptionArn STR
#Paginates
ListSubscriptionsByTopic() #Request parameters: TopicArn STR
#Response body: Subscriptions SUBSCRIPTION_ARR
#Paginates
SetSubscriptionAttributes() #Request parameters:
# - AttributeName "DeliveryPolicy|RawMessageDelivery"
# - AttributeValue STR
# - TopicArn
GetSubscriptionAttributes() #Request parameters: SubscriptionArn STR
#Response body: Attributes OBJ_ARR
# - SubscriptionArn STR
# - TopicArn STR
# - Owner STR
# - ConfirmationWasAuthenticated BOOL
# - [Effective]DeliveryPolicy JSON_STR
AddPermission() #Request parameters:
# - AWSAccountId ACCOUNT_ID_ARR
# - ActionName ACTION_ARR
# - Label STR
# - TopicArn STR
RemovePermission() #Request parameters:
# - Label STR
# - TopicArn STR
/=+===============================+=\
/ : : \
)==: METHODS PUSH NOTIFICATIONS :==(
\ :_______________________________: /
\=+===============================+=/
CreatePlatformApplication() #Request parameters:
# - Name STR
# - Platform "ADM|APNS[_SANDBOX]|GCM|Baidu|MPNS|WNS"
# - Attributes PLATFORM_ATTRIBUTES:
# - PlatformCredential "private key|API key|client secret"
# - PlatformPrincipal "SSL certificate|client id"
# - EventEndpointCreated|Deleted|Updated TOPIC_ARN
# - EventDeliveryFailure TOPIC_ARN
#Response body: PlatformApplicationArn STR
DeletePlatformApplication() #Request parameters: PlatformApplicationArn STR
SetPlatformApplication #Request parameters PLATFORM:
Attributes() # - Attributes PLATFORM_ATTRIBUTES
# - PlatformApplicationArn STR
GetPlatformApplication #Request parameters: PlatformApplicationArn STR
Attributes() #Response body: Attributes OBJ_ARR
# - EventEndpointCreated|Deleted|Updated TOPIC_ARN
# - EventDeliveryFailure TOPIC_ARN
ListPlatformApplications() #Response body: PlatformApplications PLATFORM_ARR
CreatePlatformEndpoint() #Request parameters:
# - Attributes ENDPOINT_ATTR:
# - CustomUserData STR
# - Token STR
# - Enabled BOOL
# - CustomUserData STR
# - PlatformApplicationArn STR
# - Token STR
#Response body: EndpointArn STR
DeleteEndpoint() #Request parameters: EndpointArn STR
SetEndpointAttributes() #Request parameters FULL_ENDPOINT_ATTR:
# - EndpointArn STR
# - Attributes ENDPOINT_ATTR
GetEndpointAttributes() #Request parameters: EndpointArn STR
#Response body: Attributes ENDPOINT_ATTR
ListEndpoints #Request parameters: PlatformApplicationArn STR
ByPlatformApplication() #Response body: Endpoints FULL_ENDPOINT_ATTR_ARR
#Paginates