{-# 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.DescribeActiveReceiptRuleSet
-- 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 metadata and receipt rules for the receipt rule set that is
-- currently active.
--
-- 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.DescribeActiveReceiptRuleSet
  ( -- * Creating a Request
    DescribeActiveReceiptRuleSet (..),
    newDescribeActiveReceiptRuleSet,

    -- * Destructuring the Response
    DescribeActiveReceiptRuleSetResponse (..),
    newDescribeActiveReceiptRuleSetResponse,

    -- * Response Lenses
    describeActiveReceiptRuleSetResponse_metadata,
    describeActiveReceiptRuleSetResponse_rules,
    describeActiveReceiptRuleSetResponse_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 metadata and receipt rules for the
-- receipt rule set that is currently active. 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:/ 'newDescribeActiveReceiptRuleSet' smart constructor.
data DescribeActiveReceiptRuleSet = DescribeActiveReceiptRuleSet'
  {
  }
  deriving (DescribeActiveReceiptRuleSet
-> DescribeActiveReceiptRuleSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeActiveReceiptRuleSet
-> DescribeActiveReceiptRuleSet -> Bool
$c/= :: DescribeActiveReceiptRuleSet
-> DescribeActiveReceiptRuleSet -> Bool
== :: DescribeActiveReceiptRuleSet
-> DescribeActiveReceiptRuleSet -> Bool
$c== :: DescribeActiveReceiptRuleSet
-> DescribeActiveReceiptRuleSet -> Bool
Prelude.Eq, ReadPrec [DescribeActiveReceiptRuleSet]
ReadPrec DescribeActiveReceiptRuleSet
Int -> ReadS DescribeActiveReceiptRuleSet
ReadS [DescribeActiveReceiptRuleSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeActiveReceiptRuleSet]
$creadListPrec :: ReadPrec [DescribeActiveReceiptRuleSet]
readPrec :: ReadPrec DescribeActiveReceiptRuleSet
$creadPrec :: ReadPrec DescribeActiveReceiptRuleSet
readList :: ReadS [DescribeActiveReceiptRuleSet]
$creadList :: ReadS [DescribeActiveReceiptRuleSet]
readsPrec :: Int -> ReadS DescribeActiveReceiptRuleSet
$creadsPrec :: Int -> ReadS DescribeActiveReceiptRuleSet
Prelude.Read, Int -> DescribeActiveReceiptRuleSet -> ShowS
[DescribeActiveReceiptRuleSet] -> ShowS
DescribeActiveReceiptRuleSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeActiveReceiptRuleSet] -> ShowS
$cshowList :: [DescribeActiveReceiptRuleSet] -> ShowS
show :: DescribeActiveReceiptRuleSet -> String
$cshow :: DescribeActiveReceiptRuleSet -> String
showsPrec :: Int -> DescribeActiveReceiptRuleSet -> ShowS
$cshowsPrec :: Int -> DescribeActiveReceiptRuleSet -> ShowS
Prelude.Show, forall x.
Rep DescribeActiveReceiptRuleSet x -> DescribeActiveReceiptRuleSet
forall x.
DescribeActiveReceiptRuleSet -> Rep DescribeActiveReceiptRuleSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeActiveReceiptRuleSet x -> DescribeActiveReceiptRuleSet
$cfrom :: forall x.
DescribeActiveReceiptRuleSet -> Rep DescribeActiveReceiptRuleSet x
Prelude.Generic)

-- |
-- Create a value of 'DescribeActiveReceiptRuleSet' 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.
newDescribeActiveReceiptRuleSet ::
  DescribeActiveReceiptRuleSet
newDescribeActiveReceiptRuleSet :: DescribeActiveReceiptRuleSet
newDescribeActiveReceiptRuleSet =
  DescribeActiveReceiptRuleSet
DescribeActiveReceiptRuleSet'

instance Core.AWSRequest DescribeActiveReceiptRuleSet where
  type
    AWSResponse DescribeActiveReceiptRuleSet =
      DescribeActiveReceiptRuleSetResponse
  request :: (Service -> Service)
-> DescribeActiveReceiptRuleSet
-> Request DescribeActiveReceiptRuleSet
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 DescribeActiveReceiptRuleSet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeActiveReceiptRuleSet)))
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
"DescribeActiveReceiptRuleSetResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe ReceiptRuleSetMetadata
-> Maybe [ReceiptRule]
-> Int
-> DescribeActiveReceiptRuleSetResponse
DescribeActiveReceiptRuleSetResponse'
            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
