{-# 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.DescribeReceiptRule
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the details of the specified receipt rule.
--
-- For information about setting up receipt rules, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-receipt-rules.html Amazon SES Developer Guide>.
--
-- You can execute this operation no more than once per second.
module Amazonka.SES.DescribeReceiptRule
  ( -- * Creating a Request
    DescribeReceiptRule (..),
    newDescribeReceiptRule,

    -- * Request Lenses
    describeReceiptRule_ruleSetName,
    describeReceiptRule_ruleName,

    -- * Destructuring the Response
    DescribeReceiptRuleResponse (..),
    newDescribeReceiptRuleResponse,

    -- * Response Lenses
    describeReceiptRuleResponse_rule,
    describeReceiptRuleResponse_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 return the details of 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:/ 'newDescribeReceiptRule' smart constructor.
data DescribeReceiptRule = DescribeReceiptRule'
  { -- | The name of the receipt rule set that the receipt rule belongs to.
    DescribeReceiptRule -> Text
ruleSetName :: Prelude.Text,
    -- | The name of the receipt rule.
    DescribeReceiptRule -> Text
ruleName :: Prelude.Text
  }
  deriving (DescribeReceiptRule -> DescribeReceiptRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeReceiptRule -> DescribeReceiptRule -> Bool
$c/= :: DescribeReceiptRule -> DescribeReceiptRule -> Bool
== :: DescribeReceiptRule -> DescribeReceiptRule -> Bool
$c== :: DescribeReceiptRule -> DescribeReceiptRule -> Bool
Prelude.Eq, ReadPrec [DescribeReceiptRule]
ReadPrec DescribeReceiptRule
Int -> ReadS DescribeReceiptRule
ReadS [DescribeReceiptRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeReceiptRule]
$creadListPrec :: ReadPrec [DescribeReceiptRule]
readPrec :: ReadPrec DescribeReceiptRule
$creadPrec :: ReadPrec DescribeReceiptRule
readList :: ReadS [DescribeReceiptRule]
$creadList :: ReadS [DescribeReceiptRule]
readsPrec :: Int -> ReadS DescribeReceiptRule
$creadsPrec :: Int -> ReadS DescribeReceiptRule
Prelude.Read, Int -> DescribeReceiptRule -> ShowS
[DescribeReceiptRule] -> ShowS
DescribeReceiptRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeReceiptRule] -> ShowS
$cshowList :: [DescribeReceiptRule] -> ShowS
show :: DescribeReceiptRule -> String
$cshow :: DescribeReceiptRule -> String
showsPrec :: Int -> DescribeReceiptRule -> ShowS
$cshowsPrec :: Int -> DescribeReceiptRule -> ShowS
Prelude.Show, forall x. Rep DescribeReceiptRule x -> DescribeReceiptRule
forall x. DescribeReceiptRule -> Rep DescribeReceiptRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeReceiptRule x -> DescribeReceiptRule
$cfrom :: forall x. DescribeReceiptRule -> Rep DescribeReceiptRule x
Prelude.Generic)

-- |
-- Create a value of 'DescribeReceiptRule' 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', 'describeReceiptRule_ruleSetName' - The name of the receipt rule set that the receipt rule belongs to.
--
-- 'ruleName', 'describeReceiptRule_ruleName' - The name of the receipt rule.
newDescribeReceiptRule ::
  -- | 'ruleSetName'
  Prelude.Text ->
  -- | 'ruleName'
  Prelude.Text ->
  DescribeReceiptRule
newDescribeReceiptRule :: Text -> Text -> DescribeReceiptRule
newDescribeReceiptRule Text
pRuleSetName_ Text
pRuleName_ =
  DescribeReceiptRule'
    { $sel:ruleSetName:DescribeReceiptRule' :: Text
ruleSetName = Text
pRuleSetName_,
      $sel:ruleName:DescribeReceiptRule' :: Text
ruleName = Text
pRuleName_
    }

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

-- | The name of the receipt rule.
describeReceiptRule_ruleName :: Lens.Lens' DescribeReceiptRule Prelude.Text
describeReceiptRule_ruleName :: Lens' DescribeReceiptRule Text
describeReceiptRule_ruleName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeReceiptRule' {Text
ruleName :: Text
$sel:ruleName:DescribeReceiptRule' :: DescribeReceiptRule -> Text
ruleName} -> Text
ruleName) (\s :: DescribeReceiptRule
s@DescribeReceiptRule' {} Text
a -> DescribeReceiptRule
s {$sel:ruleName:DescribeReceiptRule' :: Text
ruleName = Text
a} :: DescribeReceiptRule)

instance Core.AWSRequest DescribeReceiptRule where
  type
    AWSResponse DescribeReceiptRule =
      DescribeReceiptRuleResponse
  request :: (Service -> Service)
-> DescribeReceiptRule -> Request DescribeReceiptRule
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 DescribeReceiptRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeReceiptRule)))
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
"DescribeReceiptRuleResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe ReceiptRule -> Int -> DescribeReceiptRuleResponse
DescribeReceiptRuleResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Rule")
            forall (f :: * -> *) a b. Applicative f => 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 DescribeReceiptRule where
  hashWithSalt :: Int -> DescribeReceiptRule -> Int
hashWithSalt Int
_salt DescribeReceiptRule' {Text
ruleName :: Text
ruleSetName :: Text
$sel:ruleName:DescribeReceiptRule' :: DescribeReceiptRule -> Text
$sel:ruleSetName:DescribeReceiptRule' :: DescribeReceiptRule -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ruleSetName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ruleName

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

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

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

