{-# 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.MediaLive.Types.HlsMediaStoreSettings
-- 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.MediaLive.Types.HlsMediaStoreSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.HlsMediaStoreStorageClass
import qualified Amazonka.Prelude as Prelude

-- | Hls Media Store Settings
--
-- /See:/ 'newHlsMediaStoreSettings' smart constructor.
data HlsMediaStoreSettings = HlsMediaStoreSettings'
  { -- | Number of retry attempts that will be made before the Live Event is put
    -- into an error state.
    HlsMediaStoreSettings -> Maybe Natural
numRetries :: Prelude.Maybe Prelude.Natural,
    -- | Number of seconds to wait before retrying connection to the CDN if the
    -- connection is lost.
    HlsMediaStoreSettings -> Maybe Natural
connectionRetryInterval :: Prelude.Maybe Prelude.Natural,
    -- | Size in seconds of file cache for streaming outputs.
    HlsMediaStoreSettings -> Maybe Natural
filecacheDuration :: Prelude.Maybe Prelude.Natural,
    -- | When set to temporal, output files are stored in non-persistent memory
    -- for faster reading and writing.
    HlsMediaStoreSettings -> Maybe HlsMediaStoreStorageClass
mediaStoreStorageClass :: Prelude.Maybe HlsMediaStoreStorageClass,
    -- | If a streaming output fails, number of seconds to wait until a restart
    -- is initiated. A value of 0 means never restart.
    HlsMediaStoreSettings -> Maybe Natural
restartDelay :: Prelude.Maybe Prelude.Natural
  }
  deriving (HlsMediaStoreSettings -> HlsMediaStoreSettings -> Bool
(HlsMediaStoreSettings -> HlsMediaStoreSettings -> Bool)
-> (HlsMediaStoreSettings -> HlsMediaStoreSettings -> Bool)
-> Eq HlsMediaStoreSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HlsMediaStoreSettings -> HlsMediaStoreSettings -> Bool
$c/= :: HlsMediaStoreSettings -> HlsMediaStoreSettings -> Bool
== :: HlsMediaStoreSettings -> HlsMediaStoreSettings -> Bool
$c== :: HlsMediaStoreSettings -> HlsMediaStoreSettings -> Bool
Prelude.Eq, ReadPrec [HlsMediaStoreSettings]
ReadPrec HlsMediaStoreSettings
Int -> ReadS HlsMediaStoreSettings
ReadS [HlsMediaStoreSettings]
(Int -> ReadS HlsMediaStoreSettings)
-> ReadS [HlsMediaStoreSettings]
-> ReadPrec HlsMediaStoreSettings
-> ReadPrec [HlsMediaStoreSettings]
-> Read HlsMediaStoreSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HlsMediaStoreSettings]
$creadListPrec :: ReadPrec [HlsMediaStoreSettings]
readPrec :: ReadPrec HlsMediaStoreSettings
$creadPrec :: ReadPrec HlsMediaStoreSettings
readList :: ReadS [HlsMediaStoreSettings]
$creadList :: ReadS [HlsMediaStoreSettings]
readsPrec :: Int -> ReadS HlsMediaStoreSettings
$creadsPrec :: Int -> ReadS HlsMediaStoreSettings
Prelude.Read, Int -> HlsMediaStoreSettings -> ShowS
[HlsMediaStoreSettings] -> ShowS
HlsMediaStoreSettings -> String
(Int -> HlsMediaStoreSettings -> ShowS)
-> (HlsMediaStoreSettings -> String)
-> ([HlsMediaStoreSettings] -> ShowS)
-> Show HlsMediaStoreSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HlsMediaStoreSettings] -> ShowS
$cshowList :: [HlsMediaStoreSettings] -> ShowS
show :: HlsMediaStoreSettings -> String
$cshow :: HlsMediaStoreSettings -> String
showsPrec :: Int -> HlsMediaStoreSettings -> ShowS
$cshowsPrec :: Int -> HlsMediaStoreSettings -> ShowS
Prelude.Show, (forall x. HlsMediaStoreSettings -> Rep HlsMediaStoreSettings x)
-> (forall x. Rep HlsMediaStoreSettings x -> HlsMediaStoreSettings)
-> Generic HlsMediaStoreSettings
forall x. Rep HlsMediaStoreSettings x -> HlsMediaStoreSettings
forall x. HlsMediaStoreSettings -> Rep HlsMediaStoreSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HlsMediaStoreSettings x -> HlsMediaStoreSettings
$cfrom :: forall x. HlsMediaStoreSettings -> Rep HlsMediaStoreSettings x
Prelude.Generic)

