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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(InputLossFailoverSettings -> InputLossFailoverSettings -> Bool)
-> (InputLossFailoverSettings -> InputLossFailoverSettings -> Bool)
-> Eq InputLossFailoverSettings
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]
(Int -> ReadS InputLossFailoverSettings)
-> ReadS [InputLossFailoverSettings]
-> ReadPrec InputLossFailoverSettings
-> ReadPrec [InputLossFailoverSettings]
-> Read 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
(Int -> InputLossFailoverSettings -> ShowS)
-> (InputLossFailoverSettings -> String)
-> ([InputLossFailoverSettings] -> ShowS)
-> Show InputLossFailoverSettings
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.
 InputLossFailoverSettings -> Rep InputLossFailoverSettings x)
-> (forall x.
    Rep InputLossFailoverSettings x -> InputLossFailoverSettings)
-> Generic InputLossFailoverSettings
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' :: Maybe Natural -> InputLossFailoverSettings
InputLossFailoverSettings'
    { $sel:inputLossThresholdMsec:InputLossFailoverSettings' :: Maybe Natural
inputLossThresholdMsec =
        Maybe Natural
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 :: (Maybe Natural -> f (Maybe Natural))
-> InputLossFailoverSettings -> f InputLossFailoverSettings
inputLossFailoverSettings_inputLossThresholdMsec = (InputLossFailoverSettings -> Maybe Natural)
-> (InputLossFailoverSettings
    -> Maybe Natural -> InputLossFailoverSettings)
-> Lens
     InputLossFailoverSettings
     InputLossFailoverSettings
     (Maybe Natural)
     (Maybe Natural)
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 Core.FromJSON InputLossFailoverSettings where
  parseJSON :: Value -> Parser InputLossFailoverSettings
parseJSON =
    String
-> (Object -> Parser InputLossFailoverSettings)
-> Value
-> Parser InputLossFailoverSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputLossFailoverSettings"
      ( \Object
x ->
          Maybe Natural -> InputLossFailoverSettings
InputLossFailoverSettings'
            (Maybe Natural -> InputLossFailoverSettings)
-> Parser (Maybe Natural) -> Parser InputLossFailoverSettings
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
"inputLossThresholdMsec")
      )

instance Prelude.Hashable InputLossFailoverSettings

instance Prelude.NFData InputLossFailoverSettings

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