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

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

-- | MediaLive will perform a failover if content is not detected in this
-- input for the specified period.
--
-- /See:/ 'newInputLossFailoverSettings' smart constructor.
data InputLossFailoverSettings = InputLossFailoverSettings'
  { -- | The amount of time (in milliseconds) that no input is detected. After
    -- that time, an input failover will occur.
    InputLossFailoverSettings -> Maybe Natural
inputLossThresholdMsec :: Prelude.Maybe Prelude.Natural
  }
  deriving (InputLossFailoverSettings -> InputLossFailoverSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputLossFailoverSettings -> InputLossFailoverSettings -> Bool
$c/= :: InputLossFailoverSettings -> InputLossFailoverSettings -> Bool
== :: InputLossFailoverSettings -> InputLossFailoverSettings -> Bool
$c== :: InputLossFailoverSettings -> InputLossFailoverSettings -> Bool
Prelude.Eq, ReadPrec [InputLossFailoverSettings]
ReadPrec InputLossFailoverSettings
Int -> ReadS InputLossFailoverSettings
ReadS [InputLossFailoverSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputLossFailoverSettings]
$creadListPrec :: ReadPrec [InputLossFailoverSettings]
readPrec :: ReadPrec InputLossFailoverSettings
$creadPrec :: ReadPrec InputLossFailoverSettings
readList :: ReadS [InputLossFailoverSettings]
$creadList :: ReadS [InputLossFailoverSettings]
readsPrec :: Int -> ReadS InputLossFailoverSettings
$creadsPrec :: Int -> ReadS InputLossFailoverSettings
Prelude.Read, Int -> InputLossFailoverSettings -> ShowS
[InputLossFailoverSettings] -> ShowS
InputLossFailoverSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputLossFailoverSettings] -> ShowS
$cshowList :: [InputLossFailoverSettings] -> ShowS
show :: InputLossFailoverSettings -> String
$cshow :: InputLossFailoverSettings -> String
showsPrec :: Int -> InputLossFailoverSettings -> ShowS
$cshowsPrec :: Int -> InputLossFailoverSettings -> ShowS
Prelude.Show, forall x.
Rep InputLossFailoverSettings x -> InputLossFailoverSettings
forall x.
InputLossFailoverSettings -> Rep InputLossFailoverSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InputLossFailoverSettings x -> InputLossFailoverSettings
$cfrom :: forall x.
InputLossFailoverSettings -> Rep InputLossFailoverSettings x
Prelude.Generic)

-- |
-- Create a value of 'InputLossFailoverSettings' 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:
--
-- 'inputLossThresholdMsec', 'inputLossFailoverSettings_inputLossThresholdMsec' - The amount of time (in milliseconds) that no input is detected. After
-- that time, an input failover will occur.
newInputLossFailoverSettings ::
  InputLossFailoverSettings
newInputLossFailoverSettings :: InputLossFailoverSettings
newInputLossFailoverSettings =
  InputLossFailoverSettings'
    { $sel:inputLossThresholdMsec:InputLossFailoverSettings' :: Maybe Natural
inputLossThresholdMsec =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The amount of time (in milliseconds) that no input is detected. After
-- that time, an input failover will occur.
inputLossFailoverSettings_inputLossThresholdMsec :: Lens.Lens' InputLossFailoverSettings (Prelude.Maybe Prelude.Natural)
inputLossFailoverSettings_inputLossThresholdMsec :: Lens' InputLossFailoverSettings (Maybe Natural)
inputLossFailoverSettings_inputLossThresholdMsec = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputLossFailoverSettings' {Maybe Natural
inputLossThresholdMsec :: Maybe Natural
$sel:inputLossThresholdMsec:InputLossFailoverSettings' :: InputLossFailoverSettings -> Maybe Natural
inputLossThresholdMsec} -> Maybe Natural
inputLossThresholdMsec) (\s :: InputLossFailoverSettings
s@InputLossFailoverSettings' {} Maybe Natural
a -> InputLossFailoverSettings
s {$sel:inputLossThresholdMsec:InputLossFailoverSettings' :: Maybe Natural
inputLossThresholdMsec = Maybe Natural
a} :: InputLossFailoverSettings)

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

instance Prelude.Hashable InputLossFailoverSettings where
  hashWithSalt :: Int -> InputLossFailoverSettings -> Int
hashWithSalt Int
_salt InputLossFailoverSettings' {Maybe Natural
inputLossThresholdMsec :: Maybe Natural
$sel:inputLossThresholdMsec:InputLossFailoverSettings' :: InputLossFailoverSettings -> Maybe Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
inputLossThresholdMsec

instance Prelude.NFData InputLossFailoverSettings where
  rnf :: InputLossFailoverSettings -> ()
rnf InputLossFailoverSettings' {Maybe Natural
inputLossThresholdMsec :: Maybe Natural
$sel:inputLossThresholdMsec:InputLossFailoverSettings' :: InputLossFailoverSettings -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
inputLossThresholdMsec

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