{-# 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.SESV2.Types.EventDestination
-- 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.SESV2.Types.EventDestination where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SESV2.Types.CloudWatchDestination
import Amazonka.SESV2.Types.EventType
import Amazonka.SESV2.Types.KinesisFirehoseDestination
import Amazonka.SESV2.Types.PinpointDestination
import Amazonka.SESV2.Types.SnsDestination

-- | In the Amazon SES API v2, /events/ include message sends, deliveries,
-- opens, clicks, bounces, complaints and delivery delays. /Event
-- destinations/ are places that you can send information about these
-- events to. For example, you can send event data to Amazon SNS to receive
-- notifications when you receive bounces or complaints, or you can use
-- Amazon Kinesis Data Firehose to stream data to Amazon S3 for long-term
-- storage.
--
-- /See:/ 'newEventDestination' smart constructor.
data EventDestination = EventDestination'
  { -- | An object that defines an Amazon Pinpoint project destination for email
    -- events. You can send email event data to a Amazon Pinpoint project to
    -- view metrics using the Transactional Messaging dashboards that are built
    -- in to Amazon Pinpoint. For more information, see
    -- <https://docs.aws.amazon.com/pinpoint/latest/userguide/analytics-transactional-messages.html Transactional Messaging Charts>
    -- in the /Amazon Pinpoint User Guide/.
    EventDestination -> Maybe PinpointDestination
pinpointDestination :: Prelude.Maybe PinpointDestination,
    -- | If @true@, the event destination is enabled. When the event destination
    -- is enabled, the specified event types are sent to the destinations in
    -- this @EventDestinationDefinition@.
    --
    -- If @false@, the event destination is disabled. When the event
    -- destination is disabled, events aren\'t sent to the specified
    -- destinations.
    EventDestination -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | An object that defines an Amazon Kinesis Data Firehose destination for
    -- email events. You can use Amazon Kinesis Data Firehose to stream data to
    -- other services, such as Amazon S3 and Amazon Redshift.
    EventDestination -> Maybe KinesisFirehoseDestination
kinesisFirehoseDestination :: Prelude.Maybe KinesisFirehoseDestination,
    -- | An object that defines an Amazon CloudWatch destination for email
    -- events. You can use Amazon CloudWatch to monitor and gain insights on
    -- your email sending metrics.
    EventDestination -> Maybe CloudWatchDestination
cloudWatchDestination :: Prelude.Maybe CloudWatchDestination,
    -- | An object that defines an Amazon SNS destination for email events. You
    -- can use Amazon SNS to send notification when certain email events occur.
    EventDestination -> Maybe SnsDestination
snsDestination :: Prelude.Maybe SnsDestination,
    -- | A name that identifies the event destination.
    EventDestination -> Text
name :: Prelude.Text,
    -- | The types of events that Amazon SES sends to the specified event
    -- destinations.
    EventDestination -> [EventType]
matchingEventTypes :: [EventType]
  }
  deriving (EventDestination -> EventDestination -> Bool
(EventDestination -> EventDestination -> Bool)
-> (EventDestination -> EventDestination -> Bool)
-> Eq EventDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventDestination -> EventDestination -> Bool
$c/= :: EventDestination -> EventDestination -> Bool
== :: EventDestination -> EventDestination -> Bool
$c== :: EventDestination -> EventDestination -> Bool
Prelude.Eq, ReadPrec [EventDestination]
ReadPrec EventDestination
Int -> ReadS EventDestination
ReadS [EventDestination]
(Int -> ReadS EventDestination)
-> ReadS [EventDestination]
-> ReadPrec EventDestination
-> ReadPrec [EventDestination]
-> Read EventDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventDestination]
$creadListPrec :: ReadPrec [EventDestination]
readPrec :: ReadPrec EventDestination
$creadPrec :: ReadPrec EventDestination
readList :: ReadS [EventDestination]
$creadList :: ReadS [EventDestination]
readsPrec :: Int -> ReadS EventDestination
$creadsPrec :: Int -> ReadS EventDestination
Prelude.Read, Int -> EventDestination -> ShowS
[EventDestination] -> ShowS
EventDestination -> String
(Int -> EventDestination -> ShowS)
-> (EventDestination -> String)
-> ([EventDestination] -> ShowS)
-> Show EventDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventDestination] -> ShowS
$cshowList :: [EventDestination] -> ShowS
show :: EventDestination -> String
$cshow :: EventDestination -> String
showsPrec :: Int -> EventDestination -> ShowS
$cshowsPrec :: Int -> EventDestination -> ShowS
Prelude.Show, (forall x. EventDestination -> Rep EventDestination x)
-> (forall x. Rep EventDestination x -> EventDestination)
-> Generic EventDestination
forall x. Rep EventDestination x -> EventDestination
forall x. EventDestination -> Rep EventDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventDestination x -> EventDestination
$cfrom :: forall x. EventDestination -> Rep EventDestination x
Prelude.Generic)

