aws-sdk-sns 1.0.0.rc1 → 1.0.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,419 +1,417 @@
1
1
  # WARNING ABOUT GENERATED CODE
2
2
  #
3
- # This file is generated. See the contributing for info on making contributions:
3
+ # This file is generated. See the contributing guide for more information:
4
4
  # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
5
  #
6
6
  # WARNING ABOUT GENERATED CODE
7
7
 
8
- module Aws
9
- module SNS
10
- class Topic
8
+ module Aws::SNS
9
+ class Topic
11
10
 
12
- extend Aws::Deprecations
11
+ extend Aws::Deprecations
13
12
 
14
- # @overload def initialize(arn, options = {})
15
- # @param [String] arn
16
- # @option options [Client] :client
17
- # @overload def initialize(options = {})
18
- # @option options [required, String] :arn
19
- # @option options [Client] :client
20
- def initialize(*args)
21
- options = Hash === args.last ? args.pop.dup : {}
22
- @arn = extract_arn(args, options)
23
- @data = options.delete(:data)
24
- @client = options.delete(:client) || Client.new(options)
25
- end
13
+ # @overload def initialize(arn, options = {})
14
+ # @param [String] arn
15
+ # @option options [Client] :client
16
+ # @overload def initialize(options = {})
17
+ # @option options [required, String] :arn
18
+ # @option options [Client] :client
19
+ def initialize(*args)
20
+ options = Hash === args.last ? args.pop.dup : {}
21
+ @arn = extract_arn(args, options)
22
+ @data = options.delete(:data)
23
+ @client = options.delete(:client) || Client.new(options)
24
+ end
26
25
 
27
- # @!group Read-Only Attributes
26
+ # @!group Read-Only Attributes
28
27
 
29
- # @return [String]
30
- def arn
31
- @arn
32
- end
28
+ # @return [String]
29
+ def arn
30
+ @arn
31
+ end
33
32
 
34
- # A map of the topic's attributes. Attributes in this map include the
35
- # following:
36
- #
37
- # * `TopicArn` -- the topic's ARN
38
- #
39
- # * `Owner` -- the AWS account ID of the topic's owner
40
- #
41
- # * `Policy` -- the JSON serialization of the topic's access control
42
- # policy
43
- #
44
- # * `DisplayName` -- the human-readable name used in the "From" field
45
- # for notifications to email and email-json endpoints
46
- #
47
- # * `SubscriptionsPending` -- the number of subscriptions pending
48
- # confirmation on this topic
49
- #
50
- # * `SubscriptionsConfirmed` -- the number of confirmed subscriptions on
51
- # this topic
52
- #
53
- # * `SubscriptionsDeleted` -- the number of deleted subscriptions on
54
- # this topic
55
- #
56
- # * `DeliveryPolicy` -- the JSON serialization of the topic's delivery
57
- # policy
58
- #
59
- # * `EffectiveDeliveryPolicy` -- the JSON serialization of the effective
60
- # delivery policy that takes into account system defaults
61
- # @return [Hash<String,String>]
62
- def attributes
63
- data.attributes
64
- end
33
+ # A map of the topic's attributes. Attributes in this map include the
34
+ # following:
35
+ #
36
+ # * `TopicArn` -- the topic's ARN
37
+ #
38
+ # * `Owner` -- the AWS account ID of the topic's owner
39
+ #
40
+ # * `Policy` -- the JSON serialization of the topic's access control
41
+ # policy
42
+ #
43
+ # * `DisplayName` -- the human-readable name used in the "From" field
44
+ # for notifications to email and email-json endpoints
45
+ #
46
+ # * `SubscriptionsPending` -- the number of subscriptions pending
47
+ # confirmation on this topic
48
+ #
49
+ # * `SubscriptionsConfirmed` -- the number of confirmed subscriptions on
50
+ # this topic
51
+ #
52
+ # * `SubscriptionsDeleted` -- the number of deleted subscriptions on
53
+ # this topic
54
+ #
55
+ # * `DeliveryPolicy` -- the JSON serialization of the topic's delivery
56
+ # policy
57
+ #
58
+ # * `EffectiveDeliveryPolicy` -- the JSON serialization of the effective
59
+ # delivery policy that takes into account system defaults
60
+ # @return [Hash<String,String>]
61
+ def attributes
62
+ data.attributes
63
+ end
65
64
 
