{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.PutEmailIdentityDkimAttributes
-- 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)
--
-- Used to enable or disable DKIM authentication for an email identity.
module Amazonka.SESV2.PutEmailIdentityDkimAttributes
  ( -- * Creating a Request
    PutEmailIdentityDkimAttributes (..),
    newPutEmailIdentityDkimAttributes,

    -- * Request Lenses
    putEmailIdentityDkimAttributes_signingEnabled,
    putEmailIdentityDkimAttributes_emailIdentity,

    -- * Destructuring the Response
    PutEmailIdentityDkimAttributesResponse (..),
    newPutEmailIdentityDkimAttributesResponse,

    -- * Response Lenses
    putEmailIdentityDkimAttributesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SESV2.Types

-- | A request to enable or disable DKIM signing of email that you send from
-- an email identity.
--
-- /See:/ 'newPutEmailIdentityDkimAttributes' smart constructor.
data PutEmailIdentityDkimAttributes = PutEmailIdentityDkimAttributes'
  { -- | Sets the DKIM signing configuration for the identity.
    --
    -- When you set this value @true@, then the messages that are sent from the
    -- identity are signed using DKIM. If you set this value to @false@, your
    -- messages are sent without DKIM signing.
    PutEmailIdentityDkimAttributes -> Maybe Bool
signingEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The email identity.
    PutEmailIdentityDkimAttributes -> Text
emailIdentity :: Prelude.Text
  }
  deriving (PutEmailIdentityDkimAttributes
-> PutEmailIdentityDkimAttributes -> Bool
(PutEmailIdentityDkimAttributes
 -> PutEmailIdentityDkimAttributes -> Bool)
-> (PutEmailIdentityDkimAttributes
    -> PutEmailIdentityDkimAttributes -> Bool)
-> Eq PutEmailIdentityDkimAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEmailIdentityDkimAttributes
-> PutEmailIdentityDkimAttributes -> Bool
$c/= :: PutEmailIdentityDkimAttributes
-> PutEmailIdentityDkimAttributes -> Bool
== :: PutEmailIdentityDkimAttributes
-> PutEmailIdentityDkimAttributes -> Bool
$c== :: PutEmailIdentityDkimAttributes
-> PutEmailIdentityDkimAttributes -> Bool
Prelude.Eq, ReadPrec [PutEmailIdentityDkimAttributes]
ReadPrec PutEmailIdentityDkimAttributes
Int -> ReadS PutEmailIdentityDkimAttributes
ReadS [PutEmailIdentityDkimAttributes]
(Int -> ReadS PutEmailIdentityDkimAttributes)
-> ReadS [PutEmailIdentityDkimAttributes]
-> ReadPrec PutEmailIdentityDkimAttributes
-> ReadPrec [PutEmailIdentityDkimAttributes]
-> Read PutEmailIdentityDkimAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEmailIdentityDkimAttributes]
$creadListPrec :: ReadPrec [PutEmailIdentityDkimAttributes]
readPrec :: ReadPrec PutEmailIdentityDkimAttributes
$creadPrec :: ReadPrec PutEmailIdentityDkimAttributes
readList :: ReadS [PutEmailIdentityDkimAttributes]
$creadList :: ReadS [PutEmailIdentityDkimAttributes]
readsPrec :: Int -> ReadS PutEmailIdentityDkimAttributes
$creadsPrec :: Int -> ReadS PutEmailIdentityDkimAttributes
Prelude.Read, Int -> PutEmailIdentityDkimAttributes -> ShowS
[PutEmailIdentityDkimAttributes] -> ShowS
PutEmailIdentityDkimAttributes -> String
(Int -> PutEmailIdentityDkimAttributes -> ShowS)
-> (PutEmailIdentityDkimAttributes -> String)
-> ([PutEmailIdentityDkimAttributes] -> ShowS)
-> Show PutEmailIdentityDkimAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEmailIdentityDkimAttributes] -> ShowS
$cshowList :: [PutEmailIdentityDkimAttributes] -> ShowS
show :: PutEmailIdentityDkimAttributes -> String
$cshow :: PutEmailIdentityDkimAttributes -> String
showsPrec :: Int -> PutEmailIdentityDkimAttributes -> ShowS
$cshowsPrec :: Int -> PutEmailIdentityDkimAttributes -> ShowS
Prelude.Show, (forall x.
 PutEmailIdentityDkimAttributes
 -> Rep PutEmailIdentityDkimAttributes x)
-> (forall x.
    Rep PutEmailIdentityDkimAttributes x
    -> PutEmailIdentityDkimAttributes)
