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

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

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

-- |
-- Create a value of 'VideoSelectorPid' 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', 'videoSelectorPid_pid' - Selects a specific PID from within a video source.
newVideoSelectorPid ::
  VideoSelectorPid
newVideoSelectorPid :: VideoSelectorPid
newVideoSelectorPid =
  VideoSelectorPid' :: Maybe Natural -> VideoSelectorPid
VideoSelectorPid' {$sel:pid:VideoSelectorPid' :: Maybe Natural
pid = Maybe Natural
forall a. Maybe a
Prelude.Nothing}

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

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

instance Prelude.Hashable VideoSelectorPid

instance Prelude.NFData VideoSelectorPid

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