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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElasticTranscoder.Types.Artwork
import qualified Amazonka.Prelude as Prelude

-- | The .jpg or .png file associated with an audio file.
--
-- /See:/ 'newJobAlbumArt' smart constructor.
data JobAlbumArt = JobAlbumArt'
  { -- | The file to be used as album art. There can be multiple artworks
    -- associated with an audio file, to a maximum of 20. Valid formats are
    -- @.jpg@ and @.png@
    JobAlbumArt -> Maybe [Artwork]
artwork :: Prelude.Maybe [Artwork],
    -- | A policy that determines how Elastic Transcoder handles the existence of
    -- multiple album artwork files.
    --
    -- -   @Replace:@ The specified album art replaces any existing album art.
    --
    -- -   @Prepend:@ The specified album art is placed in front of any
    --     existing album art.
    --
    -- -   @Append:@ The specified album art is placed after any existing album
    --     art.
    --
    -- -   @Fallback:@ If the original input file contains artwork, Elastic
    --     Transcoder uses that artwork for the output. If the original input
    --     does not contain artwork, Elastic Transcoder uses the specified
    --     album art file.
    JobAlbumArt -> Maybe Text
mergePolicy :: Prelude.Maybe Prelude.Text
  }
  deriving (JobAlbumArt -> JobAlbumArt -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobAlbumArt -> JobAlbumArt -> Bool
$c/= :: JobAlbumArt -> JobAlbumArt -> Bool
== :: JobAlbumArt -> JobAlbumArt -> Bool
$c== :: JobAlbumArt -> JobAlbumArt -> Bool
Prelude.Eq, ReadPrec [JobAlbumArt]
ReadPrec JobAlbumArt
Int -> ReadS JobAlbumArt
ReadS [JobAlbumArt]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobAlbumArt]
$creadListPrec :: ReadPrec [JobAlbumArt]
readPrec :: ReadPrec JobAlbumArt
$creadPrec :: ReadPrec JobAlbumArt
readList :: ReadS [JobAlbumArt]
$creadList :: ReadS [JobAlbumArt]
readsPrec :: Int -> ReadS JobAlbumArt
$creadsPrec :: Int -> ReadS JobAlbumArt
Prelude.Read, Int -> JobAlbumArt -> ShowS
[JobAlbumArt] -> ShowS
JobAlbumArt -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobAlbumArt] -> ShowS
$cshowList :: [JobAlbumArt] -> ShowS
show :: JobAlbumArt -> String
$cshow :: JobAlbumArt -> String
showsPrec :: Int -> JobAlbumArt -> ShowS
$cshowsPrec :: Int -> JobAlbumArt -> ShowS
Prelude.Show, forall x. Rep JobAlbumArt x -> JobAlbumArt
forall x. JobAlbumArt -> Rep JobAlbumArt x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobAlbumArt x -> JobAlbumArt
$cfrom :: forall x. JobAlbumArt -> Rep JobAlbumArt x
Prelude.Generic)

-- |
-- Create a value of 'JobAlbumArt' 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:
--
-- 'artwork', 'jobAlbumArt_artwork' - The file to be used as album art. There can be multiple artworks
-- associated with an audio file, to a maximum of 20. Valid formats are
-- @.jpg@ and @.png@
--
-- 'mergePolicy', 'jobAlbumArt_mergePolicy' - A policy that determines how Elastic Transcoder handles the existence of
-- multiple album artwork files.
--
-- -   @Replace:@ The specified album art replaces any existing album art.
--
-- -   @Prepend:@ The specified album art is placed in front of any
--     existing album art.
--
-- -   @Append:@ The specified album art is placed after any existing album
--     art.
--
-- -   @Fallback:@ If the original input file contains artwork, Elastic
--     Transcoder uses that artwork for the output. If the original input
--     does not contain artwork, Elastic Transcoder uses the specified
--     album art file.
newJobAlbumArt ::
  JobAlbumArt