-- |
-- Create a value of 'EventDestination' 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:
--
-- 'pinpointDestination', 'eventDestination_pinpointDestination' - An object that defines an Amazon Pinpoint project destination for email
-- events. You can send email event data to a Amazon Pinpoint project to
-- view metrics using the Transactional Messaging dashboards that are built
-- in to Amazon Pinpoint. For more information, see
-- <https://docs.aws.amazon.com/pinpoint/latest/userguide/analytics-transactional-messages.html Transactional Messaging Charts>
-- in the /Amazon Pinpoint User Guide/.
--
-- 'enabled', 'eventDestination_enabled' - If @true@, the event destination is enabled. When the event destination
-- is enabled, the specified event types are sent to the destinations in
-- this @EventDestinationDefinition@.
--
-- If @false@, the event destination is disabled. When the event
-- destination is disabled, events aren\'t sent to the specified
-- destinations.
--
-- 'kinesisFirehoseDestination', 'eventDestination_kinesisFirehoseDestination' - An object that defines an Amazon Kinesis Data Firehose destination for
-- email events. You can use Amazon Kinesis Data Firehose to stream data to
-- other services, such as Amazon S3 and Amazon Redshift.
--
-- 'cloudWatchDestination', 'eventDestination_cloudWatchDestination' - An object that defines an Amazon CloudWatch destination for email
-- events. You can use Amazon CloudWatch to monitor and gain insights on
-- your email sending metrics.
--
-- 'snsDestination', 'eventDestination_snsDestination' - An object that defines an Amazon SNS destination for email events. You
-- can use Amazon SNS to send notification when certain email events occur.
--
-- 'name', 'eventDestination_name' - A name that identifies the event destination.
--
-- 'matchingEventTypes', 'eventDestination_matchingEventTypes' - The types of events that Amazon SES sends to the specified event
-- destinations.
newEventDestination ::
  -- | 'name'
  Prelude.Text ->
  EventDestination
newEventDestination :: Text -> EventDestination
newEventDestination Text
pName_ =
  EventDestination' :: Maybe PinpointDestination
-> Maybe Bool
-> Maybe KinesisFirehoseDestination
-> Maybe CloudWatchDestination
-> Maybe SnsDestination
-> Text
-> [EventType]
-> EventDestination
EventDestination'
    { $sel:pinpointDestination:EventDestination' :: Maybe PinpointDestination
pinpointDestination =
        Maybe PinpointDestination
forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:EventDestination' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:kinesisFirehoseDestination:EventDestination' :: Maybe KinesisFirehoseDestination
kinesisFirehoseDestination = Maybe KinesisFirehoseDestination
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudWatchDestination:EventDestination' :: Maybe CloudWatchDestination
cloudWatchDestination = Maybe CloudWatchDestination
forall a. Maybe a
Prelude.Nothing,
      $sel:snsDestination:EventDestination' :: Maybe SnsDestination
snsDestination = Maybe SnsDestination
forall a. Maybe a
Prelude.Nothing,
      $sel:name:EventDestination' :: Text
name = Text
pName_,
      $sel:matchingEventTypes:EventDestination' :: [EventType]
matchingEventTypes = [EventType]
forall a. Monoid a => a
Prelude.mempty
    }

