{-# 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.ElasticTranscoder.Types.InputCaptions
-- 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.ElasticTranscoder.Types.InputCaptions where

import qualified Amazonka.Core as Core
import Amazonka.ElasticTranscoder.Types.CaptionSource
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The captions to be created, if any.
--
-- /See:/ 'newInputCaptions' smart constructor.
data InputCaptions = InputCaptions'
  { -- | A policy that determines how Elastic Transcoder handles the existence of
    -- multiple captions.
    --
    -- -   __MergeOverride:__ Elastic Transcoder transcodes both embedded and
    --     sidecar captions into outputs. If captions for a language are
    --     embedded in the input file and also appear in a sidecar file,
    --     Elastic Transcoder uses the sidecar captions and ignores the
    --     embedded captions for that language.
    --
    -- -   __MergeRetain:__ Elastic Transcoder transcodes both embedded and
    --     sidecar captions into outputs. If captions for a language are
    --     embedded in the input file and also appear in a sidecar file,
    --     Elastic Transcoder uses the embedded captions and ignores the
    --     sidecar captions for that language. If @CaptionSources@ is empty,
    --     Elastic Transcoder omits all sidecar captions from the output files.
    --
    -- -   __Override:__ Elastic Transcoder transcodes only the sidecar
    --     captions that you specify in @CaptionSources@.
    --
    -- @MergePolicy@ cannot be null.
    InputCaptions -> Maybe Text
mergePolicy :: Prelude.Maybe Prelude.Text,
    -- | Source files for the input sidecar captions used during the transcoding
    -- process. To omit all sidecar captions, leave @CaptionSources@ blank.
    InputCaptions -> Maybe [CaptionSource]
captionSources :: Prelude.Maybe [CaptionSource]
  }
  deriving (InputCaptions -> InputCaptions -> Bool
(InputCaptions -> InputCaptions -> Bool)
-> (InputCaptions -> InputCaptions -> Bool) -> Eq InputCaptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputCaptions -> InputCaptions -> Bool
$c/= :: InputCaptions -> InputCaptions -> Bool
== :: InputCaptions -> InputCaptions -> Bool
$c== :: InputCaptions -> InputCaptions -> Bool
Prelude.Eq, ReadPrec [InputCaptions]
ReadPrec InputCaptions
Int -> ReadS InputCaptions
ReadS [InputCaptions]
(Int -> ReadS InputCaptions)
-> ReadS [InputCaptions]
-> ReadPrec InputCaptions
-> ReadPrec [InputCaptions]
-> Read InputCaptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputCaptions]
$creadListPrec :: ReadPrec [InputCaptions]
readPrec :: ReadPrec InputCaptions
$creadPrec :: ReadPrec InputCaptions
readList :: ReadS [InputCaptions]
$creadList :: ReadS [InputCaptions]
readsPrec :: Int -> ReadS InputCaptions
$creadsPrec :: Int -> ReadS InputCaptions
Prelude.Read, Int -> InputCaptions -> ShowS
[InputCaptions] -> ShowS
InputCaptions -> String
(Int -> InputCaptions -> ShowS)
-> (InputCaptions -> String)
-> ([InputCaptions] -> ShowS)
-> Show InputCaptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputCaptions] -> ShowS
$cshowList :: [InputCaptions] -> ShowS
show :: InputCaptions -> String
$cshow :: InputCaptions -> String
showsPrec :: Int -> InputCaptions -> ShowS
$cshowsPrec :: Int -> InputCaptions -> ShowS
Prelude.Show, (forall x. InputCaptions -> Rep InputCaptions x)
-> (forall x. Rep InputCaptions x -> InputCaptions)
-> Generic InputCaptions
forall x. Rep InputCaptions x -> InputCaptions
forall x. InputCaptions -> Rep InputCaptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputCaptions x -> InputCaptions
$cfrom :: forall x. InputCaptions -> Rep InputCaptions x
Prelude.Generic)

-- |
-- Create a value of 'InputCaptions' 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:
--
-- 'mergePolicy', 'inputCaptions_mergePolicy' - A policy that determines how Elastic Transcoder handles the existence of
-- multiple captions.
--
-- -   __MergeOverride:__ Elastic Transcoder transcodes both embedded and
--     sidecar captions into outputs. If captions for a language are
--     embedded in the input file and also appear in a sidecar file,
--     Elastic Transcoder uses the sidecar captions and ignores the
--     embedded captions for that language.
--
-- -   __MergeRetain:__ Elastic Transcoder transcodes both embedded and
--     sidecar captions into outputs. If captions for a language are
--     embedded in the input file and also appear in a sidecar file,
--     Elastic Transcoder uses the embedded captions and ignores the
--     sidecar captions for that language. If @CaptionSources@ is empty,
--     Elastic Transcoder omits all sidecar captions from the output files.
--
-- -   __Override:__ Elastic Transcoder transcodes only the sidecar
--     captions that you specify in @CaptionSources@.
--
-- @MergePolicy@ cannot be null.
--
-- 'captionSources', 'inputCaptions_captionSources' - Source files for the input sidecar captions used during the transcoding
-- process. To omit all sidecar captions, leave @CaptionSources@ blank.
newInputCaptions ::
  InputCaptions
newInputCaptions :: InputCaptions
newInputCaptions =
  InputCaptions' :: Maybe Text -> Maybe [CaptionSource] -> InputCaptions
InputCaptions'
    { $sel:mergePolicy:InputCaptions' :: Maybe Text
mergePolicy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:captionSources:InputCaptions' :: Maybe [CaptionSource]
captionSources = Maybe [CaptionSource]
forall a. Maybe a
Prelude.Nothing
    }