-> Generic PutEmailIdentityDkimAttributes
forall x.
Rep PutEmailIdentityDkimAttributes x
-> PutEmailIdentityDkimAttributes
forall x.
PutEmailIdentityDkimAttributes
-> Rep PutEmailIdentityDkimAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutEmailIdentityDkimAttributes x
-> PutEmailIdentityDkimAttributes
$cfrom :: forall x.
PutEmailIdentityDkimAttributes
-> Rep PutEmailIdentityDkimAttributes x
Prelude.Generic)

-- |
-- Create a value of 'PutEmailIdentityDkimAttributes' 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:
--
-- 'signingEnabled', 'putEmailIdentityDkimAttributes_signingEnabled' - Sets the DKIM signing configuration for the identity.
--
-- When you set this value @true@, then the messages that are sent from the
-- identity are signed using DKIM. If you set this value to @false@, your
-- messages are sent without DKIM signing.
--
-- 'emailIdentity', 'putEmailIdentityDkimAttributes_emailIdentity' - The email identity.
newPutEmailIdentityDkimAttributes ::
  -- | 'emailIdentity'
  Prelude.Text ->
  PutEmailIdentityDkimAttributes
newPutEmailIdentityDkimAttributes :: Text -> PutEmailIdentityDkimAttributes
newPutEmailIdentityDkimAttributes Text
pEmailIdentity_ =
  PutEmailIdentityDkimAttributes' :: Maybe Bool -> Text -> PutEmailIdentityDkimAttributes
PutEmailIdentityDkimAttributes'
    { $sel:signingEnabled:PutEmailIdentityDkimAttributes' :: Maybe Bool
signingEnabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:emailIdentity:PutEmailIdentityDkimAttributes' :: Text
emailIdentity = Text
pEmailIdentity_
    }

-- | Sets the DKIM signing configuration for the identity.
--
-- When you set this value @true@, then the messages that are sent from the
-- identity are signed using DKIM. If you set this value to @false@, your
-- messages are sent without DKIM signing.
putEmailIdentityDkimAttributes_signingEnabled :: Lens.Lens' PutEmailIdentityDkimAttributes (Prelude.Maybe Prelude.Bool)
putEmailIdentityDkimAttributes_signingEnabled :: (Maybe Bool -> f (Maybe Bool))
-> PutEmailIdentityDkimAttributes
-> f PutEmailIdentityDkimAttributes
putEmailIdentityDkimAttributes_signingEnabled = (PutEmailIdentityDkimAttributes -> Maybe Bool)
-> (PutEmailIdentityDkimAttributes
    -> Maybe Bool -> PutEmailIdentityDkimAttributes)
-> Lens
     PutEmailIdentityDkimAttributes
     PutEmailIdentityDkimAttributes
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEmailIdentityDkimAttributes' {Maybe Bool
signingEnabled :: Maybe Bool
$sel:signingEnabled:PutEmailIdentityDkimAttributes' :: PutEmailIdentityDkimAttributes -> Maybe Bool
signingEnabled} -> Maybe Bool
signingEnabled) (\s :: PutEmailIdentityDkimAttributes
s@PutEmailIdentityDkimAttributes' {} Maybe Bool
a -> PutEmailIdentityDkimAttributes
s {$sel:signingEnabled:PutEmailIdentityDkimAttributes' :: Maybe Bool
signingEnabled = Maybe Bool
a} :: PutEmailIdentityDkimAttributes)

-- | The email identity.
putEmailIdentityDkimAttributes_emailIdentity :: Lens.Lens' PutEmailIdentityDkimAttributes Prelude.Text
putEmailIdentityDkimAttributes_emailIdentity :: (Text -> f Text)
-> PutEmailIdentityDkimAttributes
-> f PutEmailIdentityDkimAttributes
putEmailIdentityDkimAttributes_emailIdentity = (PutEmailIdentityDkimAttributes -> Text)
-> (PutEmailIdentityDkimAttributes
    -> Text -> PutEmailIdentityDkimAttributes)
-> Lens
     PutEmailIdentityDkimAttributes
     PutEmailIdentityDkimAttributes
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEmailIdentityDkimAttributes' {Text
emailIdentity :: Text
$sel:emailIdentity:PutEmailIdentityDkimAttributes' :: PutEmailIdentityDkimAttributes -> Text
emailIdentity} -> Text
emailIdentity) (\s :: PutEmailIdentityDkimAttributes
s@PutEmailIdentityDkimAttributes' {} Text
a -> PutEmailIdentityDkimAttributes
s {$sel:emailIdentity:PutEmailIdentityDkimAttributes' :: Text
emailIdentity = Text
a} :: PutEmailIdentityDkimAttributes)