66
- # @!endgroup
65
+ # @!endgroup
67
66
 
68
- # @return [Client]
69
- def client
70
- @client
71
- end
67
+ # @return [Client]
68
+ def client
69
+ @client
70
+ end
72
71
 
73
- # Loads, or reloads {#data} for the current {Topic}.
74
- # Returns `self` making it possible to chain methods.
75
- #
76
- # topic.reload.data
77
- #
78
- # @return [self]
79
- def load
80
- resp = @client.get_topic_attributes(topic_arn: @arn)
81
- @data = resp.data
82
- self
83
- end
84
- alias :reload :load
72
+ # Loads, or reloads {#data} for the current {Topic}.
73
+ # Returns `self` making it possible to chain methods.
74
+ #
75
+ # topic.reload.data
76
+ #
77
+ # @return [self]
78
+ def load
79
+ resp = @client.get_topic_attributes(topic_arn: @arn)
80
+ @data = resp.data
81
+ self
82
+ end
83
+ alias :reload :load
85
84
 
86
- # @return [Types::GetTopicAttributesResponse]
87
- # Returns the data for this {Topic}. Calls
88
- # {Client#get_topic_attributes} if {#data_loaded?} is `false`.
89
- def data
90
- load unless @data
91
- @data
92
- end
85
+ # @return [Types::GetTopicAttributesResponse]
86
+ # Returns the data for this {Topic}. Calls
87
+ # {Client#get_topic_attributes} if {#data_loaded?} is `false`.
88
+ def data
89
+ load unless @data
90
+ @data
91
+ end
93
92
 
94
- # @return [Boolean]
95
- # Returns `true` if this resource is loaded. Accessing attributes or
96
- # {#data} on an unloaded resource will trigger a call to {#load}.
97
- def data_loaded?
98
- !!@data
99
- end
93
+ # @return [Boolean]
94
+ # Returns `true` if this resource is loaded. Accessing attributes or
95
+ # {#data} on an unloaded resource will trigger a call to {#load}.
96
+ def data_loaded?
97
+ !!@data
98
+ end
100
99
 
101
- # @!group Actions
100
+ # @!group Actions
102
101
 
103
- # @example Request syntax with placeholder values
104
- #
105
- # topic.add_permission({
106
- # label: "label", # required
107
- # aws_account_id: ["delegate"], # required
108
- # action_name: ["action"], # required
109
- # })
110
- # @param [Hash] options ({})
111
- # @option options [required, String] :label
112
- # A unique identifier for the new policy statement.
113
- # @option options [required, Array<String>] :aws_account_id
114
- # The AWS account IDs of the users (principals) who will be given access
115
- # to the specified actions. The users must have AWS accounts, but do not
116
- # need to be signed up for this service.
117
- # @option options [required, Array<String>] :action_name
118
- # The action you want to allow for the specified principal(s).
119
- #
120
- # Valid values: any Amazon SNS action name.
121
- # @return [EmptyStructure]
122
- def add_permission(options = {})
123
- options = options.merge(topic_arn: @arn)
124
- resp = @client.add_permission(options)
125
- resp.data
126
- end
102
+ # @example Request syntax with placeholder values
103
+ #
104
+ # topic.add_permission({
105
+ # label: "label", # required
106
+ # aws_account_id: ["delegate"], # required
107
+ # action_name: ["action"], # required
108
+ # })
109
+ # @param [Hash] options ({})
110
+ # @option options [required, String] :label
111
+ # A unique identifier for the new policy statement.
112
+ # @option options [required, Array<String>] :aws_account_id
113
+ # The AWS account IDs of the users (principals) who will be given access
114
+ # to the specified actions. The users must have AWS accounts, but do not
115
+ # need to be signed up for this service.
116
+ # @option options [required, Array<String>] :action_name
117
+ # The action you want to allow for the specified principal(s).
118
+ #
119
+ # Valid values: any Amazon SNS action name.
120
+ # @return [EmptyStructure]
121
+ def add_permission(options = {})
122
+ options = options.merge(topic_arn: @arn)
123
+ resp = @client.add_permission(options)
124
+ resp.data
125
+ end
127
126
 
