{-# 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.CaptionLanguageMapping
-- 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.MediaLive.Types.CaptionLanguageMapping 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

-- | Maps a caption channel to an ISO 693-2 language code
-- (http:\/\/www.loc.gov\/standards\/iso639-2), with an optional
-- description.
--
-- /See:/ 'newCaptionLanguageMapping' smart constructor.
data CaptionLanguageMapping = CaptionLanguageMapping'
  { -- | Three character ISO 639-2 language code (see
    -- http:\/\/www.loc.gov\/standards\/iso639-2)
    CaptionLanguageMapping -> Text
languageCode :: Prelude.Text,
    -- | Textual description of language
    CaptionLanguageMapping -> Text
languageDescription :: Prelude.Text,
    -- | The closed caption channel being described by this
    -- CaptionLanguageMapping. Each channel mapping must have a unique channel
    -- number (maximum of 4)
    CaptionLanguageMapping -> Natural
captionChannel :: Prelude.Natural
  }
  deriving (CaptionLanguageMapping -> CaptionLanguageMapping -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CaptionLanguageMapping -> CaptionLanguageMapping -> Bool
$c/= :: CaptionLanguageMapping -> CaptionLanguageMapping -> Bool
== :: CaptionLanguageMapping -> CaptionLanguageMapping -> Bool
$c== :: CaptionLanguageMapping -> CaptionLanguageMapping -> Bool
Prelude.Eq, ReadPrec [CaptionLanguageMapping]
ReadPrec CaptionLanguageMapping
Int -> ReadS CaptionLanguageMapping
ReadS [CaptionLanguageMapping]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CaptionLanguageMapping]
$creadListPrec :: ReadPrec [CaptionLanguageMapping]
readPrec :: ReadPrec CaptionLanguageMapping
$creadPrec :: ReadPrec CaptionLanguageMapping
readList :: ReadS [CaptionLanguageMapping]
$creadList :: ReadS [CaptionLanguageMapping]
readsPrec :: Int -> ReadS CaptionLanguageMapping
$creadsPrec :: Int -> ReadS CaptionLanguageMapping
Prelude.Read, Int -> CaptionLanguageMapping -> ShowS
[CaptionLanguageMapping] -> ShowS
CaptionLanguageMapping -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CaptionLanguageMapping] -> ShowS
$cshowList :: [CaptionLanguageMapping] -> ShowS
show :: CaptionLanguageMapping -> String
$cshow :: CaptionLanguageMapping -> String
showsPrec :: Int -> CaptionLanguageMapping -> ShowS
$cshowsPrec :: Int -> CaptionLanguageMapping -> ShowS
Prelude.Show, forall x. Rep CaptionLanguageMapping x -> CaptionLanguageMapping
forall x. CaptionLanguageMapping -> Rep CaptionLanguageMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CaptionLanguageMapping x -> CaptionLanguageMapping
$cfrom :: forall x. CaptionLanguageMapping -> Rep CaptionLanguageMapping x
Prelude.Generic)

-- |
-- Create a value of 'CaptionLanguageMapping' 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:
--
-- 'languageCode', 'captionLanguageMapping_languageCode' - Three character ISO 639-2 language code (see
-- http:\/\/www.loc.gov\/standards\/iso639-2)
--
-- 'languageDescription', 'captionLanguageMapping_languageDescription' - Textual description of language
--
-- 'captionChannel', 'captionLanguageMapping_captionChannel' - The closed caption channel being described by this
-- CaptionLanguageMapping. Each channel mapping must have a unique channel
-- number (maximum of 4)
newCaptionLanguageMapping ::
  -- | 'languageCode'
  Prelude.Text ->
  -- | 'languageDescription'
  Prelude.Text ->
  -- | 'captionChannel'
  Prelude.Natural ->
  CaptionLanguageMapping
newCaptionLanguageMapping :: Text -> Text -> Natural -> CaptionLanguageMapping
newCaptionLanguageMapping
  Text
pLanguageCode_
  Text
pLanguageDescription_
  Natural
pCaptionChannel_ =
    CaptionLanguageMapping'
      { $sel:languageCode:CaptionLanguageMapping' :: Text
languageCode =
          Text
pLanguageCode_,
        $sel:languageDescription:CaptionLanguageMapping' :: Text
languageDescription = Text
pLanguageDescription_,
        $sel:captionChannel:CaptionLanguageMapping' :: Natural
captionChannel = Natural
pCaptionChannel_
      }

