{-# 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-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)
--
-- 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.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 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
(DescribeReceiptRule -> DescribeReceiptRule -> Bool)
-> (DescribeReceiptRule -> DescribeReceiptRule -> Bool)
-> Eq DescribeReceiptRule
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]
(Int -> ReadS DescribeReceiptRule)
-> ReadS [DescribeReceiptRule]
-> ReadPrec DescribeReceiptRule
-> ReadPrec [DescribeReceiptRule]
-> Read 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
(Int -> DescribeReceiptRule -> ShowS)
-> (DescribeReceiptRule -> String)
-> ([DescribeReceiptRule] -> ShowS)
-> Show DescribeReceiptRule
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. DescribeReceiptRule -> Rep DescribeReceiptRule x)
-> (forall x. Rep DescribeReceiptRule x -> DescribeReceiptRule)
-> Generic DescribeReceiptRule
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' :: Text -> Text -> DescribeReceiptRule
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 :: (Text -> f Text) -> DescribeReceiptRule -> f DescribeReceiptRule
describeReceiptRule_ruleSetName = (DescribeReceiptRule -> Text)
-> (DescribeReceiptRule -> Text -> DescribeReceiptRule)
-> Lens DescribeReceiptRule DescribeReceiptRule Text Text
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 :: (Text -> f Text) -> DescribeReceiptRule -> f DescribeReceiptRule
describeReceiptRule_ruleName = (DescribeReceiptRule -> Text)
-> (DescribeReceiptRule -> Text -> DescribeReceiptRule)
-> Lens DescribeReceiptRule DescribeReceiptRule Text Text
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 :: DescribeReceiptRule -> Request DescribeReceiptRule
request = Service -> DescribeReceiptRule -> Request DescribeReceiptRule
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeReceiptRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeReceiptRule)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeReceiptRule))
-> Logger
-> Service
-> Proxy DescribeReceiptRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeReceiptRule)))
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
"DescribeReceiptRuleResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe ReceiptRule -> Int -> DescribeReceiptRuleResponse
DescribeReceiptRuleResponse'
            (Maybe ReceiptRule -> Int -> DescribeReceiptRuleResponse)
-> Either String (Maybe ReceiptRule)
-> Either String (Int -> DescribeReceiptRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe ReceiptRule)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Rule")
            Either String (Int -> DescribeReceiptRuleResponse)
-> Either String Int -> Either String DescribeReceiptRuleResponse
forall (f :: * -> *) a b. Applicative f => 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 DescribeReceiptRule

instance Prelude.NFData DescribeReceiptRule

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

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

instance Core.ToQuery DescribeReceiptRule where
  toQuery :: DescribeReceiptRule -> QueryString
toQuery DescribeReceiptRule' {Text
ruleName :: Text
ruleSetName :: Text
$sel:ruleName:DescribeReceiptRule' :: DescribeReceiptRule -> Text
$sel:ruleSetName:DescribeReceiptRule' :: DescribeReceiptRule -> 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
"DescribeReceiptRule" :: 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
"RuleName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(DescribeReceiptRuleResponse
 -> DescribeReceiptRuleResponse -> Bool)
-> (DescribeReceiptRuleResponse
    -> DescribeReceiptRuleResponse -> Bool)
-> Eq DescribeReceiptRuleResponse
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]
(Int -> ReadS DescribeReceiptRuleResponse)
-> ReadS [DescribeReceiptRuleResponse]
-> ReadPrec DescribeReceiptRuleResponse
-> ReadPrec [DescribeReceiptRuleResponse]
-> Read 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
(Int -> DescribeReceiptRuleResponse -> ShowS)
-> (DescribeReceiptRuleResponse -> String)
-> ([DescribeReceiptRuleResponse] -> ShowS)
-> Show DescribeReceiptRuleResponse
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.
 DescribeReceiptRuleResponse -> Rep DescribeReceiptRuleResponse x)
-> (forall x.
    Rep DescribeReceiptRuleResponse x -> DescribeReceiptRuleResponse)
-> Generic DescribeReceiptRuleResponse
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' :: Maybe ReceiptRule -> Int -> DescribeReceiptRuleResponse
DescribeReceiptRuleResponse'
    { $sel:rule:DescribeReceiptRuleResponse' :: Maybe ReceiptRule
rule =
        Maybe ReceiptRule
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 :: (Maybe ReceiptRule -> f (Maybe ReceiptRule))
-> DescribeReceiptRuleResponse -> f DescribeReceiptRuleResponse
describeReceiptRuleResponse_rule = (DescribeReceiptRuleResponse -> Maybe ReceiptRule)
-> (DescribeReceiptRuleResponse
    -> Maybe ReceiptRule -> DescribeReceiptRuleResponse)
-> Lens
     DescribeReceiptRuleResponse
     DescribeReceiptRuleResponse
     (Maybe ReceiptRule)
     (Maybe ReceiptRule)
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 :: (Int -> f Int)
-> DescribeReceiptRuleResponse -> f DescribeReceiptRuleResponse
describeReceiptRuleResponse_httpStatus = (DescribeReceiptRuleResponse -> Int)
-> (DescribeReceiptRuleResponse
    -> Int -> DescribeReceiptRuleResponse)
-> Lens
     DescribeReceiptRuleResponse DescribeReceiptRuleResponse Int Int
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