{-# 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.FailoverConditionSettings
-- 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.FailoverConditionSettings 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.AudioSilenceFailoverSettings
import Amazonka.MediaLive.Types.InputLossFailoverSettings
import Amazonka.MediaLive.Types.VideoBlackFailoverSettings
import qualified Amazonka.Prelude as Prelude

-- | Settings for one failover condition.
--
-- /See:/ 'newFailoverConditionSettings' smart constructor.
data FailoverConditionSettings = FailoverConditionSettings'
  { -- | MediaLive will perform a failover if the specified audio selector is
    -- silent for the specified period.
    FailoverConditionSettings -> Maybe AudioSilenceFailoverSettings
audioSilenceSettings :: Prelude.Maybe AudioSilenceFailoverSettings,
    -- | MediaLive will perform a failover if content is not detected in this
    -- input for the specified period.
    FailoverConditionSettings -> Maybe InputLossFailoverSettings
inputLossSettings :: Prelude.Maybe InputLossFailoverSettings,
    -- | MediaLive will perform a failover if content is considered black for the
    -- specified period.
    FailoverConditionSettings -> Maybe VideoBlackFailoverSettings
videoBlackSettings :: Prelude.Maybe VideoBlackFailoverSettings
  }
  deriving (FailoverConditionSettings -> FailoverConditionSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailoverConditionSettings -> FailoverConditionSettings -> Bool
$c/= :: FailoverConditionSettings -> FailoverConditionSettings -> Bool
== :: FailoverConditionSettings -> FailoverConditionSettings -> Bool
$c== :: FailoverConditionSettings -> FailoverConditionSettings -> Bool
Prelude.Eq, ReadPrec [FailoverConditionSettings]
ReadPrec FailoverConditionSettings
Int -> ReadS FailoverConditionSettings
ReadS [FailoverConditionSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailoverConditionSettings]
$creadListPrec :: ReadPrec [FailoverConditionSettings]
readPrec :: ReadPrec FailoverConditionSettings
$creadPrec :: ReadPrec FailoverConditionSettings
readList :: ReadS [FailoverConditionSettings]
$creadList :: ReadS [FailoverConditionSettings]
readsPrec :: Int -> ReadS FailoverConditionSettings
$creadsPrec :: Int -> ReadS FailoverConditionSettings
Prelude.Read, Int -> FailoverConditionSettings -> ShowS
[FailoverConditionSettings] -> ShowS
FailoverConditionSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailoverConditionSettings] -> ShowS
$cshowList :: [FailoverConditionSettings] -> ShowS
show :: FailoverConditionSettings -> String
$cshow :: FailoverConditionSettings -> String
showsPrec :: Int -> FailoverConditionSettings -> ShowS
$cshowsPrec :: Int -> FailoverConditionSettings -> ShowS
Prelude.Show, forall x.
Rep FailoverConditionSettings x -> FailoverConditionSettings
forall x.
FailoverConditionSettings -> Rep FailoverConditionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FailoverConditionSettings x -> FailoverConditionSettings
$cfrom :: forall x.
FailoverConditionSettings -> Rep FailoverConditionSettings x
Prelude.Generic)

-- |
-- Create a value of 'FailoverConditionSettings' 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:
--
-- 'audioSilenceSettings', 'failoverConditionSettings_audioSilenceSettings' - MediaLive will perform a failover if the specified audio selector is
-- silent for the specified period.
--
-- 'inputLossSettings', 'failoverConditionSettings_inputLossSettings' - MediaLive will perform a failover if content is not detected in this
-- input for the specified period.
--
-- 'videoBlackSettings', 'failoverConditionSettings_videoBlackSettings' - MediaLive will perform a failover if content is considered black for the
-- specified period.
newFailoverConditionSettings ::
  FailoverConditionSettings
newFailoverConditionSettings :: FailoverConditionSettings
newFailoverConditionSettings =
  FailoverConditionSettings'
    { $sel:audioSilenceSettings:FailoverConditionSettings' :: Maybe AudioSilenceFailoverSettings
audioSilenceSettings =
        forall a. Maybe a
Prelude.Nothing,
      $sel:inputLossSettings:FailoverConditionSettings' :: Maybe InputLossFailoverSettings
inputLossSettings = forall a. Maybe a
Prelude.Nothing,
      $sel:videoBlackSettings:FailoverConditionSettings' :: Maybe VideoBlackFailoverSettings
videoBlackSettings = forall a. Maybe a
Prelude.Nothing
    }

-- | MediaLive will perform a failover if the specified audio selector is
-- silent for the specified period.
failoverConditionSettings_audioSilenceSettings :: Lens.Lens' FailoverConditionSettings (Prelude.Maybe AudioSilenceFailoverSettings)
failoverConditionSettings_audioSilenceSettings :: Lens'
  FailoverConditionSettings (Maybe AudioSilenceFailoverSettings)
failoverConditionSettings_audioSilenceSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailoverConditionSettings' {Maybe AudioSilenceFailoverSettings
audioSilenceSettings :: Maybe AudioSilenceFailoverSettings
$sel:audioSilenceSettings:FailoverConditionSettings' :: FailoverConditionSettings -> Maybe AudioSilenceFailoverSettings
audioSilenceSettings} -> Maybe AudioSilenceFailoverSettings
audioSilenceSettings) (\s :: FailoverConditionSettings
s@FailoverConditionSettings' {} Maybe AudioSilenceFailoverSettings
a -> FailoverConditionSettings
s {$sel:audioSilenceSettings:FailoverConditionSettings' :: Maybe AudioSilenceFailoverSettings
audioSilenceSettings = Maybe AudioSilenceFailoverSettings
a} :: FailoverConditionSettings)

