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

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

-- | Input Channel Level
--
-- /See:/ 'newInputChannelLevel' smart constructor.
data InputChannelLevel = InputChannelLevel'
  { -- | The index of the input channel used as a source.
    InputChannelLevel -> Natural
inputChannel :: Prelude.Natural,
    -- | Remixing value. Units are in dB and acceptable values are within the
    -- range from -60 (mute) and 6 dB.
    InputChannelLevel -> Int
gain :: Prelude.Int
  }
  deriving (InputChannelLevel -> InputChannelLevel -> Bool
(InputChannelLevel -> InputChannelLevel -> Bool)
-> (InputChannelLevel -> InputChannelLevel -> Bool)
-> Eq InputChannelLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputChannelLevel -> InputChannelLevel -> Bool
$c/= :: InputChannelLevel -> InputChannelLevel -> Bool
== :: InputChannelLevel -> InputChannelLevel -> Bool
$c== :: InputChannelLevel -> InputChannelLevel -> Bool
Prelude.Eq, ReadPrec [InputChannelLevel]
ReadPrec InputChannelLevel
Int -> ReadS InputChannelLevel
ReadS [InputChannelLevel]
(Int -> ReadS InputChannelLevel)
-> ReadS [InputChannelLevel]
-> ReadPrec InputChannelLevel
-> ReadPrec [InputChannelLevel]
-> Read InputChannelLevel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputChannelLevel]
$creadListPrec :: ReadPrec [InputChannelLevel]
readPrec :: ReadPrec InputChannelLevel
$creadPrec :: ReadPrec InputChannelLevel
readList :: ReadS [InputChannelLevel]
$creadList :: ReadS [InputChannelLevel]
readsPrec :: Int -> ReadS InputChannelLevel
$creadsPrec :: Int -> ReadS InputChannelLevel
Prelude.Read, Int -> InputChannelLevel -> ShowS
[InputChannelLevel] -> ShowS
InputChannelLevel -> String
(Int -> InputChannelLevel -> ShowS)
-> (InputChannelLevel -> String)
-> ([InputChannelLevel] -> ShowS)
-> Show InputChannelLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputChannelLevel] -> ShowS
$cshowList :: [InputChannelLevel] -> ShowS
show :: InputChannelLevel -> String
$cshow :: InputChannelLevel -> String
showsPrec :: Int -> InputChannelLevel -> ShowS
$cshowsPrec :: Int -> InputChannelLevel -> ShowS
Prelude.Show, (forall x. InputChannelLevel -> Rep InputChannelLevel x)
-> (forall x. Rep InputChannelLevel x -> InputChannelLevel)
-> Generic InputChannelLevel
forall x. Rep InputChannelLevel x -> InputChannelLevel
forall x. InputChannelLevel -> Rep InputChannelLevel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputChannelLevel x -> InputChannelLevel
$cfrom :: forall x. InputChannelLevel -> Rep InputChannelLevel x
Prelude.Generic)

-- |
-- Create a value of 'InputChannelLevel' 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:
--
-- 'inputChannel', 'inputChannelLevel_inputChannel' - The index of the input channel used as a source.
--
-- 'gain', 'inputChannelLevel_gain' - Remixing value. Units are in dB and acceptable values are within the
-- range from -60 (mute) and 6 dB.
newInputChannelLevel ::
  -- | 'inputChannel'
  Prelude.Natural ->
  -- | 'gain'
  Prelude.Int ->
  InputChannelLevel
newInputChannelLevel :: Natural -> Int -> InputChannelLevel
newInputChannelLevel Natural
pInputChannel_ Int
pGain_ =
  InputChannelLevel' :: Natural -> Int -> InputChannelLevel
InputChannelLevel'
    { $sel:inputChannel:InputChannelLevel' :: Natural
inputChannel = Natural
pInputChannel_,
      $sel:gain:InputChannelLevel' :: Int
gain = Int
pGain_
    }

-- | The index of the input channel used as a source.
inputChannelLevel_inputChannel :: Lens.Lens' InputChannelLevel Prelude.Natural
inputChannelLevel_inputChannel :: (Natural -> f Natural) -> InputChannelLevel -> f InputChannelLevel
inputChannelLevel_inputChannel = (InputChannelLevel -> Natural)
-> (InputChannelLevel -> Natural -> InputChannelLevel)
-> Lens InputChannelLevel InputChannelLevel Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputChannelLevel' {Natural
inputChannel :: Natural
$sel:inputChannel:InputChannelLevel' :: InputChannelLevel -> Natural
inputChannel} -> Natural
inputChannel) (\s :: InputChannelLevel
s@InputChannelLevel' {} Natural
a -> InputChannelLevel
s {$sel:inputChannel:InputChannelLevel' :: Natural
inputChannel = Natural
a} :: InputChannelLevel)

-- | Remixing value. Units are in dB and acceptable values are within the
-- range from -60 (mute) and 6 dB.
inputChannelLevel_gain :: Lens.Lens' InputChannelLevel Prelude.Int
inputChannelLevel_gain :: (Int -> f Int) -> InputChannelLevel -> f InputChannelLevel
inputChannelLevel_gain = (InputChannelLevel -> Int)
-> (InputChannelLevel -> Int -> InputChannelLevel)
-> Lens InputChannelLevel InputChannelLevel Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputChannelLevel' {Int
gain :: Int
$sel:gain:InputChannelLevel' :: InputChannelLevel -> Int
gain} -> Int
gain) (\s :: InputChannelLevel
s@InputChannelLevel' {} Int
a -> InputChannelLevel
s {$sel:gain:InputChannelLevel' :: Int
gain = Int
a} :: InputChannelLevel)

instance Core.FromJSON InputChannelLevel where
  parseJSON :: Value -> Parser InputChannelLevel
parseJSON =
    String
-> (Object -> Parser InputChannelLevel)
-> Value
-> Parser InputChannelLevel
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputChannelLevel"
      ( \Object
x ->
          Natural -> Int -> InputChannelLevel
InputChannelLevel'
            (Natural -> Int -> InputChannelLevel)
-> Parser Natural -> Parser (Int -> InputChannelLevel)
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
"inputChannel")
            Parser (Int -> InputChannelLevel)
-> Parser Int -> Parser InputChannelLevel
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"gain")
      )

instance Prelude.Hashable InputChannelLevel

instance Prelude.NFData InputChannelLevel

instance Core.ToJSON InputChannelLevel where
  toJSON :: InputChannelLevel -> Value
toJSON InputChannelLevel' {Int
Natural
gain :: Int
inputChannel :: Natural
$sel:gain:InputChannelLevel' :: InputChannelLevel -> Int
$sel:inputChannel:InputChannelLevel' :: InputChannelLevel -> 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
"inputChannel" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
inputChannel),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"gain" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
gain)
          ]
      )