{-# 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.CreateReceiptRuleSet
-- 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)
--
-- Creates an empty receipt rule set.
--
-- For information about setting up receipt 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.CreateReceiptRuleSet
  ( -- * Creating a Request
    CreateReceiptRuleSet (..),
    newCreateReceiptRuleSet,

    -- * Request Lenses
    createReceiptRuleSet_ruleSetName,

    -- * Destructuring the Response
    CreateReceiptRuleSetResponse (..),
    newCreateReceiptRuleSetResponse,

    -- * Response Lenses
    createReceiptRuleSetResponse_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 create an empty 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:/ 'newCreateReceiptRuleSet' smart constructor.
data CreateReceiptRuleSet = CreateReceiptRuleSet'
  { -- | 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.
    CreateReceiptRuleSet -> Text
ruleSetName :: Prelude.Text
  }
  deriving (CreateReceiptRuleSet -> CreateReceiptRuleSet -> Bool
(CreateReceiptRuleSet -> CreateReceiptRuleSet -> Bool)
-> (CreateReceiptRuleSet -> CreateReceiptRuleSet -> Bool)
-> Eq CreateReceiptRuleSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateReceiptRuleSet -> CreateReceiptRuleSet -> Bool
$c/= :: CreateReceiptRuleSet -> CreateReceiptRuleSet -> Bool
== :: CreateReceiptRuleSet -> CreateReceiptRuleSet -> Bool
$c== :: CreateReceiptRuleSet -> CreateReceiptRuleSet -> Bool
Prelude.Eq, ReadPrec [CreateReceiptRuleSet]
ReadPrec CreateReceiptRuleSet
Int -> ReadS CreateReceiptRuleSet
ReadS [CreateReceiptRuleSet]
(Int -> ReadS CreateReceiptRuleSet)
-> ReadS [CreateReceiptRuleSet]
-> ReadPrec CreateReceiptRuleSet
-> ReadPrec [CreateReceiptRuleSet]
-> Read CreateReceiptRuleSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateReceiptRuleSet]
$creadListPrec :: ReadPrec [CreateReceiptRuleSet]
readPrec :: ReadPrec CreateReceiptRuleSet
$creadPrec :: ReadPrec CreateReceiptRuleSet
readList :: ReadS [CreateReceiptRuleSet]
$creadList :: ReadS [CreateReceiptRuleSet]
readsPrec :: Int -> ReadS CreateReceiptRuleSet
$creadsPrec :: Int -> ReadS CreateReceiptRuleSet
Prelude.Read, Int -> CreateReceiptRuleSet -> ShowS
[CreateReceiptRuleSet] -> ShowS
CreateReceiptRuleSet -> String
(Int -> CreateReceiptRuleSet -> ShowS)
-> (CreateReceiptRuleSet -> String)
-> ([CreateReceiptRuleSet] -> ShowS)
-> Show CreateReceiptRuleSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateReceiptRuleSet] -> ShowS
$cshowList :: [CreateReceiptRuleSet] -> ShowS
show :: CreateReceiptRuleSet -> String
$cshow :: CreateReceiptRuleSet -> String
showsPrec :: Int -> CreateReceiptRuleSet -> ShowS
$cshowsPrec :: Int -> CreateReceiptRuleSet -> ShowS
Prelude.Show, (forall x. CreateReceiptRuleSet -> Rep CreateReceiptRuleSet x)
-> (forall x. Rep CreateReceiptRuleSet x -> CreateReceiptRuleSet)
-> Generic CreateReceiptRuleSet
forall x. Rep CreateReceiptRuleSet x -> CreateReceiptRuleSet
forall x. CreateReceiptRuleSet -> Rep CreateReceiptRuleSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateReceiptRuleSet x -> CreateReceiptRuleSet
$cfrom :: forall x. CreateReceiptRuleSet -> Rep CreateReceiptRuleSet x
Prelude.Generic)

-- |
-- Create a value of 'CreateReceiptRuleSet' 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', 'createReceiptRuleSet_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.
newCreateReceiptRuleSet ::
  -- | 'ruleSetName'
  Prelude.Text ->
  CreateReceiptRuleSet
newCreateReceiptRuleSet :: Text -> CreateReceiptRuleSet
newCreateReceiptRuleSet Text
pRuleSetName_ =
  CreateReceiptRuleSet' :: Text -> CreateReceiptRuleSet
CreateReceiptRuleSet' {$sel:ruleSetName:CreateReceiptRuleSet' :: Text
ruleSetName = Text
pRuleSetName_}

-- | 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.
createReceiptRuleSet_ruleSetName :: Lens.Lens' CreateReceiptRuleSet Prelude.Text
createReceiptRuleSet_ruleSetName :: (Text -> f Text) -> CreateReceiptRuleSet -> f CreateReceiptRuleSet
createReceiptRuleSet_ruleSetName = (CreateReceiptRuleSet -> Text)
-> (CreateReceiptRuleSet -> Text -> CreateReceiptRuleSet)
-> Lens CreateReceiptRuleSet CreateReceiptRuleSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReceiptRuleSet' {Text
ruleSetName :: Text
$sel:ruleSetName:CreateReceiptRuleSet' :: CreateReceiptRuleSet -> Text
ruleSetName} -> Text
ruleSetName) (\s :: CreateReceiptRuleSet
s@CreateReceiptRuleSet' {} Text
a -> CreateReceiptRuleSet
s {$sel:ruleSetName:CreateReceiptRuleSet' :: Text
ruleSetName = Text
a} :: CreateReceiptRuleSet)

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

instance Prelude.NFData CreateReceiptRuleSet

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

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

instance Core.ToQuery CreateReceiptRuleSet where
  toQuery :: CreateReceiptRuleSet -> QueryString
toQuery CreateReceiptRuleSet' {Text
ruleSetName :: Text
$sel:ruleSetName:CreateReceiptRuleSet' :: CreateReceiptRuleSet -> 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
"CreateReceiptRuleSet" :: 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
      ]

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

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

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

instance Prelude.NFData CreateReceiptRuleSetResponse