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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.InputCodec
import Amazonka.MediaLive.Types.InputMaximumBitrate
import Amazonka.MediaLive.Types.InputResolution
import qualified Amazonka.Prelude as Prelude

-- | Placeholder documentation for InputSpecification
--
-- /See:/ 'newInputSpecification' smart constructor.
data InputSpecification = InputSpecification'
  { -- | Input resolution, categorized coarsely
    InputSpecification -> Maybe InputResolution
resolution :: Prelude.Maybe InputResolution,
    -- | Input codec
    InputSpecification -> Maybe InputCodec
codec :: Prelude.Maybe InputCodec,
    -- | Maximum input bitrate, categorized coarsely
    InputSpecification -> Maybe InputMaximumBitrate
maximumBitrate :: Prelude.Maybe InputMaximumBitrate
  }
  deriving (InputSpecification -> InputSpecification -> Bool
(InputSpecification -> InputSpecification -> Bool)
-> (InputSpecification -> InputSpecification -> Bool)
-> Eq InputSpecification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputSpecification -> InputSpecification -> Bool
$c/= :: InputSpecification -> InputSpecification -> Bool
== :: InputSpecification -> InputSpecification -> Bool
$c== :: InputSpecification -> InputSpecification -> Bool
Prelude.Eq, ReadPrec [InputSpecification]
ReadPrec InputSpecification
Int -> ReadS InputSpecification
ReadS [InputSpecification]
(Int -> ReadS InputSpecification)
-> ReadS [InputSpecification]
-> ReadPrec InputSpecification
-> ReadPrec [InputSpecification]
-> Read InputSpecification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputSpecification]
$creadListPrec :: ReadPrec [InputSpecification]
readPrec :: ReadPrec InputSpecification
$creadPrec :: ReadPrec InputSpecification
readList :: ReadS [InputSpecification]
$creadList :: ReadS [InputSpecification]
readsPrec :: Int -> ReadS InputSpecification
$creadsPrec :: Int -> ReadS InputSpecification
Prelude.Read, Int -> InputSpecification -> ShowS
[InputSpecification] -> ShowS
InputSpecification -> String
(Int -> InputSpecification -> ShowS)
-> (InputSpecification -> String)
-> ([InputSpecification] -> ShowS)
-> Show InputSpecification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputSpecification] -> ShowS
$cshowList :: [InputSpecification] -> ShowS
show :: InputSpecification -> String
$cshow :: InputSpecification -> String
showsPrec :: Int -> InputSpecification -> ShowS
$cshowsPrec :: Int -> InputSpecification -> ShowS
Prelude.Show, (forall x. InputSpecification -> Rep InputSpecification x)
-> (forall x. Rep InputSpecification x -> InputSpecification)
-> Generic InputSpecification
forall x. Rep InputSpecification x -> InputSpecification
forall x. InputSpecification -> Rep InputSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputSpecification x -> InputSpecification
$cfrom :: forall x. InputSpecification -> Rep InputSpecification x
Prelude.Generic)

-- |
-- Create a value of 'InputSpecification' 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:
--
-- 'resolution', 'inputSpecification_resolution' - Input resolution, categorized coarsely
--
-- 'codec', 'inputSpecification_codec' - Input codec
--
-- 'maximumBitrate', 'inputSpecification_maximumBitrate' - Maximum input bitrate, categorized coarsely
newInputSpecification ::
  InputSpecification
newInputSpecification :: InputSpecification
newInputSpecification =
  InputSpecification' :: Maybe InputResolution
-> Maybe InputCodec
-> Maybe InputMaximumBitrate
-> InputSpecification
InputSpecification'
    { $sel:resolution:InputSpecification' :: Maybe InputResolution
resolution = Maybe InputResolution
forall a. Maybe a
Prelude.Nothing,
      $sel:codec:InputSpecification' :: Maybe InputCodec
codec = Maybe InputCodec
forall a. Maybe a
Prelude.Nothing,
      $sel:maximumBitrate:InputSpecification' :: Maybe InputMaximumBitrate
maximumBitrate = Maybe InputMaximumBitrate
forall a. Maybe a
Prelude.Nothing
    }

-- | Input resolution, categorized coarsely
inputSpecification_resolution :: Lens.Lens' InputSpecification (Prelude.Maybe InputResolution)
inputSpecification_resolution :: (Maybe InputResolution -> f (Maybe InputResolution))
-> InputSpecification -> f InputSpecification
inputSpecification_resolution = (InputSpecification -> Maybe InputResolution)
-> (InputSpecification
    -> Maybe InputResolution -> InputSpecification)