-- | A policy that determines how Elastic Transcoder handles the existence of
-- multiple captions.
--
-- -   __MergeOverride:__ Elastic Transcoder transcodes both embedded and
--     sidecar captions into outputs. If captions for a language are
--     embedded in the input file and also appear in a sidecar file,
--     Elastic Transcoder uses the sidecar captions and ignores the
--     embedded captions for that language.
--
-- -   __MergeRetain:__ Elastic Transcoder transcodes both embedded and
--     sidecar captions into outputs. If captions for a language are
--     embedded in the input file and also appear in a sidecar file,
--     Elastic Transcoder uses the embedded captions and ignores the
--     sidecar captions for that language. If @CaptionSources@ is empty,
--     Elastic Transcoder omits all sidecar captions from the output files.
--
-- -   __Override:__ Elastic Transcoder transcodes only the sidecar
--     captions that you specify in @CaptionSources@.
--
-- @MergePolicy@ cannot be null.
inputCaptions_mergePolicy :: Lens.Lens' InputCaptions (Prelude.Maybe Prelude.Text)
inputCaptions_mergePolicy :: (Maybe Text -> f (Maybe Text)) -> InputCaptions -> f InputCaptions
inputCaptions_mergePolicy = (InputCaptions -> Maybe Text)
-> (InputCaptions -> Maybe Text -> InputCaptions)
-> Lens InputCaptions InputCaptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputCaptions' {Maybe Text
mergePolicy :: Maybe Text
$sel:mergePolicy:InputCaptions' :: InputCaptions -> Maybe Text
mergePolicy} -> Maybe Text
mergePolicy) (\s :: InputCaptions
s@InputCaptions' {} Maybe Text
a -> InputCaptions
s {$sel:mergePolicy:InputCaptions' :: Maybe Text
mergePolicy = Maybe Text
a} :: InputCaptions)

-- | Source files for the input sidecar captions used during the transcoding
-- process. To omit all sidecar captions, leave @CaptionSources@ blank.
inputCaptions_captionSources :: Lens.Lens' InputCaptions (Prelude.Maybe [CaptionSource])
inputCaptions_captionSources :: (Maybe [CaptionSource] -> f (Maybe [CaptionSource]))
-> InputCaptions -> f InputCaptions
inputCaptions_captionSources = (InputCaptions -> Maybe [CaptionSource])
-> (InputCaptions -> Maybe [CaptionSource] -> InputCaptions)
-> Lens
     InputCaptions
     InputCaptions
     (Maybe [CaptionSource])
     (Maybe [CaptionSource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputCaptions' {Maybe [CaptionSource]
captionSources :: Maybe [CaptionSource]
$sel:captionSources:InputCaptions' :: InputCaptions -> Maybe [CaptionSource]
captionSources} -> Maybe [CaptionSource]
captionSources) (\s :: InputCaptions
s@InputCaptions' {} Maybe [CaptionSource]
a -> InputCaptions
s {$sel:captionSources:InputCaptions' :: Maybe [CaptionSource]
captionSources = Maybe [CaptionSource]
a} :: InputCaptions) ((Maybe [CaptionSource] -> f (Maybe [CaptionSource]))
 -> InputCaptions -> f InputCaptions)
-> ((Maybe [CaptionSource] -> f (Maybe [CaptionSource]))
    -> Maybe [CaptionSource] -> f (Maybe [CaptionSource]))
-> (Maybe [CaptionSource] -> f (Maybe [CaptionSource]))
-> InputCaptions
-> f InputCaptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CaptionSource] [CaptionSource] [CaptionSource] [CaptionSource]
-> Iso
     (Maybe [CaptionSource])
     (Maybe [CaptionSource])
     (Maybe [CaptionSource])
     (Maybe [CaptionSource])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [CaptionSource] [CaptionSource] [CaptionSource] [CaptionSource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON InputCaptions where
  parseJSON :: Value -> Parser InputCaptions
parseJSON =
    String
-> (Object -> Parser InputCaptions)
-> Value
-> Parser InputCaptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputCaptions"
      ( \Object
x ->
          Maybe Text -> Maybe [CaptionSource] -> InputCaptions
InputCaptions'
            (Maybe Text -> Maybe [CaptionSource] -> InputCaptions)
-> Parser (Maybe Text)
-> Parser (Maybe [CaptionSource] -> InputCaptions)
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
"MergePolicy")
            Parser (Maybe [CaptionSource] -> InputCaptions)
-> Parser (Maybe [CaptionSource]) -> Parser InputCaptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [CaptionSource]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CaptionSources"
                            Parser (Maybe (Maybe [CaptionSource]))
-> Maybe [CaptionSource] -> Parser (Maybe [CaptionSource])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [CaptionSource]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable InputCaptions

instance Prelude.NFData InputCaptions

instance Core.ToJSON InputCaptions where
  toJSON :: InputCaptions -> Value
toJSON InputCaptions' {Maybe [CaptionSource]
Maybe Text
captionSources :: Maybe [CaptionSource]
mergePolicy :: Maybe Text
$sel:captionSources:InputCaptions' :: InputCaptions -> Maybe [CaptionSource]
$sel:mergePolicy:InputCaptions' :: InputCaptions -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MergePolicy" 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
mergePolicy,
            (Text
"CaptionSources" Text -> [CaptionSource] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([CaptionSource] -> Pair) -> Maybe [CaptionSource] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [CaptionSource]
captionSources
          ]
      )