"Metadata")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Rules"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            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
    DescribeActiveReceiptRuleSet
  where
  hashWithSalt :: Int -> DescribeActiveReceiptRuleSet -> Int
hashWithSalt Int
_salt DescribeActiveReceiptRuleSet
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData DescribeActiveReceiptRuleSet where
  rnf :: DescribeActiveReceiptRuleSet -> ()
rnf DescribeActiveReceiptRuleSet
_ = ()

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

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

instance Data.ToQuery DescribeActiveReceiptRuleSet where
  toQuery :: DescribeActiveReceiptRuleSet -> QueryString
toQuery =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ ByteString
"Action"
              forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ( ByteString
"DescribeActiveReceiptRuleSet" ::
                          Prelude.ByteString
                      ),
            ByteString
"Version"
              forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString)
          ]
      )

-- | Represents the metadata and receipt rules for the receipt rule set that
-- is currently active.
--
-- /See:/ 'newDescribeActiveReceiptRuleSetResponse' smart constructor.
data DescribeActiveReceiptRuleSetResponse = DescribeActiveReceiptRuleSetResponse'
  { -- | The metadata for the currently active receipt rule set. The metadata
    -- consists of the rule set name and a timestamp of when the rule set was
    -- created.
    DescribeActiveReceiptRuleSetResponse
-> Maybe ReceiptRuleSetMetadata
metadata :: Prelude.Maybe ReceiptRuleSetMetadata,
    -- | The receipt rules that belong to the active rule set.
    DescribeActiveReceiptRuleSetResponse -> Maybe [ReceiptRule]
rules :: Prelude.Maybe [ReceiptRule],
    -- | The response's http status code.
    DescribeActiveReceiptRuleSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeActiveReceiptRuleSetResponse
-> DescribeActiveReceiptRuleSetResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeActiveReceiptRuleSetResponse
-> DescribeActiveReceiptRuleSetResponse -> Bool
$c/= :: DescribeActiveReceiptRuleSetResponse
-> DescribeActiveReceiptRuleSetResponse -> Bool
== :: DescribeActiveReceiptRuleSetResponse
-> DescribeActiveReceiptRuleSetResponse -> Bool
$c== :: DescribeActiveReceiptRuleSetResponse
-> DescribeActiveReceiptRuleSetResponse -> Bool
Prelude.Eq, ReadPrec [DescribeActiveReceiptRuleSetResponse]
ReadPrec DescribeActiveReceiptRuleSetResponse
Int -> ReadS DescribeActiveReceiptRuleSetResponse
ReadS [DescribeActiveReceiptRuleSetResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeActiveReceiptRuleSetResponse]
$creadListPrec :: ReadPrec [DescribeActiveReceiptRuleSetResponse]
readPrec :: ReadPrec DescribeActiveReceiptRuleSetResponse
$creadPrec :: ReadPrec DescribeActiveReceiptRuleSetResponse
readList :: ReadS [DescribeActiveReceiptRuleSetResponse]
$creadList :: ReadS [DescribeActiveReceiptRuleSetResponse]
readsPrec :: Int -> ReadS DescribeActiveReceiptRuleSetResponse
$creadsPrec :: Int -> ReadS DescribeActiveReceiptRuleSetResponse
Prelude.Read, Int -> DescribeActiveReceiptRuleSetResponse -> ShowS
[DescribeActiveReceiptRuleSetResponse] -> ShowS
DescribeActiveReceiptRuleSetResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeActiveReceiptRuleSetResponse] -> ShowS
$cshowList :: [DescribeActiveReceiptRuleSetResponse] -> ShowS
show :: DescribeActiveReceiptRuleSetResponse -> String
$cshow :: DescribeActiveReceiptRuleSetResponse -> String
showsPrec :: Int -> DescribeActiveReceiptRuleSetResponse -> ShowS
$cshowsPrec :: Int -> DescribeActiveReceiptRuleSetResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeActiveReceiptRuleSetResponse x
-> DescribeActiveReceiptRuleSetResponse
forall x.
DescribeActiveReceiptRuleSetResponse
-> Rep DescribeActiveReceiptRuleSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeActiveReceiptRuleSetResponse x
-> DescribeActiveReceiptRuleSetResponse
$cfrom :: forall x.
DescribeActiveReceiptRuleSetResponse
-> Rep DescribeActiveReceiptRuleSetResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeActiveReceiptRuleSetResponse' 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:
--
-- 'metadata', 'describeActiveReceiptRuleSetResponse_metadata' - The metadata for the currently active receipt rule set. The metadata
-- consists of the rule set name and a timestamp of when the rule set was
-- created.
--
-- 'rules', 'describeActiveReceiptRuleSetResponse_rules' - The receipt rules that belong to the active rule set.
--
-- 'httpStatus', 'describeActiveReceiptRuleSetResponse_httpStatus' - The response's http status code.
newDescribeActiveReceiptRuleSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeActiveReceiptRuleSetResponse
newDescribeActiveReceiptRuleSetResponse :: Int -> DescribeActiveReceiptRuleSetResponse
newDescribeActiveReceiptRuleSetResponse Int
pHttpStatus_ =
  DescribeActiveReceiptRuleSetResponse'
    { $sel:metadata:DescribeActiveReceiptRuleSetResponse' :: Maybe ReceiptRuleSetMetadata
metadata =
        forall a. Maybe a
Prelude.Nothing,
      $sel:rules:DescribeActiveReceiptRuleSetResponse' :: Maybe [ReceiptRule]
rules = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeActiveReceiptRuleSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The metadata for the currently active receipt rule set. The metadata
-- consists of the rule set name and a timestamp of when the rule set was
-- created.
describeActiveReceiptRuleSetResponse_metadata :: Lens.Lens' DescribeActiveReceiptRuleSetResponse (Prelude.Maybe ReceiptRuleSetMetadata)
describeActiveReceiptRuleSetResponse_metadata :: Lens'
  DescribeActiveReceiptRuleSetResponse (Maybe ReceiptRuleSetMetadata)
describeActiveReceiptRuleSetResponse_metadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeActiveReceiptRuleSetResponse' {Maybe ReceiptRuleSetMetadata
metadata :: Maybe ReceiptRuleSetMetadata
$sel:metadata:DescribeActiveReceiptRuleSetResponse' :: DescribeActiveReceiptRuleSetResponse
-> Maybe ReceiptRuleSetMetadata
metadata} -> Maybe ReceiptRuleSetMetadata
metadata) (\s :: DescribeActiveReceiptRuleSetResponse
s@DescribeActiveReceiptRuleSetResponse' {} Maybe ReceiptRuleSetMetadata
a -> DescribeActiveReceiptRuleSetResponse
s {$sel:metadata:DescribeActiveReceiptRuleSetResponse' :: Maybe ReceiptRuleSetMetadata
metadata = Maybe ReceiptRuleSetMetadata
a} :: DescribeActiveReceiptRuleSetResponse)

