{-# 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-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)
module Amazonka.SES.Types.StopAction where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(StopAction -> StopAction -> Bool)
-> (StopAction -> StopAction -> Bool) -> Eq StopAction
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]
(Int -> ReadS StopAction)
-> ReadS [StopAction]
-> ReadPrec StopAction
-> ReadPrec [StopAction]
-> Read 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
(Int -> StopAction -> ShowS)
-> (StopAction -> String)
-> ([StopAction] -> ShowS)
-> Show StopAction
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. StopAction -> Rep StopAction x)
-> (forall x. Rep StopAction x -> StopAction) -> Generic StopAction
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' :: Maybe Text -> StopScope -> StopAction
StopAction'
    { $sel:topicArn:StopAction' :: Maybe Text
topicArn = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> StopAction -> f StopAction
stopAction_topicArn = (StopAction -> Maybe Text)
-> (StopAction -> Maybe Text -> StopAction)
-> Lens StopAction StopAction (Maybe Text) (Maybe Text)
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 :: (StopScope -> f StopScope) -> StopAction -> f StopAction
stopAction_scope = (StopAction -> StopScope)
-> (StopAction -> StopScope -> StopAction)
-> Lens StopAction StopAction StopScope StopScope
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 Core.FromXML StopAction where
  parseXML :: [Node] -> Either String StopAction
parseXML [Node]
x =
    Maybe Text -> StopScope -> StopAction
StopAction'
      (Maybe Text -> StopScope -> StopAction)
-> Either String (Maybe Text)
-> Either String (StopScope -> StopAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TopicArn")
      Either String (StopScope -> StopAction)
-> Either String StopScope -> Either String StopAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String StopScope
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Scope")

instance Prelude.Hashable StopAction

instance Prelude.NFData StopAction

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"TopicArn" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
topicArn, ByteString
"Scope" ByteString -> StopScope -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: StopScope
scope]