{-# 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.SES.VerifyEmailIdentity
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Adds an email address to the list of identities for your Amazon SES
-- account in the current AWS region and attempts to verify it. As a result
-- of executing this operation, a verification email is sent to the
-- specified address.
--
-- You can execute this operation no more than once per second.
module Amazonka.SES.VerifyEmailIdentity
  ( -- * Creating a Request
    VerifyEmailIdentity (..),
    newVerifyEmailIdentity,

    -- * Request Lenses
    verifyEmailIdentity_emailAddress,

    -- * Destructuring the Response
    VerifyEmailIdentityResponse (..),
    newVerifyEmailIdentityResponse,

    -- * Response Lenses
    verifyEmailIdentityResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SES.Types

-- | Represents a request to begin email address verification with Amazon
-- SES. For information about email address verification, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html Amazon SES Developer Guide>.
--
-- /See:/ 'newVerifyEmailIdentity' smart constructor.
data VerifyEmailIdentity = VerifyEmailIdentity'
  { -- | The email address to be verified.
    VerifyEmailIdentity -> Text
emailAddress :: Prelude.Text
  }
  deriving (VerifyEmailIdentity -> VerifyEmailIdentity -> Bool
(VerifyEmailIdentity -> VerifyEmailIdentity -> Bool)
-> (VerifyEmailIdentity -> VerifyEmailIdentity -> Bool)
-> Eq VerifyEmailIdentity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VerifyEmailIdentity -> VerifyEmailIdentity -> Bool
== :: VerifyEmailIdentity -> VerifyEmailIdentity -> Bool
$c/= :: VerifyEmailIdentity -> VerifyEmailIdentity -> Bool
/= :: VerifyEmailIdentity -> VerifyEmailIdentity -> Bool
Prelude.Eq, ReadPrec [VerifyEmailIdentity]
ReadPrec VerifyEmailIdentity
Int -> ReadS VerifyEmailIdentity
ReadS [VerifyEmailIdentity]
(Int -> ReadS VerifyEmailIdentity)
-> ReadS [VerifyEmailIdentity]
-> ReadPrec VerifyEmailIdentity
-> ReadPrec [VerifyEmailIdentity]
-> Read VerifyEmailIdentity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS VerifyEmailIdentity
readsPrec :: Int -> ReadS VerifyEmailIdentity
$creadList :: ReadS [VerifyEmailIdentity]
readList :: ReadS [VerifyEmailIdentity]
$creadPrec :: ReadPrec VerifyEmailIdentity
readPrec :: ReadPrec VerifyEmailIdentity
$creadListPrec :: ReadPrec [VerifyEmailIdentity]
readListPrec :: ReadPrec [VerifyEmailIdentity]
Prelude.Read, Int -> VerifyEmailIdentity -> ShowS
[VerifyEmailIdentity] -> ShowS
VerifyEmailIdentity -> String
(Int -> VerifyEmailIdentity -> ShowS)
-> (VerifyEmailIdentity -> String)
-> ([VerifyEmailIdentity] -> ShowS)
-> Show VerifyEmailIdentity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VerifyEmailIdentity -> ShowS
showsPrec :: Int -> VerifyEmailIdentity -> ShowS
$cshow :: VerifyEmailIdentity -> String
show :: VerifyEmailIdentity -> String
$cshowList :: [VerifyEmailIdentity] -> ShowS
showList :: [VerifyEmailIdentity] -> ShowS
Prelude.Show, (forall x. VerifyEmailIdentity -> Rep VerifyEmailIdentity x)
-> (forall x. Rep VerifyEmailIdentity x -> VerifyEmailIdentity)
-> Generic VerifyEmailIdentity
forall x. Rep VerifyEmailIdentity x -> VerifyEmailIdentity
forall x. VerifyEmailIdentity -> Rep VerifyEmailIdentity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. VerifyEmailIdentity -> Rep VerifyEmailIdentity x
from :: forall x. VerifyEmailIdentity -> Rep VerifyEmailIdentity x
$cto :: forall x. Rep VerifyEmailIdentity x -> VerifyEmailIdentity
to :: forall x. Rep VerifyEmailIdentity x -> VerifyEmailIdentity
Prelude.Generic)

-- |
-- Create a value of 'VerifyEmailIdentity' 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:
--
-- 'emailAddress', 'verifyEmailIdentity_emailAddress' - The email address to be verified.
newVerifyEmailIdentity ::
  -- | 'emailAddress'
  Prelude.Text ->
  VerifyEmailIdentity
newVerifyEmailIdentity :: Text -> VerifyEmailIdentity
newVerifyEmailIdentity Text
pEmailAddress_ =
  VerifyEmailIdentity' {$sel:emailAddress:VerifyEmailIdentity' :: Text
emailAddress = Text
pEmailAddress_}

-- | The email address to be verified.
verifyEmailIdentity_emailAddress :: Lens.Lens' VerifyEmailIdentity Prelude.Text
verifyEmailIdentity_emailAddress :: Lens' VerifyEmailIdentity Text
verifyEmailIdentity_emailAddress = (VerifyEmailIdentity -> Text)
-> (VerifyEmailIdentity -> Text -> VerifyEmailIdentity)
-> Lens' VerifyEmailIdentity Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VerifyEmailIdentity' {Text
$sel:emailAddress:VerifyEmailIdentity' :: VerifyEmailIdentity -> Text
emailAddress :: Text
emailAddress} -> Text
emailAddress) (\s :: VerifyEmailIdentity
s@VerifyEmailIdentity' {} Text
a -> VerifyEmailIdentity
s {emailAddress = a} :: VerifyEmailIdentity)

