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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Audio Hls Rendition Selection
--
-- /See:/ 'newAudioHlsRenditionSelection' smart constructor.
data AudioHlsRenditionSelection = AudioHlsRenditionSelection'
  { -- | Specifies the NAME in the #EXT-X-MEDIA tag of the target HLS audio
    -- rendition.
    AudioHlsRenditionSelection -> Text
name :: Prelude.Text,
    -- | Specifies the GROUP-ID in the #EXT-X-MEDIA tag of the target HLS audio
    -- rendition.
    AudioHlsRenditionSelection -> Text
groupId :: Prelude.Text
  }
  deriving (AudioHlsRenditionSelection -> AudioHlsRenditionSelection -> Bool
(AudioHlsRenditionSelection -> AudioHlsRenditionSelection -> Bool)
-> (AudioHlsRenditionSelection
    -> AudioHlsRenditionSelection -> Bool)
-> Eq AudioHlsRenditionSelection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AudioHlsRenditionSelection -> AudioHlsRenditionSelection -> Bool
$c/= :: AudioHlsRenditionSelection -> AudioHlsRenditionSelection -> Bool
== :: AudioHlsRenditionSelection -> AudioHlsRenditionSelection -> Bool
$c== :: AudioHlsRenditionSelection -> AudioHlsRenditionSelection -> Bool
Prelude.Eq, ReadPrec [AudioHlsRenditionSelection]
ReadPrec AudioHlsRenditionSelection
Int -> ReadS AudioHlsRenditionSelection
ReadS [AudioHlsRenditionSelection]
(Int -> ReadS AudioHlsRenditionSelection)
-> ReadS [AudioHlsRenditionSelection]
-> ReadPrec AudioHlsRenditionSelection
-> ReadPrec [AudioHlsRenditionSelection]
-> Read AudioHlsRenditionSelection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AudioHlsRenditionSelection]
$creadListPrec :: ReadPrec [AudioHlsRenditionSelection]
readPrec :: ReadPrec AudioHlsRenditionSelection
$creadPrec :: ReadPrec AudioHlsRenditionSelection
readList :: ReadS [AudioHlsRenditionSelection]
$creadList :: ReadS [AudioHlsRenditionSelection]
readsPrec :: Int -> ReadS AudioHlsRenditionSelection
$creadsPrec :: Int -> ReadS AudioHlsRenditionSelection
Prelude.Read, Int -> AudioHlsRenditionSelection -> ShowS
[AudioHlsRenditionSelection] -> ShowS
AudioHlsRenditionSelection -> String
(Int -> AudioHlsRenditionSelection -> ShowS)
-> (AudioHlsRenditionSelection -> String)
-> ([AudioHlsRenditionSelection] -> ShowS)
-> Show AudioHlsRenditionSelection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AudioHlsRenditionSelection] -> ShowS
$cshowList :: [AudioHlsRenditionSelection] -> ShowS
show :: AudioHlsRenditionSelection -> String
$cshow :: AudioHlsRenditionSelection -> String
showsPrec :: Int -> AudioHlsRenditionSelection -> ShowS
$cshowsPrec :: Int -> AudioHlsRenditionSelection -> ShowS
Prelude.Show, (forall x.
 AudioHlsRenditionSelection -> Rep AudioHlsRenditionSelection x)
-> (forall x.
    Rep AudioHlsRenditionSelection x -> AudioHlsRenditionSelection)
-> Generic AudioHlsRenditionSelection
forall x.
Rep AudioHlsRenditionSelection x -> AudioHlsRenditionSelection
forall x.
AudioHlsRenditionSelection -> Rep AudioHlsRenditionSelection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AudioHlsRenditionSelection x -> AudioHlsRenditionSelection
$cfrom :: forall x.
AudioHlsRenditionSelection -> Rep AudioHlsRenditionSelection x
Prelude.Generic)

-- |
-- Create a value of 'AudioHlsRenditionSelection' 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:
--
-- 'name', 'audioHlsRenditionSelection_name' - Specifies the NAME in the #EXT-X-MEDIA tag of the target HLS audio
-- rendition.
--
-- 'groupId', 'audioHlsRenditionSelection_groupId' - Specifies the GROUP-ID in the #EXT-X-MEDIA tag of the target HLS audio
-- rendition.
newAudioHlsRenditionSelection ::
  -- | 'name'
  Prelude.Text ->
  -- | 'groupId'
  Prelude.Text ->
  AudioHlsRenditionSelection
