class AWS::SimpleEmailService::Identity

@attr_reader [String] verification_status

@attr_reader [String,nil] verification_token

@attr [String] bounce_topic_arn

@attr [String] complaint_topic_arn

@attr [Boolean] forwarding_enabled When `false`, complaint and bounce

notifications will not be forwarded via email.  Can only be set to
`false` when there is both a `bounce_topic` and `complaint_topic`.

@attr [Boolean] dkim_enabled When set to `true`, Easy DKIM signing will

be enabled for email sent from this identity.

@attr_reader [Array<String>] dkim_tokens Returns a set of DNS records,

or tokens, that must be published in the domain name's DNS to
complete the DKIM verification process.  Call {#verify_dkim} if this
returns an empty list.

@attr_reader [String] dkim_verification_status

Attributes

identity[R]

@return [String] Returns the email address or domain name for

this identity.

Public Class Methods

new(email_address_or_domain, options = {}) click to toggle source

@api private

Calls superclass method AWS::Core::Resource.new
# File lib/aws/simple_email_service/identity.rb, line 42
def initialize email_address_or_domain, options = {}
  @identity = email_address_or_domain
  super
end

Public Instance Methods

bounce_topic() click to toggle source

@return [SNS::Topic,nil]

# File lib/aws/simple_email_service/identity.rb, line 107
def bounce_topic
  if arn = bounce_topic_arn
    SNS::Topic.new(arn, :config => config)
  end
end
bounce_topic=(topic) click to toggle source

@param [String,SNS::Topic] topic The topic (ARN string or topic

object) that bounce notifications should be published to.
# File lib/aws/simple_email_service/identity.rb, line 101
def bounce_topic= topic
  arn = topic.respond_to?(:arn) ? topic.arn : topic
  self.bounce_topic_arn = arn
end
complaint_topic() click to toggle source

@return [SNS::Topic,nil]

# File lib/aws/simple_email_service/identity.rb, line 121
def complaint_topic
  if arn = complaint_topic_arn
    SNS::Topic.new(arn, :config => config)
  end
end
complaint_topic=(topic) click to toggle source

@param [String,SNS::Topic] topic The topic (ARN string or topic

object) that complaint notifications should be published to.
# File lib/aws/simple_email_service/identity.rb, line 115
def complaint_topic= topic
  arn = topic.respond_to?(:arn) ? topic.arn : topic
  self.complaint_topic_arn = arn
end
delete() click to toggle source

Deletes the current identity. @return [nil]

# File lib/aws/simple_email_service/identity.rb, line 153
def delete
  client.delete_identity(:identity => identity)
  nil
end
domain?() click to toggle source

@return [Boolean] Returns `true` if this {Identity} represents a

domain.
# File lib/aws/simple_email_service/identity.rb, line 135
def domain?
  !email_address?
end
email_address?() click to toggle source

@return [Boolean] Returns `true` if this {Identity} represents an

email address.
# File lib/aws/simple_email_service/identity.rb, line 129
def email_address?
  identity.match(/@/) ? true : false
end
exists?() click to toggle source

@return [Boolean] Returns true if the identity exists.

# File lib/aws/simple_email_service/identity.rb, line 159
def exists?
  options = { :identities => [identity] }
  resp = client.get_identity_verification_attributes(options)
  !!resp[:verification_attributes][identity]
end
pending?() click to toggle source

@return [Boolean] Returns `true` if verification for this email

address/domain is still pending.
# File lib/aws/simple_email_service/identity.rb, line 147
def pending?
  verification_status == 'Pending'
end
verified?() click to toggle source

@return [Boolean] Returns `true` if this email address/domain has

been verified.
# File lib/aws/simple_email_service/identity.rb, line 141
def verified?
  verification_status == 'Success'
end
verify_dkim() click to toggle source

@return [Array<String>] Returns an array of DKIM tokens.

# File lib/aws/simple_email_service/identity.rb, line 90
def verify_dkim
  if domain?
    resp = client.verify_domain_dkim(:domain => identity)
    resp[:dkim_tokens]
  else
    raise "unable to verify dkim for an email address"
  end
end

Protected Instance Methods

get_resource(attr) click to toggle source
# File lib/aws/simple_email_service/identity.rb, line 171
def get_resource attr

  method_name =
    case attr.name.to_s
    when /dkim/         then :get_identity_dkim_attributes
    when /verification/ then :get_identity_verification_attributes
    else                     :get_identity_notification_attributes
    end

  client.send(method_name, :identities => [identity])

end
resource_identifiers() click to toggle source
# File lib/aws/simple_email_service/identity.rb, line 167
def resource_identifiers
  [[:identity, identity]]
end
update_resource(attr, value) click to toggle source
# File lib/aws/simple_email_service/identity.rb, line 184
def update_resource attr, value
  client_opts = {}
  client_opts[:identity] = identity
  case attr.name
  when :bounce_topic_arn
    method = :set_identity_notification_topic
    client_opts[:notification_type] = 'Bounce'
    client_opts[:sns_topic] = value if value
  when :complaint_topic_arn
    method = :set_identity_notification_topic
    client_opts[:notification_type] = 'Complaint'
    client_opts[:sns_topic] = value if value
  when :forwarding_enabled
    method = :set_identity_feedback_forwarding_enabled
    client_opts[:forwarding_enabled] = value
  when :dkim_enabled
    method = :set_identity_dkim_enabled
    client_opts[:dkim_enabled] = value
  else raise "unhandled attribute: #{attr.name}"
  end
  client.send(method, client_opts)
end