{-# 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.SetReceiptRulePosition
-- 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)
--
-- Sets the position of the specified receipt rule in the receipt rule set.
--
-- For information about managing receipt rules, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-managing-receipt-rules.html Amazon SES Developer Guide>.
--
-- You can execute this operation no more than once per second.
module Amazonka.SES.SetReceiptRulePosition
  ( -- * Creating a Request
    SetReceiptRulePosition (..),
    newSetReceiptRulePosition,

    -- * Request Lenses
    setReceiptRulePosition_after,
    setReceiptRulePosition_ruleSetName,
    setReceiptRulePosition_ruleName,

    -- * Destructuring the Response
    SetReceiptRulePositionResponse (..),
    newSetReceiptRulePositionResponse,

    -- * Response Lenses
    setReceiptRulePositionResponse_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.SES.Types

-- | Represents a request to set the position of a receipt rule in 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:/ 'newSetReceiptRulePosition' smart constructor.
data SetReceiptRulePosition = SetReceiptRulePosition'
  { -- | The name of the receipt rule after which to place the specified receipt
    -- rule.
    SetReceiptRulePosition -> Maybe Text
after :: Prelude.Maybe Prelude.Text,
    -- | The name of the receipt rule set that contains the receipt rule to
    -- reposition.
    SetReceiptRulePosition -> Text
ruleSetName :: Prelude.Text,
    -- | The name of the receipt rule to reposition.
    SetReceiptRulePosition -> Text
ruleName :: Prelude.Text
  }
  deriving (SetReceiptRulePosition -> SetReceiptRulePosition -> Bool
(SetReceiptRulePosition -> SetReceiptRulePosition -> Bool)
-> (SetReceiptRulePosition -> SetReceiptRulePosition -> Bool)
-> Eq SetReceiptRulePosition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetReceiptRulePosition -> SetReceiptRulePosition -> Bool
$c/= :: SetReceiptRulePosition -> SetReceiptRulePosition -> Bool
== :: SetReceiptRulePosition -> SetReceiptRulePosition -> Bool
$c== :: SetReceiptRulePosition -> SetReceiptRulePosition -> Bool
Prelude.Eq, ReadPrec [SetReceiptRulePosition]
ReadPrec SetReceiptRulePosition
Int -> ReadS SetReceiptRulePosition
ReadS [SetReceiptRulePosition]
(Int -> ReadS SetReceiptRulePosition)
-> ReadS [SetReceiptRulePosition]
-> ReadPrec SetReceiptRulePosition
-> ReadPrec [SetReceiptRulePosition]
-> Read SetReceiptRulePosition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetReceiptRulePosition]
$creadListPrec :: ReadPrec [SetReceiptRulePosition]
readPrec :: ReadPrec SetReceiptRulePosition
$creadPrec :: ReadPrec SetReceiptRulePosition
readList :: ReadS [SetReceiptRulePosition]
$creadList :: ReadS [SetReceiptRulePosition]
readsPrec :: Int -> ReadS SetReceiptRulePosition
$creadsPrec :: Int -> ReadS SetReceiptRulePosition
Prelude.Read, Int -> SetReceiptRulePosition -> ShowS
[SetReceiptRulePosition] -> ShowS
SetReceiptRulePosition -> String
(Int -> SetReceiptRulePosition -> ShowS)
-> (SetReceiptRulePosition -> String)
-> ([SetReceiptRulePosition] -> ShowS)
-> Show SetReceiptRulePosition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetReceiptRulePosition] -> ShowS
$cshowList :: [SetReceiptRulePosition] -> ShowS
show :: SetReceiptRulePosition -> String
$cshow :: SetReceiptRulePosition -> String
showsPrec :: Int -> SetReceiptRulePosition -> ShowS
$cshowsPrec :: Int -> SetReceiptRulePosition -> ShowS
Prelude.Show, (forall x. SetReceiptRulePosition -> Rep SetReceiptRulePosition x)
-> (forall x.
    Rep SetReceiptRulePosition x -> SetReceiptRulePosition)
-> Generic SetReceiptRulePosition
forall x. Rep SetReceiptRulePosition x -> SetReceiptRulePosition
forall x. SetReceiptRulePosition -> Rep SetReceiptRulePosition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetReceiptRulePosition x -> SetReceiptRulePosition
$cfrom :: forall x. SetReceiptRulePosition -> Rep SetReceiptRulePosition x
Prelude.Generic)

-- |
-- Create a value of 'SetReceiptRulePosition' 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:
--
-- 'after', 'setReceiptRulePosition_after' - The name of the receipt rule after which to place the specified receipt
-- rule.
--
-- 'ruleSetName', 'setReceiptRulePosition_ruleSetName' - The name of the receipt rule set that contains the receipt rule to
-- reposition.
--
-- 'ruleName', 'setReceiptRulePosition_ruleName' - The name of the receipt rule to reposition.
newSetReceiptRulePosition ::
  -- | 'ruleSetName'
  Prelude.Text ->
  -- | 'ruleName'
  Prelude.Text ->
  SetReceiptRulePosition
newSetReceiptRulePosition :: Text -> Text -> SetReceiptRulePosition
newSetReceiptRulePosition Text
pRuleSetName_ Text
pRuleName_ =
  SetReceiptRulePosition' :: Maybe Text -> Text -> Text -> SetReceiptRulePosition
