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

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

instance Prelude.Hashable WorkmailAction

instance Prelude.NFData WorkmailAction

instance Core.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
..} =
    [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
"OrganizationArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
organizationArn
      ]