-- |
-- Create a value of 'HlsMediaStoreSettings' 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:
--
-- 'numRetries', 'hlsMediaStoreSettings_numRetries' - Number of retry attempts that will be made before the Live Event is put
-- into an error state.
--
-- 'connectionRetryInterval', 'hlsMediaStoreSettings_connectionRetryInterval' - Number of seconds to wait before retrying connection to the CDN if the
-- connection is lost.
--
-- 'filecacheDuration', 'hlsMediaStoreSettings_filecacheDuration' - Size in seconds of file cache for streaming outputs.
--
-- 'mediaStoreStorageClass', 'hlsMediaStoreSettings_mediaStoreStorageClass' - When set to temporal, output files are stored in non-persistent memory
-- for faster reading and writing.
--
-- 'restartDelay', 'hlsMediaStoreSettings_restartDelay' - If a streaming output fails, number of seconds to wait until a restart
-- is initiated. A value of 0 means never restart.
newHlsMediaStoreSettings ::
  HlsMediaStoreSettings
newHlsMediaStoreSettings :: HlsMediaStoreSettings
newHlsMediaStoreSettings =
  HlsMediaStoreSettings' :: Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe HlsMediaStoreStorageClass
-> Maybe Natural
-> HlsMediaStoreSettings
HlsMediaStoreSettings'
    { $sel:numRetries:HlsMediaStoreSettings' :: Maybe Natural
numRetries =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionRetryInterval:HlsMediaStoreSettings' :: Maybe Natural
connectionRetryInterval = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:filecacheDuration:HlsMediaStoreSettings' :: Maybe Natural
filecacheDuration = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:mediaStoreStorageClass:HlsMediaStoreSettings' :: Maybe HlsMediaStoreStorageClass
mediaStoreStorageClass = Maybe HlsMediaStoreStorageClass
forall a. Maybe a
Prelude.Nothing,
      $sel:restartDelay:HlsMediaStoreSettings' :: Maybe Natural
restartDelay = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Number of retry attempts that will be made before the Live Event is put
-- into an error state.
hlsMediaStoreSettings_numRetries :: Lens.Lens' HlsMediaStoreSettings (Prelude.Maybe Prelude.Natural)
hlsMediaStoreSettings_numRetries :: (Maybe Natural -> f (Maybe Natural))
-> HlsMediaStoreSettings -> f HlsMediaStoreSettings
hlsMediaStoreSettings_numRetries = (HlsMediaStoreSettings -> Maybe Natural)
-> (HlsMediaStoreSettings
    -> Maybe Natural -> HlsMediaStoreSettings)
-> Lens
     HlsMediaStoreSettings
     HlsMediaStoreSettings
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsMediaStoreSettings' {Maybe Natural
numRetries :: Maybe Natural
$sel:numRetries:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
numRetries} -> Maybe Natural
numRetries) (\s :: HlsMediaStoreSettings
s@HlsMediaStoreSettings' {} Maybe Natural
a -> HlsMediaStoreSettings
s {$sel:numRetries:HlsMediaStoreSettings' :: Maybe Natural
numRetries = Maybe Natural
a} :: HlsMediaStoreSettings)

-- | Number of seconds to wait before retrying connection to the CDN if the
-- connection is lost.
hlsMediaStoreSettings_connectionRetryInterval :: Lens.Lens' HlsMediaStoreSettings (Prelude.Maybe Prelude.Natural)
hlsMediaStoreSettings_connectionRetryInterval :: (Maybe Natural -> f (Maybe Natural))
-> HlsMediaStoreSettings -> f HlsMediaStoreSettings
hlsMediaStoreSettings_connectionRetryInterval = (HlsMediaStoreSettings -> Maybe Natural)
-> (HlsMediaStoreSettings
    -> Maybe Natural -> HlsMediaStoreSettings)