-- | MediaLive will perform a failover if content is not detected in this
-- input for the specified period.
failoverConditionSettings_inputLossSettings :: Lens.Lens' FailoverConditionSettings (Prelude.Maybe InputLossFailoverSettings)
failoverConditionSettings_inputLossSettings :: Lens' FailoverConditionSettings (Maybe InputLossFailoverSettings)
failoverConditionSettings_inputLossSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailoverConditionSettings' {Maybe InputLossFailoverSettings
inputLossSettings :: Maybe InputLossFailoverSettings
$sel:inputLossSettings:FailoverConditionSettings' :: FailoverConditionSettings -> Maybe InputLossFailoverSettings
inputLossSettings} -> Maybe InputLossFailoverSettings
inputLossSettings) (\s :: FailoverConditionSettings
s@FailoverConditionSettings' {} Maybe InputLossFailoverSettings
a -> FailoverConditionSettings
s {$sel:inputLossSettings:FailoverConditionSettings' :: Maybe InputLossFailoverSettings
inputLossSettings = Maybe InputLossFailoverSettings
a} :: FailoverConditionSettings)

-- | MediaLive will perform a failover if content is considered black for the
-- specified period.
failoverConditionSettings_videoBlackSettings :: Lens.Lens' FailoverConditionSettings (Prelude.Maybe VideoBlackFailoverSettings)
failoverConditionSettings_videoBlackSettings :: Lens' FailoverConditionSettings (Maybe VideoBlackFailoverSettings)
failoverConditionSettings_videoBlackSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailoverConditionSettings' {Maybe VideoBlackFailoverSettings
videoBlackSettings :: Maybe VideoBlackFailoverSettings
$sel:videoBlackSettings:FailoverConditionSettings' :: FailoverConditionSettings -> Maybe VideoBlackFailoverSettings
videoBlackSettings} -> Maybe VideoBlackFailoverSettings
videoBlackSettings) (\s :: FailoverConditionSettings
s@FailoverConditionSettings' {} Maybe VideoBlackFailoverSettings
a -> FailoverConditionSettings
s {$sel:videoBlackSettings:FailoverConditionSettings' :: Maybe VideoBlackFailoverSettings
videoBlackSettings = Maybe VideoBlackFailoverSettings
a} :: FailoverConditionSettings)

instance Data.FromJSON FailoverConditionSettings where
  parseJSON :: Value -> Parser FailoverConditionSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FailoverConditionSettings"
      ( \Object
x ->
          Maybe AudioSilenceFailoverSettings
-> Maybe InputLossFailoverSettings
-> Maybe VideoBlackFailoverSettings
-> FailoverConditionSettings
FailoverConditionSettings'
            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
"audioSilenceSettings")
            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
"inputLossSettings")
            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
"videoBlackSettings")
      )

instance Prelude.Hashable FailoverConditionSettings where
  hashWithSalt :: Int -> FailoverConditionSettings -> Int
hashWithSalt Int
_salt FailoverConditionSettings' {Maybe AudioSilenceFailoverSettings
Maybe InputLossFailoverSettings
Maybe VideoBlackFailoverSettings
videoBlackSettings :: Maybe VideoBlackFailoverSettings
inputLossSettings :: Maybe InputLossFailoverSettings
audioSilenceSettings :: Maybe AudioSilenceFailoverSettings
$sel:videoBlackSettings:FailoverConditionSettings' :: FailoverConditionSettings -> Maybe VideoBlackFailoverSettings
$sel:inputLossSettings:FailoverConditionSettings' :: FailoverConditionSettings -> Maybe InputLossFailoverSettings
$sel:audioSilenceSettings:FailoverConditionSettings' :: FailoverConditionSettings -> Maybe AudioSilenceFailoverSettings
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AudioSilenceFailoverSettings
audioSilenceSettings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InputLossFailoverSettings
inputLossSettings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VideoBlackFailoverSettings
videoBlackSettings

instance Prelude.NFData FailoverConditionSettings where
  rnf :: FailoverConditionSettings -> ()
rnf FailoverConditionSettings' {Maybe AudioSilenceFailoverSettings
Maybe InputLossFailoverSettings
Maybe VideoBlackFailoverSettings
videoBlackSettings :: Maybe VideoBlackFailoverSettings
inputLossSettings :: Maybe InputLossFailoverSettings
audioSilenceSettings :: Maybe AudioSilenceFailoverSettings
$sel:videoBlackSettings:FailoverConditionSettings' :: FailoverConditionSettings -> Maybe VideoBlackFailoverSettings
$sel:inputLossSettings:FailoverConditionSettings' :: FailoverConditionSettings -> Maybe InputLossFailoverSettings
$sel:audioSilenceSettings:FailoverConditionSettings' :: FailoverConditionSettings -> Maybe AudioSilenceFailoverSettings
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AudioSilenceFailoverSettings
audioSilenceSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InputLossFailoverSettings
inputLossSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VideoBlackFailoverSettings
videoBlackSettings

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