{-# 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.WorkmailAction
-- 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.WorkmailAction 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

-- | When included in a receipt rule, this action calls Amazon WorkMail and,
-- optionally, publishes a notification to Amazon Simple Notification
-- Service (Amazon SNS). You will typically not use this action directly
-- because Amazon WorkMail adds the rule automatically during its setup
-- procedure.
--
-- For information using a receipt rule to call Amazon WorkMail, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-workmail.html Amazon SES Developer Guide>.
--
-- /See:/ 'newWorkmailAction' smart constructor.
data WorkmailAction = WorkmailAction'
  { -- | The Amazon Resource Name (ARN) of the Amazon SNS topic to notify when
    -- the WorkMail action is called. 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>.
    WorkmailAction -> Maybe Text
topicArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the Amazon WorkMail organization. An example of an Amazon
    -- WorkMail organization ARN is
    -- @arn:aws:workmail:us-west-2:123456789012:organization\/m-68755160c4cb4e29a2b2f8fb58f359d7@.
    -- For information about Amazon WorkMail organizations, see the
    -- <https://docs.aws.amazon.com/workmail/latest/adminguide/organizations_overview.html Amazon WorkMail Administrator Guide>.
    WorkmailAction -> Text
organizationArn :: Prelude.Text
  }
  deriving (WorkmailAction -> WorkmailAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkmailAction -> WorkmailAction -> Bool
$c/= :: WorkmailAction -> WorkmailAction -> Bool
== :: WorkmailAction -> WorkmailAction -> Bool
$c== :: WorkmailAction -> WorkmailAction -> Bool
Prelude.Eq, ReadPrec [WorkmailAction]
ReadPrec WorkmailAction
Int -> ReadS WorkmailAction
ReadS [WorkmailAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkmailAction]
$creadListPrec :: ReadPrec [WorkmailAction]
readPrec :: ReadPrec WorkmailAction
$creadPrec :: ReadPrec WorkmailAction
readList :: ReadS [WorkmailAction]
$creadList :: ReadS [WorkmailAction]
readsPrec :: Int -> ReadS WorkmailAction
$creadsPrec :: Int -> ReadS WorkmailAction
Prelude.Read, Int -> WorkmailAction -> ShowS
[WorkmailAction] -> ShowS
WorkmailAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkmailAction] -> ShowS
$cshowList :: [WorkmailAction] -> ShowS
show :: WorkmailAction -> String
$cshow :: WorkmailAction -> String
showsPrec :: Int -> WorkmailAction -> ShowS
$cshowsPrec :: Int -> WorkmailAction -> ShowS
Prelude.Show, forall x. Rep WorkmailAction x -> WorkmailAction
forall x. WorkmailAction -> Rep WorkmailAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WorkmailAction x -> WorkmailAction
$cfrom :: forall x. WorkmailAction -> Rep WorkmailAction x
Prelude.Generic)

-- |
-- Create a value of 'WorkmailAction' 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', 'workmailAction_topicArn' - The Amazon Resource Name (ARN) of the Amazon SNS topic to notify when
-- the WorkMail action is called. 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>.
--
-- 'organizationArn', 'workmailAction_organizationArn' - The ARN of the Amazon WorkMail organization. An example of an Amazon
-- WorkMail organization ARN is
-- @arn:aws:workmail:us-west-2:123456789012:organization\/m-68755160c4cb4e29a2b2f8fb58f359d7@.
-- For information about Amazon WorkMail organizations, see the
-- <https://docs.aws.amazon.com/workmail/latest/adminguide/organizations_overview.html Amazon WorkMail Administrator Guide>.
newWorkmailAction ::
  -- | 'organizationArn'
  Prelude.Text ->
  WorkmailAction
newWorkmailAction :: Text -> WorkmailAction
newWorkmailAction Text
pOrganizationArn_ =
  WorkmailAction'
    { $sel:topicArn:WorkmailAction' :: Maybe Text
topicArn = forall a. Maybe a
Prelude.Nothing,
      $sel:organizationArn:WorkmailAction' :: Text
organizationArn = Text
pOrganizationArn_
    }

-- | The Amazon Resource Name (ARN) of the Amazon SNS topic to notify when
-- the WorkMail action is called. 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>.
workmailAction_topicArn :: Lens.Lens' WorkmailAction (Prelude.Maybe Prelude.Text)
workmailAction_topicArn :: Lens' WorkmailAction (Maybe Text)
workmailAction_topicArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkmailAction' {Maybe Text
topicArn :: Maybe Text
$sel:topicArn:WorkmailAction' :: WorkmailAction -> Maybe Text
topicArn} -> Maybe Text
topicArn) (\s :: WorkmailAction
s@WorkmailAction' {} Maybe Text
a -> WorkmailAction
s {$sel:topicArn:WorkmailAction' :: Maybe Text
topicArn = Maybe Text
a} :: WorkmailAction)

-- | The ARN of the Amazon WorkMail organization. An example of an Amazon
-- WorkMail organization ARN is
-- @arn:aws:workmail:us-west-2:123456789012:organization\/m-68755160c4cb4e29a2b2f8fb58f359d7@.
-- For information about Amazon WorkMail organizations, see the
-- <https://docs.aws.amazon.com/workmail/latest/adminguide/organizations_overview.html Amazon WorkMail Administrator Guide>.
workmailAction_organizationArn :: Lens.Lens' WorkmailAction Prelude.Text
workmailAction_organizationArn :: Lens' WorkmailAction Text
workmailAction_organizationArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkmailAction' {Text
organizationArn :: Text
$sel:organizationArn:WorkmailAction' :: WorkmailAction -> Text
organizationArn} -> Text
organizationArn) (\s :: WorkmailAction
s@WorkmailAction' {} Text
a -> WorkmailAction
s {$sel:organizationArn:WorkmailAction' :: Text
organizationArn = Text
a} :: WorkmailAction)

instance Data.FromXML WorkmailAction where
  parseXML :: [Node] -> Either String WorkmailAction
parseXML [Node]
x =
    Maybe Text -> Text -> WorkmailAction
WorkmailAction'
      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
"OrganizationArn")

instance Prelude.Hashable WorkmailAction where
  hashWithSalt :: Int -> WorkmailAction -> Int
hashWithSalt Int
_salt WorkmailAction' {Maybe Text
Text
organizationArn :: Text
topicArn :: Maybe Text
$sel:organizationArn:WorkmailAction' :: WorkmailAction -> Text
$sel:topicArn:WorkmailAction' :: WorkmailAction -> 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` Text
organizationArn

instance Prelude.NFData WorkmailAction where
  rnf :: WorkmailAction -> ()
rnf WorkmailAction' {Maybe Text
Text
organizationArn :: Text
topicArn :: Maybe Text
$sel:organizationArn:WorkmailAction' :: WorkmailAction -> Text
$sel:topicArn:WorkmailAction' :: WorkmailAction -> 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 Text
organizationArn

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