-- | The receipt rules that belong to the active rule set.
describeActiveReceiptRuleSetResponse_rules :: Lens.Lens' DescribeActiveReceiptRuleSetResponse (Prelude.Maybe [ReceiptRule])
describeActiveReceiptRuleSetResponse_rules :: Lens' DescribeActiveReceiptRuleSetResponse (Maybe [ReceiptRule])
describeActiveReceiptRuleSetResponse_rules = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeActiveReceiptRuleSetResponse' {Maybe [ReceiptRule]
rules :: Maybe [ReceiptRule]
$sel:rules:DescribeActiveReceiptRuleSetResponse' :: DescribeActiveReceiptRuleSetResponse -> Maybe [ReceiptRule]
rules} -> Maybe [ReceiptRule]
rules) (\s :: DescribeActiveReceiptRuleSetResponse
s@DescribeActiveReceiptRuleSetResponse' {} Maybe [ReceiptRule]
a -> DescribeActiveReceiptRuleSetResponse
s {$sel:rules:DescribeActiveReceiptRuleSetResponse' :: Maybe [ReceiptRule]
rules = Maybe [ReceiptRule]
a} :: DescribeActiveReceiptRuleSetResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DescribeActiveReceiptRuleSetResponse
  where
  rnf :: DescribeActiveReceiptRuleSetResponse -> ()
rnf DescribeActiveReceiptRuleSetResponse' {Int
Maybe [ReceiptRule]
Maybe ReceiptRuleSetMetadata
httpStatus :: Int
rules :: Maybe [ReceiptRule]
metadata :: Maybe ReceiptRuleSetMetadata
$sel:httpStatus:DescribeActiveReceiptRuleSetResponse' :: DescribeActiveReceiptRuleSetResponse -> Int
$sel:rules:DescribeActiveReceiptRuleSetResponse' :: DescribeActiveReceiptRuleSetResponse -> Maybe [ReceiptRule]
$sel:metadata:DescribeActiveReceiptRuleSetResponse' :: DescribeActiveReceiptRuleSetResponse
-> Maybe ReceiptRuleSetMetadata
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ReceiptRuleSetMetadata
metadata
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ReceiptRule]
rules
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus