aws-sdk 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -54,25 +54,60 @@ module AWS
54
54
  #
55
55
  # This has only been tested with Rails 2.3 and Rails 3.0.
56
56
  #
57
- # = Email Addresses
58
57
  #
58
+ # = Identities
59
+ #
60
+ # Before you can send emails, you need to verify one or more identities.
61
+ # Identities are email addresses or domain names that you have control over.
59
62
  # Until you have {requested production access}[http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/InitialSetup.Customer.html]
60
- # you will only be able to send emails to and from verified email addresses.
61
- # To verify an email address:
63
+ # you will only be able to send emails to and from verified email addresses
64
+ # and domains.
62
65
  #
63
- # ses.email_addresses.verify('youremailaddress@domain.com')
66
+ # == Verifying Email Addresses
64
67
  #
65
- # AWS will send an email to the given email address. Follow the link in the
66
- # email to verify the address.
68
+ # You can verify an email address for sending/receiving emails using
69
+ # the identities collection.
67
70
  #
68
- # To explore the email addresses you have authorized:
71
+ # identity = ses.identities.verify('email@yourdomain.com')
72
+ # identity.verified? #=> false
69
73
  #
70
- # ses.email_addresses.each do |address|
71
- # puts address
72
- # end
74
+ # You will be sent an email address with a link. Follow the link to
75
+ # verify the email address.
76
+ #
77
+ # == Verifying Domains
78
+ #
79
+ # You can also verify an entire domain for sending and receiving emails.
80
+ #
81
+ # identity = ses.identities.verify('yourdomain.com')
82
+ # identity.verification_token
83
+ # #=> "216D+lZbhUL0zOoAkC83/0TAl5lJSzLmzsOjtXM7AeM="
84
+ #
85
+ # You will be expected to update the DNS records for your domain with
86
+ # the given verification token. See the service documentation for
87
+ # more details.
88
+ #
89
+ # == Listing Identities
90
+ #
91
+ # You can enumerate all identies:
73
92
  #
74
- # See {EmailAddressCollection} for more information on working with SES email
75
- # addresses.
93
+ # ses.identites.map(&:identity)
94
+ # #=> ['email@foo.com', 'somedomain.com']
95
+ #
96
+ # You can filter the types of identities enumerated:
97
+ #
98
+ # domains = ses.identities.domains.map(&:identity)
99
+ # email_addresses = ses.identities.email_addresses.map(&:identity)
100
+ #
101
+ # You can get the verfication status and token from identities as well.
102
+ #
103
+ # # for an email address
104
+ # identity = ses.identities['youremail@yourdomain.com']
105
+ # identity.verified? #=> true/false
106
+ #
107
+ # # for a domain
108
+ # identity = ses.identities['yourdomain.com']
109
+ # identity.verified? #=> true/false
110
+ # identity.verification_token #=> '...'
76
111
  #
77
112
  # = Sending Email
78
113
  #
@@ -139,18 +174,26 @@ module AWS
139
174
  autoload :Client, 'client'
140
175
  autoload :Errors, 'errors'
141
176
  autoload :EmailAddressCollection, 'email_address_collection'
177
+ autoload :Identity, 'identity'
178
+ autoload :IdentityCollection, 'identity_collection'
142
179
  autoload :Quotas, 'quotas'
143
180
  autoload :Request, 'request'
144
181
  end
145
182
 
146
183
  include Core::ServiceInterface
147
184
 
185
+ # @note This method is deprecated. Use {#identities} instead.
148
186
  # @return [EmailAddressCollection] Returns a collection that represents
149
187
  # all of the verified email addresses for your account.
150
188
  def email_addresses
151
189
  EmailAddressCollection.new(:config => config)
152
190
  end
153
191
 
192
+ # @return [IdentityCollection]
193
+ def identities
194
+ IdentityCollection.new(:config => config)
195
+ end
196
+
154
197
  # Sends an email.
155
198
  #