instance
  Core.AWSRequest
    PutEmailIdentityDkimAttributes
  where
  type
    AWSResponse PutEmailIdentityDkimAttributes =
      PutEmailIdentityDkimAttributesResponse
  request :: PutEmailIdentityDkimAttributes
-> Request PutEmailIdentityDkimAttributes
request = Service
-> PutEmailIdentityDkimAttributes
-> Request PutEmailIdentityDkimAttributes
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutEmailIdentityDkimAttributes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse PutEmailIdentityDkimAttributes)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutEmailIdentityDkimAttributes))
-> Logger
-> Service
-> Proxy PutEmailIdentityDkimAttributes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse PutEmailIdentityDkimAttributes)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutEmailIdentityDkimAttributesResponse
PutEmailIdentityDkimAttributesResponse'
            (Int -> PutEmailIdentityDkimAttributesResponse)
-> Either String Int
-> Either String PutEmailIdentityDkimAttributesResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    PutEmailIdentityDkimAttributes

instance
  Prelude.NFData
    PutEmailIdentityDkimAttributes

instance
  Core.ToHeaders
    PutEmailIdentityDkimAttributes
  where
  toHeaders :: PutEmailIdentityDkimAttributes -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> PutEmailIdentityDkimAttributes -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON PutEmailIdentityDkimAttributes where
  toJSON :: PutEmailIdentityDkimAttributes -> Value
toJSON PutEmailIdentityDkimAttributes' {Maybe Bool
Text
emailIdentity :: Text
signingEnabled :: Maybe Bool
$sel:emailIdentity:PutEmailIdentityDkimAttributes' :: PutEmailIdentityDkimAttributes -> Text
$sel:signingEnabled:PutEmailIdentityDkimAttributes' :: PutEmailIdentityDkimAttributes -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SigningEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
signingEnabled
          ]
      )

instance Core.ToPath PutEmailIdentityDkimAttributes where
  toPath :: PutEmailIdentityDkimAttributes -> ByteString
toPath PutEmailIdentityDkimAttributes' {Maybe Bool
Text
emailIdentity :: Text
signingEnabled :: Maybe Bool
$sel:emailIdentity:PutEmailIdentityDkimAttributes' :: PutEmailIdentityDkimAttributes -> Text
$sel:signingEnabled:PutEmailIdentityDkimAttributes' :: PutEmailIdentityDkimAttributes -> Maybe Bool
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v2/email/identities/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
emailIdentity,
        ByteString
"/dkim"
      ]

instance Core.ToQuery PutEmailIdentityDkimAttributes where
  toQuery :: PutEmailIdentityDkimAttributes -> QueryString
toQuery = QueryString -> PutEmailIdentityDkimAttributes -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | An HTTP 200 response if the request succeeds, or an error message if the
-- request fails.
--
-- /See:/ 'newPutEmailIdentityDkimAttributesResponse' smart constructor.
data PutEmailIdentityDkimAttributesResponse = PutEmailIdentityDkimAttributesResponse'
  { -- | The response's http status code.
    PutEmailIdentityDkimAttributesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutEmailIdentityDkimAttributesResponse
-> PutEmailIdentityDkimAttributesResponse -> Bool
(PutEmailIdentityDkimAttributesResponse
 -> PutEmailIdentityDkimAttributesResponse -> Bool)
-> (PutEmailIdentityDkimAttributesResponse
    -> PutEmailIdentityDkimAttributesResponse -> Bool)
-> Eq PutEmailIdentityDkimAttributesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEmailIdentityDkimAttributesResponse
-> PutEmailIdentityDkimAttributesResponse -> Bool
$c/= :: PutEmailIdentityDkimAttributesResponse
-> PutEmailIdentityDkimAttributesResponse -> Bool
== :: PutEmailIdentityDkimAttributesResponse
-> PutEmailIdentityDkimAttributesResponse -> Bool
$c== :: PutEmailIdentityDkimAttributesResponse
-> PutEmailIdentityDkimAttributesResponse -> Bool
Prelude.Eq, ReadPrec [PutEmailIdentityDkimAttributesResponse]
ReadPrec PutEmailIdentityDkimAttributesResponse
Int -> ReadS PutEmailIdentityDkimAttributesResponse
ReadS [PutEmailIdentityDkimAttributesResponse]
(Int -> ReadS PutEmailIdentityDkimAttributesResponse)
-> ReadS [PutEmailIdentityDkimAttributesResponse]
-> ReadPrec PutEmailIdentityDkimAttributesResponse
-> ReadPrec [PutEmailIdentityDkimAttributesResponse]
-> Read PutEmailIdentityDkimAttributesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEmailIdentityDkimAttributesResponse]
$creadListPrec :: ReadPrec [PutEmailIdentityDkimAttributesResponse]
readPrec :: ReadPrec PutEmailIdentityDkimAttributesResponse
$creadPrec :: ReadPrec PutEmailIdentityDkimAttributesResponse
readList :: ReadS [PutEmailIdentityDkimAttributesResponse]
$creadList :: ReadS [PutEmailIdentityDkimAttributesResponse]
readsPrec :: Int -> ReadS PutEmailIdentityDkimAttributesResponse
$creadsPrec :: Int -> ReadS PutEmailIdentityDkimAttributesResponse
Prelude.Read, Int -> PutEmailIdentityDkimAttributesResponse -> ShowS
[PutEmailIdentityDkimAttributesResponse] -> ShowS
PutEmailIdentityDkimAttributesResponse -> String
(Int -> PutEmailIdentityDkimAttributesResponse -> ShowS)
-> (PutEmailIdentityDkimAttributesResponse -> String)
-> ([PutEmailIdentityDkimAttributesResponse] -> ShowS)
-> Show PutEmailIdentityDkimAttributesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEmailIdentityDkimAttributesResponse] -> ShowS
$cshowList :: [PutEmailIdentityDkimAttributesResponse] -> ShowS
show :: PutEmailIdentityDkimAttributesResponse -> String
$cshow :: PutEmailIdentityDkimAttributesResponse -> String
showsPrec :: Int -> PutEmailIdentityDkimAttributesResponse -> ShowS
$cshowsPrec :: Int -> PutEmailIdentityDkimAttributesResponse -> ShowS
Prelude.Show, (forall x.
 PutEmailIdentityDkimAttributesResponse
 -> Rep PutEmailIdentityDkimAttributesResponse x)
