{-# 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.DeleteEmailIdentityPolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified sending authorization policy for the given
-- identity (an email address or a domain). This API returns successfully
-- even if a policy with the specified name does not exist.
--
-- This API is for the identity owner only. If you have not verified the
-- identity, this API will return an error.
--
-- Sending authorization is a feature that enables an identity owner to
-- authorize other senders to use its identities. For information about
-- using sending authorization, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
--
-- You can execute this operation no more than once per second.
module Amazonka.SESV2.DeleteEmailIdentityPolicy
  ( -- * Creating a Request
    DeleteEmailIdentityPolicy (..),
    newDeleteEmailIdentityPolicy,

    -- * Request Lenses
    deleteEmailIdentityPolicy_emailIdentity,
    deleteEmailIdentityPolicy_policyName,

    -- * Destructuring the Response
    DeleteEmailIdentityPolicyResponse (..),
    newDeleteEmailIdentityPolicyResponse,

    -- * Response Lenses
    deleteEmailIdentityPolicyResponse_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.SESV2.Types

-- | Represents a request to delete a sending authorization policy for an
-- identity. Sending authorization is an Amazon SES feature that enables
-- you to authorize other senders to use your identities. For information,
-- see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization-identity-owner-tasks-management.html Amazon SES Developer Guide>.
--
-- /See:/ 'newDeleteEmailIdentityPolicy' smart constructor.
data DeleteEmailIdentityPolicy = DeleteEmailIdentityPolicy'
  { -- | The email identity.
    DeleteEmailIdentityPolicy -> Text
emailIdentity :: Prelude.Text,
    -- | The name of the policy.
    --
    -- The policy name cannot exceed 64 characters and can only include
    -- alphanumeric characters, dashes, and underscores.
    DeleteEmailIdentityPolicy -> Text
policyName :: Prelude.Text
  }
  deriving (DeleteEmailIdentityPolicy -> DeleteEmailIdentityPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteEmailIdentityPolicy -> DeleteEmailIdentityPolicy -> Bool
$c/= :: DeleteEmailIdentityPolicy -> DeleteEmailIdentityPolicy -> Bool
== :: DeleteEmailIdentityPolicy -> DeleteEmailIdentityPolicy -> Bool
$c== :: DeleteEmailIdentityPolicy -> DeleteEmailIdentityPolicy -> Bool
Prelude.Eq, ReadPrec [DeleteEmailIdentityPolicy]
ReadPrec DeleteEmailIdentityPolicy
Int -> ReadS DeleteEmailIdentityPolicy
ReadS [DeleteEmailIdentityPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteEmailIdentityPolicy]
$creadListPrec :: ReadPrec [DeleteEmailIdentityPolicy]
readPrec :: ReadPrec DeleteEmailIdentityPolicy
$creadPrec :: ReadPrec DeleteEmailIdentityPolicy
readList :: ReadS [DeleteEmailIdentityPolicy]
$creadList :: ReadS [DeleteEmailIdentityPolicy]
readsPrec :: Int -> ReadS DeleteEmailIdentityPolicy
$creadsPrec :: Int -> ReadS DeleteEmailIdentityPolicy
Prelude.Read, Int -> DeleteEmailIdentityPolicy -> ShowS
[DeleteEmailIdentityPolicy] -> ShowS
DeleteEmailIdentityPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteEmailIdentityPolicy] -> ShowS
$cshowList :: [DeleteEmailIdentityPolicy] -> ShowS
show :: DeleteEmailIdentityPolicy -> String
$cshow :: DeleteEmailIdentityPolicy -> String
showsPrec :: Int -> DeleteEmailIdentityPolicy -> ShowS
$cshowsPrec :: Int -> DeleteEmailIdentityPolicy -> ShowS
Prelude.Show, forall x.
Rep DeleteEmailIdentityPolicy x -> DeleteEmailIdentityPolicy
forall x.
DeleteEmailIdentityPolicy -> Rep DeleteEmailIdentityPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteEmailIdentityPolicy x -> DeleteEmailIdentityPolicy
$cfrom :: forall x.
DeleteEmailIdentityPolicy -> Rep DeleteEmailIdentityPolicy x
Prelude.Generic)

-- |
-- Create a value of 'DeleteEmailIdentityPolicy' 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', 'deleteEmailIdentityPolicy_emailIdentity' - The email identity.
--
-- 'policyName', 'deleteEmailIdentityPolicy_policyName' - The name of the policy.
--
-- The policy name cannot exceed 64 characters and can only include
-- alphanumeric characters, dashes, and underscores.
newDeleteEmailIdentityPolicy ::
  -- | 'emailIdentity'
  Prelude.Text ->
  -- | 'policyName'
  Prelude.Text ->
  DeleteEmailIdentityPolicy
newDeleteEmailIdentityPolicy :: Text -> Text -> DeleteEmailIdentityPolicy
newDeleteEmailIdentityPolicy
  Text
pEmailIdentity_
  Text
pPolicyName_ =
    DeleteEmailIdentityPolicy'
      { $sel:emailIdentity:DeleteEmailIdentityPolicy' :: Text
emailIdentity =
          Text
pEmailIdentity_,
        $sel:policyName:DeleteEmailIdentityPolicy' :: Text
policyName = Text
pPolicyName_
      }

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

-- | The name of the policy.
--
-- The policy name cannot exceed 64 characters and can only include
-- alphanumeric characters, dashes, and underscores.
deleteEmailIdentityPolicy_policyName :: Lens.Lens' DeleteEmailIdentityPolicy Prelude.Text
deleteEmailIdentityPolicy_policyName :: Lens' DeleteEmailIdentityPolicy Text
deleteEmailIdentityPolicy_policyName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEmailIdentityPolicy' {Text
policyName :: Text
$sel:policyName:DeleteEmailIdentityPolicy' :: DeleteEmailIdentityPolicy -> Text
policyName} -> Text
policyName) (\s :: DeleteEmailIdentityPolicy
s@DeleteEmailIdentityPolicy' {} Text
a -> DeleteEmailIdentityPolicy
s {$sel:policyName:DeleteEmailIdentityPolicy' :: Text
policyName = Text
a} :: DeleteEmailIdentityPolicy)

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