156
199
  # ses.send_email(
@@ -28,6 +28,22 @@ module AWS
28
28
 
29
29
  ## client methods ##
30
30
 
31
+ # Calls the DeleteIdentity API operation.
32
+ # @method delete_identity(options = {})
33
+ #
34
+ # === Options:
35
+ #
36
+ # * +:identity+ - *required* - (String) The name of the identity to be
37
+ # removed from the list of verified identities.
38
+ #
39
+ # === Response Structure:
40
+ #
41
+ # This method returns no response data.
42
+ #
43
+ # @return [Core::Response]
44
+ #
45
+ define_client_method :delete_identity, 'DeleteIdentity'
46
+
31
47
  # Calls the DeleteVerifiedEmailAddress API operation.
32
48
  # @method delete_verified_email_address(options = {})
33
49
  #
@@ -44,6 +60,23 @@ module AWS
44
60
  #
45
61
  define_client_method :delete_verified_email_address, 'DeleteVerifiedEmailAddress'
46
62
 
63
+ # Calls the GetIdentityVerificationAttributes API operation.
64
+ # @method get_identity_verification_attributes(options = {})
65
+ #
66
+ # === Options:
67
+ #
68
+ # * +:identities+ - *required* - (Array<String>)
69
+ #
70
+ # === Response Structure:
71
+ #
72
+ # * +:verification_attributes+ - (Hash<String,Hash>)
73
+ # * +:verification_status+ - (String)
74
+ # * +:verification_token+ - (String)
75
+ #
76
+ # @return [Core::Response]
77
+ #
78
+ define_client_method :get_identity_verification_attributes, 'GetIdentityVerificationAttributes'
79
+
47
80
  # Calls the GetSendQuota API operation.
48
81
  # @method get_send_quota(options = {})
49
82
  #
@@ -81,6 +114,26 @@ module AWS
81
114
  #
82
115
  define_client_method :get_send_statistics, 'GetSendStatistics'
83
116
 
117
+ # Calls the ListIdentities API operation.
118
+ # @method list_identities(options = {})
119
+ #
120
+ # === Options:
121
+ #
122
+ # * +:identity_type+ - (String) The type of the identities listed.
123
+ # Possible values are: "EmailAddress", "Domain" or null.
124
+ # * +:next_token+ - (String) The token used for retrieving the next set
125
+ # of items.
126
+ # * +:max_items+ - (Integer) The maximum number of items returned.
127
+ #
128
+ # === Response Structure:
129
+ #
130
+ # * +:identities+ - (Array<String>)
131
+ # * +:next_token+ - (String)
132
+ #
133
+ # @return [Core::Response]
134
+ #
135
+ define_client_method :list_identities, 'ListIdentities'
136
+
84
137
  # Calls the ListVerifiedEmailAddresses API operation.
85
138
  # @method list_verified_email_addresses(options = {})
86
139
  #
@@ -101,7 +154,7 @@ module AWS
101
154
  #
102
155
  # === Options:
103
156
  #
104
- # * +:source+ - *required* - (String) The sender's email address.
157
+ # * +:source+ - *required* - (String) The identity's email address.
105
158
  # * +:destination+ - *required* - (Hash) The destination for this email,
106
159
  # composed of To:, CC:, and BCC: fields.
107
160
  # * +:to_addresses+ - (Array<String>) The To: field(s) of the message.
@@ -150,7 +203,7 @@ module AWS
150
203
  #
151
204
  # === Options:
152
205
  #
153
- # * +:source+ - (String) The sender's email address. If you specify the
206
+ # * +:source+ - (String) The identity's email address. If you specify the
154
207
  # Source parameter, then bounce notifications and complaints will be
155
208
  # sent to this email address. This takes precedence over any
156
209
  # Return-Path header that you might include in the raw text of the
@@ -168,7 +221,7 @@ module AWS
168
221
  # client must ensure that the message format complies with Internet