128
- # @example Request syntax with placeholder values
129
- #
130
- # subscription = topic.confirm_subscription({
131
- # token: "token", # required
132
- # authenticate_on_unsubscribe: "authenticateOnUnsubscribe",
133
- # })
134
- # @param [Hash] options ({})
135
- # @option options [required, String] :token
136
- # Short-lived token sent to an endpoint during the `Subscribe` action.
137
- # @option options [String] :authenticate_on_unsubscribe
138
- # Disallows unauthenticated unsubscribes of the subscription. If the
139
- # value of this parameter is `true` and the request has an AWS
140
- # signature, then only the topic owner and the subscription owner can
141
- # unsubscribe the endpoint. The unsubscribe action requires AWS
142
- # authentication.
143
- # @return [Subscription]
144
- def confirm_subscription(options = {})
145
- options = options.merge(topic_arn: @arn)
146
- resp = @client.confirm_subscription(options)
147
- Subscription.new(
148
- arn: resp.data.subscription_arn,
149
- client: @client
150
- )
151
- end
127
+ # @example Request syntax with placeholder values
128
+ #
129
+ # subscription = topic.confirm_subscription({
130
+ # token: "token", # required
131
+ # authenticate_on_unsubscribe: "authenticateOnUnsubscribe",
132
+ # })
133
+ # @param [Hash] options ({})
134
+ # @option options [required, String] :token
135
+ # Short-lived token sent to an endpoint during the `Subscribe` action.
136
+ # @option options [String] :authenticate_on_unsubscribe
137
+ # Disallows unauthenticated unsubscribes of the subscription. If the
138
+ # value of this parameter is `true` and the request has an AWS
139
+ # signature, then only the topic owner and the subscription owner can
140
+ # unsubscribe the endpoint. The unsubscribe action requires AWS
141
+ # authentication.
142
+ # @return [Subscription]
143
+ def confirm_subscription(options = {})
144
+ options = options.merge(topic_arn: @arn)
145
+ resp = @client.confirm_subscription(options)
146
+ Subscription.new(
147
+ arn: resp.data.subscription_arn,
148
+ client: @client
149
+ )
150
+ end
152
151
 
153
- # @example Request syntax with placeholder values
154
- #
155
- # topic.delete()
156
- # @param [Hash] options ({})
157
- # @return [EmptyStructure]
158
- def delete(options = {})
159
- options = options.merge(topic_arn: @arn)
160
- resp = @client.delete_topic(options)
161
- resp.data
162
- end
152
+ # @example Request syntax with placeholder values
153
+ #
154
+ # topic.delete()
155
+ # @param [Hash] options ({})
156
+ # @return [EmptyStructure]
157
+ def delete(options = {})
158
+ options = options.merge(topic_arn: @arn)
159
+ resp = @client.delete_topic(options)
160
+ resp.data
161
+ end
163
162
 
