{-# 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.SetActiveReceiptRuleSet
-- 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 specified receipt rule set as the active receipt rule set.
--
-- To disable your email-receiving through Amazon SES completely, you can
-- call this API with RuleSetName set to null.
--
-- 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.SetActiveReceiptRuleSet
  ( -- * Creating a Request
    SetActiveReceiptRuleSet (..),
    newSetActiveReceiptRuleSet,

    -- * Request Lenses
    setActiveReceiptRuleSet_ruleSetName,

    -- * Destructuring the Response
    SetActiveReceiptRuleSetResponse (..),
    newSetActiveReceiptRuleSetResponse,

    -- * Response Lenses
    setActiveReceiptRuleSetResponse_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 a receipt rule set as the active 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:/ 'newSetActiveReceiptRuleSet' smart constructor.
data SetActiveReceiptRuleSet = SetActiveReceiptRuleSet'
  { -- | The name of the receipt rule set to make active. Setting this value to
    -- null disables all email receiving.
    SetActiveReceiptRuleSet -> Maybe Text
ruleSetName :: Prelude.Maybe Prelude.Text
  }
  deriving (SetActiveReceiptRuleSet -> SetActiveReceiptRuleSet -> Bool
(SetActiveReceiptRuleSet -> SetActiveReceiptRuleSet -> Bool)
-> (SetActiveReceiptRuleSet -> SetActiveReceiptRuleSet -> Bool)
-> Eq SetActiveReceiptRuleSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetActiveReceiptRuleSet -> SetActiveReceiptRuleSet -> Bool
$c/= :: SetActiveReceiptRuleSet -> SetActiveReceiptRuleSet -> Bool
== :: SetActiveReceiptRuleSet -> SetActiveReceiptRuleSet -> Bool
$c== :: SetActiveReceiptRuleSet -> SetActiveReceiptRuleSet -> Bool
Prelude.Eq, ReadPrec [SetActiveReceiptRuleSet]
ReadPrec SetActiveReceiptRuleSet
Int -> ReadS SetActiveReceiptRuleSet
ReadS [SetActiveReceiptRuleSet]
(Int -> ReadS SetActiveReceiptRuleSet)
-> ReadS [SetActiveReceiptRuleSet]
-> ReadPrec SetActiveReceiptRuleSet
-> ReadPrec [SetActiveReceiptRuleSet]
-> Read SetActiveReceiptRuleSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetActiveReceiptRuleSet]
$creadListPrec :: ReadPrec [SetActiveReceiptRuleSet]
readPrec :: ReadPrec SetActiveReceiptRuleSet
$creadPrec :: ReadPrec SetActiveReceiptRuleSet
readList :: ReadS [SetActiveReceiptRuleSet]
$creadList :: ReadS [SetActiveReceiptRuleSet]
readsPrec :: Int -> ReadS SetActiveReceiptRuleSet
$creadsPrec :: Int -> ReadS SetActiveReceiptRuleSet
Prelude.Read, Int -> SetActiveReceiptRuleSet -> ShowS
[SetActiveReceiptRuleSet] -> ShowS
SetActiveReceiptRuleSet -> String
(Int -> SetActiveReceiptRuleSet -> ShowS)
-> (SetActiveReceiptRuleSet -> String)
-> ([SetActiveReceiptRuleSet] -> ShowS)
-> Show SetActiveReceiptRuleSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetActiveReceiptRuleSet] -> ShowS
$cshowList :: [SetActiveReceiptRuleSet] -> ShowS
show :: SetActiveReceiptRuleSet -> String
$cshow :: SetActiveReceiptRuleSet -> String
showsPrec :: Int -> SetActiveReceiptRuleSet -> ShowS
$cshowsPrec :: Int -> SetActiveReceiptRuleSet -> ShowS
Prelude.Show, (forall x.
 SetActiveReceiptRuleSet -> Rep SetActiveReceiptRuleSet x)
-> (forall x.
    Rep SetActiveReceiptRuleSet x -> SetActiveReceiptRuleSet)
-> Generic SetActiveReceiptRuleSet
forall x. Rep SetActiveReceiptRuleSet x -> SetActiveReceiptRuleSet
forall x. SetActiveReceiptRuleSet -> Rep SetActiveReceiptRuleSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetActiveReceiptRuleSet x -> SetActiveReceiptRuleSet
$cfrom :: forall x. SetActiveReceiptRuleSet -> Rep SetActiveReceiptRuleSet x
Prelude.Generic)

-- |
-- Create a value of 'SetActiveReceiptRuleSet' 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', 'setActiveReceiptRuleSet_ruleSetName' - The name of the receipt rule set to make active. Setting this value to
-- null disables all email receiving.
newSetActiveReceiptRuleSet ::
  SetActiveReceiptRuleSet
newSetActiveReceiptRuleSet :: SetActiveReceiptRuleSet
newSetActiveReceiptRuleSet =
  SetActiveReceiptRuleSet' :: Maybe Text -> SetActiveReceiptRuleSet
SetActiveReceiptRuleSet'
    { $sel:ruleSetName:SetActiveReceiptRuleSet' :: Maybe Text
ruleSetName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the receipt rule set to make active. Setting this value to
-- null disables all email receiving.
setActiveReceiptRuleSet_ruleSetName :: Lens.Lens' SetActiveReceiptRuleSet (Prelude.Maybe Prelude.Text)
setActiveReceiptRuleSet_ruleSetName :: (Maybe Text -> f (Maybe Text))
-> SetActiveReceiptRuleSet -> f SetActiveReceiptRuleSet
setActiveReceiptRuleSet_ruleSetName = (SetActiveReceiptRuleSet -> Maybe Text)
-> (SetActiveReceiptRuleSet
    -> Maybe Text -> SetActiveReceiptRuleSet)
-> Lens
     SetActiveReceiptRuleSet
     SetActiveReceiptRuleSet
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetActiveReceiptRuleSet' {Maybe Text
ruleSetName :: Maybe Text
$sel:ruleSetName:SetActiveReceiptRuleSet' :: SetActiveReceiptRuleSet -> Maybe Text
ruleSetName} -> Maybe Text
ruleSetName) (\s :: SetActiveReceiptRuleSet
s@SetActiveReceiptRuleSet' {} Maybe Text
a -> SetActiveReceiptRuleSet
s {$sel:ruleSetName:SetActiveReceiptRuleSet' :: Maybe Text
ruleSetName = Maybe Text
a} :: SetActiveReceiptRuleSet)

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

instance Prelude.NFData SetActiveReceiptRuleSet

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

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

instance Core.ToQuery SetActiveReceiptRuleSet where
  toQuery :: SetActiveReceiptRuleSet -> QueryString
toQuery SetActiveReceiptRuleSet' {Maybe Text
ruleSetName :: Maybe Text
$sel:ruleSetName:SetActiveReceiptRuleSet' :: SetActiveReceiptRuleSet -> 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
"SetActiveReceiptRuleSet" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"RuleSetName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
ruleSetName
      ]

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

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

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

instance
  Prelude.NFData
    SetActiveReceiptRuleSetResponse