{-# 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.MediaConvert.Types.WebvttHlsSourceSettings
-- 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.MediaConvert.Types.WebvttHlsSourceSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaConvert.Types.LanguageCode
import qualified Amazonka.Prelude as Prelude

-- | Settings specific to WebVTT sources in HLS alternative rendition group.
-- Specify the properties (renditionGroupId, renditionName or
-- renditionLanguageCode) to identify the unique subtitle track among the
-- alternative rendition groups present in the HLS manifest. If no unique
-- track is found, or multiple tracks match the specified properties, the
-- job fails. If there is only one subtitle track in the rendition group,
-- the settings can be left empty and the default subtitle track will be
-- chosen. If your caption source is a sidecar file, use FileSourceSettings
-- instead of WebvttHlsSourceSettings.
--
-- /See:/ 'newWebvttHlsSourceSettings' smart constructor.
data WebvttHlsSourceSettings = WebvttHlsSourceSettings'
  { -- | Optional. Specify media name
    WebvttHlsSourceSettings -> Maybe Text
renditionName :: Prelude.Maybe Prelude.Text,
    -- | Optional. Specify alternative group ID
    WebvttHlsSourceSettings -> Maybe Text
renditionGroupId :: Prelude.Maybe Prelude.Text,
    -- | Optional. Specify ISO 639-2 or ISO 639-3 code in the language property
    WebvttHlsSourceSettings -> Maybe LanguageCode
renditionLanguageCode :: Prelude.Maybe LanguageCode
  }
  deriving (WebvttHlsSourceSettings -> WebvttHlsSourceSettings -> Bool
(WebvttHlsSourceSettings -> WebvttHlsSourceSettings -> Bool)
-> (WebvttHlsSourceSettings -> WebvttHlsSourceSettings -> Bool)
-> Eq WebvttHlsSourceSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WebvttHlsSourceSettings -> WebvttHlsSourceSettings -> Bool
$c/= :: WebvttHlsSourceSettings -> WebvttHlsSourceSettings -> Bool
== :: WebvttHlsSourceSettings -> WebvttHlsSourceSettings -> Bool
$c== :: WebvttHlsSourceSettings -> WebvttHlsSourceSettings -> Bool
Prelude.Eq, ReadPrec [WebvttHlsSourceSettings]
ReadPrec WebvttHlsSourceSettings
Int -> ReadS WebvttHlsSourceSettings
ReadS [WebvttHlsSourceSettings]
(Int -> ReadS WebvttHlsSourceSettings)
-> ReadS [WebvttHlsSourceSettings]
-> ReadPrec WebvttHlsSourceSettings
-> ReadPrec [WebvttHlsSourceSettings]
-> Read WebvttHlsSourceSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WebvttHlsSourceSettings]
$creadListPrec :: ReadPrec [WebvttHlsSourceSettings]
readPrec :: ReadPrec WebvttHlsSourceSettings
$creadPrec :: ReadPrec WebvttHlsSourceSettings
readList :: ReadS [WebvttHlsSourceSettings]
$creadList :: ReadS [WebvttHlsSourceSettings]
readsPrec :: Int -> ReadS WebvttHlsSourceSettings
$creadsPrec :: Int -> ReadS WebvttHlsSourceSettings
Prelude.Read, Int -> WebvttHlsSourceSettings -> ShowS
[WebvttHlsSourceSettings] -> ShowS
WebvttHlsSourceSettings -> String
(Int -> WebvttHlsSourceSettings -> ShowS)
-> (WebvttHlsSourceSettings -> String)
-> ([WebvttHlsSourceSettings] -> ShowS)
-> Show WebvttHlsSourceSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WebvttHlsSourceSettings] -> ShowS
$cshowList :: [WebvttHlsSourceSettings] -> ShowS
show :: WebvttHlsSourceSettings -> String
$cshow :: WebvttHlsSourceSettings -> String
showsPrec :: Int -> WebvttHlsSourceSettings -> ShowS
$cshowsPrec :: Int -> WebvttHlsSourceSettings -> ShowS
Prelude.Show, (forall x.
 WebvttHlsSourceSettings -> Rep WebvttHlsSourceSettings x)
