{-# 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.ChimeSdkVoice.Types.StreamingConfiguration
-- 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.ChimeSdkVoice.Types.StreamingConfiguration where

import Amazonka.ChimeSdkVoice.Types.StreamingNotificationTarget
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | /See:/ 'newStreamingConfiguration' smart constructor.
data StreamingConfiguration = StreamingConfiguration'
  { StreamingConfiguration
-> Maybe (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets :: Prelude.Maybe (Prelude.NonEmpty StreamingNotificationTarget),
    StreamingConfiguration -> Natural
dataRetentionInHours :: Prelude.Natural,
    StreamingConfiguration -> Bool
disabled :: Prelude.Bool
  }
  deriving (StreamingConfiguration -> StreamingConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StreamingConfiguration -> StreamingConfiguration -> Bool
$c/= :: StreamingConfiguration -> StreamingConfiguration -> Bool
== :: StreamingConfiguration -> StreamingConfiguration -> Bool
$c== :: StreamingConfiguration -> StreamingConfiguration -> Bool
Prelude.Eq, ReadPrec [StreamingConfiguration]
ReadPrec StreamingConfiguration
Int -> ReadS StreamingConfiguration
ReadS [StreamingConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StreamingConfiguration]
$creadListPrec :: ReadPrec [StreamingConfiguration]
readPrec :: ReadPrec StreamingConfiguration
$creadPrec :: ReadPrec StreamingConfiguration
readList :: ReadS [StreamingConfiguration]
$creadList :: ReadS [StreamingConfiguration]
readsPrec :: Int -> ReadS StreamingConfiguration
$creadsPrec :: Int -> ReadS StreamingConfiguration
Prelude.Read, Int -> StreamingConfiguration -> ShowS
[StreamingConfiguration] -> ShowS
StreamingConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StreamingConfiguration] -> ShowS
$cshowList :: [StreamingConfiguration] -> ShowS
show :: StreamingConfiguration -> String
$cshow :: StreamingConfiguration -> String
showsPrec :: Int -> StreamingConfiguration -> ShowS
$cshowsPrec :: Int -> StreamingConfiguration -> ShowS
Prelude.Show, forall x. Rep StreamingConfiguration x -> StreamingConfiguration
forall x. StreamingConfiguration -> Rep StreamingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StreamingConfiguration x -> StreamingConfiguration
$cfrom :: forall x. StreamingConfiguration -> Rep StreamingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'StreamingConfiguration' 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:
--
-- 'streamingNotificationTargets', 'streamingConfiguration_streamingNotificationTargets' - Undocumented member.
--
-- 'dataRetentionInHours', 'streamingConfiguration_dataRetentionInHours' - Undocumented member.
--
-- 'disabled', 'streamingConfiguration_disabled' - Undocumented member.
newStreamingConfiguration ::
  -- | 'dataRetentionInHours'
  Prelude.Natural ->
  -- | 'disabled'
  Prelude.Bool ->
  StreamingConfiguration
newStreamingConfiguration :: Natural -> Bool -> StreamingConfiguration
newStreamingConfiguration
  Natural
pDataRetentionInHours_
  Bool
pDisabled_ =
    StreamingConfiguration'
      { $sel:streamingNotificationTargets:StreamingConfiguration' :: Maybe (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets =
          forall a. Maybe a
Prelude.Nothing,
        $sel:dataRetentionInHours:StreamingConfiguration' :: Natural
dataRetentionInHours = Natural
pDataRetentionInHours_,
        $sel:disabled:StreamingConfiguration' :: Bool
disabled = Bool
pDisabled_
      }

-- | Undocumented member.
streamingConfiguration_streamingNotificationTargets :: Lens.Lens' StreamingConfiguration (Prelude.Maybe (Prelude.NonEmpty StreamingNotificationTarget))
streamingConfiguration_streamingNotificationTargets :: Lens'
  StreamingConfiguration
  (Maybe (NonEmpty StreamingNotificationTarget))
streamingConfiguration_streamingNotificationTargets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamingConfiguration' {Maybe (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets :: Maybe (NonEmpty StreamingNotificationTarget)
$sel:streamingNotificationTargets:StreamingConfiguration' :: StreamingConfiguration
-> Maybe (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets} -> Maybe (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets) (\s :: StreamingConfiguration
s@StreamingConfiguration' {} Maybe (NonEmpty StreamingNotificationTarget)
a -> StreamingConfiguration
s {$sel:streamingNotificationTargets:StreamingConfiguration' :: Maybe (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets = Maybe (NonEmpty StreamingNotificationTarget)
a} :: StreamingConfiguration) 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

-- | Undocumented member.
streamingConfiguration_dataRetentionInHours :: Lens.Lens' StreamingConfiguration Prelude.Natural
streamingConfiguration_dataRetentionInHours :: Lens' StreamingConfiguration Natural
streamingConfiguration_dataRetentionInHours = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamingConfiguration' {Natural
dataRetentionInHours :: Natural
$sel:dataRetentionInHours:StreamingConfiguration' :: StreamingConfiguration -> Natural
dataRetentionInHours} -> Natural
dataRetentionInHours) (\s :: StreamingConfiguration
s@StreamingConfiguration' {} Natural
a -> StreamingConfiguration
s {$sel:dataRetentionInHours:StreamingConfiguration' :: Natural
dataRetentionInHours = Natural
a} :: StreamingConfiguration)

