{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.StopAction
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SES.Types.StopAction 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 Amazonka.SES.Types.StopScope

-- | When included in a receipt rule, this action terminates the evaluation
-- of the receipt rule set and, optionally, publishes a notification to
-- Amazon Simple Notification Service (Amazon SNS).
--
-- For information about setting a stop action in a receipt rule, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-stop.html Amazon SES Developer Guide>.
--
-- /See:/ 'newStopAction' smart constructor.
data StopAction = StopAction'
  { -- | The Amazon Resource Name (ARN) of the Amazon SNS topic to notify when
    -- the stop action is taken. An example of an Amazon SNS topic ARN is
    -- @arn:aws:sns:us-west-2:123456789012:MyTopic@. For more information about
    -- Amazon SNS topics, see the
    -- <https://docs.aws.amazon.com/sns/latest/dg/CreateTopic.html Amazon SNS Developer Guide>.
    StopAction -> Maybe Text
topicArn :: Prelude.Maybe Prelude.Text,
    -- | The scope of the StopAction. The only acceptable value is @RuleSet@.
    StopAction -> StopScope
scope :: StopScope
  }
  deriving (StopAction -> StopAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopAction -> StopAction -> Bool
$c/= :: StopAction -> StopAction -> Bool
== :: StopAction -> StopAction -> Bool
$c== :: StopAction -> StopAction -> Bool
Prelude.Eq, ReadPrec [StopAction]
ReadPrec StopAction
Int -> ReadS StopAction
ReadS [StopAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopAction]
$creadListPrec :: ReadPrec [StopAction]
readPrec :: ReadPrec StopAction
$creadPrec :: ReadPrec StopAction
readList :: ReadS [StopAction]
$creadList :: ReadS [StopAction]
readsPrec :: Int -> ReadS StopAction
$creadsPrec :: Int -> ReadS StopAction
Prelude.Read, Int -> StopAction -> ShowS
[StopAction] -> ShowS
StopAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopAction] -> ShowS
$cshowList :: [StopAction] -> ShowS
show :: StopAction -> String
$cshow :: StopAction -> String
showsPrec :: Int -> StopAction -> ShowS
$cshowsPrec :: Int -> StopAction -> ShowS
Prelude.Show, forall x. Rep StopAction x -> StopAction
forall x. StopAction -> Rep StopAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopAction x -> StopAction
$cfrom :: forall x. StopAction -> Rep StopAction x
Prelude.Generic)

-- |
-- Create a value of 'StopAction' 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:
--
-- 'topicArn', 'stopAction_topicArn' - The Amazon Resource Name (ARN) of the Amazon SNS topic to notify when
-- the stop action is taken. An example of an Amazon SNS topic ARN is
-- @arn:aws:sns:us-west-2:123456789012:MyTopic@. For more information about
-- Amazon SNS topics, see the
-- <https://docs.aws.amazon.com/sns/latest/dg/CreateTopic.html Amazon SNS Developer Guide>.
--
-- 'scope', 'stopAction_scope' - The scope of the StopAction. The only acceptable value is @RuleSet@.
newStopAction ::
  -- | 'scope'
  StopScope ->
  StopAction
newStopAction :: StopScope -> StopAction
newStopAction StopScope
pScope_ =
  StopAction'
    { $sel:topicArn:StopAction' :: Maybe Text
topicArn = forall a. Maybe a
Prelude.Nothing,
      $sel:scope:StopAction' :: StopScope
scope = StopScope
pScope_
    }

-- | The Amazon Resource Name (ARN) of the Amazon SNS topic to notify when
-- the stop action is taken. An example of an Amazon SNS topic ARN is
-- @arn:aws:sns:us-west-2:123456789012:MyTopic@. For more information about
-- Amazon SNS topics, see the
-- <https://docs.aws.amazon.com/sns/latest/dg/CreateTopic.html Amazon SNS Developer Guide>.
stopAction_topicArn :: Lens.Lens' StopAction (Prelude.Maybe Prelude.Text)
stopAction_topicArn :: Lens' StopAction (Maybe Text)
stopAction_topicArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopAction' {Maybe Text
topicArn :: Maybe Text
$sel:topicArn:StopAction' :: StopAction -> Maybe Text
topicArn} -> Maybe Text
topicArn) (\s :: StopAction
s@StopAction' {} Maybe Text
a -> StopAction
s {$sel:topicArn:StopAction' :: Maybe Text
topicArn = Maybe Text
a} :: StopAction)

-- | The scope of the StopAction. The only acceptable value is @RuleSet@.
stopAction_scope :: Lens.Lens' StopAction StopScope
stopAction_scope :: Lens' StopAction StopScope
stopAction_scope = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopAction' {StopScope
scope :: StopScope
$sel:scope:StopAction' :: StopAction -> StopScope
scope} -> StopScope
scope) (\s :: StopAction
s@StopAction' {} StopScope
a -> StopAction
s {$sel:scope:StopAction' :: StopScope
scope = StopScope
a} :: StopAction)

instance Data.FromXML StopAction where
  parseXML :: [Node] -> Either String StopAction
parseXML [Node]
x =
    Maybe Text -> StopScope -> StopAction
StopAction'
      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
"TopicArn")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Scope")

instance Prelude.Hashable StopAction where
  hashWithSalt :: Int -> StopAction -> Int
hashWithSalt Int
_salt StopAction' {Maybe Text
StopScope
scope :: StopScope
topicArn :: Maybe Text
$sel:scope:StopAction' :: StopAction -> StopScope
$sel:topicArn:StopAction' :: StopAction -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
topicArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` StopScope
scope

instance Prelude.NFData StopAction where
  rnf :: StopAction -> ()
rnf StopAction' {Maybe Text
StopScope
scope :: StopScope
topicArn :: Maybe Text
$sel:scope:StopAction' :: StopAction -> StopScope
$sel:topicArn:StopAction' :: StopAction -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
topicArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf StopScope
scope

instance Data.ToQuery StopAction where
  toQuery :: StopAction -> QueryString
toQuery StopAction' {Maybe Text
StopScope
scope :: StopScope
topicArn :: Maybe Text
$sel:scope:StopAction' :: StopAction -> StopScope
$sel:topicArn:StopAction' :: StopAction -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"TopicArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
topicArn, ByteString
"Scope" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: StopScope
scope]