{-# 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.MediaLive.Types.AudioTrackSelection
-- 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.MediaLive.Types.AudioTrackSelection where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.AudioTrack
import qualified Amazonka.Prelude as Prelude

-- | Audio Track Selection
--
-- /See:/ 'newAudioTrackSelection' smart constructor.
data AudioTrackSelection = AudioTrackSelection'
  { -- | Selects one or more unique audio tracks from within a source.
    AudioTrackSelection -> [AudioTrack]
tracks :: [AudioTrack]
  }
  deriving (AudioTrackSelection -> AudioTrackSelection -> Bool
(AudioTrackSelection -> AudioTrackSelection -> Bool)
-> (AudioTrackSelection -> AudioTrackSelection -> Bool)
-> Eq AudioTrackSelection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AudioTrackSelection -> AudioTrackSelection -> Bool
$c/= :: AudioTrackSelection -> AudioTrackSelection -> Bool
== :: AudioTrackSelection -> AudioTrackSelection -> Bool
$c== :: AudioTrackSelection -> AudioTrackSelection -> Bool
Prelude.Eq, ReadPrec [AudioTrackSelection]
ReadPrec AudioTrackSelection
Int -> ReadS AudioTrackSelection
ReadS [AudioTrackSelection]
(Int -> ReadS AudioTrackSelection)
-> ReadS [AudioTrackSelection]
-> ReadPrec AudioTrackSelection
-> ReadPrec [AudioTrackSelection]
-> Read AudioTrackSelection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AudioTrackSelection]
$creadListPrec :: ReadPrec [AudioTrackSelection]
readPrec :: ReadPrec AudioTrackSelection
$creadPrec :: ReadPrec AudioTrackSelection
readList :: ReadS [AudioTrackSelection]
$creadList :: ReadS [AudioTrackSelection]
readsPrec :: Int -> ReadS AudioTrackSelection
$creadsPrec :: Int -> ReadS AudioTrackSelection
Prelude.Read, Int -> AudioTrackSelection -> ShowS
[AudioTrackSelection] -> ShowS
AudioTrackSelection -> String
(Int -> AudioTrackSelection -> ShowS)
-> (AudioTrackSelection -> String)
-> ([AudioTrackSelection] -> ShowS)
-> Show AudioTrackSelection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AudioTrackSelection] -> ShowS
$cshowList :: [AudioTrackSelection] -> ShowS
show :: AudioTrackSelection -> String
$cshow :: AudioTrackSelection -> String
showsPrec :: Int -> AudioTrackSelection -> ShowS
$cshowsPrec :: Int -> AudioTrackSelection -> ShowS
Prelude.Show, (forall x. AudioTrackSelection -> Rep AudioTrackSelection x)
-> (forall x. Rep AudioTrackSelection x -> AudioTrackSelection)
-> Generic AudioTrackSelection
forall x. Rep AudioTrackSelection x -> AudioTrackSelection
forall x. AudioTrackSelection -> Rep AudioTrackSelection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AudioTrackSelection x -> AudioTrackSelection
$cfrom :: forall x. AudioTrackSelection -> Rep AudioTrackSelection x
Prelude.Generic)

-- |
-- Create a value of 'AudioTrackSelection' 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:
--
-- 'tracks', 'audioTrackSelection_tracks' - Selects one or more unique audio tracks from within a source.
newAudioTrackSelection ::
  AudioTrackSelection
newAudioTrackSelection :: AudioTrackSelection
newAudioTrackSelection =
  AudioTrackSelection' :: [AudioTrack] -> AudioTrackSelection
AudioTrackSelection' {$sel:tracks:AudioTrackSelection' :: [AudioTrack]
tracks = [AudioTrack]
forall a. Monoid a => a
Prelude.mempty}

-- | Selects one or more unique audio tracks from within a source.
audioTrackSelection_tracks :: Lens.Lens' AudioTrackSelection [AudioTrack]
audioTrackSelection_tracks :: ([AudioTrack] -> f [AudioTrack])
-> AudioTrackSelection -> f AudioTrackSelection
audioTrackSelection_tracks = (AudioTrackSelection -> [AudioTrack])
-> (AudioTrackSelection -> [AudioTrack] -> AudioTrackSelection)
-> Lens
     AudioTrackSelection AudioTrackSelection [AudioTrack] [AudioTrack]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioTrackSelection' {[AudioTrack]
tracks :: [AudioTrack]
$sel:tracks:AudioTrackSelection' :: AudioTrackSelection -> [AudioTrack]
tracks} -> [AudioTrack]
tracks) (\s :: AudioTrackSelection
s@AudioTrackSelection' {} [AudioTrack]
a -> AudioTrackSelection
s {$sel:tracks:AudioTrackSelection' :: [AudioTrack]
tracks = [AudioTrack]
a} :: AudioTrackSelection) (([AudioTrack] -> f [AudioTrack])
 -> AudioTrackSelection -> f AudioTrackSelection)
-> (([AudioTrack] -> f [AudioTrack])
    -> [AudioTrack] -> f [AudioTrack])
-> ([AudioTrack] -> f [AudioTrack])
-> AudioTrackSelection
-> f AudioTrackSelection
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AudioTrack] -> f [AudioTrack]) -> [AudioTrack] -> f [AudioTrack]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable AudioTrackSelection

instance Prelude.NFData AudioTrackSelection

instance Core.ToJSON AudioTrackSelection where
  toJSON :: AudioTrackSelection -> Value
toJSON AudioTrackSelection' {[AudioTrack]
tracks :: [AudioTrack]
$sel:tracks:AudioTrackSelection' :: AudioTrackSelection -> [AudioTrack]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"tracks" Text -> [AudioTrack] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [AudioTrack]
tracks)]
      )