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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 content is considered black for the
    -- specified period.
    FailoverConditionSettings -> Maybe VideoBlackFailoverSettings
videoBlackSettings :: Prelude.Maybe VideoBlackFailoverSettings,
    -- | 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 the specified audio selector is
    -- silent for the specified period.
    FailoverConditionSettings -> Maybe AudioSilenceFailoverSettings
audioSilenceSettings :: Prelude.Maybe AudioSilenceFailoverSettings
  }
  deriving (FailoverConditionSettings -> FailoverConditionSettings -> Bool
(FailoverConditionSettings -> FailoverConditionSettings -> Bool)
-> (FailoverConditionSettings -> FailoverConditionSettings -> Bool)
-> Eq FailoverConditionSettings
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]
(Int -> ReadS FailoverConditionSettings)
-> ReadS [FailoverConditionSettings]
-> ReadPrec FailoverConditionSettings
-> ReadPrec [FailoverConditionSettings]
-> Read 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
(Int -> FailoverConditionSettings -> ShowS)
-> (FailoverConditionSettings -> String)
-> ([FailoverConditionSettings] -> ShowS)
-> Show FailoverConditionSettings
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.
 FailoverConditionSettings -> Rep FailoverConditionSettings x)
-> (forall x.
    Rep FailoverConditionSettings x -> FailoverConditionSettings)
-> Generic FailoverConditionSettings
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:
--
-- 'videoBlackSettings', 'failoverConditionSettings_videoBlackSettings' - MediaLive will perform a failover if content is considered black for the
-- specified period.
--
-- 'inputLossSettings', 'failoverConditionSettings_inputLossSettings' - MediaLive will perform a failover if content is not detected in this
-- input for the specified period.
--
-- 'audioSilenceSettings', 'failoverConditionSettings_audioSilenceSettings' - MediaLive will perform a failover if the specified audio selector is
-- silent for the specified period.
newFailoverConditionSettings ::
  FailoverConditionSettings
newFailoverConditionSettings :: FailoverConditionSettings
newFailoverConditionSettings =
  FailoverConditionSettings' :: Maybe VideoBlackFailoverSettings
-> Maybe InputLossFailoverSettings
-> Maybe AudioSilenceFailoverSettings
-> FailoverConditionSettings
FailoverConditionSettings'
    { $sel:videoBlackSettings:FailoverConditionSettings' :: Maybe VideoBlackFailoverSettings
videoBlackSettings =
        Maybe VideoBlackFailoverSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:inputLossSettings:FailoverConditionSettings' :: Maybe InputLossFailoverSettings
inputLossSettings = Maybe InputLossFailoverSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:audioSilenceSettings:FailoverConditionSettings' :: Maybe AudioSilenceFailoverSettings
audioSilenceSettings = Maybe AudioSilenceFailoverSettings
forall a. Maybe a
Prelude.Nothing
    }

-- | MediaLive will perform a failover if content is considered black for the
-- specified period.
failoverConditionSettings_videoBlackSettings :: Lens.Lens' FailoverConditionSettings (Prelude.Maybe VideoBlackFailoverSettings)
failoverConditionSettings_videoBlackSettings :: (Maybe VideoBlackFailoverSettings
 -> f (Maybe VideoBlackFailoverSettings))
-> FailoverConditionSettings -> f FailoverConditionSettings
failoverConditionSettings_videoBlackSettings = (FailoverConditionSettings -> Maybe VideoBlackFailoverSettings)
-> (FailoverConditionSettings
    -> Maybe VideoBlackFailoverSettings -> FailoverConditionSettings)
-> Lens
     FailoverConditionSettings
     FailoverConditionSettings
     (Maybe VideoBlackFailoverSettings)
     (Maybe VideoBlackFailoverSettings)
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)

-- | 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 :: (Maybe InputLossFailoverSettings
 -> f (Maybe InputLossFailoverSettings))
-> FailoverConditionSettings -> f FailoverConditionSettings
failoverConditionSettings_inputLossSettings = (FailoverConditionSettings -> Maybe InputLossFailoverSettings)
-> (FailoverConditionSettings
    -> Maybe InputLossFailoverSettings -> FailoverConditionSettings)
-> Lens
     FailoverConditionSettings
     FailoverConditionSettings
     (Maybe InputLossFailoverSettings)
     (Maybe InputLossFailoverSettings)
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 the specified audio selector is
-- silent for the specified period.
failoverConditionSettings_audioSilenceSettings :: Lens.Lens' FailoverConditionSettings (Prelude.Maybe AudioSilenceFailoverSettings)
failoverConditionSettings_audioSilenceSettings :: (Maybe AudioSilenceFailoverSettings
 -> f (Maybe AudioSilenceFailoverSettings))
-> FailoverConditionSettings -> f FailoverConditionSettings
failoverConditionSettings_audioSilenceSettings = (FailoverConditionSettings -> Maybe AudioSilenceFailoverSettings)
-> (FailoverConditionSettings
    -> Maybe AudioSilenceFailoverSettings -> FailoverConditionSettings)
-> Lens
     FailoverConditionSettings
     FailoverConditionSettings
     (Maybe AudioSilenceFailoverSettings)
     (Maybe AudioSilenceFailoverSettings)
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)

instance Core.FromJSON FailoverConditionSettings where
  parseJSON :: Value -> Parser FailoverConditionSettings
parseJSON =
    String
-> (Object -> Parser FailoverConditionSettings)
-> Value
-> Parser FailoverConditionSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FailoverConditionSettings"
      ( \Object
x ->
          Maybe VideoBlackFailoverSettings
-> Maybe InputLossFailoverSettings
-> Maybe AudioSilenceFailoverSettings
-> FailoverConditionSettings
FailoverConditionSettings'
            (Maybe VideoBlackFailoverSettings
 -> Maybe InputLossFailoverSettings
 -> Maybe AudioSilenceFailoverSettings
 -> FailoverConditionSettings)
-> Parser (Maybe VideoBlackFailoverSettings)
-> Parser
     (Maybe InputLossFailoverSettings
      -> Maybe AudioSilenceFailoverSettings -> FailoverConditionSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe VideoBlackFailoverSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"videoBlackSettings")
            Parser
  (Maybe InputLossFailoverSettings
   -> Maybe AudioSilenceFailoverSettings -> FailoverConditionSettings)
-> Parser (Maybe InputLossFailoverSettings)
-> Parser
     (Maybe AudioSilenceFailoverSettings -> FailoverConditionSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InputLossFailoverSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inputLossSettings")
            Parser
  (Maybe AudioSilenceFailoverSettings -> FailoverConditionSettings)
-> Parser (Maybe AudioSilenceFailoverSettings)
-> Parser FailoverConditionSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AudioSilenceFailoverSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"audioSilenceSettings")
      )

instance Prelude.Hashable FailoverConditionSettings

instance Prelude.NFData FailoverConditionSettings

instance Core.ToJSON FailoverConditionSettings where
  toJSON :: FailoverConditionSettings -> Value
toJSON FailoverConditionSettings' {Maybe AudioSilenceFailoverSettings
Maybe InputLossFailoverSettings
Maybe VideoBlackFailoverSettings
audioSilenceSettings :: Maybe AudioSilenceFailoverSettings
inputLossSettings :: Maybe InputLossFailoverSettings
videoBlackSettings :: Maybe VideoBlackFailoverSettings
$sel:audioSilenceSettings:FailoverConditionSettings' :: FailoverConditionSettings -> Maybe AudioSilenceFailoverSettings
$sel:inputLossSettings:FailoverConditionSettings' :: FailoverConditionSettings -> Maybe InputLossFailoverSettings
$sel:videoBlackSettings:FailoverConditionSettings' :: FailoverConditionSettings -> Maybe VideoBlackFailoverSettings
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"videoBlackSettings" Text -> VideoBlackFailoverSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (VideoBlackFailoverSettings -> Pair)
-> Maybe VideoBlackFailoverSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VideoBlackFailoverSettings
videoBlackSettings,
            (Text
"inputLossSettings" Text -> InputLossFailoverSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (InputLossFailoverSettings -> Pair)
-> Maybe InputLossFailoverSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputLossFailoverSettings
inputLossSettings,
            (Text
"audioSilenceSettings" Text -> AudioSilenceFailoverSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AudioSilenceFailoverSettings -> Pair)
-> Maybe AudioSilenceFailoverSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AudioSilenceFailoverSettings
audioSilenceSettings
          ]
      )