-> (forall x.
    Rep WebvttHlsSourceSettings x -> WebvttHlsSourceSettings)
-> Generic WebvttHlsSourceSettings
forall x. Rep WebvttHlsSourceSettings x -> WebvttHlsSourceSettings
forall x. WebvttHlsSourceSettings -> Rep WebvttHlsSourceSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WebvttHlsSourceSettings x -> WebvttHlsSourceSettings
$cfrom :: forall x. WebvttHlsSourceSettings -> Rep WebvttHlsSourceSettings x
Prelude.Generic)

-- |
-- Create a value of 'WebvttHlsSourceSettings' 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:
--
-- 'renditionName', 'webvttHlsSourceSettings_renditionName' - Optional. Specify media name
--
-- 'renditionGroupId', 'webvttHlsSourceSettings_renditionGroupId' - Optional. Specify alternative group ID
--
-- 'renditionLanguageCode', 'webvttHlsSourceSettings_renditionLanguageCode' - Optional. Specify ISO 639-2 or ISO 639-3 code in the language property
newWebvttHlsSourceSettings ::
  WebvttHlsSourceSettings
newWebvttHlsSourceSettings :: WebvttHlsSourceSettings
newWebvttHlsSourceSettings =
  WebvttHlsSourceSettings' :: Maybe Text
-> Maybe Text -> Maybe LanguageCode -> WebvttHlsSourceSettings
WebvttHlsSourceSettings'
    { $sel:renditionName:WebvttHlsSourceSettings' :: Maybe Text
renditionName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:renditionGroupId:WebvttHlsSourceSettings' :: Maybe Text
renditionGroupId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:renditionLanguageCode:WebvttHlsSourceSettings' :: Maybe LanguageCode
renditionLanguageCode = Maybe LanguageCode
forall a. Maybe a
Prelude.Nothing
    }

-- | Optional. Specify media name
webvttHlsSourceSettings_renditionName :: Lens.Lens' WebvttHlsSourceSettings (Prelude.Maybe Prelude.Text)
webvttHlsSourceSettings_renditionName :: (Maybe Text -> f (Maybe Text))
-> WebvttHlsSourceSettings -> f WebvttHlsSourceSettings
webvttHlsSourceSettings_renditionName = (WebvttHlsSourceSettings -> Maybe Text)
-> (WebvttHlsSourceSettings
    -> Maybe Text -> WebvttHlsSourceSettings)
-> Lens
     WebvttHlsSourceSettings
     WebvttHlsSourceSettings
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WebvttHlsSourceSettings' {Maybe Text
renditionName :: Maybe Text
$sel:renditionName:WebvttHlsSourceSettings' :: WebvttHlsSourceSettings -> Maybe Text
renditionName} -> Maybe Text
renditionName) (\s :: WebvttHlsSourceSettings
s@WebvttHlsSourceSettings' {} Maybe Text
a -> WebvttHlsSourceSettings
s {$sel:renditionName:WebvttHlsSourceSettings' :: Maybe Text
renditionName = Maybe Text
a} :: WebvttHlsSourceSettings)

-- | Optional. Specify alternative group ID
webvttHlsSourceSettings_renditionGroupId :: Lens.Lens' WebvttHlsSourceSettings (Prelude.Maybe Prelude.Text)
webvttHlsSourceSettings_renditionGroupId :: (Maybe Text -> f (Maybe Text))
-> WebvttHlsSourceSettings -> f WebvttHlsSourceSettings
webvttHlsSourceSettings_renditionGroupId = (WebvttHlsSourceSettings -> Maybe Text)
-> (WebvttHlsSourceSettings
    -> Maybe Text -> WebvttHlsSourceSettings)
-> Lens
     WebvttHlsSourceSettings
     WebvttHlsSourceSettings
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WebvttHlsSourceSettings' {Maybe Text
renditionGroupId :: Maybe Text
$sel:renditionGroupId:WebvttHlsSourceSettings' :: WebvttHlsSourceSettings -> Maybe Text
renditionGroupId} -> Maybe Text
renditionGroupId) (\s :: WebvttHlsSourceSettings
s@WebvttHlsSourceSettings' {} Maybe Text
a -> WebvttHlsSourceSettings
s {$sel:renditionGroupId:WebvttHlsSourceSettings' :: Maybe Text
renditionGroupId = Maybe Text
a} :: WebvttHlsSourceSettings)

