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

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

-- | Enable Timed metadata insertion (TimedMetadataInsertion) to include ID3
-- tags in any HLS outputs. To include timed metadata, you must enable it
-- here, enable it in each output container, and specify tags and timecodes
-- in ID3 insertion (Id3Insertion) objects.
--
-- /See:/ 'newTimedMetadataInsertion' smart constructor.
data TimedMetadataInsertion = TimedMetadataInsertion'
  { -- | Id3Insertions contains the array of Id3Insertion instances.
    TimedMetadataInsertion -> Maybe [Id3Insertion]
id3Insertions :: Prelude.Maybe [Id3Insertion]
  }
  deriving (TimedMetadataInsertion -> TimedMetadataInsertion -> Bool
(TimedMetadataInsertion -> TimedMetadataInsertion -> Bool)
-> (TimedMetadataInsertion -> TimedMetadataInsertion -> Bool)
-> Eq TimedMetadataInsertion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimedMetadataInsertion -> TimedMetadataInsertion -> Bool
$c/= :: TimedMetadataInsertion -> TimedMetadataInsertion -> Bool
== :: TimedMetadataInsertion -> TimedMetadataInsertion -> Bool
$c== :: TimedMetadataInsertion -> TimedMetadataInsertion -> Bool
Prelude.Eq, ReadPrec [TimedMetadataInsertion]
ReadPrec TimedMetadataInsertion
Int -> ReadS TimedMetadataInsertion
ReadS [TimedMetadataInsertion]
(Int -> ReadS TimedMetadataInsertion)
-> ReadS [TimedMetadataInsertion]
-> ReadPrec TimedMetadataInsertion
-> ReadPrec [TimedMetadataInsertion]
-> Read TimedMetadataInsertion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimedMetadataInsertion]
$creadListPrec :: ReadPrec [TimedMetadataInsertion]
readPrec :: ReadPrec TimedMetadataInsertion
$creadPrec :: ReadPrec TimedMetadataInsertion
readList :: ReadS [TimedMetadataInsertion]
$creadList :: ReadS [TimedMetadataInsertion]
readsPrec :: Int -> ReadS TimedMetadataInsertion
$creadsPrec :: Int -> ReadS TimedMetadataInsertion
Prelude.Read, Int -> TimedMetadataInsertion -> ShowS
[TimedMetadataInsertion] -> ShowS
TimedMetadataInsertion -> String
(Int -> TimedMetadataInsertion -> ShowS)
-> (TimedMetadataInsertion -> String)
-> ([TimedMetadataInsertion] -> ShowS)
-> Show TimedMetadataInsertion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimedMetadataInsertion] -> ShowS
$cshowList :: [TimedMetadataInsertion] -> ShowS
show :: TimedMetadataInsertion -> String
$cshow :: TimedMetadataInsertion -> String
showsPrec :: Int -> TimedMetadataInsertion -> ShowS
$cshowsPrec :: Int -> TimedMetadataInsertion -> ShowS
Prelude.Show, (forall x. TimedMetadataInsertion -> Rep TimedMetadataInsertion x)
-> (forall x.
    Rep TimedMetadataInsertion x -> TimedMetadataInsertion)
-> Generic TimedMetadataInsertion
forall x. Rep TimedMetadataInsertion x -> TimedMetadataInsertion
forall x. TimedMetadataInsertion -> Rep TimedMetadataInsertion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimedMetadataInsertion x -> TimedMetadataInsertion
$cfrom :: forall x. TimedMetadataInsertion -> Rep TimedMetadataInsertion x
Prelude.Generic)

-- |
-- Create a value of 'TimedMetadataInsertion' 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:
--
-- 'id3Insertions', 'timedMetadataInsertion_id3Insertions' - Id3Insertions contains the array of Id3Insertion instances.
newTimedMetadataInsertion ::
  TimedMetadataInsertion
newTimedMetadataInsertion :: TimedMetadataInsertion
newTimedMetadataInsertion =
  TimedMetadataInsertion' :: Maybe [Id3Insertion] -> TimedMetadataInsertion
TimedMetadataInsertion'
    { $sel:id3Insertions:TimedMetadataInsertion' :: Maybe [Id3Insertion]
id3Insertions =
        Maybe [Id3Insertion]
forall a. Maybe a
Prelude.Nothing
    }

-- | Id3Insertions contains the array of Id3Insertion instances.
timedMetadataInsertion_id3Insertions :: Lens.Lens' TimedMetadataInsertion (Prelude.Maybe [Id3Insertion])
timedMetadataInsertion_id3Insertions :: (Maybe [Id3Insertion] -> f (Maybe [Id3Insertion]))
-> TimedMetadataInsertion -> f TimedMetadataInsertion
timedMetadataInsertion_id3Insertions = (TimedMetadataInsertion -> Maybe [Id3Insertion])
-> (TimedMetadataInsertion
    -> Maybe [Id3Insertion] -> TimedMetadataInsertion)
-> Lens
     TimedMetadataInsertion
     TimedMetadataInsertion
     (Maybe [Id3Insertion])
     (Maybe [Id3Insertion])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimedMetadataInsertion' {Maybe [Id3Insertion]
id3Insertions :: Maybe [Id3Insertion]
$sel:id3Insertions:TimedMetadataInsertion' :: TimedMetadataInsertion -> Maybe [Id3Insertion]
id3Insertions} -> Maybe [Id3Insertion]
id3Insertions) (\s :: TimedMetadataInsertion
s@TimedMetadataInsertion' {} Maybe [Id3Insertion]
a -> TimedMetadataInsertion
s {$sel:id3Insertions:TimedMetadataInsertion' :: Maybe [Id3Insertion]
id3Insertions = Maybe [Id3Insertion]
a} :: TimedMetadataInsertion) ((Maybe [Id3Insertion] -> f (Maybe [Id3Insertion]))
 -> TimedMetadataInsertion -> f TimedMetadataInsertion)
-> ((Maybe [Id3Insertion] -> f (Maybe [Id3Insertion]))
    -> Maybe [Id3Insertion] -> f (Maybe [Id3Insertion]))
-> (Maybe [Id3Insertion] -> f (Maybe [Id3Insertion]))
-> TimedMetadataInsertion
-> f TimedMetadataInsertion
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Id3Insertion] [Id3Insertion] [Id3Insertion] [Id3Insertion]
-> Iso
     (Maybe [Id3Insertion])
     (Maybe [Id3Insertion])
     (Maybe [Id3Insertion])
     (Maybe [Id3Insertion])
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 [Id3Insertion] [Id3Insertion] [Id3Insertion] [Id3Insertion]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON TimedMetadataInsertion where
  parseJSON :: Value -> Parser TimedMetadataInsertion
parseJSON =
    String
-> (Object -> Parser TimedMetadataInsertion)
-> Value
-> Parser TimedMetadataInsertion
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TimedMetadataInsertion"
      ( \Object
x ->
          Maybe [Id3Insertion] -> TimedMetadataInsertion
TimedMetadataInsertion'
            (Maybe [Id3Insertion] -> TimedMetadataInsertion)
-> Parser (Maybe [Id3Insertion]) -> Parser TimedMetadataInsertion
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Id3Insertion]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"id3Insertions" Parser (Maybe (Maybe [Id3Insertion]))
-> Maybe [Id3Insertion] -> Parser (Maybe [Id3Insertion])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Id3Insertion]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable TimedMetadataInsertion

instance Prelude.NFData TimedMetadataInsertion

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