{-# 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.MediaConnect.Types.UpdateFailoverConfig
-- 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.MediaConnect.Types.UpdateFailoverConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaConnect.Types.FailoverMode
import Amazonka.MediaConnect.Types.SourcePriority
import Amazonka.MediaConnect.Types.State
import qualified Amazonka.Prelude as Prelude

-- | The settings for source failover
--
-- /See:/ 'newUpdateFailoverConfig' smart constructor.
data UpdateFailoverConfig = UpdateFailoverConfig'
  { UpdateFailoverConfig -> Maybe State
state :: Prelude.Maybe State,
    -- | Recovery window time to look for dash-7 packets
    UpdateFailoverConfig -> Maybe Int
recoveryWindow :: Prelude.Maybe Prelude.Int,
    -- | The priority you want to assign to a source. You can have a primary
    -- stream and a backup stream or two equally prioritized streams.
    UpdateFailoverConfig -> Maybe SourcePriority
sourcePriority :: Prelude.Maybe SourcePriority,
    -- | The type of failover you choose for this flow. MERGE combines the source
    -- streams into a single stream, allowing graceful recovery from any
    -- single-source loss. FAILOVER allows switching between different streams.
    UpdateFailoverConfig -> Maybe FailoverMode
failoverMode :: Prelude.Maybe FailoverMode
  }
  deriving (UpdateFailoverConfig -> UpdateFailoverConfig -> Bool
(UpdateFailoverConfig -> UpdateFailoverConfig -> Bool)
-> (UpdateFailoverConfig -> UpdateFailoverConfig -> Bool)
-> Eq UpdateFailoverConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateFailoverConfig -> UpdateFailoverConfig -> Bool
$c/= :: UpdateFailoverConfig -> UpdateFailoverConfig -> Bool
== :: UpdateFailoverConfig -> UpdateFailoverConfig -> Bool
$c== :: UpdateFailoverConfig -> UpdateFailoverConfig -> Bool
Prelude.Eq, ReadPrec [UpdateFailoverConfig]
ReadPrec UpdateFailoverConfig
Int -> ReadS UpdateFailoverConfig
ReadS [UpdateFailoverConfig]
(Int -> ReadS UpdateFailoverConfig)
-> ReadS [UpdateFailoverConfig]
-> ReadPrec UpdateFailoverConfig
-> ReadPrec [UpdateFailoverConfig]
-> Read UpdateFailoverConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateFailoverConfig]
$creadListPrec :: ReadPrec [UpdateFailoverConfig]
readPrec :: ReadPrec UpdateFailoverConfig
$creadPrec :: ReadPrec UpdateFailoverConfig
readList :: ReadS [UpdateFailoverConfig]
$creadList :: ReadS [UpdateFailoverConfig]
readsPrec :: Int -> ReadS UpdateFailoverConfig
$creadsPrec :: Int -> ReadS UpdateFailoverConfig
Prelude.Read, Int -> UpdateFailoverConfig -> ShowS
[UpdateFailoverConfig] -> ShowS
UpdateFailoverConfig -> String
(Int -> UpdateFailoverConfig -> ShowS)
-> (UpdateFailoverConfig -> String)
-> ([UpdateFailoverConfig] -> ShowS)
-> Show UpdateFailoverConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateFailoverConfig] -> ShowS
$cshowList :: [UpdateFailoverConfig] -> ShowS
show :: UpdateFailoverConfig -> String
$cshow :: UpdateFailoverConfig -> String
showsPrec :: Int -> UpdateFailoverConfig -> ShowS
$cshowsPrec :: Int -> UpdateFailoverConfig -> ShowS
Prelude.Show, (forall x. UpdateFailoverConfig -> Rep UpdateFailoverConfig x)
-> (forall x. Rep UpdateFailoverConfig x -> UpdateFailoverConfig)
-> Generic UpdateFailoverConfig
forall x. Rep UpdateFailoverConfig x -> UpdateFailoverConfig
forall x. UpdateFailoverConfig -> Rep UpdateFailoverConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateFailoverConfig x -> UpdateFailoverConfig
$cfrom :: forall x. UpdateFailoverConfig -> Rep UpdateFailoverConfig x
Prelude.Generic)

