{-# 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.KinesisVideo.Types.LocalSizeConfig
-- 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.KinesisVideo.Types.LocalSizeConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KinesisVideo.Types.StrategyOnFullSize
import qualified Amazonka.Prelude as Prelude

-- | The configuration details that include the maximum size of the media
-- (@MaxLocalMediaSizeInMB@) that you want to store for a stream on the
-- Edge Agent, as well as the strategy that should be used
-- (@StrategyOnFullSize@) when a stream\'s maximum size has been reached.
--
-- /See:/ 'newLocalSizeConfig' smart constructor.
data LocalSizeConfig = LocalSizeConfig'
  { -- | The overall maximum size of the media that you want to store for a
    -- stream on the Edge Agent.
    LocalSizeConfig -> Maybe Natural
maxLocalMediaSizeInMB :: Prelude.Maybe Prelude.Natural,
    -- | The strategy to perform when a stream’s @MaxLocalMediaSizeInMB@ limit is
    -- reached.
    LocalSizeConfig -> Maybe StrategyOnFullSize
strategyOnFullSize :: Prelude.Maybe StrategyOnFullSize
  }
  deriving (LocalSizeConfig -> LocalSizeConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LocalSizeConfig -> LocalSizeConfig -> Bool
$c/= :: LocalSizeConfig -> LocalSizeConfig -> Bool
== :: LocalSizeConfig -> LocalSizeConfig -> Bool
$c== :: LocalSizeConfig -> LocalSizeConfig -> Bool
Prelude.Eq, ReadPrec [LocalSizeConfig]
ReadPrec LocalSizeConfig
Int -> ReadS LocalSizeConfig
ReadS [LocalSizeConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LocalSizeConfig]
$creadListPrec :: ReadPrec [LocalSizeConfig]
readPrec :: ReadPrec LocalSizeConfig
$creadPrec :: ReadPrec LocalSizeConfig
readList :: ReadS [LocalSizeConfig]
$creadList :: ReadS [LocalSizeConfig]
readsPrec :: Int -> ReadS LocalSizeConfig
$creadsPrec :: Int -> ReadS LocalSizeConfig
Prelude.Read, Int -> LocalSizeConfig -> ShowS
[LocalSizeConfig] -> ShowS
LocalSizeConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LocalSizeConfig] -> ShowS
$cshowList :: [LocalSizeConfig] -> ShowS
show :: LocalSizeConfig -> String
$cshow :: LocalSizeConfig -> String
showsPrec :: Int -> LocalSizeConfig -> ShowS
$cshowsPrec :: Int -> LocalSizeConfig -> ShowS
Prelude.Show, forall x. Rep LocalSizeConfig x -> LocalSizeConfig
forall x. LocalSizeConfig -> Rep LocalSizeConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LocalSizeConfig x -> LocalSizeConfig
$cfrom :: forall x. LocalSizeConfig -> Rep LocalSizeConfig x
Prelude.Generic)

-- |
-- Create a value of 'LocalSizeConfig' 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:
--
-- 'maxLocalMediaSizeInMB', 'localSizeConfig_maxLocalMediaSizeInMB' - The overall maximum size of the media that you want to store for a
-- stream on the Edge Agent.
--
-- 'strategyOnFullSize', 'localSizeConfig_strategyOnFullSize' - The strategy to perform when a stream’s @MaxLocalMediaSizeInMB@ limit is
-- reached.
newLocalSizeConfig ::
  LocalSizeConfig
newLocalSizeConfig :: LocalSizeConfig
newLocalSizeConfig =
  LocalSizeConfig'
    { $sel:maxLocalMediaSizeInMB:LocalSizeConfig' :: Maybe Natural
maxLocalMediaSizeInMB =
        forall a. Maybe a
Prelude.Nothing,
      $sel:strategyOnFullSize:LocalSizeConfig' :: Maybe StrategyOnFullSize
strategyOnFullSize = forall a. Maybe a
Prelude.Nothing
    }