164
- # @example Request syntax with placeholder values
165
- #
166
- # topic.publish({
167
- # target_arn: "String",
168
- # phone_number: "String",
169
- # message: "message", # required
170
- # subject: "subject",
171
- # message_structure: "messageStructure",
172
- # message_attributes: {
173
- # "String" => {
174
- # data_type: "String", # required
175
- # string_value: "String",
176
- # binary_value: "data",
177
- # },
178
- # },
179
- # })
180
- # @param [Hash] options ({})
181
- # @option options [String] :target_arn
182
- # Either TopicArn or EndpointArn, but not both.
183
- #
184
- # If you don't specify a value for the `TargetArn` parameter, you must
185
- # specify a value for the `PhoneNumber` or `TopicArn` parameters.
186
- # @option options [String] :phone_number
187
- # The phone number to which you want to deliver an SMS message. Use
188
- # E.164 format.
189
- #
190
- # If you don't specify a value for the `PhoneNumber` parameter, you
191
- # must specify a value for the `TargetArn` or `TopicArn` parameters.
192
- # @option options [required, String] :message
193
- # The message you want to send to the topic.
194
- #
195
- # If you want to send the same message to all transport protocols,
196
- # include the text of the message as a String value.
197
- #
198
- # If you want to send different messages for each transport protocol,
199
- # set the value of the `MessageStructure` parameter to `json` and use a
200
- # JSON object for the `Message` parameter.
201
- #
202
- # Constraints: Messages must be UTF-8 encoded strings at most 256 KB in
203
- # size (262144 bytes, not 262144 characters).
204
- #
205
- # JSON-specific constraints:
206
- #
207
- # * Keys in the JSON object that correspond to supported transport
208
- # protocols must have simple JSON string values.
209
- #
210
- # * The values will be parsed (unescaped) before they are used in
211
- # outgoing messages.
212
- #
213
- # * Outbound notifications are JSON encoded (meaning that the characters
214
- # will be reescaped for sending).
215
- #
216
- # * Values have a minimum length of 0 (the empty string, "", is
217
- # allowed).
218
- #
219
- # * Values have a maximum length bounded by the overall message size
220
- # (so, including multiple protocols may limit message sizes).
221
- #
222
- # * Non-string values will cause the key to be ignored.
223
- #
224
- # * Keys that do not correspond to supported transport protocols are
225
- # ignored.
226
- #
227
- # * Duplicate keys are not allowed.
228
- #
229
- # * Failure to parse or validate any key or value in the message will
230
- # cause the `Publish` call to return an error (no partial delivery).
231
- # @option options [String] :subject
232
- # Optional parameter to be used as the "Subject" line when the message
233
- # is delivered to email endpoints. This field will also be included, if
234
- # present, in the standard JSON messages delivered to other endpoints.
235
- #
236
- # Constraints: Subjects must be ASCII text that begins with a letter,
237
- # number, or punctuation mark; must not include line breaks or control
238
- # characters; and must be less than 100 characters long.
239
- # @option options [String] :message_structure
240
- # Set `MessageStructure` to `json` if you want to send a different
241
- # message for each protocol. For example, using one publish action, you
242
- # can send a short message to your SMS subscribers and a longer message
243
- # to your email subscribers. If you set `MessageStructure` to `json`,
244
- # the value of the `Message` parameter must:
245
- #
246
- # * be a syntactically valid JSON object; and
247
- #
248
- # * contain at least a top-level JSON key of "default" with a value
249
- # that is a string.
250
- #
251
- # You can define other top-level keys that define the message you want
252
- # to send to a specific transport protocol (e.g., "http").
253
- #
254
- # For information about sending different messages for each protocol
255
- # using the AWS Management Console, go to [Create Different Messages for
256
- # Each Protocol][1] in the *Amazon Simple Notification Service Getting
257
- # Started Guide*.
258
- #
259
- # Valid value: `json`
260
- #
261
- #
262
- #
263
- # [1]: http://docs.aws.amazon.com/sns/latest/gsg/Publish.html#sns-message-formatting-by-protocol
264
- # @option options [Hash<String,Types::MessageAttributeValue>] :message_attributes
265
- # Message attributes for Publish action.
266
- # @return [Types::PublishResponse]
267
- def publish(options = {})
268
- options = options.merge(topic_arn: @arn)
269
- resp = @client.publish(options)
270
- resp.data
271
- end
163
+ # @example Request syntax with placeholder values
164
+ #
165
+ # topic.publish({
166
+ # target_arn: "String",
167
+ # phone_number: "String",
168
+ # message: "message", # required
169
+ # subject: "subject",
170
+ # message_structure: "messageStructure",
171
+ # message_attributes: {
172
+ # "String" => {
173
+ # data_type: "String", # required
174
+ # string_value: "String",
175
+ # binary_value: "data",
176
+ # },
177
+ # },
178
+ # })
179
+ # @param [Hash] options ({})
180
+ # @option options [String] :target_arn
181
+ # Either TopicArn or EndpointArn, but not both.
182
+ #
183
+ # If you don't specify a value for the `TargetArn` parameter, you must
184
+ # specify a value for the `PhoneNumber` or `TopicArn` parameters.
185
+ # @option options [String] :phone_number
186
+ # The phone number to which you want to deliver an SMS message. Use
187
+ # E.164 format.
188
+ #
189
+ # If you don't specify a value for the `PhoneNumber` parameter, you
190
+ # must specify a value for the `TargetArn` or `TopicArn` parameters.
191
+ # @option options [required, String] :message
192
+ # The message you want to send to the topic.
193
+ #
194
+ # If you want to send the same message to all transport protocols,
195
+ # include the text of the message as a String value.
196
+ #
197
+ # If you want to send different messages for each transport protocol,
198
+ # set the value of the `MessageStructure` parameter to `json` and use a
199
+ # JSON object for the `Message` parameter.
200
+ #
201
+ # Constraints: Messages must be UTF-8 encoded strings at most 256 KB in
202
+ # size (262144 bytes, not 262144 characters).
203
+ #
204
+ # JSON-specific constraints:
205
+ #
206
+ # * Keys in the JSON object that correspond to supported transport
207
+ # protocols must have simple JSON string values.
208
+ #
209
+ # * The values will be parsed (unescaped) before they are used in
210
+ # outgoing messages.
211
+ #
212
+ # * Outbound notifications are JSON encoded (meaning that the characters
213
+ # will be reescaped for sending).
214
+ #
215
+ # * Values have a minimum length of 0 (the empty string, "", is
216
+ # allowed).
217
+ #
218
+ # * Values have a maximum length bounded by the overall message size
219
+ # (so, including multiple protocols may limit message sizes).
220
+ #
221
+ # * Non-string values will cause the key to be ignored.
222
+ #
223
+ # * Keys that do not correspond to supported transport protocols are
224
+ # ignored.
225
+ #
226
+ # * Duplicate keys are not allowed.
227
+ #
228
+ # * Failure to parse or validate any key or value in the message will
229
+ # cause the `Publish` call to return an error (no partial delivery).
230
+ # @option options [String] :subject
231
+ # Optional parameter to be used as the "Subject" line when the message
232
+ # is delivered to email endpoints. This field will also be included, if
233
+ # present, in the standard JSON messages delivered to other endpoints.
234
+ #
235
+ # Constraints: Subjects must be ASCII text that begins with a letter,
236
+ # number, or punctuation mark; must not include line breaks or control
237
+ # characters; and must be less than 100 characters long.
238
+ # @option options [String] :message_structure
239
+ # Set `MessageStructure` to `json` if you want to send a different
240
+ # message for each protocol. For example, using one publish action, you
241
+ # can send a short message to your SMS subscribers and a longer message
242
+ # to your email subscribers. If you set `MessageStructure` to `json`,
243
+ # the value of the `Message` parameter must:
244
+ #
245
+ # * be a syntactically valid JSON object; and
246
+ #
247
+ # * contain at least a top-level JSON key of "default" with a value
248
+ # that is a string.
249
+ #
250
+ # You can define other top-level keys that define the message you want
251
+ # to send to a specific transport protocol (e.g., "http").
252
+ #
253
+ # For information about sending different messages for each protocol
254
+ # using the AWS Management Console, go to [Create Different Messages for
255
+ # Each Protocol][1] in the *Amazon Simple Notification Service Getting
256
+ # Started Guide*.
257
+ #
258
+ # Valid value: `json`
259
+ #
260
+ #
261
+ #
262
+ # [1]: http://docs.aws.amazon.com/sns/latest/gsg/Publish.html#sns-message-formatting-by-protocol
263
+ # @option options [Hash<String,Types::MessageAttributeValue>] :message_attributes
264
+ # Message attributes for Publish action.
265
+ # @return [Types::PublishResponse]
266
+ def publish(options = {})
267
+ options = options.merge(topic_arn: @arn)
268
+ resp = @client.publish(options)
269
+ resp.data
270
+ end
272
271
 
