{-# 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.PinpointEmail.Types.EventDestinationDefinition
-- 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.PinpointEmail.Types.EventDestinationDefinition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.PinpointEmail.Types.CloudWatchDestination
import Amazonka.PinpointEmail.Types.EventType
import Amazonka.PinpointEmail.Types.KinesisFirehoseDestination
import Amazonka.PinpointEmail.Types.PinpointDestination
import Amazonka.PinpointEmail.Types.SnsDestination
import qualified Amazonka.Prelude as Prelude

-- | An object that defines the event destination. Specifically, it defines
-- which services receive events from emails sent using the configuration
-- set that the event destination is associated with. Also defines the
-- types of events that are sent to the event destination.
--
-- /See:/ 'newEventDestinationDefinition' smart constructor.
data EventDestinationDefinition = EventDestinationDefinition'
  { -- | 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.
    EventDestinationDefinition -> Maybe CloudWatchDestination
cloudWatchDestination :: Prelude.Maybe CloudWatchDestination,
    -- | 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.
    EventDestinationDefinition -> 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.
    EventDestinationDefinition -> Maybe KinesisFirehoseDestination
kinesisFirehoseDestination :: Prelude.Maybe KinesisFirehoseDestination,
    -- | An array that specifies which events Amazon Pinpoint should send to the
    -- destinations in this @EventDestinationDefinition@.
    EventDestinationDefinition -> Maybe [EventType]
matchingEventTypes :: Prelude.Maybe [EventType],
    -- | An object that defines a Amazon Pinpoint destination for email events.
    -- You can use Amazon Pinpoint events to create attributes in Amazon
    -- Pinpoint projects. You can use these attributes to create segments for
    -- your campaigns.
    EventDestinationDefinition -> Maybe PinpointDestination
pinpointDestination :: Prelude.Maybe PinpointDestination,
    -- | An object that defines an Amazon SNS destination for email events. You
    -- can use Amazon SNS to send notification when certain email events occur.
    EventDestinationDefinition -> Maybe SnsDestination
snsDestination :: Prelude.Maybe SnsDestination
  }
  deriving (EventDestinationDefinition -> EventDestinationDefinition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventDestinationDefinition -> EventDestinationDefinition -> Bool
$c/= :: EventDestinationDefinition -> EventDestinationDefinition -> Bool
== :: EventDestinationDefinition -> EventDestinationDefinition -> Bool
$c== :: EventDestinationDefinition -> EventDestinationDefinition -> Bool
Prelude.Eq, ReadPrec [EventDestinationDefinition]
ReadPrec EventDestinationDefinition
Int -> ReadS EventDestinationDefinition
ReadS [EventDestinationDefinition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventDestinationDefinition]
$creadListPrec :: ReadPrec [EventDestinationDefinition]
readPrec :: ReadPrec EventDestinationDefinition
$creadPrec :: ReadPrec EventDestinationDefinition
readList :: ReadS [EventDestinationDefinition]
$creadList :: ReadS [EventDestinationDefinition]
readsPrec :: Int -> ReadS EventDestinationDefinition
$creadsPrec :: Int -> ReadS EventDestinationDefinition
Prelude.Read, Int -> EventDestinationDefinition -> ShowS
[EventDestinationDefinition] -> ShowS
EventDestinationDefinition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventDestinationDefinition] -> ShowS
$cshowList :: [EventDestinationDefinition] -> ShowS
show :: EventDestinationDefinition -> String
$cshow :: EventDestinationDefinition -> String
showsPrec :: Int -> EventDestinationDefinition -> ShowS
$cshowsPrec :: Int -> EventDestinationDefinition -> ShowS
Prelude.Show, forall x.
Rep EventDestinationDefinition x -> EventDestinationDefinition
forall x.
EventDestinationDefinition -> Rep EventDestinationDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EventDestinationDefinition x -> EventDestinationDefinition
$cfrom :: forall x.
EventDestinationDefinition -> Rep EventDestinationDefinition x
Prelude.Generic)

-- |
-- Create a value of 'EventDestinationDefinition' 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:
--
-- 'cloudWatchDestination', 'eventDestinationDefinition_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.
--
-- 'enabled', 'eventDestinationDefinition_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', 'eventDestinationDefinition_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.
--
-- 'matchingEventTypes', 'eventDestinationDefinition_matchingEventTypes' - An array that specifies which events Amazon Pinpoint should send to the
-- destinations in this @EventDestinationDefinition@.
--
-- 'pinpointDestination', 'eventDestinationDefinition_pinpointDestination' - An object that defines a Amazon Pinpoint destination for email events.
-- You can use Amazon Pinpoint events to create attributes in Amazon
-- Pinpoint projects. You can use these attributes to create segments for
-- your campaigns.
--
-- 'snsDestination', 'eventDestinationDefinition_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.
newEventDestinationDefinition ::
  EventDestinationDefinition