-- |
-- Create a value of 'UpdateFailoverConfig' 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:
--
-- 'state', 'updateFailoverConfig_state' - Undocumented member.
--
-- 'recoveryWindow', 'updateFailoverConfig_recoveryWindow' - Recovery window time to look for dash-7 packets
--
-- 'sourcePriority', 'updateFailoverConfig_sourcePriority' - The priority you want to assign to a source. You can have a primary
-- stream and a backup stream or two equally prioritized streams.
--
-- 'failoverMode', 'updateFailoverConfig_failoverMode' - The type of failover you choose for this flow. MERGE combines the source
-- streams into a single stream, allowing graceful recovery from any
-- single-source loss. FAILOVER allows switching between different streams.
newUpdateFailoverConfig ::
  UpdateFailoverConfig
newUpdateFailoverConfig :: UpdateFailoverConfig
newUpdateFailoverConfig =
  UpdateFailoverConfig' :: Maybe State
-> Maybe Int
-> Maybe SourcePriority
-> Maybe FailoverMode
-> UpdateFailoverConfig
UpdateFailoverConfig'
    { $sel:state:UpdateFailoverConfig' :: Maybe State
state = Maybe State
forall a. Maybe a
Prelude.Nothing,
      $sel:recoveryWindow:UpdateFailoverConfig' :: Maybe Int
recoveryWindow = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:sourcePriority:UpdateFailoverConfig' :: Maybe SourcePriority
sourcePriority = Maybe SourcePriority
forall a. Maybe a
Prelude.Nothing,
      $sel:failoverMode:UpdateFailoverConfig' :: Maybe FailoverMode
failoverMode = Maybe FailoverMode
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
updateFailoverConfig_state :: Lens.Lens' UpdateFailoverConfig (Prelude.Maybe State)
updateFailoverConfig_state :: (Maybe State -> f (Maybe State))
-> UpdateFailoverConfig -> f UpdateFailoverConfig
updateFailoverConfig_state = (UpdateFailoverConfig -> Maybe State)
-> (UpdateFailoverConfig -> Maybe State -> UpdateFailoverConfig)
-> Lens
     UpdateFailoverConfig
     UpdateFailoverConfig
     (Maybe State)
     (Maybe State)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFailoverConfig' {Maybe State
state :: Maybe State
$sel:state:UpdateFailoverConfig' :: UpdateFailoverConfig -> Maybe State
state} -> Maybe State
state) (\s :: UpdateFailoverConfig
s@UpdateFailoverConfig' {} Maybe State
a -> UpdateFailoverConfig
s {$sel:state:UpdateFailoverConfig' :: Maybe State
state = Maybe State
a} :: UpdateFailoverConfig)

-- | Recovery window time to look for dash-7 packets
updateFailoverConfig_recoveryWindow :: Lens.Lens' UpdateFailoverConfig (Prelude.Maybe Prelude.Int)
updateFailoverConfig_recoveryWindow :: (Maybe Int -> f (Maybe Int))
-> UpdateFailoverConfig -> f UpdateFailoverConfig
updateFailoverConfig_recoveryWindow = (UpdateFailoverConfig -> Maybe Int)
-> (UpdateFailoverConfig -> Maybe Int -> UpdateFailoverConfig)
-> Lens
     UpdateFailoverConfig UpdateFailoverConfig (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFailoverConfig' {Maybe Int
recoveryWindow :: Maybe Int
$sel:recoveryWindow:UpdateFailoverConfig' :: UpdateFailoverConfig -> Maybe Int
recoveryWindow} -> Maybe Int
recoveryWindow) (\s :: UpdateFailoverConfig
s@UpdateFailoverConfig' {} Maybe Int
a -> UpdateFailoverConfig
s {$sel:recoveryWindow:UpdateFailoverConfig' :: Maybe Int
recoveryWindow = Maybe Int
a} :: UpdateFailoverConfig)