newJobAlbumArt :: JobAlbumArt
newJobAlbumArt =
  JobAlbumArt'
    { $sel:artwork:JobAlbumArt' :: Maybe [Artwork]
artwork = forall a. Maybe a
Prelude.Nothing,
      $sel:mergePolicy:JobAlbumArt' :: Maybe Text
mergePolicy = forall a. Maybe a
Prelude.Nothing
    }

-- | The file to be used as album art. There can be multiple artworks
-- associated with an audio file, to a maximum of 20. Valid formats are
-- @.jpg@ and @.png@
jobAlbumArt_artwork :: Lens.Lens' JobAlbumArt (Prelude.Maybe [Artwork])
jobAlbumArt_artwork :: Lens' JobAlbumArt (Maybe [Artwork])
jobAlbumArt_artwork = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobAlbumArt' {Maybe [Artwork]
artwork :: Maybe [Artwork]
$sel:artwork:JobAlbumArt' :: JobAlbumArt -> Maybe [Artwork]
artwork} -> Maybe [Artwork]
artwork) (\s :: JobAlbumArt
s@JobAlbumArt' {} Maybe [Artwork]
a -> JobAlbumArt
s {$sel:artwork:JobAlbumArt' :: Maybe [Artwork]
artwork = Maybe [Artwork]
a} :: JobAlbumArt) 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

-- | A policy that determines how Elastic Transcoder handles the existence of
-- multiple album artwork files.
--
-- -   @Replace:@ The specified album art replaces any existing album art.
--
-- -   @Prepend:@ The specified album art is placed in front of any
--     existing album art.
--
-- -   @Append:@ The specified album art is placed after any existing album
--     art.
--
-- -   @Fallback:@ If the original input file contains artwork, Elastic
--     Transcoder uses that artwork for the output. If the original input
--     does not contain artwork, Elastic Transcoder uses the specified
--     album art file.
jobAlbumArt_mergePolicy :: Lens.Lens' JobAlbumArt (Prelude.Maybe Prelude.Text)
jobAlbumArt_mergePolicy :: Lens' JobAlbumArt (Maybe Text)
jobAlbumArt_mergePolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobAlbumArt' {Maybe Text
mergePolicy :: Maybe Text
$sel:mergePolicy:JobAlbumArt' :: JobAlbumArt -> Maybe Text
mergePolicy} -> Maybe Text
mergePolicy) (\s :: JobAlbumArt
s@JobAlbumArt' {} Maybe Text
a -> JobAlbumArt
s {$sel:mergePolicy:JobAlbumArt' :: Maybe Text
mergePolicy = Maybe Text
a} :: JobAlbumArt)

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

instance Prelude.Hashable JobAlbumArt where
  hashWithSalt :: Int -> JobAlbumArt -> Int
hashWithSalt Int
_salt JobAlbumArt' {Maybe [Artwork]
Maybe Text
mergePolicy :: Maybe Text
artwork :: Maybe [Artwork]
$sel:mergePolicy:JobAlbumArt' :: JobAlbumArt -> Maybe Text
$sel:artwork:JobAlbumArt' :: JobAlbumArt -> Maybe [Artwork]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Artwork]
artwork
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
mergePolicy

instance Prelude.NFData JobAlbumArt where
  rnf :: JobAlbumArt -> ()
rnf JobAlbumArt' {Maybe [Artwork]
Maybe Text
mergePolicy :: Maybe Text
artwork :: Maybe [Artwork]
$sel:mergePolicy:JobAlbumArt' :: JobAlbumArt -> Maybe Text
$sel:artwork:JobAlbumArt' :: JobAlbumArt -> Maybe [Artwork]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Artwork]
artwork
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
mergePolicy

instance Data.ToJSON JobAlbumArt where
  toJSON :: JobAlbumArt -> Value
toJSON JobAlbumArt' {Maybe [Artwork]
Maybe Text
mergePolicy :: Maybe Text
artwork :: Maybe [Artwork]
$sel:mergePolicy:JobAlbumArt' :: JobAlbumArt -> Maybe Text
$sel:artwork:JobAlbumArt' :: JobAlbumArt -> Maybe [Artwork]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Artwork" 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 [Artwork]
artwork,
            (Key
"MergePolicy" 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 Text
mergePolicy
          ]
      )