{-# 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.UpdateReceiptRule
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates a receipt rule.
--
-- 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.UpdateReceiptRule
  ( -- * Creating a Request
    UpdateReceiptRule (..),
    newUpdateReceiptRule,

    -- * Request Lenses
    updateReceiptRule_ruleSetName,
    updateReceiptRule_rule,

    -- * Destructuring the Response
    UpdateReceiptRuleResponse (..),
    newUpdateReceiptRuleResponse,

    -- * Response Lenses
    updateReceiptRuleResponse_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 update a receipt rule. You use receipt rules 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:/ 'newUpdateReceiptRule' smart constructor.
data UpdateReceiptRule = UpdateReceiptRule'
  { -- | The name of the receipt rule set that the receipt rule belongs to.
    UpdateReceiptRule -> Text
ruleSetName :: Prelude.Text,
    -- | A data structure that contains the updated receipt rule information.
    UpdateReceiptRule -> ReceiptRule
rule :: ReceiptRule
  }
  deriving (UpdateReceiptRule -> UpdateReceiptRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateReceiptRule -> UpdateReceiptRule -> Bool
$c/= :: UpdateReceiptRule -> UpdateReceiptRule -> Bool
== :: UpdateReceiptRule -> UpdateReceiptRule -> Bool
$c== :: UpdateReceiptRule -> UpdateReceiptRule -> Bool
Prelude.Eq, ReadPrec [UpdateReceiptRule]
ReadPrec UpdateReceiptRule
Int -> ReadS UpdateReceiptRule
ReadS [UpdateReceiptRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateReceiptRule]
$creadListPrec :: ReadPrec [UpdateReceiptRule]
readPrec :: ReadPrec UpdateReceiptRule
$creadPrec :: ReadPrec UpdateReceiptRule
readList :: ReadS [UpdateReceiptRule]
$creadList :: ReadS [UpdateReceiptRule]
readsPrec :: Int -> ReadS UpdateReceiptRule
$creadsPrec :: Int -> ReadS UpdateReceiptRule
Prelude.Read, Int -> UpdateReceiptRule -> ShowS
[UpdateReceiptRule] -> ShowS
UpdateReceiptRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateReceiptRule] -> ShowS
$cshowList :: [UpdateReceiptRule] -> ShowS
show :: UpdateReceiptRule -> String
$cshow :: UpdateReceiptRule -> String
showsPrec :: Int -> UpdateReceiptRule -> ShowS
$cshowsPrec :: Int -> UpdateReceiptRule -> ShowS
Prelude.Show, forall x. Rep UpdateReceiptRule x -> UpdateReceiptRule
forall x. UpdateReceiptRule -> Rep UpdateReceiptRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateReceiptRule x -> UpdateReceiptRule
$cfrom :: forall x. UpdateReceiptRule -> Rep UpdateReceiptRule x
Prelude.Generic)

-- |
-- Create a value of 'UpdateReceiptRule' 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', 'updateReceiptRule_ruleSetName' - The name of the receipt rule set that the receipt rule belongs to.
--
-- 'rule', 'updateReceiptRule_rule' - A data structure that contains the updated receipt rule information.
newUpdateReceiptRule ::
  -- | 'ruleSetName'
  Prelude.Text ->
  -- | 'rule'
  ReceiptRule ->
  UpdateReceiptRule
newUpdateReceiptRule :: Text -> ReceiptRule -> UpdateReceiptRule
newUpdateReceiptRule Text
pRuleSetName_ ReceiptRule
pRule_ =
  UpdateReceiptRule'
    { $sel:ruleSetName:UpdateReceiptRule' :: Text
ruleSetName = Text
pRuleSetName_,
      $sel:rule:UpdateReceiptRule' :: ReceiptRule
rule = ReceiptRule
pRule_
    }

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

-- | A data structure that contains the updated receipt rule information.
updateReceiptRule_rule :: Lens.Lens' UpdateReceiptRule ReceiptRule
updateReceiptRule_rule :: Lens' UpdateReceiptRule ReceiptRule
updateReceiptRule_rule = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateReceiptRule' {ReceiptRule
rule :: ReceiptRule
$sel:rule:UpdateReceiptRule' :: UpdateReceiptRule -> ReceiptRule
rule} -> ReceiptRule
rule) (\s :: UpdateReceiptRule
s@UpdateReceiptRule' {} ReceiptRule
a -> UpdateReceiptRule
s {$sel:rule:UpdateReceiptRule' :: ReceiptRule
rule = ReceiptRule
a} :: UpdateReceiptRule)

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

instance Prelude.NFData UpdateReceiptRule where
  rnf :: UpdateReceiptRule -> ()
rnf UpdateReceiptRule' {Text
ReceiptRule
rule :: ReceiptRule
ruleSetName :: Text
$sel:rule:UpdateReceiptRule' :: UpdateReceiptRule -> ReceiptRule
$sel:ruleSetName:UpdateReceiptRule' :: UpdateReceiptRule -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
ruleSetName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ReceiptRule
rule

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

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

instance Data.ToQuery UpdateReceiptRule where
  toQuery :: UpdateReceiptRule -> QueryString
toQuery UpdateReceiptRule' {Text
ReceiptRule
rule :: ReceiptRule
ruleSetName :: Text
$sel:rule:UpdateReceiptRule' :: UpdateReceiptRule -> ReceiptRule
$sel:ruleSetName:UpdateReceiptRule' :: UpdateReceiptRule -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"UpdateReceiptRule" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"RuleSetName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
ruleSetName,
        ByteString
"Rule" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ReceiptRule
rule
      ]

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

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

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

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