{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaConvert.Types.TimedMetadataInsertion where

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

-- | Insert user-defined custom ID3 metadata (id3) at timecodes (timecode)
-- that you specify. In each output that you want to include this metadata,
-- you must set ID3 metadata (timedMetadata) to Passthrough (PASSTHROUGH).
--
-- /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
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]
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
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. 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'
    { $sel:id3Insertions:TimedMetadataInsertion' :: Maybe [Id3Insertion]
id3Insertions =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Id3Insertions contains the array of Id3Insertion instances.
timedMetadataInsertion_id3Insertions :: Lens.Lens' TimedMetadataInsertion (Prelude.Maybe [Id3Insertion])
timedMetadataInsertion_id3Insertions :: Lens' TimedMetadataInsertion (Maybe [Id3Insertion])
timedMetadataInsertion_id3Insertions = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable TimedMetadataInsertion where
  hashWithSalt :: Int -> TimedMetadataInsertion -> Int
hashWithSalt Int
_salt TimedMetadataInsertion' {Maybe [Id3Insertion]
id3Insertions :: Maybe [Id3Insertion]
$sel:id3Insertions:TimedMetadataInsertion' :: TimedMetadataInsertion -> Maybe [Id3Insertion]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Id3Insertion]
id3Insertions

instance Prelude.NFData TimedMetadataInsertion where
  rnf :: TimedMetadataInsertion -> ()
rnf TimedMetadataInsertion' {Maybe [Id3Insertion]
id3Insertions :: Maybe [Id3Insertion]
$sel:id3Insertions:TimedMetadataInsertion' :: TimedMetadataInsertion -> Maybe [Id3Insertion]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Id3Insertion]
id3Insertions

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