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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(FailoverCondition -> FailoverCondition -> Bool)
-> (FailoverCondition -> FailoverCondition -> Bool)
-> Eq FailoverCondition
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]
(Int -> ReadS FailoverCondition)
-> ReadS [FailoverCondition]
-> ReadPrec FailoverCondition
-> ReadPrec [FailoverCondition]
-> Read 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
(Int -> FailoverCondition -> ShowS)
-> (FailoverCondition -> String)
-> ([FailoverCondition] -> ShowS)
-> Show FailoverCondition
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. FailoverCondition -> Rep FailoverCondition x)
-> (forall x. Rep FailoverCondition x -> FailoverCondition)
-> Generic FailoverCondition
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' :: Maybe FailoverConditionSettings -> FailoverCondition
FailoverCondition'
    { $sel:failoverConditionSettings:FailoverCondition' :: Maybe FailoverConditionSettings
failoverConditionSettings =
        Maybe FailoverConditionSettings
forall a. Maybe a
Prelude.Nothing
    }

-- | Failover condition type-specific settings.
failoverCondition_failoverConditionSettings :: Lens.Lens' FailoverCondition (Prelude.Maybe FailoverConditionSettings)
failoverCondition_failoverConditionSettings :: (Maybe FailoverConditionSettings
 -> f (Maybe FailoverConditionSettings))
-> FailoverCondition -> f FailoverCondition
failoverCondition_failoverConditionSettings = (FailoverCondition -> Maybe FailoverConditionSettings)
-> (FailoverCondition
    -> Maybe FailoverConditionSettings -> FailoverCondition)
-> Lens
     FailoverCondition
     FailoverCondition
     (Maybe FailoverConditionSettings)
     (Maybe 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 Core.FromJSON FailoverCondition where
  parseJSON :: Value -> Parser FailoverCondition
parseJSON =
    String
-> (Object -> Parser FailoverCondition)
-> Value
-> Parser FailoverCondition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FailoverCondition"
      ( \Object
x ->
          Maybe FailoverConditionSettings -> FailoverCondition
FailoverCondition'
            (Maybe FailoverConditionSettings -> FailoverCondition)
-> Parser (Maybe FailoverConditionSettings)
-> Parser FailoverCondition
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FailoverConditionSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"failoverConditionSettings")
      )

instance Prelude.Hashable FailoverCondition

instance Prelude.NFData FailoverCondition

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