273
- # @example Request syntax with placeholder values
274
- #
275
- # topic.remove_permission({
276
- # label: "label", # required
277
- # })
278
- # @param [Hash] options ({})
279
- # @option options [required, String] :label
280
- # The unique label of the statement you want to remove.
281
- # @return [EmptyStructure]
282
- def remove_permission(options = {})
283
- options = options.merge(topic_arn: @arn)
284
- resp = @client.remove_permission(options)
285
- resp.data
286
- end
272
+ # @example Request syntax with placeholder values
273
+ #
274
+ # topic.remove_permission({
275
+ # label: "label", # required
276
+ # })
277
+ # @param [Hash] options ({})
278
+ # @option options [required, String] :label
279
+ # The unique label of the statement you want to remove.
280
+ # @return [EmptyStructure]
281
+ def remove_permission(options = {})
282
+ options = options.merge(topic_arn: @arn)
283
+ resp = @client.remove_permission(options)
284
+ resp.data
285
+ end
287
286
 
288
- # @example Request syntax with placeholder values
289
- #
290
- # topic.set_attributes({
291
- # attribute_name: "attributeName", # required
292
- # attribute_value: "attributeValue",
293
- # })
294
- # @param [Hash] options ({})
295
- # @option options [required, String] :attribute_name
296
- # The name of the attribute you want to set. Only a subset of the
297
- # topic's attributes are mutable.
298
- #
299
- # Valid values: `Policy` \| `DisplayName` \| `DeliveryPolicy`
300
- # @option options [String] :attribute_value
301
- # The new value for the attribute.
302
- # @return [EmptyStructure]
303
- def set_attributes(options = {})
304
- options = options.merge(topic_arn: @arn)
305
- resp = @client.set_topic_attributes(options)
306
- resp.data
307
- end
287
+ # @example Request syntax with placeholder values
288
+ #
289
+ # topic.set_attributes({
290
+ # attribute_name: "attributeName", # required
291
+ # attribute_value: "attributeValue",
292
+ # })
293
+ # @param [Hash] options ({})
294
+ # @option options [required, String] :attribute_name
295
+ # The name of the attribute you want to set. Only a subset of the
296
+ # topic's attributes are mutable.
297
+ #
298
+ # Valid values: `Policy` \| `DisplayName` \| `DeliveryPolicy`
299
+ # @option options [String] :attribute_value
300
+ # The new value for the attribute.
301
+ # @return [EmptyStructure]
302
+ def set_attributes(options = {})
303
+ options = options.merge(topic_arn: @arn)
304
+ resp = @client.set_topic_attributes(options)
305
+ resp.data
306
+ end
308
307
 
