aws-sdk-sns 1.0.0.rc1
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.
- checksums.yaml +7 -0
- data/lib/aws-sdk-sns.rb +51 -0
- data/lib/aws-sdk-sns/client.rb +1378 -0
- data/lib/aws-sdk-sns/client_api.rb +749 -0
- data/lib/aws-sdk-sns/customizations.rb +2 -0
- data/lib/aws-sdk-sns/errors.rb +23 -0
- data/lib/aws-sdk-sns/message_verifier.rb +157 -0
- data/lib/aws-sdk-sns/platform_application.rb +235 -0
- data/lib/aws-sdk-sns/platform_endpoint.rb +266 -0
- data/lib/aws-sdk-sns/resource.rb +185 -0
- data/lib/aws-sdk-sns/subscription.rb +149 -0
- data/lib/aws-sdk-sns/topic.rb +419 -0
- data/lib/aws-sdk-sns/types.rb +1351 -0
- metadata +85 -0
@@ -0,0 +1,185 @@
|
|
1
|
+
# WARNING ABOUT GENERATED CODE
|
2
|
+
#
|
3
|
+
# This file is generated. See the contributing for info on making contributions:
|
4
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
5
|
+
#
|
6
|
+
# WARNING ABOUT GENERATED CODE
|
7
|
+
|
8
|
+
module Aws
|
9
|
+
module SNS
|
10
|
+
class Resource
|
11
|
+
|
12
|
+
# @param options ({})
|
13
|
+
# @option options [Client] :client
|
14
|
+
def initialize(options = {})
|
15
|
+
@client = options[:client] || Client.new(options)
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Client]
|
19
|
+
def client
|
20
|
+
@client
|
21
|
+
end
|
22
|
+
|
23
|
+
# @!group Actions
|
24
|
+
|
25
|
+
# @example Request syntax with placeholder values
|
26
|
+
#
|
27
|
+
# platformapplication = sns.create_platform_application({
|
28
|
+
# name: "String", # required
|
29
|
+
# platform: "String", # required
|
30
|
+
# attributes: { # required
|
31
|
+
# "String" => "String",
|
32
|
+
# },
|
33
|
+
# })
|
34
|
+
# @param [Hash] options ({})
|
35
|
+
# @option options [required, String] :name
|
36
|
+
# Application names must be made up of only uppercase and lowercase
|
37
|
+
# ASCII letters, numbers, underscores, hyphens, and periods, and must be
|
38
|
+
# between 1 and 256 characters long.
|
39
|
+
# @option options [required, String] :platform
|
40
|
+
# The following platforms are supported: ADM (Amazon Device Messaging),
|
41
|
+
# APNS (Apple Push Notification Service), APNS\_SANDBOX, and GCM (Google
|
42
|
+
# Cloud Messaging).
|
43
|
+
# @option options [required, Hash<String,String>] :attributes
|
44
|
+
# For a list of attributes, see [SetPlatformApplicationAttributes][1]
|
45
|
+
#
|
46
|
+
#
|
47
|
+
#
|
48
|
+
# [1]: http://docs.aws.amazon.com/sns/latest/api/API_SetPlatformApplicationAttributes.html
|
49
|
+
# @return [PlatformApplication]
|
50
|
+
def create_platform_application(options = {})
|
51
|
+
resp = @client.create_platform_application(options)
|
52
|
+
PlatformApplication.new(
|
53
|
+
arn: resp.data.platform_application_arn,
|
54
|
+
client: @client
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
# @example Request syntax with placeholder values
|
59
|
+
#
|
60
|
+
# topic = sns.create_topic({
|
61
|
+
# name: "topicName", # required
|
62
|
+
# })
|
63
|
+
# @param [Hash] options ({})
|
64
|
+
# @option options [required, String] :name
|
65
|
+
# The name of the topic you want to create.
|
66
|
+
#
|
67
|
+
# Constraints: Topic names must be made up of only uppercase and
|
68
|
+
# lowercase ASCII letters, numbers, underscores, and hyphens, and must
|
69
|
+
# be between 1 and 256 characters long.
|
70
|
+
# @return [Topic]
|
71
|
+
def create_topic(options = {})
|
72
|
+
resp = @client.create_topic(options)
|
73
|
+
Topic.new(
|
74
|
+
arn: resp.data.topic_arn,
|
75
|
+
client: @client
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
# @!group Associations
|
80
|
+
|
81
|
+
# @param [String] arn
|
82
|
+
# @return [PlatformApplication]
|
83
|
+
def platform_application(arn)
|
84
|
+
PlatformApplication.new(
|
85
|
+
arn: arn,
|
86
|
+
client: @client
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
# @example Request syntax with placeholder values
|
91
|
+
#
|
92
|
+
# platformapplications = sns.platform_applications()
|
93
|
+
# @param [Hash] options ({})
|
94
|
+
# @return [PlatformApplication::Collection]
|
95
|
+
def platform_applications(options = {})
|
96
|
+
batches = Enumerator.new do |y|
|
97
|
+
resp = @client.list_platform_applications(options)
|
98
|
+
resp.each_page do |page|
|
99
|
+
batch = []
|
100
|
+
page.data.platform_applications.each do |p|
|
101
|
+
batch << PlatformApplication.new(
|
102
|
+
arn: p.platform_application_arn,
|
103
|
+
client: @client
|
104
|
+
)
|
105
|
+
end
|
106
|
+
y.yield(batch)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
PlatformApplication::Collection.new(batches)
|
110
|
+
end
|
111
|
+
|
112
|
+
# @param [String] arn
|
113
|
+
# @return [PlatformEndpoint]
|
114
|
+
def platform_endpoint(arn)
|
115
|
+
PlatformEndpoint.new(
|
116
|
+
arn: arn,
|
117
|
+
client: @client
|
118
|
+
)
|
119
|
+
end
|
120
|
+
|
121
|
+
# @param [String] arn
|
122
|
+
# @return [Subscription]
|
123
|
+
def subscription(arn)
|
124
|
+
Subscription.new(
|
125
|
+
arn: arn,
|
126
|
+
client: @client
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
# @example Request syntax with placeholder values
|
131
|
+
#
|
132
|
+
# subscriptions = sns.subscriptions()
|
133
|
+
# @param [Hash] options ({})
|
134
|
+
# @return [Subscription::Collection]
|
135
|
+
def subscriptions(options = {})
|
136
|
+
batches = Enumerator.new do |y|
|
137
|
+
resp = @client.list_subscriptions(options)
|
138
|
+
resp.each_page do |page|
|
139
|
+
batch = []
|
140
|
+
page.data.subscriptions.each do |s|
|
141
|
+
batch << Subscription.new(
|
142
|
+
arn: s.subscription_arn,
|
143
|
+
client: @client
|
144
|
+
)
|
145
|
+
end
|
146
|
+
y.yield(batch)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
Subscription::Collection.new(batches)
|
150
|
+
end
|
151
|
+
|
152
|
+
# @param [String] arn
|
153
|
+
# @return [Topic]
|
154
|
+
def topic(arn)
|
155
|
+
Topic.new(
|
156
|
+
arn: arn,
|
157
|
+
client: @client
|
158
|
+
)
|
159
|
+
end
|
160
|
+
|
161
|
+
# @example Request syntax with placeholder values
|
162
|
+
#
|
163
|
+
# topics = sns.topics()
|
164
|
+
# @param [Hash] options ({})
|
165
|
+
# @return [Topic::Collection]
|
166
|
+
def topics(options = {})
|
167
|
+
batches = Enumerator.new do |y|
|
168
|
+
resp = @client.list_topics(options)
|
169
|
+
resp.each_page do |page|
|
170
|
+
batch = []
|
171
|
+
page.data.topics.each do |t|
|
172
|
+
batch << Topic.new(
|
173
|
+
arn: t.topic_arn,
|
174
|
+
client: @client
|
175
|
+
)
|
176
|
+
end
|
177
|
+
y.yield(batch)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
Topic::Collection.new(batches)
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# WARNING ABOUT GENERATED CODE
|
2
|
+
#
|
3
|
+
# This file is generated. See the contributing for info on making contributions:
|
4
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
5
|
+
#
|
6
|
+
# WARNING ABOUT GENERATED CODE
|
7
|
+
|
8
|
+
module Aws
|
9
|
+
module SNS
|
10
|
+
class Subscription
|
11
|
+
|
12
|
+
extend Aws::Deprecations
|
13
|
+
|
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
|
26
|
+
|
27
|
+
# @!group Read-Only Attributes
|
28
|
+
|
29
|
+
# @return [String]
|
30
|
+
def arn
|
31
|
+
@arn
|
32
|
+
end
|
33
|
+
|
34
|
+
# A map of the subscription's attributes. Attributes in this map
|
35
|
+
# include the following:
|
36
|
+
#
|
37
|
+
# * `SubscriptionArn` -- the subscription's ARN
|
38
|
+
#
|
39
|
+
# * `TopicArn` -- the topic ARN that the subscription is associated with
|
40
|
+
#
|
41
|
+
# * `Owner` -- the AWS account ID of the subscription's owner
|
42
|
+
#
|
43
|
+
# * `ConfirmationWasAuthenticated` -- true if the subscription
|
44
|
+
# confirmation request was authenticated
|
45
|
+
#
|
46
|
+
# * `DeliveryPolicy` -- the JSON serialization of the subscription's
|
47
|
+
# delivery policy
|
48
|
+
#
|
49
|
+
# * `EffectiveDeliveryPolicy` -- the JSON serialization of the effective
|
50
|
+
# delivery policy that takes into account the topic delivery policy
|
51
|
+
# and account system defaults
|
52
|
+
# @return [Hash<String,String>]
|
53
|
+
def attributes
|
54
|
+
data.attributes
|
55
|
+
end
|
56
|
+
|
57
|
+
# @!endgroup
|
58
|
+
|
59
|
+
# @return [Client]
|
60
|
+
def client
|
61
|
+
@client
|
62
|
+
end
|
63
|
+
|
64
|
+
# Loads, or reloads {#data} for the current {Subscription}.
|
65
|
+
# Returns `self` making it possible to chain methods.
|
66
|
+
#
|
67
|
+
# subscription.reload.data
|
68
|
+
#
|
69
|
+
# @return [self]
|
70
|
+
def load
|
71
|
+
resp = @client.get_subscription_attributes(subscription_arn: @arn)
|
72
|
+
@data = resp.data
|
73
|
+
self
|
74
|
+
end
|
75
|
+
alias :reload :load
|
76
|
+
|
77
|
+
# @return [Types::GetSubscriptionAttributesResponse]
|
78
|
+
# Returns the data for this {Subscription}. Calls
|
79
|
+
# {Client#get_subscription_attributes} if {#data_loaded?} is `false`.
|
80
|
+
def data
|
81
|
+
load unless @data
|
82
|
+
@data
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [Boolean]
|
86
|
+
# Returns `true` if this resource is loaded. Accessing attributes or
|
87
|
+
# {#data} on an unloaded resource will trigger a call to {#load}.
|
88
|
+
def data_loaded?
|
89
|
+
!!@data
|
90
|
+
end
|
91
|
+
|
92
|
+
# @!group Actions
|
93
|
+
|
94
|
+
# @example Request syntax with placeholder values
|
95
|
+
#
|
96
|
+
# subscription.delete()
|
97
|
+
# @param [Hash] options ({})
|
98
|
+
# @return [EmptyStructure]
|
99
|
+
def delete(options = {})
|
100
|
+
options = options.merge(subscription_arn: @arn)
|
101
|
+
resp = @client.unsubscribe(options)
|
102
|
+
resp.data
|
103
|
+
end
|
104
|
+
|
105
|
+
# @example Request syntax with placeholder values
|
106
|
+
#
|
107
|
+
# subscription.set_attributes({
|
108
|
+
# attribute_name: "attributeName", # required
|
109
|
+
# attribute_value: "attributeValue",
|
110
|
+
# })
|
111
|
+
# @param [Hash] options ({})
|
112
|
+
# @option options [required, String] :attribute_name
|
113
|
+
# The name of the attribute you want to set. Only a subset of the
|
114
|
+
# subscriptions attributes are mutable.
|
115
|
+
#
|
116
|
+
# Valid values: `DeliveryPolicy` \| `RawMessageDelivery`
|
117
|
+
# @option options [String] :attribute_value
|
118
|
+
# The new value for the attribute in JSON format.
|
119
|
+
# @return [EmptyStructure]
|
120
|
+
def set_attributes(options = {})
|
121
|
+
options = options.merge(subscription_arn: @arn)
|
122
|
+
resp = @client.set_subscription_attributes(options)
|
123
|
+
resp.data
|
124
|
+
end
|
125
|
+
|
126
|
+
# @deprecated
|
127
|
+
# @api private
|
128
|
+
def identifiers
|
129
|
+
{ arn: @arn }
|
130
|
+
end
|
131
|
+
deprecated(:identifiers)
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
def extract_arn(args, options)
|
136
|
+
value = args[0] || options.delete(:arn)
|
137
|
+
case value
|
138
|
+
when String then value
|
139
|
+
when nil then raise ArgumentError, "missing required option :arn"
|
140
|
+
else
|
141
|
+
msg = "expected :arn to be a String, got #{value.class}"
|
142
|
+
raise ArgumentError, msg
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class Collection < Aws::Resources::Collection; end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,419 @@
|
|
1
|
+
# WARNING ABOUT GENERATED CODE
|
2
|
+
#
|
3
|
+
# This file is generated. See the contributing for info on making contributions:
|
4
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
5
|
+
#
|
6
|
+
# WARNING ABOUT GENERATED CODE
|
7
|
+
|
8
|
+
module Aws
|
9
|
+
module SNS
|
10
|
+
class Topic
|
11
|
+
|
12
|
+
extend Aws::Deprecations
|
13
|
+
|
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
|
26
|
+
|
27
|
+
# @!group Read-Only Attributes
|
28
|
+
|
29
|
+
# @return [String]
|
30
|
+
def arn
|
31
|
+
@arn
|
32
|
+
end
|
33
|
+
|
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
|
65
|
+
|
66
|
+
# @!endgroup
|
67
|
+
|
68
|
+
# @return [Client]
|
69
|
+
def client
|
70
|
+
@client
|
71
|
+
end
|
72
|
+
|
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
|
85
|
+
|
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
|
93
|
+
|
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
|
100
|
+
|
101
|
+
# @!group Actions
|
102
|
+
|
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
|
127
|
+
|
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
|
152
|
+
|
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
|
163
|
+
|
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
|
272
|
+
|
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
|
287
|
+
|
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
|
308
|
+
|
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
|
370
|
+
|
371
|
+
# @!group Associations
|
372
|
+
|
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)
|
391
|
+
end
|
392
|
+
end
|
393
|
+
Subscription::Collection.new(batches)
|
394
|
+
end
|
395
|
+
|
396
|
+
# @deprecated
|
397
|
+
# @api private
|
398
|
+
def identifiers
|
399
|
+
{ arn: @arn }
|
400
|
+
end
|
401
|
+
deprecated(:identifiers)
|
402
|
+
|
403
|
+
private
|
404
|
+
|
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
|
414
|
+
end
|
415
|
+
|
416
|
+
class Collection < Aws::Resources::Collection; end
|
417
|
+
end
|
418
|
+
end
|
419
|
+
end
|