{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SES.Types.IdentityDkimAttributes
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SES.Types.IdentityDkimAttributes where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SES.Types.VerificationStatus

-- | Represents the DKIM attributes of a verified email address or a domain.
--
-- /See:/ 'newIdentityDkimAttributes' smart constructor.
data IdentityDkimAttributes = IdentityDkimAttributes'
  { -- | A set of character strings that represent the domain\'s identity. Using
    -- these tokens, you need to create DNS CNAME records that point to DKIM
    -- public keys that are hosted by Amazon SES. Amazon Web Services
    -- eventually detects that you\'ve updated your DNS records. This detection
    -- process might take up to 72 hours. After successful detection, Amazon
    -- SES is able to DKIM-sign email originating from that domain. (This only
    -- applies to domain identities, not email address identities.)
    --
    -- For more information about creating DNS records using DKIM tokens, see
    -- the
    -- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/easy-dkim.html Amazon SES Developer Guide>.
    IdentityDkimAttributes -> Maybe [Text]
dkimTokens :: Prelude.Maybe [Prelude.Text],
    -- | Is true if DKIM signing is enabled for email sent from the identity.
    -- It\'s false otherwise. The default value is true.
    IdentityDkimAttributes -> Bool
dkimEnabled :: Prelude.Bool,
    -- | Describes whether Amazon SES has successfully verified the DKIM DNS
    -- records (tokens) published in the domain name\'s DNS. (This only applies
    -- to domain identities, not email address identities.)
    IdentityDkimAttributes -> VerificationStatus
dkimVerificationStatus :: VerificationStatus
  }
  deriving (IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
(IdentityDkimAttributes -> IdentityDkimAttributes -> Bool)
-> (IdentityDkimAttributes -> IdentityDkimAttributes -> Bool)
-> Eq IdentityDkimAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
$c/= :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
== :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
$c== :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
Prelude.Eq, ReadPrec [IdentityDkimAttributes]
ReadPrec IdentityDkimAttributes
Int -> ReadS IdentityDkimAttributes
ReadS [IdentityDkimAttributes]
(Int -> ReadS IdentityDkimAttributes)
-> ReadS [IdentityDkimAttributes]
-> ReadPrec IdentityDkimAttributes
-> ReadPrec [IdentityDkimAttributes]
-> Read IdentityDkimAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IdentityDkimAttributes]
$creadListPrec :: ReadPrec [IdentityDkimAttributes]
readPrec :: ReadPrec IdentityDkimAttributes
$creadPrec :: ReadPrec IdentityDkimAttributes
readList :: ReadS [IdentityDkimAttributes]
$creadList :: ReadS [IdentityDkimAttributes]
readsPrec :: Int -> ReadS IdentityDkimAttributes
$creadsPrec :: Int -> ReadS IdentityDkimAttributes
Prelude.Read, Int -> IdentityDkimAttributes -> ShowS
[IdentityDkimAttributes] -> ShowS
IdentityDkimAttributes -> String
(Int -> IdentityDkimAttributes -> ShowS)
-> (IdentityDkimAttributes -> String)
-> ([IdentityDkimAttributes] -> ShowS)
-> Show IdentityDkimAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IdentityDkimAttributes] -> ShowS
$cshowList :: [IdentityDkimAttributes] -> ShowS
show :: IdentityDkimAttributes -> String
$cshow :: IdentityDkimAttributes -> String
showsPrec :: Int -> IdentityDkimAttributes -> ShowS
$cshowsPrec :: Int -> IdentityDkimAttributes -> ShowS
Prelude.Show, (forall x. IdentityDkimAttributes -> Rep IdentityDkimAttributes x)
-> (forall x.
    Rep IdentityDkimAttributes x -> IdentityDkimAttributes)
-> Generic IdentityDkimAttributes
forall x. Rep IdentityDkimAttributes x -> IdentityDkimAttributes
forall x. IdentityDkimAttributes -> Rep IdentityDkimAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IdentityDkimAttributes x -> IdentityDkimAttributes
$cfrom :: forall x. IdentityDkimAttributes -> Rep IdentityDkimAttributes x
Prelude.Generic)

