{-# 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.FailoverCondition
-- 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.FailoverCondition 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.FailoverConditionSettings
import qualified Amazonka.Prelude as Prelude

-- | Failover Condition settings. There can be multiple failover conditions
-- inside AutomaticInputFailoverSettings.
--
-- /See:/ 'newFailoverCondition' smart constructor.
data FailoverCondition = FailoverCondition'
  { -- | Failover condition type-specific settings.
    FailoverCondition -> Maybe FailoverConditionSettings
failoverConditionSettings :: Prelude.Maybe FailoverConditionSettings
  }
  deriving (FailoverCondition -> FailoverCondition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailoverCondition -> FailoverCondition -> Bool
$c/= :: FailoverCondition -> FailoverCondition -> Bool
== :: FailoverCondition -> FailoverCondition -> Bool
$c== :: FailoverCondition -> FailoverCondition -> Bool
Prelude.Eq, ReadPrec [FailoverCondition]
ReadPrec FailoverCondition
Int -> ReadS FailoverCondition
ReadS [FailoverCondition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailoverCondition]
$creadListPrec :: ReadPrec [FailoverCondition]
readPrec :: ReadPrec FailoverCondition
$creadPrec :: ReadPrec FailoverCondition
readList :: ReadS [FailoverCondition]
$creadList :: ReadS [FailoverCondition]
readsPrec :: Int -> ReadS FailoverCondition
$creadsPrec :: Int -> ReadS FailoverCondition
Prelude.Read, Int -> FailoverCondition -> ShowS
[FailoverCondition] -> ShowS
FailoverCondition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailoverCondition] -> ShowS
$cshowList :: [FailoverCondition] -> ShowS
show :: FailoverCondition -> String
$cshow :: FailoverCondition -> String
showsPrec :: Int -> FailoverCondition -> ShowS
$cshowsPrec :: Int -> FailoverCondition -> ShowS
Prelude.Show, forall x. Rep FailoverCondition x -> FailoverCondition
forall x. FailoverCondition -> Rep FailoverCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailoverCondition x -> FailoverCondition
$cfrom :: forall x. FailoverCondition -> Rep FailoverCondition x
Prelude.Generic)

-- |
-- Create a value of 'FailoverCondition' 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:
--
-- 'failoverConditionSettings', 'failoverCondition_failoverConditionSettings' - Failover condition type-specific settings.
newFailoverCondition ::
  FailoverCondition
newFailoverCondition :: FailoverCondition
newFailoverCondition =
  FailoverCondition'
    { $sel:failoverConditionSettings:FailoverCondition' :: Maybe FailoverConditionSettings
failoverConditionSettings =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Failover condition type-specific settings.
failoverCondition_failoverConditionSettings :: Lens.Lens' FailoverCondition (Prelude.Maybe FailoverConditionSettings)
failoverCondition_failoverConditionSettings :: Lens' FailoverCondition (Maybe FailoverConditionSettings)
failoverCondition_failoverConditionSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailoverCondition' {Maybe FailoverConditionSettings
failoverConditionSettings :: Maybe FailoverConditionSettings
$sel:failoverConditionSettings:FailoverCondition' :: FailoverCondition -> Maybe FailoverConditionSettings
failoverConditionSettings} -> Maybe FailoverConditionSettings
failoverConditionSettings) (\s :: FailoverCondition
s@FailoverCondition' {} Maybe FailoverConditionSettings
a -> FailoverCondition
s {$sel:failoverConditionSettings:FailoverCondition' :: Maybe FailoverConditionSettings
failoverConditionSettings = Maybe FailoverConditionSettings
a} :: FailoverCondition)

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

instance Prelude.Hashable FailoverCondition where
  hashWithSalt :: Int -> FailoverCondition -> Int
hashWithSalt Int
_salt FailoverCondition' {Maybe FailoverConditionSettings
failoverConditionSettings :: Maybe FailoverConditionSettings
$sel:failoverConditionSettings:FailoverCondition' :: FailoverCondition -> Maybe FailoverConditionSettings
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FailoverConditionSettings
failoverConditionSettings

instance Prelude.NFData FailoverCondition where
  rnf :: FailoverCondition -> ()
rnf FailoverCondition' {Maybe FailoverConditionSettings
failoverConditionSettings :: Maybe FailoverConditionSettings
$sel:failoverConditionSettings:FailoverCondition' :: FailoverCondition -> Maybe FailoverConditionSettings
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FailoverConditionSettings
failoverConditionSettings

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