-- | Optional. Specify ISO 639-2 or ISO 639-3 code in the language property
webvttHlsSourceSettings_renditionLanguageCode :: Lens.Lens' WebvttHlsSourceSettings (Prelude.Maybe LanguageCode)
webvttHlsSourceSettings_renditionLanguageCode :: (Maybe LanguageCode -> f (Maybe LanguageCode))
-> WebvttHlsSourceSettings -> f WebvttHlsSourceSettings
webvttHlsSourceSettings_renditionLanguageCode = (WebvttHlsSourceSettings -> Maybe LanguageCode)
-> (WebvttHlsSourceSettings
    -> Maybe LanguageCode -> WebvttHlsSourceSettings)
-> Lens
     WebvttHlsSourceSettings
     WebvttHlsSourceSettings
     (Maybe LanguageCode)
     (Maybe LanguageCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WebvttHlsSourceSettings' {Maybe LanguageCode
renditionLanguageCode :: Maybe LanguageCode
$sel:renditionLanguageCode:WebvttHlsSourceSettings' :: WebvttHlsSourceSettings -> Maybe LanguageCode
renditionLanguageCode} -> Maybe LanguageCode
renditionLanguageCode) (\s :: WebvttHlsSourceSettings
s@WebvttHlsSourceSettings' {} Maybe LanguageCode
a -> WebvttHlsSourceSettings
s {$sel:renditionLanguageCode:WebvttHlsSourceSettings' :: Maybe LanguageCode
renditionLanguageCode = Maybe LanguageCode
a} :: WebvttHlsSourceSettings)

instance Core.FromJSON WebvttHlsSourceSettings where
  parseJSON :: Value -> Parser WebvttHlsSourceSettings
parseJSON =
    String
-> (Object -> Parser WebvttHlsSourceSettings)
-> Value
-> Parser WebvttHlsSourceSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WebvttHlsSourceSettings"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe LanguageCode -> WebvttHlsSourceSettings
WebvttHlsSourceSettings'
            (Maybe Text
 -> Maybe Text -> Maybe LanguageCode -> WebvttHlsSourceSettings)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe LanguageCode -> WebvttHlsSourceSettings)
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
"renditionName")
            Parser
  (Maybe Text -> Maybe LanguageCode -> WebvttHlsSourceSettings)
-> Parser (Maybe Text)
-> Parser (Maybe LanguageCode -> WebvttHlsSourceSettings)
forall (f :: * -> *) a b. Applicative f => 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
"renditionGroupId")
            Parser (Maybe LanguageCode -> WebvttHlsSourceSettings)
-> Parser (Maybe LanguageCode) -> Parser WebvttHlsSourceSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe LanguageCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"renditionLanguageCode")
      )

instance Prelude.Hashable WebvttHlsSourceSettings

instance Prelude.NFData WebvttHlsSourceSettings

instance Core.ToJSON WebvttHlsSourceSettings where
  toJSON :: WebvttHlsSourceSettings -> Value
toJSON WebvttHlsSourceSettings' {Maybe Text
Maybe LanguageCode
renditionLanguageCode :: Maybe LanguageCode
renditionGroupId :: Maybe Text
renditionName :: Maybe Text
$sel:renditionLanguageCode:WebvttHlsSourceSettings' :: WebvttHlsSourceSettings -> Maybe LanguageCode
$sel:renditionGroupId:WebvttHlsSourceSettings' :: WebvttHlsSourceSettings -> Maybe Text
$sel:renditionName:WebvttHlsSourceSettings' :: WebvttHlsSourceSettings -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"renditionName" 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
renditionName,
            (Text
"renditionGroupId" 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
renditionGroupId,
            (Text
"renditionLanguageCode" Text -> LanguageCode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (LanguageCode -> Pair) -> Maybe LanguageCode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LanguageCode
renditionLanguageCode
          ]
      )