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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.CaptionSelectorSettings
import qualified Amazonka.Prelude as Prelude

-- | Output groups for this Live Event. Output groups contain information
-- about where streams should be distributed.
--
-- /See:/ 'newCaptionSelector' smart constructor.
data CaptionSelector = CaptionSelector'
  { -- | When specified this field indicates the three letter language code of
    -- the caption track to extract from the source.
    CaptionSelector -> Maybe Text
languageCode :: Prelude.Maybe Prelude.Text,
    -- | Caption selector settings.
    CaptionSelector -> Maybe CaptionSelectorSettings
selectorSettings :: Prelude.Maybe CaptionSelectorSettings,
    -- | Name identifier for a caption selector. This name is used to associate
    -- this caption selector with one or more caption descriptions. Names must
    -- be unique within an event.
    CaptionSelector -> Text
name :: Prelude.Text
  }
  deriving (CaptionSelector -> CaptionSelector -> Bool
(CaptionSelector -> CaptionSelector -> Bool)
-> (CaptionSelector -> CaptionSelector -> Bool)
-> Eq CaptionSelector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CaptionSelector -> CaptionSelector -> Bool
$c/= :: CaptionSelector -> CaptionSelector -> Bool
== :: CaptionSelector -> CaptionSelector -> Bool
$c== :: CaptionSelector -> CaptionSelector -> Bool
Prelude.Eq, ReadPrec [CaptionSelector]
ReadPrec CaptionSelector
Int -> ReadS CaptionSelector
ReadS [CaptionSelector]
(Int -> ReadS CaptionSelector)
-> ReadS [CaptionSelector]
-> ReadPrec CaptionSelector
-> ReadPrec [CaptionSelector]
-> Read CaptionSelector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CaptionSelector]
$creadListPrec :: ReadPrec [CaptionSelector]
readPrec :: ReadPrec CaptionSelector
$creadPrec :: ReadPrec CaptionSelector
readList :: ReadS [CaptionSelector]
$creadList :: ReadS [CaptionSelector]
readsPrec :: Int -> ReadS CaptionSelector
$creadsPrec :: Int -> ReadS CaptionSelector
Prelude.Read, Int -> CaptionSelector -> ShowS
[CaptionSelector] -> ShowS
CaptionSelector -> String
(Int -> CaptionSelector -> ShowS)
-> (CaptionSelector -> String)
-> ([CaptionSelector] -> ShowS)
-> Show CaptionSelector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CaptionSelector] -> ShowS
$cshowList :: [CaptionSelector] -> ShowS
show :: CaptionSelector -> String
$cshow :: CaptionSelector -> String
showsPrec :: Int -> CaptionSelector -> ShowS
$cshowsPrec :: Int -> CaptionSelector -> ShowS
Prelude.Show, (forall x. CaptionSelector -> Rep CaptionSelector x)
-> (forall x. Rep CaptionSelector x -> CaptionSelector)
-> Generic CaptionSelector
forall x. Rep CaptionSelector x -> CaptionSelector
forall x. CaptionSelector -> Rep CaptionSelector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CaptionSelector x -> CaptionSelector
$cfrom :: forall x. CaptionSelector -> Rep CaptionSelector x
Prelude.Generic)

-- |
-- Create a value of 'CaptionSelector' 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', 'captionSelector_languageCode' - When specified this field indicates the three letter language code of
-- the caption track to extract from the source.
--
-- 'selectorSettings', 'captionSelector_selectorSettings' - Caption selector settings.
--
-- 'name', 'captionSelector_name' - Name identifier for a caption selector. This name is used to associate
-- this caption selector with one or more caption descriptions. Names must
-- be unique within an event.
newCaptionSelector ::
  -- | 'name'
  Prelude.Text ->
  CaptionSelector
newCaptionSelector :: Text -> CaptionSelector
newCaptionSelector Text
pName_ =
  CaptionSelector' :: Maybe Text
-> Maybe CaptionSelectorSettings -> Text -> CaptionSelector
CaptionSelector'
    { $sel:languageCode:CaptionSelector' :: Maybe Text
languageCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:selectorSettings:CaptionSelector' :: Maybe CaptionSelectorSettings
selectorSettings = Maybe CaptionSelectorSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CaptionSelector' :: Text
name = Text
pName_
    }