instance Prelude.Hashable DeleteEmailIdentityPolicy where
  hashWithSalt :: Int -> DeleteEmailIdentityPolicy -> Int
hashWithSalt Int
_salt DeleteEmailIdentityPolicy' {Text
policyName :: Text
emailIdentity :: Text
$sel:policyName:DeleteEmailIdentityPolicy' :: DeleteEmailIdentityPolicy -> Text
$sel:emailIdentity:DeleteEmailIdentityPolicy' :: DeleteEmailIdentityPolicy -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
emailIdentity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyName

instance Prelude.NFData DeleteEmailIdentityPolicy where
  rnf :: DeleteEmailIdentityPolicy -> ()
rnf DeleteEmailIdentityPolicy' {Text
policyName :: Text
emailIdentity :: Text
$sel:policyName:DeleteEmailIdentityPolicy' :: DeleteEmailIdentityPolicy -> Text
$sel:emailIdentity:DeleteEmailIdentityPolicy' :: DeleteEmailIdentityPolicy -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
emailIdentity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
policyName

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

instance Data.ToPath DeleteEmailIdentityPolicy where
  toPath :: DeleteEmailIdentityPolicy -> ByteString
toPath DeleteEmailIdentityPolicy' {Text
policyName :: Text
emailIdentity :: Text
$sel:policyName:DeleteEmailIdentityPolicy' :: DeleteEmailIdentityPolicy -> Text
$sel:emailIdentity:DeleteEmailIdentityPolicy' :: DeleteEmailIdentityPolicy -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v2/email/identities/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
emailIdentity,
        ByteString
"/policies/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
policyName
      ]

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

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

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

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

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