-- | An object that defines an Amazon Pinpoint project destination for email
-- events. You can send email event data to a Amazon Pinpoint project to
-- view metrics using the Transactional Messaging dashboards that are built
-- in to Amazon Pinpoint. For more information, see
-- <https://docs.aws.amazon.com/pinpoint/latest/userguide/analytics-transactional-messages.html Transactional Messaging Charts>
-- in the /Amazon Pinpoint User Guide/.
eventDestination_pinpointDestination :: Lens.Lens' EventDestination (Prelude.Maybe PinpointDestination)
eventDestination_pinpointDestination :: (Maybe PinpointDestination -> f (Maybe PinpointDestination))
-> EventDestination -> f EventDestination
eventDestination_pinpointDestination = (EventDestination -> Maybe PinpointDestination)
-> (EventDestination
    -> Maybe PinpointDestination -> EventDestination)
-> Lens
     EventDestination
     EventDestination
     (Maybe PinpointDestination)
     (Maybe PinpointDestination)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestination' {Maybe PinpointDestination
pinpointDestination :: Maybe PinpointDestination
$sel:pinpointDestination:EventDestination' :: EventDestination -> Maybe PinpointDestination
pinpointDestination} -> Maybe PinpointDestination
pinpointDestination) (\s :: EventDestination
s@EventDestination' {} Maybe PinpointDestination
a -> EventDestination
s {$sel:pinpointDestination:EventDestination' :: Maybe PinpointDestination
pinpointDestination = Maybe PinpointDestination
a} :: EventDestination)

-- | If @true@, the event destination is enabled. When the event destination
-- is enabled, the specified event types are sent to the destinations in
-- this @EventDestinationDefinition@.
--
-- If @false@, the event destination is disabled. When the event
-- destination is disabled, events aren\'t sent to the specified
-- destinations.
eventDestination_enabled :: Lens.Lens' EventDestination (Prelude.Maybe Prelude.Bool)
eventDestination_enabled :: (Maybe Bool -> f (Maybe Bool))
-> EventDestination -> f EventDestination
eventDestination_enabled = (EventDestination -> Maybe Bool)
-> (EventDestination -> Maybe Bool -> EventDestination)
-> Lens EventDestination EventDestination (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestination' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:EventDestination' :: EventDestination -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: EventDestination
s@EventDestination' {} Maybe Bool
a -> EventDestination
s {$sel:enabled:EventDestination' :: Maybe Bool
enabled = Maybe Bool
a} :: EventDestination)

-- | An object that defines an Amazon Kinesis Data Firehose destination for
-- email events. You can use Amazon Kinesis Data Firehose to stream data to
-- other services, such as Amazon S3 and Amazon Redshift.
eventDestination_kinesisFirehoseDestination :: Lens.Lens' EventDestination (Prelude.Maybe KinesisFirehoseDestination)
eventDestination_kinesisFirehoseDestination :: (Maybe KinesisFirehoseDestination
 -> f (Maybe KinesisFirehoseDestination))
-> EventDestination -> f EventDestination
eventDestination_kinesisFirehoseDestination = (EventDestination -> Maybe KinesisFirehoseDestination)
-> (EventDestination
    -> Maybe KinesisFirehoseDestination -> EventDestination)
-> Lens
     EventDestination
     EventDestination
     (Maybe KinesisFirehoseDestination)
     (Maybe KinesisFirehoseDestination)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestination' {Maybe KinesisFirehoseDestination
