{-# 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.CloneReceiptRuleSet
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a receipt rule set by cloning an existing one. All receipt rules
-- and configurations are copied to the new receipt rule set and are
-- completely independent of the source rule set.
--
-- For information about setting up rule sets, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-receipt-rule-set.html Amazon SES Developer Guide>.
--
-- You can execute this operation no more than once per second.
module Amazonka.SES.CloneReceiptRuleSet
  ( -- * Creating a Request
    CloneReceiptRuleSet (..),
    newCloneReceiptRuleSet,

    -- * Request Lenses
    cloneReceiptRuleSet_ruleSetName,
    cloneReceiptRuleSet_originalRuleSetName,

    -- * Destructuring the Response
    CloneReceiptRuleSetResponse (..),
    newCloneReceiptRuleSetResponse,

    -- * Response Lenses
    cloneReceiptRuleSetResponse_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 create a receipt rule set by cloning an existing
-- one. 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:/ 'newCloneReceiptRuleSet' smart constructor.
data CloneReceiptRuleSet = CloneReceiptRuleSet'
  { -- | The name of the rule set to create. The name must:
    --
    -- -   This value can only contain ASCII letters (a-z, A-Z), numbers (0-9),
    --     underscores (_), or dashes (-).
    --
    -- -   Start and end with a letter or number.
    --
    -- -   Contain less than 64 characters.
    CloneReceiptRuleSet -> Text
ruleSetName :: Prelude.Text,
    -- | The name of the rule set to clone.
    CloneReceiptRuleSet -> Text
originalRuleSetName :: Prelude.Text
  }
  deriving (CloneReceiptRuleSet -> CloneReceiptRuleSet -> Bool
(CloneReceiptRuleSet -> CloneReceiptRuleSet -> Bool)
-> (CloneReceiptRuleSet -> CloneReceiptRuleSet -> Bool)
-> Eq CloneReceiptRuleSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CloneReceiptRuleSet -> CloneReceiptRuleSet -> Bool
== :: CloneReceiptRuleSet -> CloneReceiptRuleSet -> Bool
$c/= :: CloneReceiptRuleSet -> CloneReceiptRuleSet -> Bool
/= :: CloneReceiptRuleSet -> CloneReceiptRuleSet -> Bool
Prelude.Eq, ReadPrec [CloneReceiptRuleSet]
ReadPrec CloneReceiptRuleSet
Int -> ReadS CloneReceiptRuleSet
ReadS [CloneReceiptRuleSet]
(Int -> ReadS CloneReceiptRuleSet)
-> ReadS [CloneReceiptRuleSet]
-> ReadPrec CloneReceiptRuleSet
-> ReadPrec [CloneReceiptRuleSet]
-> Read CloneReceiptRuleSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS CloneReceiptRuleSet
readsPrec :: Int -> ReadS CloneReceiptRuleSet
$creadList :: ReadS [CloneReceiptRuleSet]
readList :: ReadS [CloneReceiptRuleSet]
$creadPrec :: ReadPrec CloneReceiptRuleSet
readPrec :: ReadPrec CloneReceiptRuleSet
$creadListPrec :: ReadPrec [CloneReceiptRuleSet]
readListPrec :: ReadPrec [CloneReceiptRuleSet]
Prelude.Read, Int -> CloneReceiptRuleSet -> ShowS
[CloneReceiptRuleSet] -> ShowS
CloneReceiptRuleSet -> String
(Int -> CloneReceiptRuleSet -> ShowS)
-> (CloneReceiptRuleSet -> String)
-> ([CloneReceiptRuleSet] -> ShowS)
-> Show CloneReceiptRuleSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CloneReceiptRuleSet -> ShowS
showsPrec :: Int -> CloneReceiptRuleSet -> ShowS
$cshow :: CloneReceiptRuleSet -> String
show :: CloneReceiptRuleSet -> String
$cshowList :: [CloneReceiptRuleSet] -> ShowS
showList :: [CloneReceiptRuleSet] -> ShowS
Prelude.Show, (forall x. CloneReceiptRuleSet -> Rep CloneReceiptRuleSet x)
-> (forall x. Rep CloneReceiptRuleSet x -> CloneReceiptRuleSet)
-> Generic CloneReceiptRuleSet
forall x. Rep CloneReceiptRuleSet x -> CloneReceiptRuleSet
forall x. CloneReceiptRuleSet -> Rep CloneReceiptRuleSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CloneReceiptRuleSet -> Rep CloneReceiptRuleSet x
from :: forall x. CloneReceiptRuleSet -> Rep CloneReceiptRuleSet x
$cto :: forall x. Rep CloneReceiptRuleSet x -> CloneReceiptRuleSet
to :: forall x. Rep CloneReceiptRuleSet x -> CloneReceiptRuleSet
Prelude.Generic)

-- |
-- Create a value of 'CloneReceiptRuleSet' 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', 'cloneReceiptRuleSet_ruleSetName' - The name of the rule set to create. The name must:
--
-- -   This value can only contain ASCII letters (a-z, A-Z), numbers (0-9),
--     underscores (_), or dashes (-).
--
-- -   Start and end with a letter or number.
--
-- -   Contain less than 64 characters.
--
-- 'originalRuleSetName', 'cloneReceiptRuleSet_originalRuleSetName' - The name of the rule set to clone.
newCloneReceiptRuleSet ::
  -- | 'ruleSetName'
  Prelude.Text ->
  -- | 'originalRuleSetName'
  Prelude.Text ->
  CloneReceiptRuleSet
newCloneReceiptRuleSet :: Text -> Text -> CloneReceiptRuleSet
newCloneReceiptRuleSet
  Text
pRuleSetName_
  Text
pOriginalRuleSetName_ =
    CloneReceiptRuleSet'
      { $sel:ruleSetName:CloneReceiptRuleSet' :: Text
ruleSetName = Text
pRuleSetName_,
        $sel:originalRuleSetName:CloneReceiptRuleSet' :: Text
originalRuleSetName = Text
pOriginalRuleSetName_
      }

-- | The name of the rule set to create. The name must:
--
-- -   This value can only contain ASCII letters (a-z, A-Z), numbers (0-9),
--     underscores (_), or dashes (-).
--
-- -   Start and end with a letter or number.
--
-- -   Contain less than 64 characters.
cloneReceiptRuleSet_ruleSetName :: Lens.Lens' CloneReceiptRuleSet Prelude.Text
cloneReceiptRuleSet_ruleSetName :: Lens' CloneReceiptRuleSet Text
cloneReceiptRuleSet_ruleSetName = (CloneReceiptRuleSet -> Text)
-> (CloneReceiptRuleSet -> Text -> CloneReceiptRuleSet)
-> Lens' CloneReceiptRuleSet Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloneReceiptRuleSet' {Text
$sel:ruleSetName:CloneReceiptRuleSet' :: CloneReceiptRuleSet -> Text
ruleSetName :: Text
ruleSetName} -> Text
ruleSetName) (\s :: CloneReceiptRuleSet
s@CloneReceiptRuleSet' {} Text
a -> CloneReceiptRuleSet
s {ruleSetName = a} :: CloneReceiptRuleSet)

-- | The name of the rule set to clone.
cloneReceiptRuleSet_originalRuleSetName :: Lens.Lens' CloneReceiptRuleSet Prelude.Text
cloneReceiptRuleSet_originalRuleSetName :: Lens' CloneReceiptRuleSet Text
cloneReceiptRuleSet_originalRuleSetName = (CloneReceiptRuleSet -> Text)
-> (CloneReceiptRuleSet -> Text -> CloneReceiptRuleSet)
-> Lens' CloneReceiptRuleSet Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloneReceiptRuleSet' {Text
$sel:originalRuleSetName:CloneReceiptRuleSet' :: CloneReceiptRuleSet -> Text
originalRuleSetName :: Text
originalRuleSetName} -> Text
originalRuleSetName) (\s :: CloneReceiptRuleSet
s@CloneReceiptRuleSet' {} Text
a -> CloneReceiptRuleSet
s {originalRuleSetName = a} :: CloneReceiptRuleSet)

