{-# 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-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)
--
-- 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.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 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
(UpdateReceiptRule -> UpdateReceiptRule -> Bool)
-> (UpdateReceiptRule -> UpdateReceiptRule -> Bool)
-> Eq UpdateReceiptRule
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]
(Int -> ReadS UpdateReceiptRule)
-> ReadS [UpdateReceiptRule]
-> ReadPrec UpdateReceiptRule
-> ReadPrec [UpdateReceiptRule]
-> Read 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
(Int -> UpdateReceiptRule -> ShowS)
-> (UpdateReceiptRule -> String)
-> ([UpdateReceiptRule] -> ShowS)
-> Show UpdateReceiptRule
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. UpdateReceiptRule -> Rep UpdateReceiptRule x)
-> (forall x. Rep UpdateReceiptRule x -> UpdateReceiptRule)
-> Generic UpdateReceiptRule
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' :: Text -> ReceiptRule -> UpdateReceiptRule
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 :: (Text -> f Text) -> UpdateReceiptRule -> f UpdateReceiptRule
updateReceiptRule_ruleSetName = (UpdateReceiptRule -> Text)
-> (UpdateReceiptRule -> Text -> UpdateReceiptRule)
-> Lens UpdateReceiptRule UpdateReceiptRule Text Text
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 :: (ReceiptRule -> f ReceiptRule)
-> UpdateReceiptRule -> f UpdateReceiptRule
updateReceiptRule_rule = (UpdateReceiptRule -> ReceiptRule)
-> (UpdateReceiptRule -> ReceiptRule -> UpdateReceiptRule)
-> Lens UpdateReceiptRule UpdateReceiptRule ReceiptRule ReceiptRule
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 :: UpdateReceiptRule -> Request UpdateReceiptRule
request = Service -> UpdateReceiptRule -> Request UpdateReceiptRule
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateReceiptRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateReceiptRule)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse UpdateReceiptRule))
-> Logger
-> Service
-> Proxy UpdateReceiptRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateReceiptRule)))
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
"UpdateReceiptRuleResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> UpdateReceiptRuleResponse
UpdateReceiptRuleResponse'
            (Int -> UpdateReceiptRuleResponse)
-> Either String Int -> Either String UpdateReceiptRuleResponse
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 UpdateReceiptRule

instance Prelude.NFData UpdateReceiptRule

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

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

instance Core.ToQuery UpdateReceiptRule where
  toQuery :: UpdateReceiptRule -> QueryString
toQuery UpdateReceiptRule' {Text
ReceiptRule
rule :: ReceiptRule
ruleSetName :: Text
$sel:rule:UpdateReceiptRule' :: UpdateReceiptRule -> ReceiptRule
$sel:ruleSetName:UpdateReceiptRule' :: UpdateReceiptRule -> 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
"UpdateReceiptRule" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"RuleSetName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
ruleSetName,
        ByteString
"Rule" ByteString -> ReceiptRule -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(UpdateReceiptRuleResponse -> UpdateReceiptRuleResponse -> Bool)
-> (UpdateReceiptRuleResponse -> UpdateReceiptRuleResponse -> Bool)
-> Eq UpdateReceiptRuleResponse
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]
(Int -> ReadS UpdateReceiptRuleResponse)
-> ReadS [UpdateReceiptRuleResponse]
-> ReadPrec UpdateReceiptRuleResponse
-> ReadPrec [UpdateReceiptRuleResponse]
-> Read 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
(Int -> UpdateReceiptRuleResponse -> ShowS)
-> (UpdateReceiptRuleResponse -> String)
-> ([UpdateReceiptRuleResponse] -> ShowS)
-> Show UpdateReceiptRuleResponse
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.
 UpdateReceiptRuleResponse -> Rep UpdateReceiptRuleResponse x)
-> (forall x.
    Rep UpdateReceiptRuleResponse x -> UpdateReceiptRuleResponse)
-> Generic UpdateReceiptRuleResponse
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' :: Int -> UpdateReceiptRuleResponse
UpdateReceiptRuleResponse'
    { $sel:httpStatus:UpdateReceiptRuleResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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