{-# 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-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 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.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

-- | 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
(DeleteEmailIdentityPolicy -> DeleteEmailIdentityPolicy -> Bool)
-> (DeleteEmailIdentityPolicy -> DeleteEmailIdentityPolicy -> Bool)
-> Eq DeleteEmailIdentityPolicy
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]
(Int -> ReadS DeleteEmailIdentityPolicy)
-> ReadS [DeleteEmailIdentityPolicy]
-> ReadPrec DeleteEmailIdentityPolicy
-> ReadPrec [DeleteEmailIdentityPolicy]
-> Read 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
(Int -> DeleteEmailIdentityPolicy -> ShowS)
-> (DeleteEmailIdentityPolicy -> String)
-> ([DeleteEmailIdentityPolicy] -> ShowS)
-> Show DeleteEmailIdentityPolicy
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.
 DeleteEmailIdentityPolicy -> Rep DeleteEmailIdentityPolicy x)
-> (forall x.
    Rep DeleteEmailIdentityPolicy x -> DeleteEmailIdentityPolicy)
-> Generic DeleteEmailIdentityPolicy
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' :: Text -> Text -> DeleteEmailIdentityPolicy
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 :: (Text -> f Text)
-> DeleteEmailIdentityPolicy -> f DeleteEmailIdentityPolicy
deleteEmailIdentityPolicy_emailIdentity = (DeleteEmailIdentityPolicy -> Text)
-> (DeleteEmailIdentityPolicy -> Text -> DeleteEmailIdentityPolicy)
-> Lens
     DeleteEmailIdentityPolicy DeleteEmailIdentityPolicy Text Text
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 :: (Text -> f Text)
-> DeleteEmailIdentityPolicy -> f DeleteEmailIdentityPolicy
deleteEmailIdentityPolicy_policyName = (DeleteEmailIdentityPolicy -> Text)
-> (DeleteEmailIdentityPolicy -> Text -> DeleteEmailIdentityPolicy)
-> Lens
     DeleteEmailIdentityPolicy DeleteEmailIdentityPolicy Text Text
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 :: DeleteEmailIdentityPolicy -> Request DeleteEmailIdentityPolicy
request = Service
-> DeleteEmailIdentityPolicy -> Request DeleteEmailIdentityPolicy
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteEmailIdentityPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteEmailIdentityPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteEmailIdentityPolicy))
-> Logger
-> Service
-> Proxy DeleteEmailIdentityPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteEmailIdentityPolicy)))
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 -> DeleteEmailIdentityPolicyResponse
DeleteEmailIdentityPolicyResponse'
            (Int -> DeleteEmailIdentityPolicyResponse)
-> Either String Int
-> Either String DeleteEmailIdentityPolicyResponse
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 DeleteEmailIdentityPolicy

instance Prelude.NFData DeleteEmailIdentityPolicy

instance Core.ToHeaders DeleteEmailIdentityPolicy where
  toHeaders :: DeleteEmailIdentityPolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteEmailIdentityPolicy -> 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 DeleteEmailIdentityPolicy where
  toPath :: DeleteEmailIdentityPolicy -> ByteString
toPath DeleteEmailIdentityPolicy' {Text
policyName :: Text
emailIdentity :: Text
$sel:policyName:DeleteEmailIdentityPolicy' :: DeleteEmailIdentityPolicy -> Text
$sel:emailIdentity:DeleteEmailIdentityPolicy' :: DeleteEmailIdentityPolicy -> Text
..} =
    [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
"/policies/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
policyName
      ]

instance Core.ToQuery DeleteEmailIdentityPolicy where
  toQuery :: DeleteEmailIdentityPolicy -> QueryString
toQuery = QueryString -> DeleteEmailIdentityPolicy -> 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:/ 'newDeleteEmailIdentityPolicyResponse' smart constructor.
data DeleteEmailIdentityPolicyResponse = DeleteEmailIdentityPolicyResponse'
  { -- | The response's http status code.
    DeleteEmailIdentityPolicyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteEmailIdentityPolicyResponse
-> DeleteEmailIdentityPolicyResponse -> Bool
(DeleteEmailIdentityPolicyResponse
 -> DeleteEmailIdentityPolicyResponse -> Bool)
-> (DeleteEmailIdentityPolicyResponse
    -> DeleteEmailIdentityPolicyResponse -> Bool)
-> Eq DeleteEmailIdentityPolicyResponse
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]
(Int -> ReadS DeleteEmailIdentityPolicyResponse)
-> ReadS [DeleteEmailIdentityPolicyResponse]
-> ReadPrec DeleteEmailIdentityPolicyResponse
-> ReadPrec [DeleteEmailIdentityPolicyResponse]
-> Read 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
(Int -> DeleteEmailIdentityPolicyResponse -> ShowS)
-> (DeleteEmailIdentityPolicyResponse -> String)
-> ([DeleteEmailIdentityPolicyResponse] -> ShowS)
-> Show DeleteEmailIdentityPolicyResponse
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.
 DeleteEmailIdentityPolicyResponse
 -> Rep DeleteEmailIdentityPolicyResponse x)
-> (forall x.
    Rep DeleteEmailIdentityPolicyResponse x
    -> DeleteEmailIdentityPolicyResponse)
-> Generic DeleteEmailIdentityPolicyResponse
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' :: Int -> DeleteEmailIdentityPolicyResponse
DeleteEmailIdentityPolicyResponse'
    { $sel:httpStatus:DeleteEmailIdentityPolicyResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteEmailIdentityPolicyResponse_httpStatus :: Lens.Lens' DeleteEmailIdentityPolicyResponse Prelude.Int
deleteEmailIdentityPolicyResponse_httpStatus :: (Int -> f Int)
-> DeleteEmailIdentityPolicyResponse
-> f DeleteEmailIdentityPolicyResponse
deleteEmailIdentityPolicyResponse_httpStatus = (DeleteEmailIdentityPolicyResponse -> Int)
-> (DeleteEmailIdentityPolicyResponse
    -> Int -> DeleteEmailIdentityPolicyResponse)
-> Lens
     DeleteEmailIdentityPolicyResponse
     DeleteEmailIdentityPolicyResponse
     Int
     Int
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