-- |
-- Create a value of 'IdentityDkimAttributes' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'dkimTokens', 'identityDkimAttributes_dkimTokens' - A set of character strings that represent the domain\'s identity. Using
-- these tokens, you need to create DNS CNAME records that point to DKIM
-- public keys that are hosted by Amazon SES. Amazon Web Services
-- eventually detects that you\'ve updated your DNS records. This detection
-- process might take up to 72 hours. After successful detection, Amazon
-- SES is able to DKIM-sign email originating from that domain. (This only
-- applies to domain identities, not email address identities.)
--
-- For more information about creating DNS records using DKIM tokens, see
-- the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/easy-dkim.html Amazon SES Developer Guide>.
--
-- 'dkimEnabled', 'identityDkimAttributes_dkimEnabled' - Is true if DKIM signing is enabled for email sent from the identity.
-- It\'s false otherwise. The default value is true.
--
-- 'dkimVerificationStatus', 'identityDkimAttributes_dkimVerificationStatus' - Describes whether Amazon SES has successfully verified the DKIM DNS
-- records (tokens) published in the domain name\'s DNS. (This only applies
-- to domain identities, not email address identities.)
newIdentityDkimAttributes ::
  -- | 'dkimEnabled'
  Prelude.Bool ->
  -- | 'dkimVerificationStatus'
  VerificationStatus ->
  IdentityDkimAttributes
newIdentityDkimAttributes :: Bool -> VerificationStatus -> IdentityDkimAttributes
newIdentityDkimAttributes
  Bool
pDkimEnabled_
  VerificationStatus
pDkimVerificationStatus_ =
    IdentityDkimAttributes' :: Maybe [Text]
-> Bool -> VerificationStatus -> IdentityDkimAttributes
IdentityDkimAttributes'
      { $sel:dkimTokens:IdentityDkimAttributes' :: Maybe [Text]
dkimTokens =
          Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:dkimEnabled:IdentityDkimAttributes' :: Bool
dkimEnabled = Bool
pDkimEnabled_,
        $sel:dkimVerificationStatus:IdentityDkimAttributes' :: VerificationStatus
dkimVerificationStatus = VerificationStatus
pDkimVerificationStatus_
      }

-- | A set of character strings that represent the domain\'s identity. Using
-- these tokens, you need to create DNS CNAME records that point to DKIM
-- public keys that are hosted by Amazon SES. Amazon Web Services
-- eventually detects that you\'ve updated your DNS records. This detection
-- process might take up to 72 hours. After successful detection, Amazon
-- SES is able to DKIM-sign email originating from that domain. (This only
-- applies to domain identities, not email address identities.)
--
-- For more information about creating DNS records using DKIM tokens, see
-- the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/easy-dkim.html Amazon SES Developer Guide>.
identityDkimAttributes_dkimTokens :: Lens.Lens' IdentityDkimAttributes (Prelude.Maybe [Prelude.Text])
identityDkimAttributes_dkimTokens :: (Maybe [Text] -> f (Maybe [Text]))
-> IdentityDkimAttributes -> f IdentityDkimAttributes
identityDkimAttributes_dkimTokens = (IdentityDkimAttributes -> Maybe [Text])
-> (IdentityDkimAttributes
    -> Maybe [Text] -> IdentityDkimAttributes)
-> Lens
     IdentityDkimAttributes
     IdentityDkimAttributes
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityDkimAttributes' {Maybe [Text]
dkimTokens :: Maybe [Text]
$sel:dkimTokens:IdentityDkimAttributes' :: IdentityDkimAttributes -> Maybe [Text]
dkimTokens} -> Maybe [Text]
dkimTokens) (\s :: IdentityDkimAttributes
s@IdentityDkimAttributes' {} Maybe [Text]
a -> IdentityDkimAttributes
s {$sel:dkimTokens:IdentityDkimAttributes' :: Maybe [Text]
dkimTokens = Maybe [Text]
a} :: IdentityDkimAttributes) ((Maybe [Text] -> f (Maybe [Text]))
 -> IdentityDkimAttributes -> f IdentityDkimAttributes)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> IdentityDkimAttributes