instance Data.ToQuery DescribeReceiptRule where
  toQuery :: DescribeReceiptRule -> QueryString
toQuery DescribeReceiptRule' {Text
ruleName :: Text
ruleSetName :: Text
$sel:ruleName:DescribeReceiptRule' :: DescribeReceiptRule -> Text
$sel:ruleSetName:DescribeReceiptRule' :: DescribeReceiptRule -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DescribeReceiptRule" :: 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
"RuleName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
ruleName
      ]

-- | Represents the details of a receipt rule.
--
-- /See:/ 'newDescribeReceiptRuleResponse' smart constructor.
data DescribeReceiptRuleResponse = DescribeReceiptRuleResponse'
  { -- | A data structure that contains the specified receipt rule\'s name,
    -- actions, recipients, domains, enabled status, scan status, and Transport
    -- Layer Security (TLS) policy.
    DescribeReceiptRuleResponse -> Maybe ReceiptRule
rule :: Prelude.Maybe ReceiptRule,
    -- | The response's http status code.
    DescribeReceiptRuleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeReceiptRuleResponse -> DescribeReceiptRuleResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeReceiptRuleResponse -> DescribeReceiptRuleResponse -> Bool
$c/= :: DescribeReceiptRuleResponse -> DescribeReceiptRuleResponse -> Bool
== :: DescribeReceiptRuleResponse -> DescribeReceiptRuleResponse -> Bool
$c== :: DescribeReceiptRuleResponse -> DescribeReceiptRuleResponse -> Bool
Prelude.Eq, ReadPrec [DescribeReceiptRuleResponse]
ReadPrec DescribeReceiptRuleResponse
Int -> ReadS DescribeReceiptRuleResponse
ReadS [DescribeReceiptRuleResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeReceiptRuleResponse]
$creadListPrec :: ReadPrec [DescribeReceiptRuleResponse]
readPrec :: ReadPrec DescribeReceiptRuleResponse
$creadPrec :: ReadPrec DescribeReceiptRuleResponse
readList :: ReadS [DescribeReceiptRuleResponse]
$creadList :: ReadS [DescribeReceiptRuleResponse]
readsPrec :: Int -> ReadS DescribeReceiptRuleResponse
$creadsPrec :: Int -> ReadS DescribeReceiptRuleResponse
Prelude.Read, Int -> DescribeReceiptRuleResponse -> ShowS
[DescribeReceiptRuleResponse] -> ShowS
DescribeReceiptRuleResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeReceiptRuleResponse] -> ShowS
$cshowList :: [DescribeReceiptRuleResponse] -> ShowS
show :: DescribeReceiptRuleResponse -> String
$cshow :: DescribeReceiptRuleResponse -> String
showsPrec :: Int -> DescribeReceiptRuleResponse -> ShowS
$cshowsPrec :: Int -> DescribeReceiptRuleResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeReceiptRuleResponse x -> DescribeReceiptRuleResponse
forall x.
DescribeReceiptRuleResponse -> Rep DescribeReceiptRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeReceiptRuleResponse x -> DescribeReceiptRuleResponse
$cfrom :: forall x.
DescribeReceiptRuleResponse -> Rep DescribeReceiptRuleResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeReceiptRuleResponse' 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:
--
-- 'rule', 'describeReceiptRuleResponse_rule' - A data structure that contains the specified receipt rule\'s name,
-- actions, recipients, domains, enabled status, scan status, and Transport
-- Layer Security (TLS) policy.
--
-- 'httpStatus', 'describeReceiptRuleResponse_httpStatus' - The response's http status code.
newDescribeReceiptRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeReceiptRuleResponse
newDescribeReceiptRuleResponse :: Int -> DescribeReceiptRuleResponse
newDescribeReceiptRuleResponse Int
pHttpStatus_ =
  DescribeReceiptRuleResponse'
    { $sel:rule:DescribeReceiptRuleResponse' :: Maybe ReceiptRule
rule =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeReceiptRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A data structure that contains the specified receipt rule\'s name,
-- actions, recipients, domains, enabled status, scan status, and Transport
-- Layer Security (TLS) policy.
describeReceiptRuleResponse_rule :: Lens.Lens' DescribeReceiptRuleResponse (Prelude.Maybe ReceiptRule)
describeReceiptRuleResponse_rule :: Lens' DescribeReceiptRuleResponse (Maybe ReceiptRule)
describeReceiptRuleResponse_rule = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeReceiptRuleResponse' {Maybe ReceiptRule
rule :: Maybe ReceiptRule
$sel:rule:DescribeReceiptRuleResponse' :: DescribeReceiptRuleResponse -> Maybe ReceiptRule
rule} -> Maybe ReceiptRule
rule) (\s :: DescribeReceiptRuleResponse
s@DescribeReceiptRuleResponse' {} Maybe ReceiptRule
a -> DescribeReceiptRuleResponse
s {$sel:rule:DescribeReceiptRuleResponse' :: Maybe ReceiptRule
rule = Maybe ReceiptRule
a} :: DescribeReceiptRuleResponse)

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

instance Prelude.NFData DescribeReceiptRuleResponse where
  rnf :: DescribeReceiptRuleResponse -> ()
rnf DescribeReceiptRuleResponse' {Int
Maybe ReceiptRule
httpStatus :: Int
rule :: Maybe ReceiptRule
$sel:httpStatus:DescribeReceiptRuleResponse' :: DescribeReceiptRuleResponse -> Int
$sel:rule:DescribeReceiptRuleResponse' :: DescribeReceiptRuleResponse -> Maybe ReceiptRule
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ReceiptRule
rule
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus