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

import Amazonka.Chime.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

-- | The streaming configuration associated with an Amazon Chime Voice
-- Connector. Specifies whether media streaming is enabled for sending to
-- Amazon Kinesis, and shows the retention period for the Amazon Kinesis
-- data, in hours.
--
-- /See:/ 'newStreamingConfiguration' smart constructor.
data StreamingConfiguration = StreamingConfiguration'
  { -- | When true, media streaming to Amazon Kinesis is turned off.
    StreamingConfiguration -> Maybe Bool
disabled :: Prelude.Maybe Prelude.Bool,
    -- | The streaming notification targets.
    StreamingConfiguration
-> Maybe (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets :: Prelude.Maybe (Prelude.NonEmpty StreamingNotificationTarget),
    -- | The retention period, in hours, for the Amazon Kinesis data.
    StreamingConfiguration -> Natural
dataRetentionInHours :: Prelude.Natural
  }
  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:
--
-- 'disabled', 'streamingConfiguration_disabled' - When true, media streaming to Amazon Kinesis is turned off.
--
-- 'streamingNotificationTargets', 'streamingConfiguration_streamingNotificationTargets' - The streaming notification targets.
--
-- 'dataRetentionInHours', 'streamingConfiguration_dataRetentionInHours' - The retention period, in hours, for the Amazon Kinesis data.
newStreamingConfiguration ::
  -- | 'dataRetentionInHours'
  Prelude.Natural ->
  StreamingConfiguration
newStreamingConfiguration :: Natural -> StreamingConfiguration
newStreamingConfiguration Natural
pDataRetentionInHours_ =
  StreamingConfiguration'
    { $sel:disabled:StreamingConfiguration' :: Maybe Bool
disabled = forall a. Maybe a
Prelude.Nothing,
      $sel:streamingNotificationTargets:StreamingConfiguration' :: Maybe (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets = forall a. Maybe a
Prelude.Nothing,
      $sel:dataRetentionInHours:StreamingConfiguration' :: Natural
dataRetentionInHours = Natural
pDataRetentionInHours_
    }

-- | When true, media streaming to Amazon Kinesis is turned off.
streamingConfiguration_disabled :: Lens.Lens' StreamingConfiguration (Prelude.Maybe Prelude.Bool)
streamingConfiguration_disabled :: Lens' StreamingConfiguration (Maybe Bool)
streamingConfiguration_disabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamingConfiguration' {Maybe Bool
disabled :: Maybe Bool
$sel:disabled:StreamingConfiguration' :: StreamingConfiguration -> Maybe Bool
disabled} -> Maybe Bool
disabled) (\s :: StreamingConfiguration
s@StreamingConfiguration' {} Maybe Bool
a -> StreamingConfiguration
s {$sel:disabled:StreamingConfiguration' :: Maybe Bool
disabled = Maybe Bool
a} :: StreamingConfiguration)

-- | The streaming notification targets.
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

-- | The retention period, in hours, for the Amazon Kinesis data.
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)

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 Bool
-> Maybe (NonEmpty StreamingNotificationTarget)
-> Natural
-> 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
"Disabled")
            forall (f :: * -> *) a b. Applicative f => 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")
      )

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

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

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