{-# 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.SESV2.Types.DkimSigningAttributes
-- 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.SESV2.Types.DkimSigningAttributes where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SESV2.Types.DkimSigningKeyLength

-- | An object that contains configuration for Bring Your Own DKIM (BYODKIM),
-- or, for Easy DKIM
--
-- /See:/ 'newDkimSigningAttributes' smart constructor.
data DkimSigningAttributes = DkimSigningAttributes'
  { -- | [Easy DKIM] The key length of the future DKIM key pair to be generated.
    -- This can be changed at most once per day.
    DkimSigningAttributes -> Maybe DkimSigningKeyLength
nextSigningKeyLength :: Prelude.Maybe DkimSigningKeyLength,
    -- | [Bring Your Own DKIM] A private key that\'s used to generate a DKIM
    -- signature.
    --
    -- The private key must use 1024 or 2048-bit RSA encryption, and must be
    -- encoded using base64 encoding.
    DkimSigningAttributes -> Maybe (Sensitive Text)
domainSigningPrivateKey :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | [Bring Your Own DKIM] A string that\'s used to identify a public key in
    -- the DNS configuration for a domain.
    DkimSigningAttributes -> Maybe Text
domainSigningSelector :: Prelude.Maybe Prelude.Text
  }
  deriving (DkimSigningAttributes -> DkimSigningAttributes -> Bool
(DkimSigningAttributes -> DkimSigningAttributes -> Bool)
-> (DkimSigningAttributes -> DkimSigningAttributes -> Bool)
-> Eq DkimSigningAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DkimSigningAttributes -> DkimSigningAttributes -> Bool
$c/= :: DkimSigningAttributes -> DkimSigningAttributes -> Bool
== :: DkimSigningAttributes -> DkimSigningAttributes -> Bool
$c== :: DkimSigningAttributes -> DkimSigningAttributes -> Bool
Prelude.Eq, Int -> DkimSigningAttributes -> ShowS
[DkimSigningAttributes] -> ShowS
DkimSigningAttributes -> String
(Int -> DkimSigningAttributes -> ShowS)
-> (DkimSigningAttributes -> String)
-> ([DkimSigningAttributes] -> ShowS)
-> Show DkimSigningAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DkimSigningAttributes] -> ShowS
$cshowList :: [DkimSigningAttributes] -> ShowS
show :: DkimSigningAttributes -> String
$cshow :: DkimSigningAttributes -> String
showsPrec :: Int -> DkimSigningAttributes -> ShowS
$cshowsPrec :: Int -> DkimSigningAttributes -> ShowS
Prelude.Show, (forall x. DkimSigningAttributes -> Rep DkimSigningAttributes x)
-> (forall x. Rep DkimSigningAttributes x -> DkimSigningAttributes)
-> Generic DkimSigningAttributes
forall x. Rep DkimSigningAttributes x -> DkimSigningAttributes
forall x. DkimSigningAttributes -> Rep DkimSigningAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DkimSigningAttributes x -> DkimSigningAttributes
$cfrom :: forall x. DkimSigningAttributes -> Rep DkimSigningAttributes x
Prelude.Generic)

-- |
-- Create a value of 'DkimSigningAttributes' 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:
--
-- 'nextSigningKeyLength', 'dkimSigningAttributes_nextSigningKeyLength' - [Easy DKIM] The key length of the future DKIM key pair to be generated.
-- This can be changed at most once per day.
--
-- 'domainSigningPrivateKey', 'dkimSigningAttributes_domainSigningPrivateKey' - [Bring Your Own DKIM] A private key that\'s used to generate a DKIM
-- signature.
--
-- The private key must use 1024 or 2048-bit RSA encryption, and must be
-- encoded using base64 encoding.
--
-- 'domainSigningSelector', 'dkimSigningAttributes_domainSigningSelector' - [Bring Your Own DKIM] A string that\'s used to identify a public key in
-- the DNS configuration for a domain.
newDkimSigningAttributes ::
  DkimSigningAttributes
newDkimSigningAttributes :: DkimSigningAttributes
newDkimSigningAttributes =
  DkimSigningAttributes' :: Maybe DkimSigningKeyLength
-> Maybe (Sensitive Text) -> Maybe Text -> DkimSigningAttributes
DkimSigningAttributes'
    { $sel:nextSigningKeyLength:DkimSigningAttributes' :: Maybe DkimSigningKeyLength
nextSigningKeyLength =
        Maybe DkimSigningKeyLength
forall a. Maybe a
Prelude.Nothing,
      $sel:domainSigningPrivateKey:DkimSigningAttributes' :: Maybe (Sensitive Text)
domainSigningPrivateKey = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:domainSigningSelector:DkimSigningAttributes' :: Maybe Text
domainSigningSelector = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | [Easy DKIM] The key length of the future DKIM key pair to be generated.
-- This can be changed at most once per day.
dkimSigningAttributes_nextSigningKeyLength :: Lens.Lens' DkimSigningAttributes (Prelude.Maybe DkimSigningKeyLength)
dkimSigningAttributes_nextSigningKeyLength :: (Maybe DkimSigningKeyLength -> f (Maybe DkimSigningKeyLength))
-> DkimSigningAttributes -> f DkimSigningAttributes
dkimSigningAttributes_nextSigningKeyLength = (DkimSigningAttributes -> Maybe DkimSigningKeyLength)
-> (DkimSigningAttributes
    -> Maybe DkimSigningKeyLength -> DkimSigningAttributes)
-> Lens
     DkimSigningAttributes
     DkimSigningAttributes
     (Maybe DkimSigningKeyLength)
     (Maybe DkimSigningKeyLength)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DkimSigningAttributes' {Maybe DkimSigningKeyLength
nextSigningKeyLength :: Maybe DkimSigningKeyLength
$sel:nextSigningKeyLength:DkimSigningAttributes' :: DkimSigningAttributes -> Maybe DkimSigningKeyLength
nextSigningKeyLength} -> Maybe DkimSigningKeyLength
nextSigningKeyLength) (\s :: DkimSigningAttributes
s@DkimSigningAttributes' {} Maybe DkimSigningKeyLength
a -> DkimSigningAttributes
s {$sel:nextSigningKeyLength:DkimSigningAttributes' :: Maybe DkimSigningKeyLength
nextSigningKeyLength = Maybe DkimSigningKeyLength
a} :: DkimSigningAttributes)

