/
PublishRequest.cs
413 lines (388 loc) · 20.1 KB
/
PublishRequest.cs
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
/*
* Do not modify this file. This file is generated from the sns-2010-03-31.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;
using System.IO;
using System.Net;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
namespace Amazon.SimpleNotificationService.Model
{
/// <summary>
/// Container for the parameters to the Publish operation.
/// Sends a message to an Amazon SNS topic, a text message (SMS message) directly to a
/// phone number, or a message to a mobile platform endpoint (when you specify the <code>TargetArn</code>).
///
///
/// <para>
/// If you send a message to a topic, Amazon SNS delivers the message to each endpoint
/// that is subscribed to the topic. The format of the message depends on the notification
/// protocol for each subscribed endpoint.
/// </para>
///
/// <para>
/// When a <code>messageId</code> is returned, the message is saved and Amazon SNS immediately
/// delivers it to subscribers.
/// </para>
///
/// <para>
/// To use the <code>Publish</code> action for publishing a message to a mobile endpoint,
/// such as an app on a Kindle device or mobile phone, you must specify the EndpointArn
/// for the TargetArn parameter. The EndpointArn is returned when making a call with the
/// <code>CreatePlatformEndpoint</code> action.
/// </para>
///
/// <para>
/// For more information about formatting messages, see <a href="https://docs.aws.amazon.com/sns/latest/dg/mobile-push-send-custommessage.html">Send
/// Custom Platform-Specific Payloads in Messages to Mobile Devices</a>.
/// </para>
/// <important>
/// <para>
/// You can publish messages only to topics and endpoints in the same Amazon Web Services
/// Region.
/// </para>
/// </important>
/// </summary>
public partial class PublishRequest : AmazonSimpleNotificationServiceRequest
{
private string _message;
private Dictionary<string, MessageAttributeValue> _messageAttributes = new Dictionary<string, MessageAttributeValue>();
private string _messageDeduplicationId;
private string _messageGroupId;
private string _messageStructure;
private string _phoneNumber;
private string _subject;
private string _targetArn;
private string _topicArn;
/// <summary>
/// Empty constructor used to set properties independently even when a simple constructor is available
/// </summary>
public PublishRequest() { }
/// <summary>
/// Instantiates PublishRequest with the parameterized properties
/// </summary>
/// <param name="topicArn">The topic you want to publish to. If you don't specify a value for the <code>TopicArn</code> parameter, you must specify a value for the <code>PhoneNumber</code> or <code>TargetArn</code> parameters.</param>
/// <param name="message">The message you want to send. If you are publishing to a topic and you want to send the same message to all transport protocols, include the text of the message as a String value. If you want to send different messages for each transport protocol, set the value of the <code>MessageStructure</code> parameter to <code>json</code> and use a JSON object for the <code>Message</code> parameter. <p/> Constraints: <ul> <li> With the exception of SMS, messages must be UTF-8 encoded strings and at most 256 KB in size (262,144 bytes, not 262,144 characters). </li> <li> For SMS, each message can contain up to 140 characters. This character limit depends on the encoding schema. For example, an SMS message can contain 160 GSM characters, 140 ASCII characters, or 70 UCS-2 characters. If you publish a message that exceeds this size limit, Amazon SNS sends the message as multiple messages, each fitting within the size limit. Messages aren't truncated mid-word but are cut off at whole-word boundaries. The total size limit for a single SMS <code>Publish</code> action is 1,600 characters. </li> </ul> JSON-specific constraints: <ul> <li> Keys in the JSON object that correspond to supported transport protocols must have simple JSON string values. </li> <li> The values will be parsed (unescaped) before they are used in outgoing messages. </li> <li> Outbound notifications are JSON encoded (meaning that the characters will be reescaped for sending). </li> <li> Values have a minimum length of 0 (the empty string, "", is allowed). </li> <li> Values have a maximum length bounded by the overall message size (so, including multiple protocols may limit message sizes). </li> <li> Non-string values will cause the key to be ignored. </li> <li> Keys that do not correspond to supported transport protocols are ignored. </li> <li> Duplicate keys are not allowed. </li> <li> Failure to parse or validate any key or value in the message will cause the <code>Publish</code> call to return an error (no partial delivery). </li> </ul></param>
public PublishRequest(string topicArn, string message)
{
_topicArn = topicArn;
_message = message;
}
/// <summary>
/// Instantiates PublishRequest with the parameterized properties
/// </summary>
/// <param name="topicArn">The topic you want to publish to. If you don't specify a value for the <code>TopicArn</code> parameter, you must specify a value for the <code>PhoneNumber</code> or <code>TargetArn</code> parameters.</param>
/// <param name="message">The message you want to send. If you are publishing to a topic and you want to send the same message to all transport protocols, include the text of the message as a String value. If you want to send different messages for each transport protocol, set the value of the <code>MessageStructure</code> parameter to <code>json</code> and use a JSON object for the <code>Message</code> parameter. <p/> Constraints: <ul> <li> With the exception of SMS, messages must be UTF-8 encoded strings and at most 256 KB in size (262,144 bytes, not 262,144 characters). </li> <li> For SMS, each message can contain up to 140 characters. This character limit depends on the encoding schema. For example, an SMS message can contain 160 GSM characters, 140 ASCII characters, or 70 UCS-2 characters. If you publish a message that exceeds this size limit, Amazon SNS sends the message as multiple messages, each fitting within the size limit. Messages aren't truncated mid-word but are cut off at whole-word boundaries. The total size limit for a single SMS <code>Publish</code> action is 1,600 characters. </li> </ul> JSON-specific constraints: <ul> <li> Keys in the JSON object that correspond to supported transport protocols must have simple JSON string values. </li> <li> The values will be parsed (unescaped) before they are used in outgoing messages. </li> <li> Outbound notifications are JSON encoded (meaning that the characters will be reescaped for sending). </li> <li> Values have a minimum length of 0 (the empty string, "", is allowed). </li> <li> Values have a maximum length bounded by the overall message size (so, including multiple protocols may limit message sizes). </li> <li> Non-string values will cause the key to be ignored. </li> <li> Keys that do not correspond to supported transport protocols are ignored. </li> <li> Duplicate keys are not allowed. </li> <li> Failure to parse or validate any key or value in the message will cause the <code>Publish</code> call to return an error (no partial delivery). </li> </ul></param>
/// <param name="subject">Optional parameter to be used as the "Subject" line when the message is delivered to email endpoints. This field will also be included, if present, in the standard JSON messages delivered to other endpoints. Constraints: Subjects must be ASCII text that begins with a letter, number, or punctuation mark; must not include line breaks or control characters; and must be less than 100 characters long.</param>
public PublishRequest(string topicArn, string message, string subject)
{
_topicArn = topicArn;
_message = message;
_subject = subject;
}
/// <summary>
/// Gets and sets the property Message.
/// <para>
/// The message you want to send.
/// </para>
///
/// <para>
/// If you are publishing to a topic and you want to send the same message to all transport
/// protocols, include the text of the message as a String value. If you want to send
/// different messages for each transport protocol, set the value of the <code>MessageStructure</code>
/// parameter to <code>json</code> and use a JSON object for the <code>Message</code>
/// parameter.
/// </para>
///
/// <para>
/// Constraints:
/// </para>
/// <ul> <li>
/// <para>
/// With the exception of SMS, messages must be UTF-8 encoded strings and at most 256
/// KB in size (262,144 bytes, not 262,144 characters).
/// </para>
/// </li> <li>
/// <para>
/// For SMS, each message can contain up to 140 characters. This character limit depends
/// on the encoding schema. For example, an SMS message can contain 160 GSM characters,
/// 140 ASCII characters, or 70 UCS-2 characters.
/// </para>
///
/// <para>
/// If you publish a message that exceeds this size limit, Amazon SNS sends the message
/// as multiple messages, each fitting within the size limit. Messages aren't truncated
/// mid-word but are cut off at whole-word boundaries.
/// </para>
///
/// <para>
/// The total size limit for a single SMS <code>Publish</code> action is 1,600 characters.
/// </para>
/// </li> </ul>
/// <para>
/// JSON-specific constraints:
/// </para>
/// <ul> <li>
/// <para>
/// Keys in the JSON object that correspond to supported transport protocols must have
/// simple JSON string values.
/// </para>
/// </li> <li>
/// <para>
/// The values will be parsed (unescaped) before they are used in outgoing messages.
/// </para>
/// </li> <li>
/// <para>
/// Outbound notifications are JSON encoded (meaning that the characters will be reescaped
/// for sending).
/// </para>
/// </li> <li>
/// <para>
/// Values have a minimum length of 0 (the empty string, "", is allowed).
/// </para>
/// </li> <li>
/// <para>
/// Values have a maximum length bounded by the overall message size (so, including multiple
/// protocols may limit message sizes).
/// </para>
/// </li> <li>
/// <para>
/// Non-string values will cause the key to be ignored.
/// </para>
/// </li> <li>
/// <para>
/// Keys that do not correspond to supported transport protocols are ignored.
/// </para>
/// </li> <li>
/// <para>
/// Duplicate keys are not allowed.
/// </para>
/// </li> <li>
/// <para>
/// Failure to parse or validate any key or value in the message will cause the <code>Publish</code>
/// call to return an error (no partial delivery).
/// </para>
/// </li> </ul>
/// </summary>
[AWSProperty(Required=true)]
public string Message
{
get { return this._message; }
set { this._message = value; }
}
// Check to see if Message property is set
internal bool IsSetMessage()
{
return this._message != null;
}
/// <summary>
/// Gets and sets the property MessageAttributes.
/// <para>
/// Message attributes for Publish action.
/// </para>
/// </summary>
public Dictionary<string, MessageAttributeValue> MessageAttributes
{
get { return this._messageAttributes; }
set { this._messageAttributes = value; }
}
// Check to see if MessageAttributes property is set
internal bool IsSetMessageAttributes()
{
return this._messageAttributes != null && this._messageAttributes.Count > 0;
}
/// <summary>
/// Gets and sets the property MessageDeduplicationId.
/// <para>
/// This parameter applies only to FIFO (first-in-first-out) topics. The <code>MessageDeduplicationId</code>
/// can contain up to 128 alphanumeric characters <code>(a-z, A-Z, 0-9)</code> and punctuation
/// <code>(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)</code>.
/// </para>
///
/// <para>
/// Every message must have a unique <code>MessageDeduplicationId</code>, which is a token
/// used for deduplication of sent messages. If a message with a particular <code>MessageDeduplicationId</code>
/// is sent successfully, any message sent with the same <code>MessageDeduplicationId</code>
/// during the 5-minute deduplication interval is treated as a duplicate.
/// </para>
///
/// <para>
/// If the topic has <code>ContentBasedDeduplication</code> set, the system generates
/// a <code>MessageDeduplicationId</code> based on the contents of the message. Your <code>MessageDeduplicationId</code>
/// overrides the generated one.
/// </para>
/// </summary>
public string MessageDeduplicationId
{
get { return this._messageDeduplicationId; }
set { this._messageDeduplicationId = value; }
}
// Check to see if MessageDeduplicationId property is set
internal bool IsSetMessageDeduplicationId()
{
return this._messageDeduplicationId != null;
}
/// <summary>
/// Gets and sets the property MessageGroupId.
/// <para>
/// This parameter applies only to FIFO (first-in-first-out) topics. The <code>MessageGroupId</code>
/// can contain up to 128 alphanumeric characters <code>(a-z, A-Z, 0-9)</code> and punctuation
/// <code>(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)</code>.
/// </para>
///
/// <para>
/// The <code>MessageGroupId</code> is a tag that specifies that a message belongs to
/// a specific message group. Messages that belong to the same message group are processed
/// in a FIFO manner (however, messages in different message groups might be processed
/// out of order). Every message must include a <code>MessageGroupId</code>.
/// </para>
/// </summary>
public string MessageGroupId
{
get { return this._messageGroupId; }
set { this._messageGroupId = value; }
}
// Check to see if MessageGroupId property is set
internal bool IsSetMessageGroupId()
{
return this._messageGroupId != null;
}
/// <summary>
/// Gets and sets the property MessageStructure.
/// <para>
/// Set <code>MessageStructure</code> to <code>json</code> if you want to send a different
/// message for each protocol. For example, using one publish action, you can send a short
/// message to your SMS subscribers and a longer message to your email subscribers. If
/// you set <code>MessageStructure</code> to <code>json</code>, the value of the <code>Message</code>
/// parameter must:
/// </para>
/// <ul> <li>
/// <para>
/// be a syntactically valid JSON object; and
/// </para>
/// </li> <li>
/// <para>
/// contain at least a top-level JSON key of "default" with a value that is a string.
/// </para>
/// </li> </ul>
/// <para>
/// You can define other top-level keys that define the message you want to send to a
/// specific transport protocol (e.g., "http").
/// </para>
///
/// <para>
/// Valid value: <code>json</code>
/// </para>
/// </summary>
public string MessageStructure
{
get { return this._messageStructure; }
set { this._messageStructure = value; }
}
// Check to see if MessageStructure property is set
internal bool IsSetMessageStructure()
{
return this._messageStructure != null;
}
/// <summary>
/// Gets and sets the property PhoneNumber.
/// <para>
/// The phone number to which you want to deliver an SMS message. Use E.164 format.
/// </para>
///
/// <para>
/// If you don't specify a value for the <code>PhoneNumber</code> parameter, you must
/// specify a value for the <code>TargetArn</code> or <code>TopicArn</code> parameters.
/// </para>
/// </summary>
public string PhoneNumber
{
get { return this._phoneNumber; }
set { this._phoneNumber = value; }
}
// Check to see if PhoneNumber property is set
internal bool IsSetPhoneNumber()
{
return this._phoneNumber != null;
}
/// <summary>
/// Gets and sets the property Subject.
/// <para>
/// Optional parameter to be used as the "Subject" line when the message is delivered
/// to email endpoints. This field will also be included, if present, in the standard
/// JSON messages delivered to other endpoints.
/// </para>
///
/// <para>
/// Constraints: Subjects must be ASCII text that begins with a letter, number, or punctuation
/// mark; must not include line breaks or control characters; and must be less than 100
/// characters long.
/// </para>
/// </summary>
public string Subject
{
get { return this._subject; }
set { this._subject = value; }
}
// Check to see if Subject property is set
internal bool IsSetSubject()
{
return this._subject != null;
}
/// <summary>
/// Gets and sets the property TargetArn.
/// <para>
/// If you don't specify a value for the <code>TargetArn</code> parameter, you must specify
/// a value for the <code>PhoneNumber</code> or <code>TopicArn</code> parameters.
/// </para>
/// </summary>
public string TargetArn
{
get { return this._targetArn; }
set { this._targetArn = value; }
}
// Check to see if TargetArn property is set
internal bool IsSetTargetArn()
{
return this._targetArn != null;
}
/// <summary>
/// Gets and sets the property TopicArn.
/// <para>
/// The topic you want to publish to.
/// </para>
///
/// <para>
/// If you don't specify a value for the <code>TopicArn</code> parameter, you must specify
/// a value for the <code>PhoneNumber</code> or <code>TargetArn</code> parameters.
/// </para>
/// </summary>
public string TopicArn
{
get { return this._topicArn; }
set { this._topicArn = value; }
}
// Check to see if TopicArn property is set
internal bool IsSetTopicArn()
{
return this._topicArn != null;
}
}
}