-> Lens
     HlsMediaStoreSettings
     HlsMediaStoreSettings
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsMediaStoreSettings' {Maybe Natural
connectionRetryInterval :: Maybe Natural
$sel:connectionRetryInterval:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
connectionRetryInterval} -> Maybe Natural
connectionRetryInterval) (\s :: HlsMediaStoreSettings
s@HlsMediaStoreSettings' {} Maybe Natural
a -> HlsMediaStoreSettings
s {$sel:connectionRetryInterval:HlsMediaStoreSettings' :: Maybe Natural
connectionRetryInterval = Maybe Natural
a} :: HlsMediaStoreSettings)

-- | Size in seconds of file cache for streaming outputs.
hlsMediaStoreSettings_filecacheDuration :: Lens.Lens' HlsMediaStoreSettings (Prelude.Maybe Prelude.Natural)
hlsMediaStoreSettings_filecacheDuration :: (Maybe Natural -> f (Maybe Natural))
-> HlsMediaStoreSettings -> f HlsMediaStoreSettings
hlsMediaStoreSettings_filecacheDuration = (HlsMediaStoreSettings -> Maybe Natural)
-> (HlsMediaStoreSettings
    -> Maybe Natural -> HlsMediaStoreSettings)
-> Lens
     HlsMediaStoreSettings
     HlsMediaStoreSettings
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsMediaStoreSettings' {Maybe Natural
filecacheDuration :: Maybe Natural
$sel:filecacheDuration:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
filecacheDuration} -> Maybe Natural
filecacheDuration) (\s :: HlsMediaStoreSettings
s@HlsMediaStoreSettings' {} Maybe Natural
a -> HlsMediaStoreSettings
s {$sel:filecacheDuration:HlsMediaStoreSettings' :: Maybe Natural
filecacheDuration = Maybe Natural
a} :: HlsMediaStoreSettings)

-- | When set to temporal, output files are stored in non-persistent memory
-- for faster reading and writing.
hlsMediaStoreSettings_mediaStoreStorageClass :: Lens.Lens' HlsMediaStoreSettings (Prelude.Maybe HlsMediaStoreStorageClass)
hlsMediaStoreSettings_mediaStoreStorageClass :: (Maybe HlsMediaStoreStorageClass
 -> f (Maybe HlsMediaStoreStorageClass))
-> HlsMediaStoreSettings -> f HlsMediaStoreSettings
hlsMediaStoreSettings_mediaStoreStorageClass = (HlsMediaStoreSettings -> Maybe HlsMediaStoreStorageClass)
-> (HlsMediaStoreSettings
    -> Maybe HlsMediaStoreStorageClass -> HlsMediaStoreSettings)
-> Lens
     HlsMediaStoreSettings
     HlsMediaStoreSettings
     (Maybe HlsMediaStoreStorageClass)
     (Maybe HlsMediaStoreStorageClass)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsMediaStoreSettings' {Maybe HlsMediaStoreStorageClass
mediaStoreStorageClass :: Maybe HlsMediaStoreStorageClass
$sel:mediaStoreStorageClass:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe HlsMediaStoreStorageClass
mediaStoreStorageClass} -> Maybe HlsMediaStoreStorageClass
mediaStoreStorageClass) (\s :: HlsMediaStoreSettings
s@HlsMediaStoreSettings' {} Maybe HlsMediaStoreStorageClass
a -> HlsMediaStoreSettings
s {$sel:mediaStoreStorageClass:HlsMediaStoreSettings' :: Maybe HlsMediaStoreStorageClass
mediaStoreStorageClass = Maybe HlsMediaStoreStorageClass
a} :: HlsMediaStoreSettings)