newEventDestinationDefinition :: EventDestinationDefinition
newEventDestinationDefinition =
  EventDestinationDefinition'
    { $sel:cloudWatchDestination:EventDestinationDefinition' :: Maybe CloudWatchDestination
cloudWatchDestination =
        forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:EventDestinationDefinition' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
      $sel:kinesisFirehoseDestination:EventDestinationDefinition' :: Maybe KinesisFirehoseDestination
kinesisFirehoseDestination = forall a. Maybe a
Prelude.Nothing,
      $sel:matchingEventTypes:EventDestinationDefinition' :: Maybe [EventType]
matchingEventTypes = forall a. Maybe a
Prelude.Nothing,
      $sel:pinpointDestination:EventDestinationDefinition' :: Maybe PinpointDestination
pinpointDestination = forall a. Maybe a
Prelude.Nothing,
      $sel:snsDestination:EventDestinationDefinition' :: Maybe SnsDestination
snsDestination = forall a. Maybe a
Prelude.Nothing
    }

-- | 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.
eventDestinationDefinition_cloudWatchDestination :: Lens.Lens' EventDestinationDefinition (Prelude.Maybe CloudWatchDestination)
eventDestinationDefinition_cloudWatchDestination :: Lens' EventDestinationDefinition (Maybe CloudWatchDestination)
eventDestinationDefinition_cloudWatchDestination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestinationDefinition' {Maybe CloudWatchDestination
cloudWatchDestination :: Maybe CloudWatchDestination
$sel:cloudWatchDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe CloudWatchDestination
cloudWatchDestination} -> Maybe CloudWatchDestination
cloudWatchDestination) (\s :: EventDestinationDefinition
s@EventDestinationDefinition' {} Maybe CloudWatchDestination
a -> EventDestinationDefinition
s {$sel:cloudWatchDestination:EventDestinationDefinition' :: Maybe CloudWatchDestination
cloudWatchDestination = Maybe CloudWatchDestination
a} :: EventDestinationDefinition)

-- | 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.
eventDestinationDefinition_enabled :: Lens.Lens' EventDestinationDefinition (Prelude.Maybe Prelude.Bool)
eventDestinationDefinition_enabled :: Lens' EventDestinationDefinition (Maybe Bool)
eventDestinationDefinition_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestinationDefinition' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: EventDestinationDefinition
s@EventDestinationDefinition' {} Maybe Bool
a -> EventDestinationDefinition
s {$sel:enabled:EventDestinationDefinition' :: Maybe Bool
enabled = Maybe Bool
a} :: EventDestinationDefinition)

-- | 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.
eventDestinationDefinition_kinesisFirehoseDestination :: Lens.Lens' EventDestinationDefinition (Prelude.Maybe KinesisFirehoseDestination)
eventDestinationDefinition_kinesisFirehoseDestination :: Lens' EventDestinationDefinition (Maybe KinesisFirehoseDestination)
eventDestinationDefinition_kinesisFirehoseDestination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestinationDefinition' {Maybe KinesisFirehoseDestination
kinesisFirehoseDestination :: Maybe KinesisFirehoseDestination
$sel:kinesisFirehoseDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe KinesisFirehoseDestination
kinesisFirehoseDestination} -> Maybe KinesisFirehoseDestination
kinesisFirehoseDestination) (\s :: EventDestinationDefinition
s@EventDestinationDefinition' {} Maybe KinesisFirehoseDestination
a -> EventDestinationDefinition
s {$sel:kinesisFirehoseDestination:EventDestinationDefinition' :: Maybe KinesisFirehoseDestination
kinesisFirehoseDestination = Maybe KinesisFirehoseDestination
a} :: EventDestinationDefinition)

-- | An array that specifies which events Amazon Pinpoint should send to the
-- destinations in this @EventDestinationDefinition@.
eventDestinationDefinition_matchingEventTypes :: Lens.Lens' EventDestinationDefinition (Prelude.Maybe [EventType])
eventDestinationDefinition_matchingEventTypes :: Lens' EventDestinationDefinition (Maybe [EventType])
eventDestinationDefinition_matchingEventTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestinationDefinition' {Maybe [EventType]
matchingEventTypes :: Maybe [EventType]
$sel:matchingEventTypes:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe [EventType]
matchingEventTypes} -> Maybe [EventType]
matchingEventTypes) (\s :: EventDestinationDefinition
s@EventDestinationDefinition' {} Maybe [EventType]
a -> EventDestinationDefinition
s {$sel:matchingEventTypes:EventDestinationDefinition' :: Maybe [EventType]
matchingEventTypes = Maybe [EventType]
a} :: EventDestinationDefinition) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An object that defines a Amazon Pinpoint destination for email events.
-- You can use Amazon Pinpoint events to create attributes in Amazon
-- Pinpoint projects. You can use these attributes to create segments for
-- your campaigns.
eventDestinationDefinition_pinpointDestination :: Lens.Lens' EventDestinationDefinition (Prelude.Maybe PinpointDestination)
eventDestinationDefinition_pinpointDestination :: Lens' EventDestinationDefinition (Maybe PinpointDestination)
eventDestinationDefinition_pinpointDestination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestinationDefinition' {Maybe PinpointDestination
pinpointDestination :: Maybe PinpointDestination
$sel:pinpointDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe PinpointDestination
pinpointDestination} -> Maybe PinpointDestination
pinpointDestination) (\s :: EventDestinationDefinition
s@EventDestinationDefinition' {} Maybe PinpointDestination
a -> EventDestinationDefinition
s {$sel:pinpointDestination:EventDestinationDefinition' :: Maybe PinpointDestination
pinpointDestination = Maybe PinpointDestination
a} :: EventDestinationDefinition)

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