SetReceiptRulePosition'
    { $sel:after:SetReceiptRulePosition' :: Maybe Text
after = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleSetName:SetReceiptRulePosition' :: Text
ruleSetName = Text
pRuleSetName_,
      $sel:ruleName:SetReceiptRulePosition' :: Text
ruleName = Text
pRuleName_
    }

-- | The name of the receipt rule after which to place the specified receipt
-- rule.
setReceiptRulePosition_after :: Lens.Lens' SetReceiptRulePosition (Prelude.Maybe Prelude.Text)
setReceiptRulePosition_after :: (Maybe Text -> f (Maybe Text))
-> SetReceiptRulePosition -> f SetReceiptRulePosition
setReceiptRulePosition_after = (SetReceiptRulePosition -> Maybe Text)
-> (SetReceiptRulePosition -> Maybe Text -> SetReceiptRulePosition)
-> Lens
     SetReceiptRulePosition
     SetReceiptRulePosition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetReceiptRulePosition' {Maybe Text
after :: Maybe Text
$sel:after:SetReceiptRulePosition' :: SetReceiptRulePosition -> Maybe Text
after} -> Maybe Text
after) (\s :: SetReceiptRulePosition
s@SetReceiptRulePosition' {} Maybe Text
a -> SetReceiptRulePosition
s {$sel:after:SetReceiptRulePosition' :: Maybe Text
after = Maybe Text
a} :: SetReceiptRulePosition)

-- | The name of the receipt rule set that contains the receipt rule to
-- reposition.
setReceiptRulePosition_ruleSetName :: Lens.Lens' SetReceiptRulePosition Prelude.Text
setReceiptRulePosition_ruleSetName :: (Text -> f Text)
-> SetReceiptRulePosition -> f SetReceiptRulePosition
setReceiptRulePosition_ruleSetName = (SetReceiptRulePosition -> Text)
-> (SetReceiptRulePosition -> Text -> SetReceiptRulePosition)
-> Lens SetReceiptRulePosition SetReceiptRulePosition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetReceiptRulePosition' {Text
ruleSetName :: Text
$sel:ruleSetName:SetReceiptRulePosition' :: SetReceiptRulePosition -> Text
ruleSetName} -> Text
ruleSetName) (\s :: SetReceiptRulePosition
s@SetReceiptRulePosition' {} Text
a -> SetReceiptRulePosition
s {$sel:ruleSetName:SetReceiptRulePosition' :: Text
ruleSetName = Text
a} :: SetReceiptRulePosition)

-- | The name of the receipt rule to reposition.
setReceiptRulePosition_ruleName :: Lens.Lens' SetReceiptRulePosition Prelude.Text
setReceiptRulePosition_ruleName :: (Text -> f Text)
-> SetReceiptRulePosition -> f SetReceiptRulePosition
setReceiptRulePosition_ruleName = (SetReceiptRulePosition -> Text)
-> (SetReceiptRulePosition -> Text -> SetReceiptRulePosition)
-> Lens SetReceiptRulePosition SetReceiptRulePosition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetReceiptRulePosition' {Text
ruleName :: Text
$sel:ruleName:SetReceiptRulePosition' :: SetReceiptRulePosition -> Text
ruleName} -> Text
ruleName) (\s :: SetReceiptRulePosition
s@SetReceiptRulePosition' {} Text
a -> SetReceiptRulePosition
s {$sel:ruleName:SetReceiptRulePosition' :: Text
ruleName = Text
a} :: SetReceiptRulePosition)

instance Core.AWSRequest SetReceiptRulePosition where
  type
    AWSResponse SetReceiptRulePosition =
      SetReceiptRulePositionResponse
  request :: SetReceiptRulePosition -> Request SetReceiptRulePosition
request = Service -> SetReceiptRulePosition -> Request SetReceiptRulePosition
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy SetReceiptRulePosition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetReceiptRulePosition)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse SetReceiptRulePosition))
-> Logger
-> Service
-> Proxy SetReceiptRulePosition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetReceiptRulePosition)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"SetReceiptRulePositionResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> SetReceiptRulePositionResponse
SetReceiptRulePositionResponse'
            (Int -> SetReceiptRulePositionResponse)
-> Either String Int
-> Either String SetReceiptRulePositionResponse
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 SetReceiptRulePosition

instance Prelude.NFData SetReceiptRulePosition

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

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

instance Core.ToQuery SetReceiptRulePosition where
  toQuery :: SetReceiptRulePosition -> QueryString
toQuery SetReceiptRulePosition' {Maybe Text
Text
ruleName :: Text
ruleSetName :: Text
after :: Maybe Text
$sel:ruleName:SetReceiptRulePosition' :: SetReceiptRulePosition -> Text
$sel:ruleSetName:SetReceiptRulePosition' :: SetReceiptRulePosition -> Text
$sel:after:SetReceiptRulePosition' :: SetReceiptRulePosition -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"SetReceiptRulePosition" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"After" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
after,
        ByteString
"RuleSetName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
ruleSetName,
        ByteString
"RuleName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
ruleName
      ]

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

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

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

instance
  Prelude.NFData
    SetReceiptRulePositionResponse