instance Core.AWSRequest CloneReceiptRuleSet where
  type
    AWSResponse CloneReceiptRuleSet =
      CloneReceiptRuleSetResponse
  request :: (Service -> Service)
-> CloneReceiptRuleSet -> Request CloneReceiptRuleSet
request Service -> Service
overrides =
    Service -> CloneReceiptRuleSet -> Request CloneReceiptRuleSet
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 CloneReceiptRuleSet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CloneReceiptRuleSet)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse CloneReceiptRuleSet))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CloneReceiptRuleSet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CloneReceiptRuleSet)))
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
"CloneReceiptRuleSetResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> CloneReceiptRuleSetResponse
CloneReceiptRuleSetResponse'
            (Int -> CloneReceiptRuleSetResponse)
-> Either String Int -> Either String CloneReceiptRuleSetResponse
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 CloneReceiptRuleSet where
  hashWithSalt :: Int -> CloneReceiptRuleSet -> Int
hashWithSalt Int
_salt CloneReceiptRuleSet' {Text
$sel:ruleSetName:CloneReceiptRuleSet' :: CloneReceiptRuleSet -> Text
$sel:originalRuleSetName:CloneReceiptRuleSet' :: CloneReceiptRuleSet -> Text
ruleSetName :: Text
originalRuleSetName :: 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
originalRuleSetName

instance Prelude.NFData CloneReceiptRuleSet where
  rnf :: CloneReceiptRuleSet -> ()
rnf CloneReceiptRuleSet' {Text
$sel:ruleSetName:CloneReceiptRuleSet' :: CloneReceiptRuleSet -> Text
$sel:originalRuleSetName:CloneReceiptRuleSet' :: CloneReceiptRuleSet -> Text
ruleSetName :: Text
originalRuleSetName :: 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
originalRuleSetName

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

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

instance Data.ToQuery CloneReceiptRuleSet where
  toQuery :: CloneReceiptRuleSet -> QueryString
toQuery CloneReceiptRuleSet' {Text
$sel:ruleSetName:CloneReceiptRuleSet' :: CloneReceiptRuleSet -> Text
$sel:originalRuleSetName:CloneReceiptRuleSet' :: CloneReceiptRuleSet -> Text
ruleSetName :: Text
originalRuleSetName :: 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
"CloneReceiptRuleSet" :: 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
"OriginalRuleSetName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
originalRuleSetName
      ]

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

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

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

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