instance Core.AWSRequest VerifyEmailIdentity where
  type
    AWSResponse VerifyEmailIdentity =
      VerifyEmailIdentityResponse
  request :: (Service -> Service)
-> VerifyEmailIdentity -> Request VerifyEmailIdentity
request Service -> Service
overrides =
    Service -> VerifyEmailIdentity -> Request VerifyEmailIdentity
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy VerifyEmailIdentity
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse VerifyEmailIdentity)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse VerifyEmailIdentity))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy VerifyEmailIdentity
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse VerifyEmailIdentity)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"VerifyEmailIdentityResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> VerifyEmailIdentityResponse
VerifyEmailIdentityResponse'
            (Int -> VerifyEmailIdentityResponse)
-> Either String Int -> Either String VerifyEmailIdentityResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall a. a -> Either String a
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 VerifyEmailIdentity where
  hashWithSalt :: Int -> VerifyEmailIdentity -> Int
hashWithSalt Int
_salt VerifyEmailIdentity' {Text
$sel:emailAddress:VerifyEmailIdentity' :: VerifyEmailIdentity -> Text
emailAddress :: Text
..} =
    Int
_salt Int -> Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
emailAddress

instance Prelude.NFData VerifyEmailIdentity where
  rnf :: VerifyEmailIdentity -> ()
rnf VerifyEmailIdentity' {Text
$sel:emailAddress:VerifyEmailIdentity' :: VerifyEmailIdentity -> Text
emailAddress :: Text
..} =
    Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Text
emailAddress

instance Data.ToHeaders VerifyEmailIdentity where
  toHeaders :: VerifyEmailIdentity -> ResponseHeaders
toHeaders = ResponseHeaders -> VerifyEmailIdentity -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath VerifyEmailIdentity where
  toPath :: VerifyEmailIdentity -> ByteString
toPath = ByteString -> VerifyEmailIdentity -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery VerifyEmailIdentity where
  toQuery :: VerifyEmailIdentity -> QueryString
toQuery VerifyEmailIdentity' {Text
$sel:emailAddress:VerifyEmailIdentity' :: VerifyEmailIdentity -> Text
emailAddress :: Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"VerifyEmailIdentity" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"EmailAddress" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
emailAddress
      ]