309
- # @example Request syntax with placeholder values
310
- #
311
- # subscription = topic.subscribe({
312
- # protocol: "protocol", # required
313
- # endpoint: "endpoint",
314
- # })
315
- # @param [Hash] options ({})
316
- # @option options [required, String] :protocol
317
- # The protocol you want to use. Supported protocols include:
318
- #
319
- # * `http` -- delivery of JSON-encoded message via HTTP POST
320
- #
321
- # * `https` -- delivery of JSON-encoded message via HTTPS POST
322
- #
323
- # * `email` -- delivery of message via SMTP
324
- #
325
- # * `email-json` -- delivery of JSON-encoded message via SMTP
326
- #
327
- # * `sms` -- delivery of message via SMS
328
- #
329
- # * `sqs` -- delivery of JSON-encoded message to an Amazon SQS queue
330
- #
331
- # * `application` -- delivery of JSON-encoded message to an EndpointArn
332
- # for a mobile app and device.
333
- #
334
- # * `lambda` -- delivery of JSON-encoded message to an AWS Lambda
335
- # function.
336
- # @option options [String] :endpoint
337
- # The endpoint that you want to receive notifications. Endpoints vary by
338
- # protocol:
339
- #
340
- # * For the `http` protocol, the endpoint is an URL beginning with
341
- # "http://"
342
- #
343
- # * For the `https` protocol, the endpoint is a URL beginning with
344
- # "https://"
345
- #
346
- # * For the `email` protocol, the endpoint is an email address
347
- #
348
- # * For the `email-json` protocol, the endpoint is an email address
349
- #
350
- # * For the `sms` protocol, the endpoint is a phone number of an
351
- # SMS-enabled device
352
- #
353
- # * For the `sqs` protocol, the endpoint is the ARN of an Amazon SQS
354
- # queue
355
- #
356
- # * For the `application` protocol, the endpoint is the EndpointArn of a
357
- # mobile app and device.
358
- #
359
- # * For the `lambda` protocol, the endpoint is the ARN of an AWS Lambda
360
- # function.
361
- # @return [Subscription]
362
- def subscribe(options = {})
363
- options = options.merge(topic_arn: @arn)
364
- resp = @client.subscribe(options)
365
- Subscription.new(
366
- arn: resp.data.subscription_arn,
367
- client: @client
368
- )
369
- end
308
+ # @example Request syntax with placeholder values
309
+ #
310
+ # subscription = topic.subscribe({
311
+ # protocol: "protocol", # required
312
+ # endpoint: "endpoint",
313
+ # })
314
+ # @param [Hash] options ({})
315
+ # @option options [required, String] :protocol
316
+ # The protocol you want to use. Supported protocols include:
317
+ #
318
+ # * `http` -- delivery of JSON-encoded message via HTTP POST
319
+ #
320
+ # * `https` -- delivery of JSON-encoded message via HTTPS POST
321
+ #
322
+ # * `email` -- delivery of message via SMTP
323
+ #
324
+ # * `email-json` -- delivery of JSON-encoded message via SMTP
325
+ #
326
+ # * `sms` -- delivery of message via SMS
327
+ #
328
+ # * `sqs` -- delivery of JSON-encoded message to an Amazon SQS queue
329
+ #
330
+ # * `application` -- delivery of JSON-encoded message to an EndpointArn
331
+ # for a mobile app and device.
332
+ #
333
+ # * `lambda` -- delivery of JSON-encoded message to an AWS Lambda
334
+ # function.
335
+ # @option options [String] :endpoint
336
+ # The endpoint that you want to receive notifications. Endpoints vary by
337
+ # protocol:
338
+ #
339
+ # * For the `http` protocol, the endpoint is an URL beginning with
340
+ # "http://"
341
+ #
342
+ # * For the `https` protocol, the endpoint is a URL beginning with
343
+ # "https://"
344
+ #
345
+ # * For the `email` protocol, the endpoint is an email address
346
+ #
347
+ # * For the `email-json` protocol, the endpoint is an email address
348
+ #
349
+ # * For the `sms` protocol, the endpoint is a phone number of an
350
+ # SMS-enabled device
351
+ #
352
+ # * For the `sqs` protocol, the endpoint is the ARN of an Amazon SQS
353
+ # queue
354
+ #
355
+ # * For the `application` protocol, the endpoint is the EndpointArn of a
356
+ # mobile app and device.
357
+ #
358
+ # * For the `lambda` protocol, the endpoint is the ARN of an AWS Lambda
359
+ # function.
360
+ # @return [Subscription]
361
+ def subscribe(options = {})
362
+ options = options.merge(topic_arn: @arn)
363
+ resp = @client.subscribe(options)
364
+ Subscription.new(
365
+ arn: resp.data.subscription_arn,
366
+ client: @client
367
+ )
368
+ end
370
369
 
