{-# 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.DeleteIdentityPolicy
-- 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.SES.DeleteIdentityPolicy
  ( -- * Creating a Request
    DeleteIdentityPolicy (..),
    newDeleteIdentityPolicy,

    -- * Request Lenses
    deleteIdentityPolicy_identity,
    deleteIdentityPolicy_policyName,

    -- * Destructuring the Response
    DeleteIdentityPolicyResponse (..),
    newDeleteIdentityPolicyResponse,

    -- * Response Lenses
    deleteIdentityPolicyResponse_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 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.html Amazon SES Developer Guide>.
--
-- /See:/ 'newDeleteIdentityPolicy' smart constructor.
data DeleteIdentityPolicy = DeleteIdentityPolicy'
  { -- | The identity that is associated with the policy that you want to delete.
    -- You can specify the identity by using its name or by using its Amazon
    -- Resource Name (ARN). Examples: @user\@example.com@, @example.com@,
    -- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@.
    --
    -- To successfully call this API, you must own the identity.
    DeleteIdentityPolicy -> Text
identity :: Prelude.Text,
    -- | The name of the policy to be deleted.
    DeleteIdentityPolicy -> Text
policyName :: Prelude.Text
  }
  deriving (DeleteIdentityPolicy -> DeleteIdentityPolicy -> Bool
(DeleteIdentityPolicy -> DeleteIdentityPolicy -> Bool)
-> (DeleteIdentityPolicy -> DeleteIdentityPolicy -> Bool)
-> Eq DeleteIdentityPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DeleteIdentityPolicy -> DeleteIdentityPolicy -> Bool
== :: DeleteIdentityPolicy -> DeleteIdentityPolicy -> Bool
$c/= :: DeleteIdentityPolicy -> DeleteIdentityPolicy -> Bool
/= :: DeleteIdentityPolicy -> DeleteIdentityPolicy -> Bool
Prelude.Eq, ReadPrec [DeleteIdentityPolicy]
ReadPrec DeleteIdentityPolicy
Int -> ReadS DeleteIdentityPolicy
ReadS [DeleteIdentityPolicy]
(Int -> ReadS DeleteIdentityPolicy)
-> ReadS [DeleteIdentityPolicy]
-> ReadPrec DeleteIdentityPolicy
-> ReadPrec [DeleteIdentityPolicy]
-> Read DeleteIdentityPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DeleteIdentityPolicy
readsPrec :: Int -> ReadS DeleteIdentityPolicy
$creadList :: ReadS [DeleteIdentityPolicy]
readList :: ReadS [DeleteIdentityPolicy]
$creadPrec :: ReadPrec DeleteIdentityPolicy
readPrec :: ReadPrec DeleteIdentityPolicy
$creadListPrec :: ReadPrec [DeleteIdentityPolicy]
readListPrec :: ReadPrec [DeleteIdentityPolicy]
Prelude.Read, Int -> DeleteIdentityPolicy -> ShowS
[DeleteIdentityPolicy] -> ShowS
DeleteIdentityPolicy -> String
(Int -> DeleteIdentityPolicy -> ShowS)
-> (DeleteIdentityPolicy -> String)
-> ([DeleteIdentityPolicy] -> ShowS)
-> Show DeleteIdentityPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DeleteIdentityPolicy -> ShowS
showsPrec :: Int -> DeleteIdentityPolicy -> ShowS
$cshow :: DeleteIdentityPolicy -> String
show :: DeleteIdentityPolicy -> String
$cshowList :: [DeleteIdentityPolicy] -> ShowS
showList :: [DeleteIdentityPolicy] -> ShowS
Prelude.Show, (forall x. DeleteIdentityPolicy -> Rep DeleteIdentityPolicy x)
-> (forall x. Rep DeleteIdentityPolicy x -> DeleteIdentityPolicy)
-> Generic DeleteIdentityPolicy
forall x. Rep DeleteIdentityPolicy x -> DeleteIdentityPolicy
forall x. DeleteIdentityPolicy -> Rep DeleteIdentityPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DeleteIdentityPolicy -> Rep DeleteIdentityPolicy x
from :: forall x. DeleteIdentityPolicy -> Rep DeleteIdentityPolicy x
$cto :: forall x. Rep DeleteIdentityPolicy x -> DeleteIdentityPolicy
to :: forall x. Rep DeleteIdentityPolicy x -> DeleteIdentityPolicy
Prelude.Generic)

-- |
-- Create a value of 'DeleteIdentityPolicy' 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:
--
-- 'identity', 'deleteIdentityPolicy_identity' - The identity that is associated with the policy that you want to delete.
-- You can specify the identity by using its name or by using its Amazon
-- Resource Name (ARN). Examples: @user\@example.com@, @example.com@,
-- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@.
--
-- To successfully call this API, you must own the identity.
--
-- 'policyName', 'deleteIdentityPolicy_policyName' - The name of the policy to be deleted.
newDeleteIdentityPolicy ::
  -- | 'identity'
  Prelude.Text ->
  -- | 'policyName'
  Prelude.Text ->
  DeleteIdentityPolicy
newDeleteIdentityPolicy :: Text -> Text -> DeleteIdentityPolicy
newDeleteIdentityPolicy Text
pIdentity_ Text
pPolicyName_ =
  DeleteIdentityPolicy'
    { $sel:identity:DeleteIdentityPolicy' :: Text
identity = Text
pIdentity_,
      $sel:policyName:DeleteIdentityPolicy' :: Text
policyName = Text
pPolicyName_
    }

-- | The identity that is associated with the policy that you want to delete.
-- You can specify the identity by using its name or by using its Amazon
-- Resource Name (ARN). Examples: @user\@example.com@, @example.com@,
-- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@.
--
-- To successfully call this API, you must own the identity.
deleteIdentityPolicy_identity :: Lens.Lens' DeleteIdentityPolicy Prelude.Text
deleteIdentityPolicy_identity :: Lens' DeleteIdentityPolicy Text
deleteIdentityPolicy_identity = (DeleteIdentityPolicy -> Text)
-> (DeleteIdentityPolicy -> Text -> DeleteIdentityPolicy)
-> Lens' DeleteIdentityPolicy Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteIdentityPolicy' {Text
$sel:identity:DeleteIdentityPolicy' :: DeleteIdentityPolicy -> Text
identity :: Text
identity} -> Text
identity) (\s :: DeleteIdentityPolicy
s@DeleteIdentityPolicy' {} Text
a -> DeleteIdentityPolicy
s {identity = a} :: DeleteIdentityPolicy)

-- | The name of the policy to be deleted.
deleteIdentityPolicy_policyName :: Lens.Lens' DeleteIdentityPolicy Prelude.Text
deleteIdentityPolicy_policyName :: Lens' DeleteIdentityPolicy Text
deleteIdentityPolicy_policyName = (DeleteIdentityPolicy -> Text)
-> (DeleteIdentityPolicy -> Text -> DeleteIdentityPolicy)
-> Lens' DeleteIdentityPolicy Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteIdentityPolicy' {Text
$sel:policyName:DeleteIdentityPolicy' :: DeleteIdentityPolicy -> Text
policyName :: Text
policyName} -> Text
policyName) (\s :: DeleteIdentityPolicy
s@DeleteIdentityPolicy' {} Text
a -> DeleteIdentityPolicy
s {policyName = a} :: DeleteIdentityPolicy)