-- | An empty element returned on a successful request.
--
-- /See:/ 'newVerifyEmailIdentityResponse' smart constructor.
data VerifyEmailIdentityResponse = VerifyEmailIdentityResponse'
  { -- | The response's http status code.
    VerifyEmailIdentityResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (VerifyEmailIdentityResponse -> VerifyEmailIdentityResponse -> Bool
(VerifyEmailIdentityResponse
 -> VerifyEmailIdentityResponse -> Bool)
-> (VerifyEmailIdentityResponse
    -> VerifyEmailIdentityResponse -> Bool)
-> Eq VerifyEmailIdentityResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VerifyEmailIdentityResponse -> VerifyEmailIdentityResponse -> Bool
== :: VerifyEmailIdentityResponse -> VerifyEmailIdentityResponse -> Bool
$c/= :: VerifyEmailIdentityResponse -> VerifyEmailIdentityResponse -> Bool
/= :: VerifyEmailIdentityResponse -> VerifyEmailIdentityResponse -> Bool
Prelude.Eq, ReadPrec [VerifyEmailIdentityResponse]
ReadPrec VerifyEmailIdentityResponse
Int -> ReadS VerifyEmailIdentityResponse
ReadS [VerifyEmailIdentityResponse]
(Int -> ReadS VerifyEmailIdentityResponse)
-> ReadS [VerifyEmailIdentityResponse]
-> ReadPrec VerifyEmailIdentityResponse
-> ReadPrec [VerifyEmailIdentityResponse]
-> Read VerifyEmailIdentityResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS VerifyEmailIdentityResponse
readsPrec :: Int -> ReadS VerifyEmailIdentityResponse
$creadList :: ReadS [VerifyEmailIdentityResponse]
readList :: ReadS [VerifyEmailIdentityResponse]
$creadPrec :: ReadPrec VerifyEmailIdentityResponse
readPrec :: ReadPrec VerifyEmailIdentityResponse
$creadListPrec :: ReadPrec [VerifyEmailIdentityResponse]
readListPrec :: ReadPrec [VerifyEmailIdentityResponse]
Prelude.Read, Int -> VerifyEmailIdentityResponse -> ShowS
[VerifyEmailIdentityResponse] -> ShowS
VerifyEmailIdentityResponse -> String
(Int -> VerifyEmailIdentityResponse -> ShowS)
-> (VerifyEmailIdentityResponse -> String)
-> ([VerifyEmailIdentityResponse] -> ShowS)
-> Show VerifyEmailIdentityResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VerifyEmailIdentityResponse -> ShowS
showsPrec :: Int -> VerifyEmailIdentityResponse -> ShowS
$cshow :: VerifyEmailIdentityResponse -> String
show :: VerifyEmailIdentityResponse -> String
$cshowList :: [VerifyEmailIdentityResponse] -> ShowS
showList :: [VerifyEmailIdentityResponse] -> ShowS
Prelude.Show, (forall x.
 VerifyEmailIdentityResponse -> Rep VerifyEmailIdentityResponse x)
-> (forall x.
    Rep VerifyEmailIdentityResponse x -> VerifyEmailIdentityResponse)
-> Generic VerifyEmailIdentityResponse
forall x.
Rep VerifyEmailIdentityResponse x -> VerifyEmailIdentityResponse
forall x.
VerifyEmailIdentityResponse -> Rep VerifyEmailIdentityResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
VerifyEmailIdentityResponse -> Rep VerifyEmailIdentityResponse x
from :: forall x.
VerifyEmailIdentityResponse -> Rep VerifyEmailIdentityResponse x
$cto :: forall x.
Rep VerifyEmailIdentityResponse x -> VerifyEmailIdentityResponse
to :: forall x.
Rep VerifyEmailIdentityResponse x -> VerifyEmailIdentityResponse
Prelude.Generic)

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

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

instance Prelude.NFData VerifyEmailIdentityResponse where
  rnf :: VerifyEmailIdentityResponse -> ()
rnf VerifyEmailIdentityResponse' {Int
$sel:httpStatus:VerifyEmailIdentityResponse' :: VerifyEmailIdentityResponse -> Int
httpStatus :: Int
..} =
    Int -> ()
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus