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

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

-- | Audio Pid Selection
--
-- /See:/ 'newAudioPidSelection' smart constructor.
data AudioPidSelection = AudioPidSelection'
  { -- | Selects a specific PID from within a source.
    AudioPidSelection -> Natural
pid :: Prelude.Natural
  }
  deriving (AudioPidSelection -> AudioPidSelection -> Bool
(AudioPidSelection -> AudioPidSelection -> Bool)
-> (AudioPidSelection -> AudioPidSelection -> Bool)
-> Eq AudioPidSelection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AudioPidSelection -> AudioPidSelection -> Bool
$c/= :: AudioPidSelection -> AudioPidSelection -> Bool
== :: AudioPidSelection -> AudioPidSelection -> Bool
$c== :: AudioPidSelection -> AudioPidSelection -> Bool
Prelude.Eq, ReadPrec [AudioPidSelection]
ReadPrec AudioPidSelection
Int -> ReadS AudioPidSelection
ReadS [AudioPidSelection]
(Int -> ReadS AudioPidSelection)
-> ReadS [AudioPidSelection]
-> ReadPrec AudioPidSelection
-> ReadPrec [AudioPidSelection]
-> Read AudioPidSelection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AudioPidSelection]
$creadListPrec :: ReadPrec [AudioPidSelection]
readPrec :: ReadPrec AudioPidSelection
$creadPrec :: ReadPrec AudioPidSelection
readList :: ReadS [AudioPidSelection]
$creadList :: ReadS [AudioPidSelection]
readsPrec :: Int -> ReadS AudioPidSelection
$creadsPrec :: Int -> ReadS AudioPidSelection
Prelude.Read, Int -> AudioPidSelection -> ShowS
[AudioPidSelection] -> ShowS
AudioPidSelection -> String
(Int -> AudioPidSelection -> ShowS)
-> (AudioPidSelection -> String)
-> ([AudioPidSelection] -> ShowS)
-> Show AudioPidSelection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AudioPidSelection] -> ShowS
$cshowList :: [AudioPidSelection] -> ShowS
show :: AudioPidSelection -> String
$cshow :: AudioPidSelection -> String
showsPrec :: Int -> AudioPidSelection -> ShowS
$cshowsPrec :: Int -> AudioPidSelection -> ShowS
Prelude.Show, (forall x. AudioPidSelection -> Rep AudioPidSelection x)
-> (forall x. Rep AudioPidSelection x -> AudioPidSelection)
-> Generic AudioPidSelection
forall x. Rep AudioPidSelection x -> AudioPidSelection
forall x. AudioPidSelection -> Rep AudioPidSelection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AudioPidSelection x -> AudioPidSelection
$cfrom :: forall x. AudioPidSelection -> Rep AudioPidSelection x
Prelude.Generic)

-- |
-- Create a value of 'AudioPidSelection' 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:
--
-- 'pid', 'audioPidSelection_pid' - Selects a specific PID from within a source.
newAudioPidSelection ::
  -- | 'pid'
  Prelude.Natural ->
  AudioPidSelection
newAudioPidSelection :: Natural -> AudioPidSelection
newAudioPidSelection Natural
pPid_ =
  AudioPidSelection' :: Natural -> AudioPidSelection
AudioPidSelection' {$sel:pid:AudioPidSelection' :: Natural
pid = Natural
pPid_}

-- | Selects a specific PID from within a source.
audioPidSelection_pid :: Lens.Lens' AudioPidSelection Prelude.Natural
audioPidSelection_pid :: (Natural -> f Natural) -> AudioPidSelection -> f AudioPidSelection
audioPidSelection_pid = (AudioPidSelection -> Natural)
-> (AudioPidSelection -> Natural -> AudioPidSelection)
-> Lens AudioPidSelection AudioPidSelection Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioPidSelection' {Natural
pid :: Natural
$sel:pid:AudioPidSelection' :: AudioPidSelection -> Natural
pid} -> Natural
pid) (\s :: AudioPidSelection
s@AudioPidSelection' {} Natural
a -> AudioPidSelection
s {$sel:pid:AudioPidSelection' :: Natural
pid = Natural
a} :: AudioPidSelection)

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

instance Prelude.Hashable AudioPidSelection

instance Prelude.NFData AudioPidSelection

instance Core.ToJSON AudioPidSelection where
  toJSON :: AudioPidSelection -> Value
toJSON AudioPidSelection' {Natural
pid :: Natural
$sel:pid:AudioPidSelection' :: AudioPidSelection -> Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"pid" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
pid)]
      )