newAudioHlsRenditionSelection :: Text -> Text -> AudioHlsRenditionSelection
newAudioHlsRenditionSelection Text
pName_ Text
pGroupId_ =
  AudioHlsRenditionSelection' :: Text -> Text -> AudioHlsRenditionSelection
AudioHlsRenditionSelection'
    { $sel:name:AudioHlsRenditionSelection' :: Text
name = Text
pName_,
      $sel:groupId:AudioHlsRenditionSelection' :: Text
groupId = Text
pGroupId_
    }

-- | Specifies the NAME in the #EXT-X-MEDIA tag of the target HLS audio
-- rendition.
audioHlsRenditionSelection_name :: Lens.Lens' AudioHlsRenditionSelection Prelude.Text
audioHlsRenditionSelection_name :: (Text -> f Text)
-> AudioHlsRenditionSelection -> f AudioHlsRenditionSelection
audioHlsRenditionSelection_name = (AudioHlsRenditionSelection -> Text)
-> (AudioHlsRenditionSelection
    -> Text -> AudioHlsRenditionSelection)
-> Lens
     AudioHlsRenditionSelection AudioHlsRenditionSelection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioHlsRenditionSelection' {Text
name :: Text
$sel:name:AudioHlsRenditionSelection' :: AudioHlsRenditionSelection -> Text
name} -> Text
name) (\s :: AudioHlsRenditionSelection
s@AudioHlsRenditionSelection' {} Text
a -> AudioHlsRenditionSelection
s {$sel:name:AudioHlsRenditionSelection' :: Text
name = Text
a} :: AudioHlsRenditionSelection)

-- | Specifies the GROUP-ID in the #EXT-X-MEDIA tag of the target HLS audio
-- rendition.
audioHlsRenditionSelection_groupId :: Lens.Lens' AudioHlsRenditionSelection Prelude.Text
audioHlsRenditionSelection_groupId :: (Text -> f Text)
-> AudioHlsRenditionSelection -> f AudioHlsRenditionSelection
audioHlsRenditionSelection_groupId = (AudioHlsRenditionSelection -> Text)
-> (AudioHlsRenditionSelection
    -> Text -> AudioHlsRenditionSelection)
-> Lens
     AudioHlsRenditionSelection AudioHlsRenditionSelection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioHlsRenditionSelection' {Text
groupId :: Text
$sel:groupId:AudioHlsRenditionSelection' :: AudioHlsRenditionSelection -> Text
groupId} -> Text
groupId) (\s :: AudioHlsRenditionSelection
s@AudioHlsRenditionSelection' {} Text
a -> AudioHlsRenditionSelection
s {$sel:groupId:AudioHlsRenditionSelection' :: Text
groupId = Text
a} :: AudioHlsRenditionSelection)

instance Core.FromJSON AudioHlsRenditionSelection where
  parseJSON :: Value -> Parser AudioHlsRenditionSelection
parseJSON =
    String
-> (Object -> Parser AudioHlsRenditionSelection)
-> Value
-> Parser AudioHlsRenditionSelection
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AudioHlsRenditionSelection"
      ( \Object
x ->
          Text -> Text -> AudioHlsRenditionSelection
AudioHlsRenditionSelection'
            (Text -> Text -> AudioHlsRenditionSelection)
-> Parser Text -> Parser (Text -> AudioHlsRenditionSelection)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name") Parser (Text -> AudioHlsRenditionSelection)
-> Parser Text -> Parser AudioHlsRenditionSelection
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"groupId")
      )

instance Prelude.Hashable AudioHlsRenditionSelection

instance Prelude.NFData AudioHlsRenditionSelection

instance Core.ToJSON AudioHlsRenditionSelection where
  toJSON :: AudioHlsRenditionSelection -> Value
toJSON AudioHlsRenditionSelection' {Text
groupId :: Text
name :: Text
$sel:groupId:AudioHlsRenditionSelection' :: AudioHlsRenditionSelection -> Text
$sel:name:AudioHlsRenditionSelection' :: AudioHlsRenditionSelection -> Text
..} =
    [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
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"groupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
groupId)
          ]
      )