169
222
  # email standards regarding email header fields, MIME types, MIME
170
223
  # encoding, and base64 encoding (if necessary). For more information,
171
- # go to the Amazon SES Developer Guide.
224
+ # go to theAmazon SES Developer Guide.
172
225
  #
173
226
  # === Response Structure:
174
227
  #
@@ -178,6 +231,22 @@ module AWS
178
231
  #
179
232
  define_client_method :send_raw_email, 'SendRawEmail'
180
233
 
234
+ # Calls the VerifyDomainIdentity API operation.
235
+ # @method verify_domain_identity(options = {})
236
+ #
237
+ # === Options:
238
+ #
239
+ # * +:domain+ - *required* - (String) The name of the domain to be
240
+ # verified.
241
+ #
242
+ # === Response Structure:
243
+ #
244
+ # * +:verification_token+ - (String)
245
+ #
246
+ # @return [Core::Response]
247
+ #
248
+ define_client_method :verify_domain_identity, 'VerifyDomainIdentity'
249
+
181
250
  # Calls the VerifyEmailAddress API operation.
182
251
  # @method verify_email_address(options = {})
183
252
  #
@@ -194,6 +263,22 @@ module AWS
194
263
  #
195
264
  define_client_method :verify_email_address, 'VerifyEmailAddress'
196
265
 
266
+ # Calls the VerifyEmailIdentity API operation.
267
+ # @method verify_email_identity(options = {})
268
+ #
269
+ # === Options:
270
+ #
271
+ # * +:email_address+ - *required* - (String) The email address to be
272
+ # verified.
273
+ #
274
+ # === Response Structure:
275
+ #
276
+ # This method returns no response data.
277
+ #
278
+ # @return [Core::Response]
279
+ #
280
+ define_client_method :verify_email_identity, 'VerifyEmailIdentity'
281
+
197
282
  ## end client methods ##
198
283
 
199
284
  end
@@ -15,6 +15,8 @@ module AWS
15
15
  class SimpleEmailService
16
16
 
17
17
  # Helps you manage your verified SimpleEmailService email addresses.
18
+ # @note This class is deprecated. Please use
19
+ # {SimpleEmailService#identities} instead.
18
20
  class EmailAddressCollection
19
21
 
20
22
  include Core::Model
@@ -26,6 +28,7 @@ module AWS
26
28
  #
27
29
  # @param [String] email_address The email address to verify.
28
30
  # @return [nil]
31
+ # @note This method is deprecated.
29
32
  def verify email_address
30
33
  client.verify_email_address(:email_address => email_address)
31
34
  nil
@@ -36,11 +39,13 @@ module AWS
36
39
  # of verified email addresses. Useful for cleanup as there is a 100
37
40
  # email address limit.
38
41
  # @return [nil]
42
+ # @note This method is deprecated.
39
43
  def delete email_address
40
44
  client.delete_verified_email_address(:email_address => email_address)
41
45
  nil
42
46
  end
43
47
 
48
+ # @note This method is deprecated.
44
49
  def include?
45
50
  # this is so jruby can detect that verified? is an alias
46
51
  super
@@ -50,6 +55,7 @@ module AWS
50
55
  # Yields each verified email address as a string.
51
56
  # @return [nil]
52
57
  # yielded.
58
+ # @note This method is deprecated.
53
59
  def each &block
54
60
  response = client.list_verified_email_addresses({})
55
61
  response.verified_email_addresses.each do |email_address|
