{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaLive.Types.HlsMediaStoreSettings where

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

-- | Hls Media Store Settings
--
-- /See:/ 'newHlsMediaStoreSettings' smart constructor.
data HlsMediaStoreSettings = HlsMediaStoreSettings'
  { -- | 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,
    -- | 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,
    -- | 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
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]
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
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. 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:
--
-- '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.
--
-- 'numRetries', 'hlsMediaStoreSettings_numRetries' - Number of retry attempts that will be made before the Live Event is put
-- into an error state.
--
-- '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'
    { $sel:connectionRetryInterval:HlsMediaStoreSettings' :: Maybe Natural
connectionRetryInterval =
        forall a. Maybe a
Prelude.Nothing,
      $sel:filecacheDuration:HlsMediaStoreSettings' :: Maybe Natural
filecacheDuration = forall a. Maybe a
Prelude.Nothing,
      $sel:mediaStoreStorageClass:HlsMediaStoreSettings' :: Maybe HlsMediaStoreStorageClass
mediaStoreStorageClass = forall a. Maybe a
Prelude.Nothing,
      $sel:numRetries:HlsMediaStoreSettings' :: Maybe Natural
numRetries = forall a. Maybe a
Prelude.Nothing,
      $sel:restartDelay:HlsMediaStoreSettings' :: Maybe Natural
restartDelay = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' HlsMediaStoreSettings (Maybe Natural)
hlsMediaStoreSettings_connectionRetryInterval = 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 :: Lens' HlsMediaStoreSettings (Maybe Natural)
hlsMediaStoreSettings_filecacheDuration = 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 :: Lens' HlsMediaStoreSettings (Maybe HlsMediaStoreStorageClass)
hlsMediaStoreSettings_mediaStoreStorageClass = 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)

-- | 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 :: Lens' HlsMediaStoreSettings (Maybe Natural)
hlsMediaStoreSettings_numRetries = 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)

-- | 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 :: Lens' HlsMediaStoreSettings (Maybe Natural)
hlsMediaStoreSettings_restartDelay = 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 Data.FromJSON HlsMediaStoreSettings where
  parseJSON :: Value -> Parser HlsMediaStoreSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HlsMediaStoreSettings"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural
-> Maybe HlsMediaStoreStorageClass
-> Maybe Natural
-> Maybe Natural
-> HlsMediaStoreSettings
HlsMediaStoreSettings'
            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
"connectionRetryInterval")
            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
"filecacheDuration")
            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
"mediaStoreStorageClass")
            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
"numRetries")
            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
"restartDelay")
      )

instance Prelude.Hashable HlsMediaStoreSettings where
  hashWithSalt :: Int -> HlsMediaStoreSettings -> Int
hashWithSalt Int
_salt HlsMediaStoreSettings' {Maybe Natural
Maybe HlsMediaStoreStorageClass
restartDelay :: Maybe Natural
numRetries :: Maybe Natural
mediaStoreStorageClass :: Maybe HlsMediaStoreStorageClass
filecacheDuration :: Maybe Natural
connectionRetryInterval :: Maybe Natural
$sel:restartDelay:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
$sel:numRetries:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
$sel:mediaStoreStorageClass:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe HlsMediaStoreStorageClass
$sel:filecacheDuration:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
$sel:connectionRetryInterval:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
connectionRetryInterval
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
filecacheDuration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HlsMediaStoreStorageClass
mediaStoreStorageClass
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
numRetries
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
restartDelay

instance Prelude.NFData HlsMediaStoreSettings where
  rnf :: HlsMediaStoreSettings -> ()
rnf HlsMediaStoreSettings' {Maybe Natural
Maybe HlsMediaStoreStorageClass
restartDelay :: Maybe Natural
numRetries :: Maybe Natural
mediaStoreStorageClass :: Maybe HlsMediaStoreStorageClass
filecacheDuration :: Maybe Natural
connectionRetryInterval :: Maybe Natural
$sel:restartDelay:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
$sel:numRetries:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
$sel:mediaStoreStorageClass:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe HlsMediaStoreStorageClass
$sel:filecacheDuration:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
$sel:connectionRetryInterval:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
connectionRetryInterval
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
filecacheDuration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe HlsMediaStoreStorageClass
mediaStoreStorageClass
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
numRetries
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
restartDelay

instance Data.ToJSON HlsMediaStoreSettings where
  toJSON :: HlsMediaStoreSettings -> Value
toJSON HlsMediaStoreSettings' {Maybe Natural
Maybe HlsMediaStoreStorageClass
restartDelay :: Maybe Natural
numRetries :: Maybe Natural
mediaStoreStorageClass :: Maybe HlsMediaStoreStorageClass
filecacheDuration :: Maybe Natural
connectionRetryInterval :: Maybe Natural
$sel:restartDelay:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
$sel:numRetries:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
$sel:mediaStoreStorageClass:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe HlsMediaStoreStorageClass
$sel:filecacheDuration:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
$sel:connectionRetryInterval:HlsMediaStoreSettings' :: HlsMediaStoreSettings -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"connectionRetryInterval" 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 Natural
connectionRetryInterval,
            (Key
"filecacheDuration" 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 Natural
filecacheDuration,
            (Key
"mediaStoreStorageClass" 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 HlsMediaStoreStorageClass
mediaStoreStorageClass,
            (Key
"numRetries" 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 Natural
numRetries,
            (Key
"restartDelay" 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 Natural
restartDelay
          ]
      )