{-# 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.ReorderReceiptRuleSet
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Reorders the receipt rules within a receipt rule set.
--
-- All of the rules in the rule set must be represented in this request.
-- That is, this API will return an error if the reorder request doesn\'t
-- explicitly position all of the rules.
--
-- For information about managing receipt rule sets, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-managing-receipt-rule-sets.html Amazon SES Developer Guide>.
--
-- You can execute this operation no more than once per second.
module Amazonka.SES.ReorderReceiptRuleSet
  ( -- * Creating a Request
    ReorderReceiptRuleSet (..),
    newReorderReceiptRuleSet,

    -- * Request Lenses
    reorderReceiptRuleSet_ruleSetName,
    reorderReceiptRuleSet_ruleNames,

    -- * Destructuring the Response
    ReorderReceiptRuleSetResponse (..),
    newReorderReceiptRuleSetResponse,

    -- * Response Lenses
    reorderReceiptRuleSetResponse_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 reorder the receipt rules within a receipt rule
-- set. You use receipt rule sets to receive email with Amazon SES. For
-- more information, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-concepts.html Amazon SES Developer Guide>.
--
-- /See:/ 'newReorderReceiptRuleSet' smart constructor.
data ReorderReceiptRuleSet = ReorderReceiptRuleSet'
  { -- | The name of the receipt rule set to reorder.
    ReorderReceiptRuleSet -> Text
ruleSetName :: Prelude.Text,
    -- | A list of the specified receipt rule set\'s receipt rules in the order
    -- that you want to put them.
    ReorderReceiptRuleSet -> [Text]
ruleNames :: [Prelude.Text]
  }
  deriving (ReorderReceiptRuleSet -> ReorderReceiptRuleSet -> Bool
(ReorderReceiptRuleSet -> ReorderReceiptRuleSet -> Bool)
-> (ReorderReceiptRuleSet -> ReorderReceiptRuleSet -> Bool)
-> Eq ReorderReceiptRuleSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReorderReceiptRuleSet -> ReorderReceiptRuleSet -> Bool
== :: ReorderReceiptRuleSet -> ReorderReceiptRuleSet -> Bool
$c/= :: ReorderReceiptRuleSet -> ReorderReceiptRuleSet -> Bool
/= :: ReorderReceiptRuleSet -> ReorderReceiptRuleSet -> Bool
Prelude.Eq, ReadPrec [ReorderReceiptRuleSet]
ReadPrec ReorderReceiptRuleSet
Int -> ReadS ReorderReceiptRuleSet
ReadS [ReorderReceiptRuleSet]
(Int -> ReadS ReorderReceiptRuleSet)
-> ReadS [ReorderReceiptRuleSet]
-> ReadPrec ReorderReceiptRuleSet
-> ReadPrec [ReorderReceiptRuleSet]
-> Read ReorderReceiptRuleSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ReorderReceiptRuleSet
readsPrec :: Int -> ReadS ReorderReceiptRuleSet
$creadList :: ReadS [ReorderReceiptRuleSet]
readList :: ReadS [ReorderReceiptRuleSet]
$creadPrec :: ReadPrec ReorderReceiptRuleSet
readPrec :: ReadPrec ReorderReceiptRuleSet
$creadListPrec :: ReadPrec [ReorderReceiptRuleSet]
readListPrec :: ReadPrec [ReorderReceiptRuleSet]
Prelude.Read, Int -> ReorderReceiptRuleSet -> ShowS
[ReorderReceiptRuleSet] -> ShowS
ReorderReceiptRuleSet -> String
(Int -> ReorderReceiptRuleSet -> ShowS)
-> (ReorderReceiptRuleSet -> String)
-> ([ReorderReceiptRuleSet] -> ShowS)
-> Show ReorderReceiptRuleSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReorderReceiptRuleSet -> ShowS
showsPrec :: Int -> ReorderReceiptRuleSet -> ShowS
$cshow :: ReorderReceiptRuleSet -> String
show :: ReorderReceiptRuleSet -> String
$cshowList :: [ReorderReceiptRuleSet] -> ShowS
showList :: [ReorderReceiptRuleSet] -> ShowS
Prelude.Show, (forall x. ReorderReceiptRuleSet -> Rep ReorderReceiptRuleSet x)
-> (forall x. Rep ReorderReceiptRuleSet x -> ReorderReceiptRuleSet)
-> Generic ReorderReceiptRuleSet
forall x. Rep ReorderReceiptRuleSet x -> ReorderReceiptRuleSet
forall x. ReorderReceiptRuleSet -> Rep ReorderReceiptRuleSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReorderReceiptRuleSet -> Rep ReorderReceiptRuleSet x
from :: forall x. ReorderReceiptRuleSet -> Rep ReorderReceiptRuleSet x
$cto :: forall x. Rep ReorderReceiptRuleSet x -> ReorderReceiptRuleSet
to :: forall x. Rep ReorderReceiptRuleSet x -> ReorderReceiptRuleSet
Prelude.Generic)

-- |
-- Create a value of 'ReorderReceiptRuleSet' 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:
--
-- 'ruleSetName', 'reorderReceiptRuleSet_ruleSetName' - The name of the receipt rule set to reorder.
--
-- 'ruleNames', 'reorderReceiptRuleSet_ruleNames' - A list of the specified receipt rule set\'s receipt rules in the order
-- that you want to put them.
newReorderReceiptRuleSet ::
  -- | 'ruleSetName'
  Prelude.Text ->
  ReorderReceiptRuleSet
newReorderReceiptRuleSet :: Text -> ReorderReceiptRuleSet
newReorderReceiptRuleSet Text
pRuleSetName_ =
  ReorderReceiptRuleSet'
    { $sel:ruleSetName:ReorderReceiptRuleSet' :: Text
ruleSetName = Text
pRuleSetName_,
      $sel:ruleNames:ReorderReceiptRuleSet' :: [Text]
ruleNames = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the receipt rule set to reorder.
reorderReceiptRuleSet_ruleSetName :: Lens.Lens' ReorderReceiptRuleSet Prelude.Text
reorderReceiptRuleSet_ruleSetName :: Lens' ReorderReceiptRuleSet Text
reorderReceiptRuleSet_ruleSetName = (ReorderReceiptRuleSet -> Text)
-> (ReorderReceiptRuleSet -> Text -> ReorderReceiptRuleSet)
-> Lens' ReorderReceiptRuleSet Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReorderReceiptRuleSet' {Text
$sel:ruleSetName:ReorderReceiptRuleSet' :: ReorderReceiptRuleSet -> Text
ruleSetName :: Text
ruleSetName} -> Text
ruleSetName) (\s :: ReorderReceiptRuleSet
s@ReorderReceiptRuleSet' {} Text
a -> ReorderReceiptRuleSet
s {ruleSetName = a} :: ReorderReceiptRuleSet)

-- | A list of the specified receipt rule set\'s receipt rules in the order
-- that you want to put them.
reorderReceiptRuleSet_ruleNames :: Lens.Lens' ReorderReceiptRuleSet [Prelude.Text]
reorderReceiptRuleSet_ruleNames :: Lens' ReorderReceiptRuleSet [Text]
reorderReceiptRuleSet_ruleNames = (ReorderReceiptRuleSet -> [Text])
-> (ReorderReceiptRuleSet -> [Text] -> ReorderReceiptRuleSet)
-> Lens' ReorderReceiptRuleSet [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReorderReceiptRuleSet' {[Text]
$sel:ruleNames:ReorderReceiptRuleSet' :: ReorderReceiptRuleSet -> [Text]
ruleNames :: [Text]
ruleNames} -> [Text]
ruleNames) (\s :: ReorderReceiptRuleSet
s@ReorderReceiptRuleSet' {} [Text]
a -> ReorderReceiptRuleSet
s {ruleNames = a} :: ReorderReceiptRuleSet) (([Text] -> f [Text])
 -> ReorderReceiptRuleSet -> f ReorderReceiptRuleSet)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> ReorderReceiptRuleSet
-> f ReorderReceiptRuleSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Iso [Text] [Text] [Text] [Text]
Lens.coerced

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

instance Prelude.NFData ReorderReceiptRuleSet where
  rnf :: ReorderReceiptRuleSet -> ()
rnf ReorderReceiptRuleSet' {[Text]
Text
$sel:ruleSetName:ReorderReceiptRuleSet' :: ReorderReceiptRuleSet -> Text
$sel:ruleNames:ReorderReceiptRuleSet' :: ReorderReceiptRuleSet -> [Text]
ruleSetName :: Text
ruleNames :: [Text]
..} =
    Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Text
ruleSetName
      () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq` [Text] -> ()
forall a. NFData a => a -> ()
Prelude.rnf [Text]
ruleNames

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

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

instance Data.ToQuery ReorderReceiptRuleSet where
  toQuery :: ReorderReceiptRuleSet -> QueryString
toQuery ReorderReceiptRuleSet' {[Text]
Text
$sel:ruleSetName:ReorderReceiptRuleSet' :: ReorderReceiptRuleSet -> Text
$sel:ruleNames:ReorderReceiptRuleSet' :: ReorderReceiptRuleSet -> [Text]
ruleSetName :: Text
ruleNames :: [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
"ReorderReceiptRuleSet" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"RuleSetName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
ruleSetName,
        ByteString
"RuleNames"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" [Text]
ruleNames
      ]

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

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

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

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