{-# 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.PinpointEmail.DeleteEmailIdentity
-- 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)
--
-- Deletes an email identity that you previously verified for use with
-- Amazon Pinpoint. An identity can be either an email address or a domain
-- name.
module Amazonka.PinpointEmail.DeleteEmailIdentity
  ( -- * Creating a Request
    DeleteEmailIdentity (..),
    newDeleteEmailIdentity,

    -- * Request Lenses
    deleteEmailIdentity_emailIdentity,

    -- * Destructuring the Response
    DeleteEmailIdentityResponse (..),
    newDeleteEmailIdentityResponse,

    -- * Response Lenses
    deleteEmailIdentityResponse_httpStatus,
  )
where

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

-- | A request to delete an existing email identity. When you delete an
-- identity, you lose the ability to use Amazon Pinpoint to send email from
-- that identity. You can restore your ability to send email by completing
-- the verification process for the identity again.
--
-- /See:/ 'newDeleteEmailIdentity' smart constructor.
data DeleteEmailIdentity = DeleteEmailIdentity'
  { -- | The identity (that is, the email address or domain) that you want to
    -- delete from your Amazon Pinpoint account.
    DeleteEmailIdentity -> Text
emailIdentity :: Prelude.Text
  }
  deriving (DeleteEmailIdentity -> DeleteEmailIdentity -> Bool
(DeleteEmailIdentity -> DeleteEmailIdentity -> Bool)
-> (DeleteEmailIdentity -> DeleteEmailIdentity -> Bool)
-> Eq DeleteEmailIdentity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteEmailIdentity -> DeleteEmailIdentity -> Bool
$c/= :: DeleteEmailIdentity -> DeleteEmailIdentity -> Bool
== :: DeleteEmailIdentity -> DeleteEmailIdentity -> Bool
$c== :: DeleteEmailIdentity -> DeleteEmailIdentity -> Bool
Prelude.Eq, ReadPrec [DeleteEmailIdentity]
ReadPrec DeleteEmailIdentity
Int -> ReadS DeleteEmailIdentity
ReadS [DeleteEmailIdentity]
(Int -> ReadS DeleteEmailIdentity)
-> ReadS [DeleteEmailIdentity]
-> ReadPrec DeleteEmailIdentity
-> ReadPrec [DeleteEmailIdentity]
-> Read DeleteEmailIdentity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteEmailIdentity]
$creadListPrec :: ReadPrec [DeleteEmailIdentity]
readPrec :: ReadPrec DeleteEmailIdentity
$creadPrec :: ReadPrec DeleteEmailIdentity
readList :: ReadS [DeleteEmailIdentity]
$creadList :: ReadS [DeleteEmailIdentity]
readsPrec :: Int -> ReadS DeleteEmailIdentity
$creadsPrec :: Int -> ReadS DeleteEmailIdentity
Prelude.Read, Int -> DeleteEmailIdentity -> ShowS
[DeleteEmailIdentity] -> ShowS
DeleteEmailIdentity -> String
(Int -> DeleteEmailIdentity -> ShowS)
-> (DeleteEmailIdentity -> String)
-> ([DeleteEmailIdentity] -> ShowS)
-> Show DeleteEmailIdentity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteEmailIdentity] -> ShowS
$cshowList :: [DeleteEmailIdentity] -> ShowS
show :: DeleteEmailIdentity -> String
$cshow :: DeleteEmailIdentity -> String
showsPrec :: Int -> DeleteEmailIdentity -> ShowS
$cshowsPrec :: Int -> DeleteEmailIdentity -> ShowS
Prelude.Show, (forall x. DeleteEmailIdentity -> Rep DeleteEmailIdentity x)
-> (forall x. Rep DeleteEmailIdentity x -> DeleteEmailIdentity)
-> Generic DeleteEmailIdentity
forall x. Rep DeleteEmailIdentity x -> DeleteEmailIdentity
forall x. DeleteEmailIdentity -> Rep DeleteEmailIdentity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteEmailIdentity x -> DeleteEmailIdentity
$cfrom :: forall x. DeleteEmailIdentity -> Rep DeleteEmailIdentity x
Prelude.Generic)

-- |
-- Create a value of 'DeleteEmailIdentity' 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:
--
-- 'emailIdentity', 'deleteEmailIdentity_emailIdentity' - The identity (that is, the email address or domain) that you want to
-- delete from your Amazon Pinpoint account.
newDeleteEmailIdentity ::
  -- | 'emailIdentity'
  Prelude.Text ->
  DeleteEmailIdentity
newDeleteEmailIdentity :: Text -> DeleteEmailIdentity
newDeleteEmailIdentity Text
pEmailIdentity_ =
  DeleteEmailIdentity' :: Text -> DeleteEmailIdentity
DeleteEmailIdentity'
    { $sel:emailIdentity:DeleteEmailIdentity' :: Text
emailIdentity =
        Text
pEmailIdentity_
    }

-- | The identity (that is, the email address or domain) that you want to
-- delete from your Amazon Pinpoint account.
deleteEmailIdentity_emailIdentity :: Lens.Lens' DeleteEmailIdentity Prelude.Text
deleteEmailIdentity_emailIdentity :: (Text -> f Text) -> DeleteEmailIdentity -> f DeleteEmailIdentity
deleteEmailIdentity_emailIdentity = (DeleteEmailIdentity -> Text)
-> (DeleteEmailIdentity -> Text -> DeleteEmailIdentity)
-> Lens DeleteEmailIdentity DeleteEmailIdentity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEmailIdentity' {Text
emailIdentity :: Text
$sel:emailIdentity:DeleteEmailIdentity' :: DeleteEmailIdentity -> Text
emailIdentity} -> Text
emailIdentity) (\s :: DeleteEmailIdentity
s@DeleteEmailIdentity' {} Text
a -> DeleteEmailIdentity
s {$sel:emailIdentity:DeleteEmailIdentity' :: Text
emailIdentity = Text
a} :: DeleteEmailIdentity)