-- | The overall maximum size of the media that you want to store for a
-- stream on the Edge Agent.
localSizeConfig_maxLocalMediaSizeInMB :: Lens.Lens' LocalSizeConfig (Prelude.Maybe Prelude.Natural)
localSizeConfig_maxLocalMediaSizeInMB :: Lens' LocalSizeConfig (Maybe Natural)
localSizeConfig_maxLocalMediaSizeInMB = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocalSizeConfig' {Maybe Natural
maxLocalMediaSizeInMB :: Maybe Natural
$sel:maxLocalMediaSizeInMB:LocalSizeConfig' :: LocalSizeConfig -> Maybe Natural
maxLocalMediaSizeInMB} -> Maybe Natural
maxLocalMediaSizeInMB) (\s :: LocalSizeConfig
s@LocalSizeConfig' {} Maybe Natural
a -> LocalSizeConfig
s {$sel:maxLocalMediaSizeInMB:LocalSizeConfig' :: Maybe Natural
maxLocalMediaSizeInMB = Maybe Natural
a} :: LocalSizeConfig)

-- | The strategy to perform when a stream’s @MaxLocalMediaSizeInMB@ limit is
-- reached.
localSizeConfig_strategyOnFullSize :: Lens.Lens' LocalSizeConfig (Prelude.Maybe StrategyOnFullSize)
localSizeConfig_strategyOnFullSize :: Lens' LocalSizeConfig (Maybe StrategyOnFullSize)
localSizeConfig_strategyOnFullSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocalSizeConfig' {Maybe StrategyOnFullSize
strategyOnFullSize :: Maybe StrategyOnFullSize
$sel:strategyOnFullSize:LocalSizeConfig' :: LocalSizeConfig -> Maybe StrategyOnFullSize
strategyOnFullSize} -> Maybe StrategyOnFullSize
strategyOnFullSize) (\s :: LocalSizeConfig
s@LocalSizeConfig' {} Maybe StrategyOnFullSize
a -> LocalSizeConfig
s {$sel:strategyOnFullSize:LocalSizeConfig' :: Maybe StrategyOnFullSize
strategyOnFullSize = Maybe StrategyOnFullSize
a} :: LocalSizeConfig)

instance Data.FromJSON LocalSizeConfig where
  parseJSON :: Value -> Parser LocalSizeConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LocalSizeConfig"
      ( \Object
x ->
          Maybe Natural -> Maybe StrategyOnFullSize -> LocalSizeConfig
LocalSizeConfig'
            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
"MaxLocalMediaSizeInMB")
            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
"StrategyOnFullSize")
      )

instance Prelude.Hashable LocalSizeConfig where
  hashWithSalt :: Int -> LocalSizeConfig -> Int
hashWithSalt Int
_salt LocalSizeConfig' {Maybe Natural
Maybe StrategyOnFullSize
strategyOnFullSize :: Maybe StrategyOnFullSize
maxLocalMediaSizeInMB :: Maybe Natural
$sel:strategyOnFullSize:LocalSizeConfig' :: LocalSizeConfig -> Maybe StrategyOnFullSize
$sel:maxLocalMediaSizeInMB:LocalSizeConfig' :: LocalSizeConfig -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxLocalMediaSizeInMB
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StrategyOnFullSize
strategyOnFullSize

instance Prelude.NFData LocalSizeConfig where
  rnf :: LocalSizeConfig -> ()
rnf LocalSizeConfig' {Maybe Natural
Maybe StrategyOnFullSize
strategyOnFullSize :: Maybe StrategyOnFullSize
maxLocalMediaSizeInMB :: Maybe Natural
$sel:strategyOnFullSize:LocalSizeConfig' :: LocalSizeConfig -> Maybe StrategyOnFullSize
$sel:maxLocalMediaSizeInMB:LocalSizeConfig' :: LocalSizeConfig -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxLocalMediaSizeInMB
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StrategyOnFullSize
strategyOnFullSize

instance Data.ToJSON LocalSizeConfig where
  toJSON :: LocalSizeConfig -> Value
toJSON LocalSizeConfig' {Maybe Natural
Maybe StrategyOnFullSize
strategyOnFullSize :: Maybe StrategyOnFullSize
maxLocalMediaSizeInMB :: Maybe Natural
$sel:strategyOnFullSize:LocalSizeConfig' :: LocalSizeConfig -> Maybe StrategyOnFullSize
$sel:maxLocalMediaSizeInMB:LocalSizeConfig' :: LocalSizeConfig -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxLocalMediaSizeInMB" 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
maxLocalMediaSizeInMB,
            (Key
"StrategyOnFullSize" 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 StrategyOnFullSize
strategyOnFullSize
          ]
      )