instance Core.AWSRequest DeleteIdentityPolicy where
  type
    AWSResponse DeleteIdentityPolicy =
      DeleteIdentityPolicyResponse
  request :: (Service -> Service)
-> DeleteIdentityPolicy -> Request DeleteIdentityPolicy
request Service -> Service
overrides =
    Service -> DeleteIdentityPolicy -> Request DeleteIdentityPolicy
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 DeleteIdentityPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteIdentityPolicy)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DeleteIdentityPolicy))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteIdentityPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteIdentityPolicy)))
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
"DeleteIdentityPolicyResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> DeleteIdentityPolicyResponse
DeleteIdentityPolicyResponse'
            (Int -> DeleteIdentityPolicyResponse)
-> Either String Int -> Either String DeleteIdentityPolicyResponse
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 DeleteIdentityPolicy where
  hashWithSalt :: Int -> DeleteIdentityPolicy -> Int
hashWithSalt Int
_salt DeleteIdentityPolicy' {Text
$sel:identity:DeleteIdentityPolicy' :: DeleteIdentityPolicy -> Text
$sel:policyName:DeleteIdentityPolicy' :: DeleteIdentityPolicy -> Text
identity :: Text
policyName :: Text
..} =
    Int
_salt
      Int -> Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
identity
      Int -> Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyName

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

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

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

instance Data.ToQuery DeleteIdentityPolicy where
  toQuery :: DeleteIdentityPolicy -> QueryString
toQuery DeleteIdentityPolicy' {Text
$sel:identity:DeleteIdentityPolicy' :: DeleteIdentityPolicy -> Text
$sel:policyName:DeleteIdentityPolicy' :: DeleteIdentityPolicy -> Text
identity :: Text
policyName :: 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
"DeleteIdentityPolicy" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"Identity" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
identity,
        ByteString
"PolicyName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
policyName
      ]

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

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

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

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