-- | When specified this field indicates the three letter language code of
-- the caption track to extract from the source.
captionSelector_languageCode :: Lens.Lens' CaptionSelector (Prelude.Maybe Prelude.Text)
captionSelector_languageCode :: (Maybe Text -> f (Maybe Text))
-> CaptionSelector -> f CaptionSelector
captionSelector_languageCode = (CaptionSelector -> Maybe Text)
-> (CaptionSelector -> Maybe Text -> CaptionSelector)
-> Lens CaptionSelector CaptionSelector (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionSelector' {Maybe Text
languageCode :: Maybe Text
$sel:languageCode:CaptionSelector' :: CaptionSelector -> Maybe Text
languageCode} -> Maybe Text
languageCode) (\s :: CaptionSelector
s@CaptionSelector' {} Maybe Text
a -> CaptionSelector
s {$sel:languageCode:CaptionSelector' :: Maybe Text
languageCode = Maybe Text
a} :: CaptionSelector)

-- | Caption selector settings.
captionSelector_selectorSettings :: Lens.Lens' CaptionSelector (Prelude.Maybe CaptionSelectorSettings)
captionSelector_selectorSettings :: (Maybe CaptionSelectorSettings
 -> f (Maybe CaptionSelectorSettings))
-> CaptionSelector -> f CaptionSelector
captionSelector_selectorSettings = (CaptionSelector -> Maybe CaptionSelectorSettings)
-> (CaptionSelector
    -> Maybe CaptionSelectorSettings -> CaptionSelector)
-> Lens
     CaptionSelector
     CaptionSelector
     (Maybe CaptionSelectorSettings)
     (Maybe CaptionSelectorSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionSelector' {Maybe CaptionSelectorSettings
selectorSettings :: Maybe CaptionSelectorSettings
$sel:selectorSettings:CaptionSelector' :: CaptionSelector -> Maybe CaptionSelectorSettings
selectorSettings} -> Maybe CaptionSelectorSettings
selectorSettings) (\s :: CaptionSelector
s@CaptionSelector' {} Maybe CaptionSelectorSettings
a -> CaptionSelector
s {$sel:selectorSettings:CaptionSelector' :: Maybe CaptionSelectorSettings
selectorSettings = Maybe CaptionSelectorSettings
a} :: CaptionSelector)

-- | Name identifier for a caption selector. This name is used to associate
-- this caption selector with one or more caption descriptions. Names must
-- be unique within an event.
captionSelector_name :: Lens.Lens' CaptionSelector Prelude.Text
captionSelector_name :: (Text -> f Text) -> CaptionSelector -> f CaptionSelector
captionSelector_name = (CaptionSelector -> Text)
-> (CaptionSelector -> Text -> CaptionSelector)
-> Lens CaptionSelector CaptionSelector Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionSelector' {Text
name :: Text
$sel:name:CaptionSelector' :: CaptionSelector -> Text
name} -> Text
name) (\s :: CaptionSelector
s@CaptionSelector' {} Text
a -> CaptionSelector
s {$sel:name:CaptionSelector' :: Text
name = Text
a} :: CaptionSelector)

instance Core.FromJSON CaptionSelector where
  parseJSON :: Value -> Parser CaptionSelector
parseJSON =
    String
-> (Object -> Parser CaptionSelector)
-> Value
-> Parser CaptionSelector
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CaptionSelector"
      ( \Object
x ->
          Maybe Text
-> Maybe CaptionSelectorSettings -> Text -> CaptionSelector
CaptionSelector'
            (Maybe Text
 -> Maybe CaptionSelectorSettings -> Text -> CaptionSelector)
-> Parser (Maybe Text)
-> Parser
     (Maybe CaptionSelectorSettings -> Text -> CaptionSelector)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"languageCode")
            Parser (Maybe CaptionSelectorSettings -> Text -> CaptionSelector)
-> Parser (Maybe CaptionSelectorSettings)
-> Parser (Text -> CaptionSelector)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CaptionSelectorSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"selectorSettings")
            Parser (Text -> CaptionSelector)
-> Parser Text -> Parser CaptionSelector
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
"name")
      )

instance Prelude.Hashable CaptionSelector

instance Prelude.NFData CaptionSelector

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