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

import Amazonka.Chime.Types.StreamingNotificationTarget
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(StreamingConfiguration -> StreamingConfiguration -> Bool)
-> (StreamingConfiguration -> StreamingConfiguration -> Bool)
-> Eq StreamingConfiguration
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]
(Int -> ReadS StreamingConfiguration)
-> ReadS [StreamingConfiguration]
-> ReadPrec StreamingConfiguration
-> ReadPrec [StreamingConfiguration]
-> Read 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
(Int -> StreamingConfiguration -> ShowS)
-> (StreamingConfiguration -> String)
-> ([StreamingConfiguration] -> ShowS)
-> Show StreamingConfiguration
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. StreamingConfiguration -> Rep StreamingConfiguration x)
-> (forall x.
    Rep StreamingConfiguration x -> StreamingConfiguration)
-> Generic StreamingConfiguration
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' :: Maybe Bool
-> Maybe (NonEmpty StreamingNotificationTarget)
-> Natural
-> StreamingConfiguration
StreamingConfiguration'
    { $sel:disabled:StreamingConfiguration' :: Maybe Bool
disabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:streamingNotificationTargets:StreamingConfiguration' :: Maybe (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets = Maybe (NonEmpty StreamingNotificationTarget)
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 :: (Maybe Bool -> f (Maybe Bool))
-> StreamingConfiguration -> f StreamingConfiguration
streamingConfiguration_disabled = (StreamingConfiguration -> Maybe Bool)
-> (StreamingConfiguration -> Maybe Bool -> StreamingConfiguration)
-> Lens
     StreamingConfiguration
     StreamingConfiguration
     (Maybe Bool)
     (Maybe Bool)
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 :: (Maybe (NonEmpty StreamingNotificationTarget)
 -> f (Maybe (NonEmpty StreamingNotificationTarget)))
-> StreamingConfiguration -> f StreamingConfiguration
streamingConfiguration_streamingNotificationTargets = (StreamingConfiguration
 -> Maybe (NonEmpty StreamingNotificationTarget))
-> (StreamingConfiguration
    -> Maybe (NonEmpty StreamingNotificationTarget)
    -> StreamingConfiguration)
-> Lens
     StreamingConfiguration
     StreamingConfiguration
     (Maybe (NonEmpty StreamingNotificationTarget))
     (Maybe (NonEmpty StreamingNotificationTarget))
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) ((Maybe (NonEmpty StreamingNotificationTarget)
  -> f (Maybe (NonEmpty StreamingNotificationTarget)))
 -> StreamingConfiguration -> f StreamingConfiguration)
-> ((Maybe (NonEmpty StreamingNotificationTarget)
     -> f (Maybe (NonEmpty StreamingNotificationTarget)))
    -> Maybe (NonEmpty StreamingNotificationTarget)
    -> f (Maybe (NonEmpty StreamingNotificationTarget)))
-> (Maybe (NonEmpty StreamingNotificationTarget)
    -> f (Maybe (NonEmpty StreamingNotificationTarget)))
-> StreamingConfiguration
-> f StreamingConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty StreamingNotificationTarget)
  (NonEmpty StreamingNotificationTarget)
  (NonEmpty StreamingNotificationTarget)
  (NonEmpty StreamingNotificationTarget)
-> Iso
     (Maybe (NonEmpty StreamingNotificationTarget))
     (Maybe (NonEmpty StreamingNotificationTarget))
     (Maybe (NonEmpty StreamingNotificationTarget))
     (Maybe (NonEmpty StreamingNotificationTarget))
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
  (NonEmpty StreamingNotificationTarget)
  (NonEmpty StreamingNotificationTarget)
  (NonEmpty StreamingNotificationTarget)
  (NonEmpty StreamingNotificationTarget)
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 :: (Natural -> f Natural)
-> StreamingConfiguration -> f StreamingConfiguration
streamingConfiguration_dataRetentionInHours = (StreamingConfiguration -> Natural)
-> (StreamingConfiguration -> Natural -> StreamingConfiguration)
-> Lens
     StreamingConfiguration StreamingConfiguration Natural Natural
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 Core.FromJSON StreamingConfiguration where
  parseJSON :: Value -> Parser StreamingConfiguration
parseJSON =
    String
-> (Object -> Parser StreamingConfiguration)
-> Value
-> Parser StreamingConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StreamingConfiguration"
      ( \Object
x ->
          Maybe Bool
-> Maybe (NonEmpty StreamingNotificationTarget)
-> Natural
-> StreamingConfiguration
StreamingConfiguration'
            (Maybe Bool
 -> Maybe (NonEmpty StreamingNotificationTarget)
 -> Natural
 -> StreamingConfiguration)
-> Parser (Maybe Bool)
-> Parser
     (Maybe (NonEmpty StreamingNotificationTarget)
      -> Natural -> StreamingConfiguration)
forall (f :: * -> *) a b. Functor 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
"Disabled")
            Parser
  (Maybe (NonEmpty StreamingNotificationTarget)
   -> Natural -> StreamingConfiguration)
-> Parser (Maybe (NonEmpty StreamingNotificationTarget))
-> Parser (Natural -> StreamingConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (NonEmpty StreamingNotificationTarget))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StreamingNotificationTargets")
            Parser (Natural -> StreamingConfiguration)
-> Parser Natural -> Parser StreamingConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DataRetentionInHours")
      )

instance Prelude.Hashable StreamingConfiguration

instance Prelude.NFData StreamingConfiguration

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Disabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
disabled,
            (Text
"StreamingNotificationTargets" Text -> NonEmpty StreamingNotificationTarget -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty StreamingNotificationTarget -> Pair)
-> Maybe (NonEmpty StreamingNotificationTarget) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty StreamingNotificationTarget)
streamingNotificationTargets,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"DataRetentionInHours"
                  Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
dataRetentionInHours
              )
          ]
      )