kinesisFirehoseDestination :: Maybe KinesisFirehoseDestination
$sel:kinesisFirehoseDestination:EventDestination' :: EventDestination -> Maybe KinesisFirehoseDestination
kinesisFirehoseDestination} -> Maybe KinesisFirehoseDestination
kinesisFirehoseDestination) (\s :: EventDestination
s@EventDestination' {} Maybe KinesisFirehoseDestination
a -> EventDestination
s {$sel:kinesisFirehoseDestination:EventDestination' :: Maybe KinesisFirehoseDestination
kinesisFirehoseDestination = Maybe KinesisFirehoseDestination
a} :: EventDestination)

-- | An object that defines an Amazon CloudWatch destination for email
-- events. You can use Amazon CloudWatch to monitor and gain insights on
-- your email sending metrics.
eventDestination_cloudWatchDestination :: Lens.Lens' EventDestination (Prelude.Maybe CloudWatchDestination)
eventDestination_cloudWatchDestination :: (Maybe CloudWatchDestination -> f (Maybe CloudWatchDestination))
-> EventDestination -> f EventDestination
eventDestination_cloudWatchDestination = (EventDestination -> Maybe CloudWatchDestination)
-> (EventDestination
    -> Maybe CloudWatchDestination -> EventDestination)
-> Lens
     EventDestination
     EventDestination
     (Maybe CloudWatchDestination)
     (Maybe CloudWatchDestination)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestination' {Maybe CloudWatchDestination
cloudWatchDestination :: Maybe CloudWatchDestination
$sel:cloudWatchDestination:EventDestination' :: EventDestination -> Maybe CloudWatchDestination
cloudWatchDestination} -> Maybe CloudWatchDestination
cloudWatchDestination) (\s :: EventDestination
s@EventDestination' {} Maybe CloudWatchDestination
a -> EventDestination
s {$sel:cloudWatchDestination:EventDestination' :: Maybe CloudWatchDestination
cloudWatchDestination = Maybe CloudWatchDestination
a} :: EventDestination)

-- | An object that defines an Amazon SNS destination for email events. You
-- can use Amazon SNS to send notification when certain email events occur.
eventDestination_snsDestination :: Lens.Lens' EventDestination (Prelude.Maybe SnsDestination)
eventDestination_snsDestination :: (Maybe SnsDestination -> f (Maybe SnsDestination))
-> EventDestination -> f EventDestination
eventDestination_snsDestination = (EventDestination -> Maybe SnsDestination)
-> (EventDestination -> Maybe SnsDestination -> EventDestination)
-> Lens
     EventDestination
     EventDestination
     (Maybe SnsDestination)
     (Maybe SnsDestination)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestination' {Maybe SnsDestination
snsDestination :: Maybe SnsDestination
$sel:snsDestination:EventDestination' :: EventDestination -> Maybe SnsDestination
snsDestination} -> Maybe SnsDestination
snsDestination) (\s :: EventDestination
s@EventDestination' {} Maybe SnsDestination
a -> EventDestination
s {$sel:snsDestination:EventDestination' :: Maybe SnsDestination
snsDestination = Maybe SnsDestination
a} :: EventDestination)

-- | A name that identifies the event destination.
eventDestination_name :: Lens.Lens' EventDestination Prelude.Text
eventDestination_name :: (Text -> f Text) -> EventDestination -> f EventDestination
eventDestination_name = (EventDestination -> Text)
-> (EventDestination -> Text -> EventDestination)
-> Lens EventDestination EventDestination Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestination' {Text
name :: Text
$sel:name:EventDestination' :: EventDestination -> Text
name} -> Text
name) (\s :: EventDestination
s@EventDestination' {} Text
a -> EventDestination
s {$sel:name:EventDestination' :: Text
name = Text
a} :: EventDestination)