instance Prelude.Hashable EventDestinationDefinition where
  hashWithSalt :: Int -> EventDestinationDefinition -> Int
hashWithSalt Int
_salt EventDestinationDefinition' {Maybe Bool
Maybe [EventType]
Maybe CloudWatchDestination
Maybe KinesisFirehoseDestination
Maybe PinpointDestination
Maybe SnsDestination
snsDestination :: Maybe SnsDestination
pinpointDestination :: Maybe PinpointDestination
matchingEventTypes :: Maybe [EventType]
kinesisFirehoseDestination :: Maybe KinesisFirehoseDestination
enabled :: Maybe Bool
cloudWatchDestination :: Maybe CloudWatchDestination
$sel:snsDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe SnsDestination
$sel:pinpointDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe PinpointDestination
$sel:matchingEventTypes:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe [EventType]
$sel:kinesisFirehoseDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe KinesisFirehoseDestination
$sel:enabled:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe Bool
$sel:cloudWatchDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe CloudWatchDestination
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CloudWatchDestination
cloudWatchDestination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe KinesisFirehoseDestination
kinesisFirehoseDestination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [EventType]
matchingEventTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PinpointDestination
pinpointDestination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SnsDestination
snsDestination

instance Prelude.NFData EventDestinationDefinition where
  rnf :: EventDestinationDefinition -> ()
rnf EventDestinationDefinition' {Maybe Bool
Maybe [EventType]
Maybe CloudWatchDestination
Maybe KinesisFirehoseDestination
Maybe PinpointDestination
Maybe SnsDestination
snsDestination :: Maybe SnsDestination
pinpointDestination :: Maybe PinpointDestination
matchingEventTypes :: Maybe [EventType]
kinesisFirehoseDestination :: Maybe KinesisFirehoseDestination
enabled :: Maybe Bool
cloudWatchDestination :: Maybe CloudWatchDestination
$sel:snsDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe SnsDestination
$sel:pinpointDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe PinpointDestination
$sel:matchingEventTypes:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe [EventType]
$sel:kinesisFirehoseDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe KinesisFirehoseDestination
$sel:enabled:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe Bool
$sel:cloudWatchDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe CloudWatchDestination
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CloudWatchDestination
cloudWatchDestination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe KinesisFirehoseDestination
kinesisFirehoseDestination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [EventType]
matchingEventTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PinpointDestination
pinpointDestination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SnsDestination
snsDestination

instance Data.ToJSON EventDestinationDefinition where
  toJSON :: EventDestinationDefinition -> Value
toJSON EventDestinationDefinition' {Maybe Bool
Maybe [EventType]
Maybe CloudWatchDestination
Maybe KinesisFirehoseDestination
Maybe PinpointDestination
Maybe SnsDestination
snsDestination :: Maybe SnsDestination
pinpointDestination :: Maybe PinpointDestination
matchingEventTypes :: Maybe [EventType]
kinesisFirehoseDestination :: Maybe KinesisFirehoseDestination
enabled :: Maybe Bool
cloudWatchDestination :: Maybe CloudWatchDestination
$sel:snsDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe SnsDestination
$sel:pinpointDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe PinpointDestination
$sel:matchingEventTypes:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe [EventType]
$sel:kinesisFirehoseDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe KinesisFirehoseDestination
$sel:enabled:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe Bool
$sel:cloudWatchDestination:EventDestinationDefinition' :: EventDestinationDefinition -> Maybe CloudWatchDestination
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CloudWatchDestination" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CloudWatchDestination
cloudWatchDestination,
            (Key
"Enabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (Key
"KinesisFirehoseDestination" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe KinesisFirehoseDestination
kinesisFirehoseDestination,
            (Key
"MatchingEventTypes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [EventType]
matchingEventTypes,
            (Key
"PinpointDestination" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PinpointDestination
pinpointDestination,
            (Key
"SnsDestination" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SnsDestination
snsDestination
          ]
      )