-- | Undocumented member.
streamingConfiguration_disabled :: Lens.Lens' StreamingConfiguration Prelude.Bool
streamingConfiguration_disabled :: Lens' StreamingConfiguration Bool
streamingConfiguration_disabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamingConfiguration' {Bool
disabled :: Bool
$sel:disabled:StreamingConfiguration' :: StreamingConfiguration -> Bool
disabled} -> Bool
disabled) (\s :: StreamingConfiguration
s@StreamingConfiguration' {} Bool
a -> StreamingConfiguration
s {$sel:disabled:StreamingConfiguration' :: Bool
disabled = Bool
a} :: StreamingConfiguration)

instance Data.FromJSON StreamingConfiguration where
  parseJSON :: Value -> Parser StreamingConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StreamingConfiguration"
      ( \Object
x ->
          Maybe (NonEmpty StreamingNotificationTarget)
-> Natural -> Bool -> StreamingConfiguration
StreamingConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StreamingNotificationTargets")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DataRetentionInHours")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Disabled")
      )

instance Prelude.Hashable StreamingConfiguration where
  hashWithSalt :: Int -> StreamingConfiguration -> Int
hashWithSalt Int
_salt StreamingConfiguration' {Bool
Natural
Maybe (NonEmpty StreamingNotificationTarget)
disabled :: Bool
dataRetentionInHours :: Natural
streamingNotificationTargets :: Maybe (NonEmpty StreamingNotificationTarget)
$sel:disabled:StreamingConfiguration' :: StreamingConfiguration -> Bool
$sel:dataRetentionInHours:StreamingConfiguration' :: StreamingConfiguration -> Natural
$sel:streamingNotificationTargets:StreamingConfiguration' :: StreamingConfiguration
-> Maybe (NonEmpty StreamingNotificationTarget)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
dataRetentionInHours
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
disabled

instance Prelude.NFData StreamingConfiguration where
  rnf :: StreamingConfiguration -> ()
rnf StreamingConfiguration' {Bool
Natural
Maybe (NonEmpty StreamingNotificationTarget)
disabled :: Bool
dataRetentionInHours :: Natural
streamingNotificationTargets :: Maybe (NonEmpty StreamingNotificationTarget)
$sel:disabled:StreamingConfiguration' :: StreamingConfiguration -> Bool
$sel:dataRetentionInHours:StreamingConfiguration' :: StreamingConfiguration -> Natural
$sel:streamingNotificationTargets:StreamingConfiguration' :: StreamingConfiguration
-> Maybe (NonEmpty StreamingNotificationTarget)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
dataRetentionInHours
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
disabled

instance Data.ToJSON StreamingConfiguration where
  toJSON :: StreamingConfiguration -> Value
toJSON StreamingConfiguration' {Bool
Natural
Maybe (NonEmpty StreamingNotificationTarget)
disabled :: Bool
dataRetentionInHours :: Natural
streamingNotificationTargets :: Maybe (NonEmpty StreamingNotificationTarget)
$sel:disabled:StreamingConfiguration' :: StreamingConfiguration -> Bool
$sel:dataRetentionInHours:StreamingConfiguration' :: StreamingConfiguration -> Natural
$sel:streamingNotificationTargets:StreamingConfiguration' :: StreamingConfiguration
-> Maybe (NonEmpty StreamingNotificationTarget)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"StreamingNotificationTargets" 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 (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets,
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"DataRetentionInHours"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
dataRetentionInHours
              ),
            forall a. a -> Maybe a
Prelude.Just (Key
"Disabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
disabled)
          ]
      )