-- | Three character ISO 639-2 language code (see
-- http:\/\/www.loc.gov\/standards\/iso639-2)
captionLanguageMapping_languageCode :: Lens.Lens' CaptionLanguageMapping Prelude.Text
captionLanguageMapping_languageCode :: Lens' CaptionLanguageMapping Text
captionLanguageMapping_languageCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionLanguageMapping' {Text
languageCode :: Text
$sel:languageCode:CaptionLanguageMapping' :: CaptionLanguageMapping -> Text
languageCode} -> Text
languageCode) (\s :: CaptionLanguageMapping
s@CaptionLanguageMapping' {} Text
a -> CaptionLanguageMapping
s {$sel:languageCode:CaptionLanguageMapping' :: Text
languageCode = Text
a} :: CaptionLanguageMapping)

-- | Textual description of language
captionLanguageMapping_languageDescription :: Lens.Lens' CaptionLanguageMapping Prelude.Text
captionLanguageMapping_languageDescription :: Lens' CaptionLanguageMapping Text
captionLanguageMapping_languageDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionLanguageMapping' {Text
languageDescription :: Text
$sel:languageDescription:CaptionLanguageMapping' :: CaptionLanguageMapping -> Text
languageDescription} -> Text
languageDescription) (\s :: CaptionLanguageMapping
s@CaptionLanguageMapping' {} Text
a -> CaptionLanguageMapping
s {$sel:languageDescription:CaptionLanguageMapping' :: Text
languageDescription = Text
a} :: CaptionLanguageMapping)

-- | The closed caption channel being described by this
-- CaptionLanguageMapping. Each channel mapping must have a unique channel
-- number (maximum of 4)
captionLanguageMapping_captionChannel :: Lens.Lens' CaptionLanguageMapping Prelude.Natural
captionLanguageMapping_captionChannel :: Lens' CaptionLanguageMapping Natural
captionLanguageMapping_captionChannel = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionLanguageMapping' {Natural
captionChannel :: Natural
$sel:captionChannel:CaptionLanguageMapping' :: CaptionLanguageMapping -> Natural
captionChannel} -> Natural
captionChannel) (\s :: CaptionLanguageMapping
s@CaptionLanguageMapping' {} Natural
a -> CaptionLanguageMapping
s {$sel:captionChannel:CaptionLanguageMapping' :: Natural
captionChannel = Natural
a} :: CaptionLanguageMapping)

instance Data.FromJSON CaptionLanguageMapping where
  parseJSON :: Value -> Parser CaptionLanguageMapping
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CaptionLanguageMapping"
      ( \Object
x ->
          Text -> Text -> Natural -> CaptionLanguageMapping
CaptionLanguageMapping'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"languageCode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"languageDescription")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"captionChannel")
      )

instance Prelude.Hashable CaptionLanguageMapping where
  hashWithSalt :: Int -> CaptionLanguageMapping -> Int
hashWithSalt Int
_salt CaptionLanguageMapping' {Natural
Text
captionChannel :: Natural
languageDescription :: Text
languageCode :: Text
$sel:captionChannel:CaptionLanguageMapping' :: CaptionLanguageMapping -> Natural
$sel:languageDescription:CaptionLanguageMapping' :: CaptionLanguageMapping -> Text
$sel:languageCode:CaptionLanguageMapping' :: CaptionLanguageMapping -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
languageCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
languageDescription
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
captionChannel

instance Prelude.NFData CaptionLanguageMapping where
  rnf :: CaptionLanguageMapping -> ()
rnf CaptionLanguageMapping' {Natural
Text
captionChannel :: Natural
languageDescription :: Text
languageCode :: Text
$sel:captionChannel:CaptionLanguageMapping' :: CaptionLanguageMapping -> Natural
$sel:languageDescription:CaptionLanguageMapping' :: CaptionLanguageMapping -> Text
$sel:languageCode:CaptionLanguageMapping' :: CaptionLanguageMapping -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
languageCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
languageDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
captionChannel

instance Data.ToJSON CaptionLanguageMapping where
  toJSON :: CaptionLanguageMapping -> Value
toJSON CaptionLanguageMapping' {Natural
Text
captionChannel :: Natural
languageDescription :: Text
languageCode :: Text
$sel:captionChannel:CaptionLanguageMapping' :: CaptionLanguageMapping -> Natural
$sel:languageDescription:CaptionLanguageMapping' :: CaptionLanguageMapping -> Text
$sel:languageCode:CaptionLanguageMapping' :: CaptionLanguageMapping -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"languageCode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
languageCode),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"languageDescription" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
languageDescription),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"captionChannel" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
captionChannel)
          ]
      )