@@ -0,0 +1,91 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ module AWS
15
+ class SimpleEmailService
16
+
17
+ # @attr_reader [String] verification_status
18
+ #
19
+ # @attr_reader [String,nil] verification_token
20
+ #
21
+ class Identity < Core::Resource
22
+
23
+ # @private
24
+ def initialize email_address_or_domain, options = {}
25
+ @identity = email_address_or_domain
26
+ super
27
+ end
28
+
29
+ # @return [String] Returns the email address or domain name for
30
+ # this identity.
31
+ attr_reader :identity
32
+
33
+ attribute :verification_status
34
+
35
+ attribute :verification_token, :static => true
36
+
37
+ populates_from(:get_identity_verification_attributes) do |resp|
38
+ resp.data[:verification_attributes][identity]
39
+ end
40
+
41
+ # @return [Boolean] Returns +true+ if this {Identity} represents an
42
+ # email address.
43
+ def email_address?
44
+ identity =~ /@/ ? true : false
45
+ end
46
+
47
+ # @return [Boolean] Returns +true+ if this {Identity} represents a
48
+ # domain.
49
+ def domain?
50
+ !email_address?
51
+ end
52
+
53
+ # @return [Boolean] Returns +true+ if this email address/domain has
54
+ # been verified.
55
+ def verified?
56
+ verification_status == 'Success'
57
+ end
58
+
59
+ # @return [Boolean] Returns +true+ if verification for this email
60
+ # address/domain is still pending.
61
+ def pending?
62
+ verification_status == 'Pending'
63
+ end
64
+
65
+ # Deletes the current identity.
66
+ # @return [nil]
67
+ def delete
68
+ client.delete_identity(:identity => identity)
69
+ nil
70
+ end
71
+
72
+ # @return [Boolean] Returns true if the identity exists.
73
+ def exists?
74
+ !!get_resource[:verification_attributes][identity]
75
+ end
76
+
77
+ protected
78
+
79
+ def resource_identifiers
80
+ [[:identity, identity]]
81
+ end
82
+
83
+ def get_resource attr = nil
84
+ client_opts = {}
85
+ client_opts[:identities] = [identity]
86
+ client.get_identity_verification_attributes(client_opts)
87
+ end
88
+
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,81 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ module AWS
15
+ class SimpleEmailService
16
+ class IdentityCollection
17
+
18
+ include Core::Collection::Limitable
19
+
20
+ # @private
21
+ def initialize options = {}
22
+ @type = options[:type]
23
+ super
24
+ end
25
+
26
+ # Request verification for an email address or a domain.
27
+ # @param [String] email_or_domain
28
+ # @return [Identity] Returns an {Iidentity} object. Identities for
29
+ # domains will have a #verification_token.
30
+ def verify email_or_domain
31
+
32
+ resp = email_or_domain =~ /@/ ?
33
+ client.verify_email_identity(:email_address => email_or_domain) :
34
+ client.verify_domain_identity(:domain => email_or_domain)
35
+
36
+ Identity.new(email_or_domain,
37
+ :verification_token => resp.data[:verification_token],
38
+ :config => config)
39
+
40
+ end
41
+ alias_method :create, :verify
42
+
43
+ # @param [String] email_or_domain
44
+ # @return [Identity] Returns an {Identity} with the given
45
+ # email address or domain name.
46
+ def [] email_or_domain
47
+ Identity.new(email_or_domain, :config => config)
48
+ end
49
+
50
+ # @return [IdentityCollection] Returns a collection that only
51
+ # enumerates email addresses.
52
+ def email_addresses
53
+ self.class.new(:type => 'EmailAddress', :config => config)
54
+ end
55
+
56
+ # @return [IdentityCollection] Returns a collection that only
57
+ # enumerates domains.
58
+ def domains
59
+ self.class.new(:type => 'Domain', :config => config)
60
+ end
61
+
62
+ protected
63
+
64
+ def _each_item next_token, limit, options = {}, &block
65
+
66
+ options[:max_items] = limit if limit
67
+ options[:next_token] = next_token if next_token
68
+ options[:identity_type] = @type if @type
69
+
70
+ resp = client.list_identities(options)
71
+ resp.data[:identities].each do |identity|
72
+ yield(self[identity])
73
+ end
74
+
75
+ resp.data[:next_token]
76
+
77
+ end
78
+
79
+ end
80
+ end
81
+ end