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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The priority you want to assign to a source. You can have a primary
-- stream and a backup stream or two equally prioritized streams.
--
-- /See:/ 'newSourcePriority' smart constructor.
data SourcePriority = SourcePriority'
  { -- | The name of the source you choose as the primary source for this flow.
    SourcePriority -> Maybe Text
primarySource :: Prelude.Maybe Prelude.Text
  }
  deriving (SourcePriority -> SourcePriority -> Bool
(SourcePriority -> SourcePriority -> Bool)
-> (SourcePriority -> SourcePriority -> Bool) -> Eq SourcePriority
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourcePriority -> SourcePriority -> Bool
$c/= :: SourcePriority -> SourcePriority -> Bool
== :: SourcePriority -> SourcePriority -> Bool
$c== :: SourcePriority -> SourcePriority -> Bool
Prelude.Eq, ReadPrec [SourcePriority]
ReadPrec SourcePriority
Int -> ReadS SourcePriority
ReadS [SourcePriority]
(Int -> ReadS SourcePriority)
-> ReadS [SourcePriority]
-> ReadPrec SourcePriority
-> ReadPrec [SourcePriority]
-> Read SourcePriority
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourcePriority]
$creadListPrec :: ReadPrec [SourcePriority]
readPrec :: ReadPrec SourcePriority
$creadPrec :: ReadPrec SourcePriority
readList :: ReadS [SourcePriority]
$creadList :: ReadS [SourcePriority]
readsPrec :: Int -> ReadS SourcePriority
$creadsPrec :: Int -> ReadS SourcePriority
Prelude.Read, Int -> SourcePriority -> ShowS
[SourcePriority] -> ShowS
SourcePriority -> String
(Int -> SourcePriority -> ShowS)
-> (SourcePriority -> String)
-> ([SourcePriority] -> ShowS)
-> Show SourcePriority
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourcePriority] -> ShowS
$cshowList :: [SourcePriority] -> ShowS
show :: SourcePriority -> String
$cshow :: SourcePriority -> String
showsPrec :: Int -> SourcePriority -> ShowS
$cshowsPrec :: Int -> SourcePriority -> ShowS
Prelude.Show, (forall x. SourcePriority -> Rep SourcePriority x)
-> (forall x. Rep SourcePriority x -> SourcePriority)
-> Generic SourcePriority
forall x. Rep SourcePriority x -> SourcePriority
forall x. SourcePriority -> Rep SourcePriority x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourcePriority x -> SourcePriority
$cfrom :: forall x. SourcePriority -> Rep SourcePriority x
Prelude.Generic)

-- |
-- Create a value of 'SourcePriority' 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:
--
-- 'primarySource', 'sourcePriority_primarySource' - The name of the source you choose as the primary source for this flow.
newSourcePriority ::
  SourcePriority
newSourcePriority :: SourcePriority
newSourcePriority =
  SourcePriority' :: Maybe Text -> SourcePriority
SourcePriority' {$sel:primarySource:SourcePriority' :: Maybe Text
primarySource = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The name of the source you choose as the primary source for this flow.
sourcePriority_primarySource :: Lens.Lens' SourcePriority (Prelude.Maybe Prelude.Text)
sourcePriority_primarySource :: (Maybe Text -> f (Maybe Text))
-> SourcePriority -> f SourcePriority
sourcePriority_primarySource = (SourcePriority -> Maybe Text)
-> (SourcePriority -> Maybe Text -> SourcePriority)
-> Lens SourcePriority SourcePriority (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourcePriority' {Maybe Text
primarySource :: Maybe Text
$sel:primarySource:SourcePriority' :: SourcePriority -> Maybe Text
primarySource} -> Maybe Text
primarySource) (\s :: SourcePriority
s@SourcePriority' {} Maybe Text
a -> SourcePriority
s {$sel:primarySource:SourcePriority' :: Maybe Text
primarySource = Maybe Text
a} :: SourcePriority)

instance Core.FromJSON SourcePriority where
  parseJSON :: Value -> Parser SourcePriority
parseJSON =
    String
-> (Object -> Parser SourcePriority)
-> Value
-> Parser SourcePriority
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SourcePriority"
      ( \Object
x ->
          Maybe Text -> SourcePriority
SourcePriority'
            (Maybe Text -> SourcePriority)
-> Parser (Maybe Text) -> Parser SourcePriority
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"primarySource")
      )

instance Prelude.Hashable SourcePriority

instance Prelude.NFData SourcePriority

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