{-# 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.Chime.Types.StreamingNotificationTarget
-- 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.Chime.Types.StreamingNotificationTarget where

import Amazonka.Chime.Types.NotificationTarget
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The targeted recipient for a streaming configuration notification.
--
-- /See:/ 'newStreamingNotificationTarget' smart constructor.
data StreamingNotificationTarget = StreamingNotificationTarget'
  { -- | The streaming notification target.
    StreamingNotificationTarget -> NotificationTarget
notificationTarget :: NotificationTarget
  }
  deriving (StreamingNotificationTarget -> StreamingNotificationTarget -> Bool
(StreamingNotificationTarget
 -> StreamingNotificationTarget -> Bool)
-> (StreamingNotificationTarget
    -> StreamingNotificationTarget -> Bool)
-> Eq StreamingNotificationTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StreamingNotificationTarget -> StreamingNotificationTarget -> Bool
$c/= :: StreamingNotificationTarget -> StreamingNotificationTarget -> Bool
== :: StreamingNotificationTarget -> StreamingNotificationTarget -> Bool
$c== :: StreamingNotificationTarget -> StreamingNotificationTarget -> Bool
Prelude.Eq, ReadPrec [StreamingNotificationTarget]
ReadPrec StreamingNotificationTarget
Int -> ReadS StreamingNotificationTarget
ReadS [StreamingNotificationTarget]
(Int -> ReadS StreamingNotificationTarget)
-> ReadS [StreamingNotificationTarget]
-> ReadPrec StreamingNotificationTarget
-> ReadPrec [StreamingNotificationTarget]
-> Read StreamingNotificationTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StreamingNotificationTarget]
$creadListPrec :: ReadPrec [StreamingNotificationTarget]
readPrec :: ReadPrec StreamingNotificationTarget
$creadPrec :: ReadPrec StreamingNotificationTarget
readList :: ReadS [StreamingNotificationTarget]
$creadList :: ReadS [StreamingNotificationTarget]
readsPrec :: Int -> ReadS StreamingNotificationTarget
$creadsPrec :: Int -> ReadS StreamingNotificationTarget
Prelude.Read, Int -> StreamingNotificationTarget -> ShowS
[StreamingNotificationTarget] -> ShowS
StreamingNotificationTarget -> String
(Int -> StreamingNotificationTarget -> ShowS)
-> (StreamingNotificationTarget -> String)
-> ([StreamingNotificationTarget] -> ShowS)
-> Show StreamingNotificationTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StreamingNotificationTarget] -> ShowS
$cshowList :: [StreamingNotificationTarget] -> ShowS
show :: StreamingNotificationTarget -> String
$cshow :: StreamingNotificationTarget -> String
showsPrec :: Int -> StreamingNotificationTarget -> ShowS
$cshowsPrec :: Int -> StreamingNotificationTarget -> ShowS
Prelude.Show, (forall x.
 StreamingNotificationTarget -> Rep StreamingNotificationTarget x)
-> (forall x.
    Rep StreamingNotificationTarget x -> StreamingNotificationTarget)
-> Generic StreamingNotificationTarget
forall x.
Rep StreamingNotificationTarget x -> StreamingNotificationTarget
forall x.
StreamingNotificationTarget -> Rep StreamingNotificationTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StreamingNotificationTarget x -> StreamingNotificationTarget
$cfrom :: forall x.
StreamingNotificationTarget -> Rep StreamingNotificationTarget x
Prelude.Generic)

-- |
-- Create a value of 'StreamingNotificationTarget' 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:
--
-- 'notificationTarget', 'streamingNotificationTarget_notificationTarget' - The streaming notification target.
newStreamingNotificationTarget ::
  -- | 'notificationTarget'
  NotificationTarget ->
  StreamingNotificationTarget
newStreamingNotificationTarget :: NotificationTarget -> StreamingNotificationTarget
newStreamingNotificationTarget NotificationTarget
pNotificationTarget_ =
  StreamingNotificationTarget' :: NotificationTarget -> StreamingNotificationTarget
StreamingNotificationTarget'
    { $sel:notificationTarget:StreamingNotificationTarget' :: NotificationTarget
notificationTarget =
        NotificationTarget
pNotificationTarget_
    }

-- | The streaming notification target.
streamingNotificationTarget_notificationTarget :: Lens.Lens' StreamingNotificationTarget NotificationTarget
streamingNotificationTarget_notificationTarget :: (NotificationTarget -> f NotificationTarget)
-> StreamingNotificationTarget -> f StreamingNotificationTarget
streamingNotificationTarget_notificationTarget = (StreamingNotificationTarget -> NotificationTarget)
-> (StreamingNotificationTarget
    -> NotificationTarget -> StreamingNotificationTarget)
-> Lens
     StreamingNotificationTarget
     StreamingNotificationTarget
     NotificationTarget
     NotificationTarget
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamingNotificationTarget' {NotificationTarget
notificationTarget :: NotificationTarget
$sel:notificationTarget:StreamingNotificationTarget' :: StreamingNotificationTarget -> NotificationTarget
notificationTarget} -> NotificationTarget
notificationTarget) (\s :: StreamingNotificationTarget
s@StreamingNotificationTarget' {} NotificationTarget
a -> StreamingNotificationTarget
s {$sel:notificationTarget:StreamingNotificationTarget' :: NotificationTarget
notificationTarget = NotificationTarget
a} :: StreamingNotificationTarget)

instance Core.FromJSON StreamingNotificationTarget where
  parseJSON :: Value -> Parser StreamingNotificationTarget
parseJSON =
    String
-> (Object -> Parser StreamingNotificationTarget)
-> Value
-> Parser StreamingNotificationTarget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StreamingNotificationTarget"
      ( \Object
x ->
          NotificationTarget -> StreamingNotificationTarget
StreamingNotificationTarget'
            (NotificationTarget -> StreamingNotificationTarget)
-> Parser NotificationTarget -> Parser StreamingNotificationTarget
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser NotificationTarget
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"NotificationTarget")
      )

instance Prelude.Hashable StreamingNotificationTarget

instance Prelude.NFData StreamingNotificationTarget

instance Core.ToJSON StreamingNotificationTarget where
  toJSON :: StreamingNotificationTarget -> Value
toJSON StreamingNotificationTarget' {NotificationTarget
notificationTarget :: NotificationTarget
$sel:notificationTarget:StreamingNotificationTarget' :: StreamingNotificationTarget -> NotificationTarget
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"NotificationTarget" Text -> NotificationTarget -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NotificationTarget
notificationTarget)
          ]
      )