-> f IdentityDkimAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Is true if DKIM signing is enabled for email sent from the identity.
-- It\'s false otherwise. The default value is true.
identityDkimAttributes_dkimEnabled :: Lens.Lens' IdentityDkimAttributes Prelude.Bool
identityDkimAttributes_dkimEnabled :: (Bool -> f Bool)
-> IdentityDkimAttributes -> f IdentityDkimAttributes
identityDkimAttributes_dkimEnabled = (IdentityDkimAttributes -> Bool)
-> (IdentityDkimAttributes -> Bool -> IdentityDkimAttributes)
-> Lens IdentityDkimAttributes IdentityDkimAttributes Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityDkimAttributes' {Bool
dkimEnabled :: Bool
$sel:dkimEnabled:IdentityDkimAttributes' :: IdentityDkimAttributes -> Bool
dkimEnabled} -> Bool
dkimEnabled) (\s :: IdentityDkimAttributes
s@IdentityDkimAttributes' {} Bool
a -> IdentityDkimAttributes
s {$sel:dkimEnabled:IdentityDkimAttributes' :: Bool
dkimEnabled = Bool
a} :: IdentityDkimAttributes)

-- | Describes whether Amazon SES has successfully verified the DKIM DNS
-- records (tokens) published in the domain name\'s DNS. (This only applies
-- to domain identities, not email address identities.)
identityDkimAttributes_dkimVerificationStatus :: Lens.Lens' IdentityDkimAttributes VerificationStatus
identityDkimAttributes_dkimVerificationStatus :: (VerificationStatus -> f VerificationStatus)
-> IdentityDkimAttributes -> f IdentityDkimAttributes
identityDkimAttributes_dkimVerificationStatus = (IdentityDkimAttributes -> VerificationStatus)
-> (IdentityDkimAttributes
    -> VerificationStatus -> IdentityDkimAttributes)
-> Lens
     IdentityDkimAttributes
     IdentityDkimAttributes
     VerificationStatus
     VerificationStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityDkimAttributes' {VerificationStatus
dkimVerificationStatus :: VerificationStatus
$sel:dkimVerificationStatus:IdentityDkimAttributes' :: IdentityDkimAttributes -> VerificationStatus
dkimVerificationStatus} -> VerificationStatus
dkimVerificationStatus) (\s :: IdentityDkimAttributes
s@IdentityDkimAttributes' {} VerificationStatus
a -> IdentityDkimAttributes
s {$sel:dkimVerificationStatus:IdentityDkimAttributes' :: VerificationStatus
dkimVerificationStatus = VerificationStatus
a} :: IdentityDkimAttributes)

instance Core.FromXML IdentityDkimAttributes where
  parseXML :: [Node] -> Either String IdentityDkimAttributes
parseXML [Node]
x =
    Maybe [Text]
-> Bool -> VerificationStatus -> IdentityDkimAttributes
IdentityDkimAttributes'
      (Maybe [Text]
 -> Bool -> VerificationStatus -> IdentityDkimAttributes)
-> Either String (Maybe [Text])
-> Either
     String (Bool -> VerificationStatus -> IdentityDkimAttributes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DkimTokens" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either
  String (Bool -> VerificationStatus -> IdentityDkimAttributes)
-> Either String Bool
-> Either String (VerificationStatus -> IdentityDkimAttributes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Bool
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"DkimEnabled")
      Either String (VerificationStatus -> IdentityDkimAttributes)
-> Either String VerificationStatus
-> Either String IdentityDkimAttributes
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String VerificationStatus
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"DkimVerificationStatus")

instance Prelude.Hashable IdentityDkimAttributes

instance Prelude.NFData IdentityDkimAttributes