371
- # @!group Associations
370
+ # @!group Associations
372
371
 
373
- # @example Request syntax with placeholder values
374
- #
375
- # subscriptions = topic.subscriptions()
376
- # @param [Hash] options ({})
377
- # @return [Subscription::Collection]
378
- def subscriptions(options = {})
379
- batches = Enumerator.new do |y|
380
- options = options.merge(topic_arn: @arn)
381
- resp = @client.list_subscriptions_by_topic(options)
382
- resp.each_page do |page|
383
- batch = []
384
- page.data.subscriptions.each do |s|
385
- batch << Subscription.new(
386
- arn: s.subscription_arn,
387
- client: @client
388
- )
389
- end
390
- y.yield(batch)
372
+ # @example Request syntax with placeholder values
373
+ #
374
+ # topic.subscriptions()
375
+ # @param [Hash] options ({})
376
+ # @return [Subscription::Collection]
377
+ def subscriptions(options = {})
378
+ batches = Enumerator.new do |y|
379
+ options = options.merge(topic_arn: @arn)
380
+ resp = @client.list_subscriptions_by_topic(options)
381
+ resp.each_page do |page|
382
+ batch = []
383
+ page.data.subscriptions.each do |s|
384
+ batch << Subscription.new(
385
+ arn: s.subscription_arn,
386
+ client: @client
387
+ )
391
388
  end
389
+ y.yield(batch)
392
390
  end
393
- Subscription::Collection.new(batches)
394
391
  end
392
+ Subscription::Collection.new(batches)
393
+ end
395
394
 
396
- # @deprecated
397
- # @api private
398
- def identifiers
399
- { arn: @arn }
400
- end
401
- deprecated(:identifiers)
395
+ # @deprecated
396
+ # @api private
397
+ def identifiers
398
+ { arn: @arn }
399
+ end
400
+ deprecated(:identifiers)
402
401
 
403
- private
402
+ private
404
403
 
405
- def extract_arn(args, options)
406
- value = args[0] || options.delete(:arn)
407
- case value
408
- when String then value
409
- when nil then raise ArgumentError, "missing required option :arn"
410
- else
411
- msg = "expected :arn to be a String, got #{value.class}"
412
- raise ArgumentError, msg
413
- end
404
+ def extract_arn(args, options)
405
+ value = args[0] || options.delete(:arn)
406
+ case value
407
+ when String then value
408
+ when nil then raise ArgumentError, "missing required option :arn"
409
+ else
410
+ msg = "expected :arn to be a String, got #{value.class}"
411
+ raise ArgumentError, msg
414
412
  end
415
-
416
- class Collection < Aws::Resources::Collection; end
417
413
  end
414
+
415
+ class Collection < Aws::Resources::Collection; end
418
416
  end
419
417
  end