{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaConnect.Types.SourcePriority where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$sel:primarySource:SourcePriority' :: Maybe Text
primarySource = 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 :: Lens' SourcePriority (Maybe Text)
sourcePriority_primarySource = 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 Data.FromJSON SourcePriority where
  parseJSON :: Value -> Parser SourcePriority
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SourcePriority"
      ( \Object
x ->
          Maybe Text -> SourcePriority
SourcePriority'
            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
"primarySource")
      )

instance Prelude.Hashable SourcePriority where
  hashWithSalt :: Int -> SourcePriority -> Int
hashWithSalt Int
_salt SourcePriority' {Maybe Text
primarySource :: Maybe Text
$sel:primarySource:SourcePriority' :: SourcePriority -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
primarySource

instance Prelude.NFData SourcePriority where
  rnf :: SourcePriority -> ()
rnf SourcePriority' {Maybe Text
primarySource :: Maybe Text
$sel:primarySource:SourcePriority' :: SourcePriority -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
primarySource

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