instance Core.AWSRequest DeleteEmailIdentity where
  type
    AWSResponse DeleteEmailIdentity =
      DeleteEmailIdentityResponse
  request :: DeleteEmailIdentity -> Request DeleteEmailIdentity
request = Service -> DeleteEmailIdentity -> Request DeleteEmailIdentity
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteEmailIdentity
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteEmailIdentity)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteEmailIdentity))
-> Logger
-> Service
-> Proxy DeleteEmailIdentity
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteEmailIdentity)))
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 -> DeleteEmailIdentityResponse
DeleteEmailIdentityResponse'
            (Int -> DeleteEmailIdentityResponse)
-> Either String Int -> Either String DeleteEmailIdentityResponse
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 DeleteEmailIdentity

instance Prelude.NFData DeleteEmailIdentity

instance Core.ToHeaders DeleteEmailIdentity where
  toHeaders :: DeleteEmailIdentity -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteEmailIdentity -> 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.ToPath DeleteEmailIdentity where
  toPath :: DeleteEmailIdentity -> ByteString
toPath DeleteEmailIdentity' {Text
emailIdentity :: Text
$sel:emailIdentity:DeleteEmailIdentity' :: DeleteEmailIdentity -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/email/identities/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
emailIdentity]

instance Core.ToQuery DeleteEmailIdentity where
  toQuery :: DeleteEmailIdentity -> QueryString
toQuery = QueryString -> DeleteEmailIdentity -> 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:/ 'newDeleteEmailIdentityResponse' smart constructor.
data DeleteEmailIdentityResponse = DeleteEmailIdentityResponse'
  { -- | The response's http status code.
    DeleteEmailIdentityResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteEmailIdentityResponse -> DeleteEmailIdentityResponse -> Bool
(DeleteEmailIdentityResponse
 -> DeleteEmailIdentityResponse -> Bool)
-> (DeleteEmailIdentityResponse
    -> DeleteEmailIdentityResponse -> Bool)
-> Eq DeleteEmailIdentityResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteEmailIdentityResponse -> DeleteEmailIdentityResponse -> Bool
$c/= :: DeleteEmailIdentityResponse -> DeleteEmailIdentityResponse -> Bool
== :: DeleteEmailIdentityResponse -> DeleteEmailIdentityResponse -> Bool
$c== :: DeleteEmailIdentityResponse -> DeleteEmailIdentityResponse -> Bool
Prelude.Eq, ReadPrec [DeleteEmailIdentityResponse]
ReadPrec DeleteEmailIdentityResponse
Int -> ReadS DeleteEmailIdentityResponse
ReadS [DeleteEmailIdentityResponse]
(Int -> ReadS DeleteEmailIdentityResponse)
-> ReadS [DeleteEmailIdentityResponse]
-> ReadPrec DeleteEmailIdentityResponse
-> ReadPrec [DeleteEmailIdentityResponse]
-> Read DeleteEmailIdentityResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteEmailIdentityResponse]
$creadListPrec :: ReadPrec [DeleteEmailIdentityResponse]
readPrec :: ReadPrec DeleteEmailIdentityResponse
$creadPrec :: ReadPrec DeleteEmailIdentityResponse
readList :: ReadS [DeleteEmailIdentityResponse]
$creadList :: ReadS [DeleteEmailIdentityResponse]
readsPrec :: Int -> ReadS DeleteEmailIdentityResponse
$creadsPrec :: Int -> ReadS DeleteEmailIdentityResponse
Prelude.Read, Int -> DeleteEmailIdentityResponse -> ShowS
[DeleteEmailIdentityResponse] -> ShowS
DeleteEmailIdentityResponse -> String
(Int -> DeleteEmailIdentityResponse -> ShowS)
-> (DeleteEmailIdentityResponse -> String)
-> ([DeleteEmailIdentityResponse] -> ShowS)
-> Show DeleteEmailIdentityResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteEmailIdentityResponse] -> ShowS
$cshowList :: [DeleteEmailIdentityResponse] -> ShowS
show :: DeleteEmailIdentityResponse -> String
$cshow :: DeleteEmailIdentityResponse -> String
showsPrec :: Int -> DeleteEmailIdentityResponse -> ShowS
$cshowsPrec :: Int -> DeleteEmailIdentityResponse -> ShowS
Prelude.Show, (forall x.
 DeleteEmailIdentityResponse -> Rep DeleteEmailIdentityResponse x)
-> (forall x.
    Rep DeleteEmailIdentityResponse x -> DeleteEmailIdentityResponse)
-> Generic DeleteEmailIdentityResponse
forall x.
Rep DeleteEmailIdentityResponse x -> DeleteEmailIdentityResponse
forall x.
DeleteEmailIdentityResponse -> Rep DeleteEmailIdentityResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteEmailIdentityResponse x -> DeleteEmailIdentityResponse
$cfrom :: forall x.
DeleteEmailIdentityResponse -> Rep DeleteEmailIdentityResponse x
Prelude.Generic)

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

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

instance Prelude.NFData DeleteEmailIdentityResponse