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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.PinpointSMSVoice.Types.CloudWatchLogsDestination
import Amazonka.PinpointSMSVoice.Types.EventType
import Amazonka.PinpointSMSVoice.Types.KinesisFirehoseDestination
import Amazonka.PinpointSMSVoice.Types.SnsDestination
import qualified Amazonka.Prelude as Prelude

-- | An object that defines an event destination.
--
-- /See:/ 'newEventDestination' smart constructor.
data EventDestination = EventDestination'
  { EventDestination -> Maybe [EventType]
matchingEventTypes :: Prelude.Maybe [EventType],
    -- | Indicates whether or not the event destination is enabled. If the event
    -- destination is enabled, then Amazon Pinpoint sends response data to the
    -- specified event destination.
    EventDestination -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    EventDestination -> Maybe KinesisFirehoseDestination
kinesisFirehoseDestination :: Prelude.Maybe KinesisFirehoseDestination,
    -- | A name that identifies the event destination configuration.
    EventDestination -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    EventDestination -> Maybe SnsDestination
snsDestination :: Prelude.Maybe SnsDestination,
    EventDestination -> Maybe CloudWatchLogsDestination
cloudWatchLogsDestination :: Prelude.Maybe CloudWatchLogsDestination
  }
  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:
--
-- 'matchingEventTypes', 'eventDestination_matchingEventTypes' - Undocumented member.
--
-- 'enabled', 'eventDestination_enabled' - Indicates whether or not the event destination is enabled. If the event
-- destination is enabled, then Amazon Pinpoint sends response data to the
-- specified event destination.
--
-- 'kinesisFirehoseDestination', 'eventDestination_kinesisFirehoseDestination' - Undocumented member.
--
-- 'name', 'eventDestination_name' - A name that identifies the event destination configuration.
--
-- 'snsDestination', 'eventDestination_snsDestination' - Undocumented member.
--
-- 'cloudWatchLogsDestination', 'eventDestination_cloudWatchLogsDestination' - Undocumented member.
newEventDestination ::
  EventDestination
newEventDestination :: EventDestination
newEventDestination =
  EventDestination' :: Maybe [EventType]
-> Maybe Bool
-> Maybe KinesisFirehoseDestination
-> Maybe Text
-> Maybe SnsDestination
-> Maybe CloudWatchLogsDestination
-> EventDestination
EventDestination'
    { $sel:matchingEventTypes:EventDestination' :: Maybe [EventType]
matchingEventTypes =
        Maybe [EventType]
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:name:EventDestination' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:snsDestination:EventDestination' :: Maybe SnsDestination
snsDestination = Maybe SnsDestination
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudWatchLogsDestination:EventDestination' :: Maybe CloudWatchLogsDestination
cloudWatchLogsDestination = Maybe CloudWatchLogsDestination
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
eventDestination_matchingEventTypes :: Lens.Lens' EventDestination (Prelude.Maybe [EventType])
eventDestination_matchingEventTypes :: (Maybe [EventType] -> f (Maybe [EventType]))
-> EventDestination -> f EventDestination
eventDestination_matchingEventTypes = (EventDestination -> Maybe [EventType])
-> (EventDestination -> Maybe [EventType] -> EventDestination)
-> Lens
     EventDestination
     EventDestination
     (Maybe [EventType])
     (Maybe [EventType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestination' {Maybe [EventType]
matchingEventTypes :: Maybe [EventType]
$sel:matchingEventTypes:EventDestination' :: EventDestination -> Maybe [EventType]
matchingEventTypes} -> Maybe [EventType]
matchingEventTypes) (\s :: EventDestination
s@EventDestination' {} Maybe [EventType]
a -> EventDestination
s {$sel:matchingEventTypes:EventDestination' :: Maybe [EventType]
matchingEventTypes = Maybe [EventType]
a} :: EventDestination) ((Maybe [EventType] -> f (Maybe [EventType]))
 -> EventDestination -> f EventDestination)
-> ((Maybe [EventType] -> f (Maybe [EventType]))
    -> Maybe [EventType] -> f (Maybe [EventType]))
-> (Maybe [EventType] -> f (Maybe [EventType]))
-> EventDestination
-> f EventDestination
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [EventType] [EventType] [EventType] [EventType]
-> Iso
     (Maybe [EventType])
     (Maybe [EventType])
     (Maybe [EventType])
     (Maybe [EventType])
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 AnIso [EventType] [EventType] [EventType] [EventType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Indicates whether or not the event destination is enabled. If the event
-- destination is enabled, then Amazon Pinpoint sends response data to the
-- specified event destination.
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)

-- | Undocumented member.
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)

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