-- | The priority you want to assign to a source. You can have a primary
-- stream and a backup stream or two equally prioritized streams.
updateFailoverConfig_sourcePriority :: Lens.Lens' UpdateFailoverConfig (Prelude.Maybe SourcePriority)
updateFailoverConfig_sourcePriority :: (Maybe SourcePriority -> f (Maybe SourcePriority))
-> UpdateFailoverConfig -> f UpdateFailoverConfig
updateFailoverConfig_sourcePriority = (UpdateFailoverConfig -> Maybe SourcePriority)
-> (UpdateFailoverConfig
    -> Maybe SourcePriority -> UpdateFailoverConfig)
-> Lens
     UpdateFailoverConfig
     UpdateFailoverConfig
     (Maybe SourcePriority)
     (Maybe SourcePriority)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFailoverConfig' {Maybe SourcePriority
sourcePriority :: Maybe SourcePriority
$sel:sourcePriority:UpdateFailoverConfig' :: UpdateFailoverConfig -> Maybe SourcePriority
sourcePriority} -> Maybe SourcePriority
sourcePriority) (\s :: UpdateFailoverConfig
s@UpdateFailoverConfig' {} Maybe SourcePriority
a -> UpdateFailoverConfig
s {$sel:sourcePriority:UpdateFailoverConfig' :: Maybe SourcePriority
sourcePriority = Maybe SourcePriority
a} :: UpdateFailoverConfig)

-- | The type of failover you choose for this flow. MERGE combines the source
-- streams into a single stream, allowing graceful recovery from any
-- single-source loss. FAILOVER allows switching between different streams.
updateFailoverConfig_failoverMode :: Lens.Lens' UpdateFailoverConfig (Prelude.Maybe FailoverMode)
updateFailoverConfig_failoverMode :: (Maybe FailoverMode -> f (Maybe FailoverMode))
-> UpdateFailoverConfig -> f UpdateFailoverConfig
updateFailoverConfig_failoverMode = (UpdateFailoverConfig -> Maybe FailoverMode)
-> (UpdateFailoverConfig
    -> Maybe FailoverMode -> UpdateFailoverConfig)
-> Lens
     UpdateFailoverConfig
     UpdateFailoverConfig
     (Maybe FailoverMode)
     (Maybe FailoverMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFailoverConfig' {Maybe FailoverMode
failoverMode :: Maybe FailoverMode
$sel:failoverMode:UpdateFailoverConfig' :: UpdateFailoverConfig -> Maybe FailoverMode
failoverMode} -> Maybe FailoverMode
failoverMode) (\s :: UpdateFailoverConfig
s@UpdateFailoverConfig' {} Maybe FailoverMode
a -> UpdateFailoverConfig
s {$sel:failoverMode:UpdateFailoverConfig' :: Maybe FailoverMode
failoverMode = Maybe FailoverMode
a} :: UpdateFailoverConfig)

instance Prelude.Hashable UpdateFailoverConfig

instance Prelude.NFData UpdateFailoverConfig

instance Core.ToJSON UpdateFailoverConfig where
  toJSON :: UpdateFailoverConfig -> Value
toJSON UpdateFailoverConfig' {Maybe Int
Maybe FailoverMode
Maybe SourcePriority
Maybe State
failoverMode :: Maybe FailoverMode
sourcePriority :: Maybe SourcePriority
recoveryWindow :: Maybe Int
state :: Maybe State
$sel:failoverMode:UpdateFailoverConfig' :: UpdateFailoverConfig -> Maybe FailoverMode
$sel:sourcePriority:UpdateFailoverConfig' :: UpdateFailoverConfig -> Maybe SourcePriority
$sel:recoveryWindow:UpdateFailoverConfig' :: UpdateFailoverConfig -> Maybe Int
$sel:state:UpdateFailoverConfig' :: UpdateFailoverConfig -> Maybe State
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"state" Text -> State -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (State -> Pair) -> Maybe State -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe State
state,
            (Text
"recoveryWindow" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
recoveryWindow,
            (Text
"sourcePriority" Text -> SourcePriority -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SourcePriority -> Pair) -> Maybe SourcePriority -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SourcePriority
sourcePriority,
            (Text
"failoverMode" Text -> FailoverMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FailoverMode -> Pair) -> Maybe FailoverMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FailoverMode
failoverMode
          ]
      )