-> Lens
     InputSpecification
     InputSpecification
     (Maybe InputResolution)
     (Maybe InputResolution)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSpecification' {Maybe InputResolution
resolution :: Maybe InputResolution
$sel:resolution:InputSpecification' :: InputSpecification -> Maybe InputResolution
resolution} -> Maybe InputResolution
resolution) (\s :: InputSpecification
s@InputSpecification' {} Maybe InputResolution
a -> InputSpecification
s {$sel:resolution:InputSpecification' :: Maybe InputResolution
resolution = Maybe InputResolution
a} :: InputSpecification)

-- | Input codec
inputSpecification_codec :: Lens.Lens' InputSpecification (Prelude.Maybe InputCodec)
inputSpecification_codec :: (Maybe InputCodec -> f (Maybe InputCodec))
-> InputSpecification -> f InputSpecification
inputSpecification_codec = (InputSpecification -> Maybe InputCodec)
-> (InputSpecification -> Maybe InputCodec -> InputSpecification)
-> Lens
     InputSpecification
     InputSpecification
     (Maybe InputCodec)
     (Maybe InputCodec)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSpecification' {Maybe InputCodec
codec :: Maybe InputCodec
$sel:codec:InputSpecification' :: InputSpecification -> Maybe InputCodec
codec} -> Maybe InputCodec
codec) (\s :: InputSpecification
s@InputSpecification' {} Maybe InputCodec
a -> InputSpecification
s {$sel:codec:InputSpecification' :: Maybe InputCodec
codec = Maybe InputCodec
a} :: InputSpecification)

-- | Maximum input bitrate, categorized coarsely
inputSpecification_maximumBitrate :: Lens.Lens' InputSpecification (Prelude.Maybe InputMaximumBitrate)
inputSpecification_maximumBitrate :: (Maybe InputMaximumBitrate -> f (Maybe InputMaximumBitrate))
-> InputSpecification -> f InputSpecification
inputSpecification_maximumBitrate = (InputSpecification -> Maybe InputMaximumBitrate)
-> (InputSpecification
    -> Maybe InputMaximumBitrate -> InputSpecification)
-> Lens
     InputSpecification
     InputSpecification
     (Maybe InputMaximumBitrate)
     (Maybe InputMaximumBitrate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSpecification' {Maybe InputMaximumBitrate
maximumBitrate :: Maybe InputMaximumBitrate
$sel:maximumBitrate:InputSpecification' :: InputSpecification -> Maybe InputMaximumBitrate
maximumBitrate} -> Maybe InputMaximumBitrate
maximumBitrate) (\s :: InputSpecification
s@InputSpecification' {} Maybe InputMaximumBitrate
a -> InputSpecification
s {$sel:maximumBitrate:InputSpecification' :: Maybe InputMaximumBitrate
maximumBitrate = Maybe InputMaximumBitrate
a} :: InputSpecification)

instance Core.FromJSON InputSpecification where
  parseJSON :: Value -> Parser InputSpecification
parseJSON =
    String
-> (Object -> Parser InputSpecification)
-> Value
-> Parser InputSpecification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputSpecification"
      ( \Object
x ->
          Maybe InputResolution
-> Maybe InputCodec
-> Maybe InputMaximumBitrate
-> InputSpecification
InputSpecification'
            (Maybe InputResolution
 -> Maybe InputCodec
 -> Maybe InputMaximumBitrate
 -> InputSpecification)
-> Parser (Maybe InputResolution)
-> Parser
     (Maybe InputCodec
      -> Maybe InputMaximumBitrate -> InputSpecification)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe InputResolution)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"resolution")
            Parser
  (Maybe InputCodec
   -> Maybe InputMaximumBitrate -> InputSpecification)
-> Parser (Maybe InputCodec)
-> Parser (Maybe InputMaximumBitrate -> InputSpecification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InputCodec)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"codec")
            Parser (Maybe InputMaximumBitrate -> InputSpecification)
-> Parser (Maybe InputMaximumBitrate) -> Parser InputSpecification
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InputMaximumBitrate)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"maximumBitrate")
      )

instance Prelude.Hashable InputSpecification

instance Prelude.NFData InputSpecification

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