-- | Undocumented member.
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)

-- | Undocumented member.
eventDestination_cloudWatchLogsDestination :: Lens.Lens' EventDestination (Prelude.Maybe CloudWatchLogsDestination)
eventDestination_cloudWatchLogsDestination :: (Maybe CloudWatchLogsDestination
 -> f (Maybe CloudWatchLogsDestination))
-> EventDestination -> f EventDestination
eventDestination_cloudWatchLogsDestination = (EventDestination -> Maybe CloudWatchLogsDestination)
-> (EventDestination
    -> Maybe CloudWatchLogsDestination -> EventDestination)
-> Lens
     EventDestination
     EventDestination
     (Maybe CloudWatchLogsDestination)
     (Maybe CloudWatchLogsDestination)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDestination' {Maybe CloudWatchLogsDestination
cloudWatchLogsDestination :: Maybe CloudWatchLogsDestination
$sel:cloudWatchLogsDestination:EventDestination' :: EventDestination -> Maybe CloudWatchLogsDestination
cloudWatchLogsDestination} -> Maybe CloudWatchLogsDestination
cloudWatchLogsDestination) (\s :: EventDestination
s@EventDestination' {} Maybe CloudWatchLogsDestination
a -> EventDestination
s {$sel:cloudWatchLogsDestination:EventDestination' :: Maybe CloudWatchLogsDestination
cloudWatchLogsDestination = Maybe CloudWatchLogsDestination
a} :: EventDestination)

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 [EventType]
-> Maybe Bool
-> Maybe KinesisFirehoseDestination
-> Maybe Text
-> Maybe SnsDestination
-> Maybe CloudWatchLogsDestination
-> EventDestination
EventDestination'
            (Maybe [EventType]
 -> Maybe Bool
 -> Maybe KinesisFirehoseDestination
 -> Maybe Text
 -> Maybe SnsDestination
 -> Maybe CloudWatchLogsDestination
 -> EventDestination)
-> Parser (Maybe [EventType])
-> Parser
     (Maybe Bool
      -> Maybe KinesisFirehoseDestination
      -> Maybe Text
      -> Maybe SnsDestination
      -> Maybe CloudWatchLogsDestination
      -> EventDestination)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [EventType]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MatchingEventTypes"
                            Parser (Maybe (Maybe [EventType]))
-> Maybe [EventType] -> Parser (Maybe [EventType])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [EventType]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe Bool
   -> Maybe KinesisFirehoseDestination
   -> Maybe Text
   -> Maybe SnsDestination
   -> Maybe CloudWatchLogsDestination
   -> EventDestination)
-> Parser (Maybe Bool)
-> Parser
     (Maybe KinesisFirehoseDestination
      -> Maybe Text
      -> Maybe SnsDestination
      -> Maybe CloudWatchLogsDestination
      -> 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 Text
   -> Maybe SnsDestination
   -> Maybe CloudWatchLogsDestination
   -> EventDestination)
-> Parser (Maybe KinesisFirehoseDestination)
-> Parser
     (Maybe Text
      -> Maybe SnsDestination
      -> Maybe CloudWatchLogsDestination
      -> 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 Text
   -> Maybe SnsDestination
   -> Maybe CloudWatchLogsDestination
   -> EventDestination)
-> Parser (Maybe Text)
-> Parser
     (Maybe SnsDestination
      -> Maybe CloudWatchLogsDestination -> EventDestination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
            Parser
  (Maybe SnsDestination
   -> Maybe CloudWatchLogsDestination -> EventDestination)
-> Parser (Maybe SnsDestination)
-> Parser (Maybe CloudWatchLogsDestination -> 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 (Maybe CloudWatchLogsDestination -> EventDestination)
-> Parser (Maybe CloudWatchLogsDestination)
-> Parser EventDestination
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CloudWatchLogsDestination)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CloudWatchLogsDestination")
      )

instance Prelude.Hashable EventDestination

instance Prelude.NFData EventDestination