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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(CaptionLanguageMapping -> CaptionLanguageMapping -> Bool)
-> (CaptionLanguageMapping -> CaptionLanguageMapping -> Bool)
-> Eq CaptionLanguageMapping
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]
(Int -> ReadS CaptionLanguageMapping)
-> ReadS [CaptionLanguageMapping]
-> ReadPrec CaptionLanguageMapping
-> ReadPrec [CaptionLanguageMapping]
-> Read 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
(Int -> CaptionLanguageMapping -> ShowS)
-> (CaptionLanguageMapping -> String)
-> ([CaptionLanguageMapping] -> ShowS)
-> Show CaptionLanguageMapping
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. CaptionLanguageMapping -> Rep CaptionLanguageMapping x)
-> (forall x.
    Rep CaptionLanguageMapping x -> CaptionLanguageMapping)
-> Generic CaptionLanguageMapping
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' :: Text -> Text -> Natural -> CaptionLanguageMapping
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 :: (Text -> f Text)
-> CaptionLanguageMapping -> f CaptionLanguageMapping
captionLanguageMapping_languageCode = (CaptionLanguageMapping -> Text)
-> (CaptionLanguageMapping -> Text -> CaptionLanguageMapping)
-> Lens CaptionLanguageMapping CaptionLanguageMapping Text Text
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 :: (Text -> f Text)
-> CaptionLanguageMapping -> f CaptionLanguageMapping
captionLanguageMapping_languageDescription = (CaptionLanguageMapping -> Text)
-> (CaptionLanguageMapping -> Text -> CaptionLanguageMapping)
-> Lens CaptionLanguageMapping CaptionLanguageMapping Text Text
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 :: (Natural -> f Natural)
-> CaptionLanguageMapping -> f CaptionLanguageMapping
captionLanguageMapping_captionChannel = (CaptionLanguageMapping -> Natural)
-> (CaptionLanguageMapping -> Natural -> CaptionLanguageMapping)
-> Lens
     CaptionLanguageMapping CaptionLanguageMapping Natural Natural
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 Core.FromJSON CaptionLanguageMapping where
  parseJSON :: Value -> Parser CaptionLanguageMapping
parseJSON =
    String
-> (Object -> Parser CaptionLanguageMapping)
-> Value
-> Parser CaptionLanguageMapping
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CaptionLanguageMapping"
      ( \Object
x ->
          Text -> Text -> Natural -> CaptionLanguageMapping
CaptionLanguageMapping'
            (Text -> Text -> Natural -> CaptionLanguageMapping)
-> Parser Text
-> Parser (Text -> Natural -> CaptionLanguageMapping)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"languageCode")
            Parser (Text -> Natural -> CaptionLanguageMapping)
-> Parser Text -> Parser (Natural -> CaptionLanguageMapping)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"languageDescription")
            Parser (Natural -> CaptionLanguageMapping)
-> Parser Natural -> Parser CaptionLanguageMapping
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"captionChannel")
      )

instance Prelude.Hashable CaptionLanguageMapping

instance Prelude.NFData CaptionLanguageMapping

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"languageCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
languageCode),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"languageDescription" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
languageDescription),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"captionChannel" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
captionChannel)
          ]
      )