-- | If a streaming output fails, number of seconds to wait until a restart
-- is initiated. A value of 0 means never restart.
hlsMediaStoreSettings_restartDelay :: Lens.Lens' HlsMediaStoreSettings (Prelude.Maybe Prelude.Natural)
hlsMediaStoreSettings_restartDelay :: (Maybe Natural -> f (Maybe Natural))
-> HlsMediaStoreSettings -> f HlsMediaStoreSettings
hlsMediaStoreSettings_restartDelay = (HlsMediaStoreSettings -> Maybe Natural)
-> (HlsMediaStoreSettings
    -> Maybe Natural -> HlsMediaStoreSettings)
-> Lens
     HlsMediaStoreSettings
     HlsMediaStoreSettings
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsMediaStoreSettings' {Maybe Natural
restartDelay :: Maybe Natural
$sel:restartDelay:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
restartDelay} -> Maybe Natural
restartDelay) (\s :: HlsMediaStoreSettings
s@HlsMediaStoreSettings' {} Maybe Natural
a -> HlsMediaStoreSettings
s {$sel:restartDelay:HlsMediaStoreSettings' :: Maybe Natural
restartDelay = Maybe Natural
a} :: HlsMediaStoreSettings)

instance Core.FromJSON HlsMediaStoreSettings where
  parseJSON :: Value -> Parser HlsMediaStoreSettings
parseJSON =
    String
-> (Object -> Parser HlsMediaStoreSettings)
-> Value
-> Parser HlsMediaStoreSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HlsMediaStoreSettings"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe HlsMediaStoreStorageClass
-> Maybe Natural
-> HlsMediaStoreSettings
HlsMediaStoreSettings'
            (Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe HlsMediaStoreStorageClass
 -> Maybe Natural
 -> HlsMediaStoreSettings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural
      -> Maybe HlsMediaStoreStorageClass
      -> Maybe Natural
      -> HlsMediaStoreSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"numRetries")
            Parser
  (Maybe Natural
   -> Maybe Natural
   -> Maybe HlsMediaStoreStorageClass
   -> Maybe Natural
   -> HlsMediaStoreSettings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe HlsMediaStoreStorageClass
      -> Maybe Natural
      -> HlsMediaStoreSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"connectionRetryInterval")
            Parser
  (Maybe Natural
   -> Maybe HlsMediaStoreStorageClass
   -> Maybe Natural
   -> HlsMediaStoreSettings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe HlsMediaStoreStorageClass
      -> Maybe Natural -> HlsMediaStoreSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"filecacheDuration")
            Parser
  (Maybe HlsMediaStoreStorageClass
   -> Maybe Natural -> HlsMediaStoreSettings)
-> Parser (Maybe HlsMediaStoreStorageClass)
-> Parser (Maybe Natural -> HlsMediaStoreSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HlsMediaStoreStorageClass)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"mediaStoreStorageClass")
            Parser (Maybe Natural -> HlsMediaStoreSettings)
-> Parser (Maybe Natural) -> Parser HlsMediaStoreSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"restartDelay")
      )

instance Prelude.Hashable HlsMediaStoreSettings

instance Prelude.NFData HlsMediaStoreSettings

instance Core.ToJSON HlsMediaStoreSettings where
  toJSON :: HlsMediaStoreSettings -> Value
toJSON HlsMediaStoreSettings' {Maybe Natural
Maybe HlsMediaStoreStorageClass
restartDelay :: Maybe Natural
mediaStoreStorageClass :: Maybe HlsMediaStoreStorageClass
filecacheDuration :: Maybe Natural
connectionRetryInterval :: Maybe Natural
numRetries :: Maybe Natural
$sel:restartDelay:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
$sel:mediaStoreStorageClass:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe HlsMediaStoreStorageClass
$sel:filecacheDuration:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
$sel:connectionRetryInterval:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
$sel:numRetries:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"numRetries" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
numRetries,
            (Text
"connectionRetryInterval" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
connectionRetryInterval,
            (Text
"filecacheDuration" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
filecacheDuration,
            (Text
"mediaStoreStorageClass" Text -> HlsMediaStoreStorageClass -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HlsMediaStoreStorageClass -> Pair)
-> Maybe HlsMediaStoreStorageClass -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HlsMediaStoreStorageClass
mediaStoreStorageClass,
            (Text
"restartDelay" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
restartDelay
          ]
      )