-> (forall x.
    Rep PutEmailIdentityDkimAttributesResponse x
    -> PutEmailIdentityDkimAttributesResponse)
-> Generic PutEmailIdentityDkimAttributesResponse
forall x.
Rep PutEmailIdentityDkimAttributesResponse x
-> PutEmailIdentityDkimAttributesResponse
forall x.
PutEmailIdentityDkimAttributesResponse
-> Rep PutEmailIdentityDkimAttributesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutEmailIdentityDkimAttributesResponse x
-> PutEmailIdentityDkimAttributesResponse
$cfrom :: forall x.
PutEmailIdentityDkimAttributesResponse
-> Rep PutEmailIdentityDkimAttributesResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutEmailIdentityDkimAttributesResponse' 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:
--
-- 'httpStatus', 'putEmailIdentityDkimAttributesResponse_httpStatus' - The response's http status code.
newPutEmailIdentityDkimAttributesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutEmailIdentityDkimAttributesResponse
newPutEmailIdentityDkimAttributesResponse :: Int -> PutEmailIdentityDkimAttributesResponse
newPutEmailIdentityDkimAttributesResponse
  Int
pHttpStatus_ =
    PutEmailIdentityDkimAttributesResponse' :: Int -> PutEmailIdentityDkimAttributesResponse
PutEmailIdentityDkimAttributesResponse'
      { $sel:httpStatus:PutEmailIdentityDkimAttributesResponse' :: Int
httpStatus =
          Int
pHttpStatus_
      }

-- | The response's http status code.
putEmailIdentityDkimAttributesResponse_httpStatus :: Lens.Lens' PutEmailIdentityDkimAttributesResponse Prelude.Int
putEmailIdentityDkimAttributesResponse_httpStatus :: (Int -> f Int)
-> PutEmailIdentityDkimAttributesResponse
-> f PutEmailIdentityDkimAttributesResponse
putEmailIdentityDkimAttributesResponse_httpStatus = (PutEmailIdentityDkimAttributesResponse -> Int)
-> (PutEmailIdentityDkimAttributesResponse
    -> Int -> PutEmailIdentityDkimAttributesResponse)
-> Lens
     PutEmailIdentityDkimAttributesResponse
     PutEmailIdentityDkimAttributesResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEmailIdentityDkimAttributesResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutEmailIdentityDkimAttributesResponse' :: PutEmailIdentityDkimAttributesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutEmailIdentityDkimAttributesResponse
s@PutEmailIdentityDkimAttributesResponse' {} Int
a -> PutEmailIdentityDkimAttributesResponse
s {$sel:httpStatus:PutEmailIdentityDkimAttributesResponse' :: Int
httpStatus = Int
a} :: PutEmailIdentityDkimAttributesResponse)

instance
  Prelude.NFData
    PutEmailIdentityDkimAttributesResponse