-- | The types of events that Amazon SES sends to the specified event
-- destinations.
eventDestination_matchingEventTypes :: Lens.Lens' EventDestination [EventType]
eventDestination_matchingEventTypes :: ([EventType] -> f [EventType])
-> EventDestination -> f EventDestination
eventDestination_matchingEventTypes = (EventDestination -> [EventType])
-> (EventDestination -> [EventType] -> EventDestination)
-> Lens EventDestination EventDestination [EventType] [EventType]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestination' {[EventType]
matchingEventTypes :: [EventType]
$sel:matchingEventTypes:EventDestination' :: EventDestination -> [EventType]
matchingEventTypes} -> [EventType]
matchingEventTypes) (\s :: EventDestination
s@EventDestination' {} [EventType]
a -> EventDestination
s {$sel:matchingEventTypes:EventDestination' :: [EventType]
matchingEventTypes = [EventType]
a} :: EventDestination) (([EventType] -> f [EventType])
 -> EventDestination -> f EventDestination)
-> (([EventType] -> f [EventType]) -> [EventType] -> f [EventType])
-> ([EventType] -> f [EventType])
-> EventDestination
-> f EventDestination
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([EventType] -> f [EventType]) -> [EventType] -> f [EventType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON EventDestination where
  parseJSON :: Value -> Parser EventDestination
parseJSON =
    String
-> (Object -> Parser EventDestination)
-> Value
-> Parser EventDestination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventDestination"
      ( \Object
x ->
          Maybe PinpointDestination
-> Maybe Bool
-> Maybe KinesisFirehoseDestination
-> Maybe CloudWatchDestination
-> Maybe SnsDestination
-> Text
-> [EventType]
-> EventDestination
EventDestination'
            (Maybe PinpointDestination
 -> Maybe Bool
 -> Maybe KinesisFirehoseDestination
 -> Maybe CloudWatchDestination
 -> Maybe SnsDestination
 -> Text
 -> [EventType]
 -> EventDestination)
-> Parser (Maybe PinpointDestination)
-> Parser
     (Maybe Bool
      -> Maybe KinesisFirehoseDestination
      -> Maybe CloudWatchDestination
      -> Maybe SnsDestination
      -> Text
      -> [EventType]
      -> EventDestination)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe PinpointDestination)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PinpointDestination")
            Parser
  (Maybe Bool
   -> Maybe KinesisFirehoseDestination
   -> Maybe CloudWatchDestination
   -> Maybe SnsDestination
   -> Text
   -> [EventType]
   -> EventDestination)
-> Parser (Maybe Bool)
-> Parser
     (Maybe KinesisFirehoseDestination
      -> Maybe CloudWatchDestination
      -> Maybe SnsDestination
      -> Text
      -> [EventType]
      -> EventDestination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Enabled")
            Parser
  (Maybe KinesisFirehoseDestination
   -> Maybe CloudWatchDestination
   -> Maybe SnsDestination
   -> Text
   -> [EventType]
   -> EventDestination)
-> Parser (Maybe KinesisFirehoseDestination)
-> Parser
     (Maybe CloudWatchDestination
      -> Maybe SnsDestination -> Text -> [EventType] -> EventDestination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe KinesisFirehoseDestination)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"KinesisFirehoseDestination")
            Parser
  (Maybe CloudWatchDestination
   -> Maybe SnsDestination -> Text -> [EventType] -> EventDestination)
-> Parser (Maybe CloudWatchDestination)
-> Parser
     (Maybe SnsDestination -> Text -> [EventType] -> EventDestination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CloudWatchDestination)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CloudWatchDestination")
            Parser
  (Maybe SnsDestination -> Text -> [EventType] -> EventDestination)
-> Parser (Maybe SnsDestination)
-> Parser (Text -> [EventType] -> EventDestination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SnsDestination)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SnsDestination")
            Parser (Text -> [EventType] -> EventDestination)
-> Parser Text -> Parser ([EventType] -> EventDestination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
            Parser ([EventType] -> EventDestination)
-> Parser [EventType] -> Parser EventDestination
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe [EventType])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MatchingEventTypes"
                            Parser (Maybe [EventType]) -> [EventType] -> Parser [EventType]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [EventType]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable EventDestination

instance Prelude.NFData EventDestination