-- | [Bring Your Own DKIM] A private key that\'s used to generate a DKIM
-- signature.
--
-- The private key must use 1024 or 2048-bit RSA encryption, and must be
-- encoded using base64 encoding.
dkimSigningAttributes_domainSigningPrivateKey :: Lens.Lens' DkimSigningAttributes (Prelude.Maybe Prelude.Text)
dkimSigningAttributes_domainSigningPrivateKey :: (Maybe Text -> f (Maybe Text))
-> DkimSigningAttributes -> f DkimSigningAttributes
dkimSigningAttributes_domainSigningPrivateKey = (DkimSigningAttributes -> Maybe (Sensitive Text))
-> (DkimSigningAttributes
    -> Maybe (Sensitive Text) -> DkimSigningAttributes)
-> Lens
     DkimSigningAttributes
     DkimSigningAttributes
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DkimSigningAttributes' {Maybe (Sensitive Text)
domainSigningPrivateKey :: Maybe (Sensitive Text)
$sel:domainSigningPrivateKey:DkimSigningAttributes' :: DkimSigningAttributes -> Maybe (Sensitive Text)
domainSigningPrivateKey} -> Maybe (Sensitive Text)
domainSigningPrivateKey) (\s :: DkimSigningAttributes
s@DkimSigningAttributes' {} Maybe (Sensitive Text)
a -> DkimSigningAttributes
s {$sel:domainSigningPrivateKey:DkimSigningAttributes' :: Maybe (Sensitive Text)
domainSigningPrivateKey = Maybe (Sensitive Text)
a} :: DkimSigningAttributes) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> DkimSigningAttributes -> f DkimSigningAttributes)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> DkimSigningAttributes
-> f DkimSigningAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | [Bring Your Own DKIM] A string that\'s used to identify a public key in
-- the DNS configuration for a domain.
dkimSigningAttributes_domainSigningSelector :: Lens.Lens' DkimSigningAttributes (Prelude.Maybe Prelude.Text)
dkimSigningAttributes_domainSigningSelector :: (Maybe Text -> f (Maybe Text))
-> DkimSigningAttributes -> f DkimSigningAttributes
dkimSigningAttributes_domainSigningSelector = (DkimSigningAttributes -> Maybe Text)
-> (DkimSigningAttributes -> Maybe Text -> DkimSigningAttributes)
-> Lens
     DkimSigningAttributes
     DkimSigningAttributes
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DkimSigningAttributes' {Maybe Text
domainSigningSelector :: Maybe Text
$sel:domainSigningSelector:DkimSigningAttributes' :: DkimSigningAttributes -> Maybe Text
domainSigningSelector} -> Maybe Text
domainSigningSelector) (\s :: DkimSigningAttributes
s@DkimSigningAttributes' {} Maybe Text
a -> DkimSigningAttributes
s {$sel:domainSigningSelector:DkimSigningAttributes' :: Maybe Text
domainSigningSelector = Maybe Text
a} :: DkimSigningAttributes)

instance Prelude.Hashable DkimSigningAttributes

instance Prelude.NFData DkimSigningAttributes

instance Core.ToJSON DkimSigningAttributes where
  toJSON :: DkimSigningAttributes -> Value
toJSON DkimSigningAttributes' {Maybe Text
Maybe (Sensitive Text)
Maybe DkimSigningKeyLength
domainSigningSelector :: Maybe Text
domainSigningPrivateKey :: Maybe (Sensitive Text)
nextSigningKeyLength :: Maybe DkimSigningKeyLength
$sel:domainSigningSelector:DkimSigningAttributes' :: DkimSigningAttributes -> Maybe Text
$sel:domainSigningPrivateKey:DkimSigningAttributes' :: DkimSigningAttributes -> Maybe (Sensitive Text)
$sel:nextSigningKeyLength:DkimSigningAttributes' :: DkimSigningAttributes -> Maybe DkimSigningKeyLength
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextSigningKeyLength" Text -> DkimSigningKeyLength -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DkimSigningKeyLength -> Pair)
-> Maybe DkimSigningKeyLength -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DkimSigningKeyLength
nextSigningKeyLength,
            (Text
"DomainSigningPrivateKey" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
domainSigningPrivateKey,
            (Text
"DomainSigningSelector" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
domainSigningSelector
          ]
      )