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

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

-- | The .jpg or .png file associated with an audio file.
--
-- /See:/ 'newJobAlbumArt' smart constructor.
data JobAlbumArt = JobAlbumArt'
  { -- | 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,
    -- | 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]
  }
  deriving (JobAlbumArt -> JobAlbumArt -> Bool
(JobAlbumArt -> JobAlbumArt -> Bool)
-> (JobAlbumArt -> JobAlbumArt -> Bool) -> Eq JobAlbumArt
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]
(Int -> ReadS JobAlbumArt)
-> ReadS [JobAlbumArt]
-> ReadPrec JobAlbumArt
-> ReadPrec [JobAlbumArt]
-> Read 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
(Int -> JobAlbumArt -> ShowS)
-> (JobAlbumArt -> String)
-> ([JobAlbumArt] -> ShowS)
-> Show JobAlbumArt
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. JobAlbumArt -> Rep JobAlbumArt x)
-> (forall x. Rep JobAlbumArt x -> JobAlbumArt)
-> Generic JobAlbumArt
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:
--
-- '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.
--
-- '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@
newJobAlbumArt ::
  JobAlbumArt
newJobAlbumArt :: JobAlbumArt
newJobAlbumArt =
  JobAlbumArt' :: Maybe Text -> Maybe [Artwork] -> JobAlbumArt
JobAlbumArt'
    { $sel:mergePolicy:JobAlbumArt' :: Maybe Text
mergePolicy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:artwork:JobAlbumArt' :: Maybe [Artwork]
artwork = Maybe [Artwork]
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> JobAlbumArt -> f JobAlbumArt
jobAlbumArt_mergePolicy = (JobAlbumArt -> Maybe Text)
-> (JobAlbumArt -> Maybe Text -> JobAlbumArt)
-> Lens JobAlbumArt JobAlbumArt (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe [Artwork] -> f (Maybe [Artwork]))
-> JobAlbumArt -> f JobAlbumArt
jobAlbumArt_artwork = (JobAlbumArt -> Maybe [Artwork])
-> (JobAlbumArt -> Maybe [Artwork] -> JobAlbumArt)
-> Lens JobAlbumArt JobAlbumArt (Maybe [Artwork]) (Maybe [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) ((Maybe [Artwork] -> f (Maybe [Artwork]))
 -> JobAlbumArt -> f JobAlbumArt)
-> ((Maybe [Artwork] -> f (Maybe [Artwork]))
    -> Maybe [Artwork] -> f (Maybe [Artwork]))
-> (Maybe [Artwork] -> f (Maybe [Artwork]))
-> JobAlbumArt
-> f JobAlbumArt
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Artwork] [Artwork] [Artwork] [Artwork]
-> Iso
     (Maybe [Artwork])
     (Maybe [Artwork])
     (Maybe [Artwork])
     (Maybe [Artwork])
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 [Artwork] [Artwork] [Artwork] [Artwork]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable JobAlbumArt

instance Prelude.NFData JobAlbumArt

instance Core.ToJSON JobAlbumArt where
  toJSON :: JobAlbumArt -> Value
toJSON JobAlbumArt' {Maybe [Artwork]
Maybe Text
artwork :: Maybe [Artwork]
mergePolicy :: Maybe Text
$sel:artwork:JobAlbumArt' :: JobAlbumArt -> Maybe [Artwork]
$sel:mergePolicy:JobAlbumArt' :: JobAlbumArt -> 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
"Artwork" Text -> [Artwork] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Artwork] -> Pair) -> Maybe [Artwork] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Artwork]
artwork
          ]
      )