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

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

-- | Output settings. There can be multiple outputs within a group.
--
-- /See:/ 'newOutput' smart constructor.
data Output = Output'
  { -- | The names of the CaptionDescriptions used as caption sources for this
    -- output.
    Output -> Maybe [Text]
captionDescriptionNames :: Prelude.Maybe [Prelude.Text],
    -- | The name of the VideoDescription used as the source for this output.
    Output -> Maybe Text
videoDescriptionName :: Prelude.Maybe Prelude.Text,
    -- | The name used to identify an output.
    Output -> Maybe Text
outputName :: Prelude.Maybe Prelude.Text,
    -- | The names of the AudioDescriptions used as audio sources for this
    -- output.
    Output -> Maybe [Text]
audioDescriptionNames :: Prelude.Maybe [Prelude.Text],
    -- | Output type-specific settings.
    Output -> OutputSettings
outputSettings :: OutputSettings
  }
  deriving (Output -> Output -> Bool
(Output -> Output -> Bool)
-> (Output -> Output -> Bool) -> Eq Output
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Output -> Output -> Bool
$c/= :: Output -> Output -> Bool
== :: Output -> Output -> Bool
$c== :: Output -> Output -> Bool
Prelude.Eq, ReadPrec [Output]
ReadPrec Output
Int -> ReadS Output
ReadS [Output]
(Int -> ReadS Output)
-> ReadS [Output]
-> ReadPrec Output
-> ReadPrec [Output]
-> Read Output
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Output]
$creadListPrec :: ReadPrec [Output]
readPrec :: ReadPrec Output
$creadPrec :: ReadPrec Output
readList :: ReadS [Output]
$creadList :: ReadS [Output]
readsPrec :: Int -> ReadS Output
$creadsPrec :: Int -> ReadS Output
Prelude.Read, Int -> Output -> ShowS
[Output] -> ShowS
Output -> String
(Int -> Output -> ShowS)
-> (Output -> String) -> ([Output] -> ShowS) -> Show Output
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Output] -> ShowS
$cshowList :: [Output] -> ShowS
show :: Output -> String
$cshow :: Output -> String
showsPrec :: Int -> Output -> ShowS
$cshowsPrec :: Int -> Output -> ShowS
Prelude.Show, (forall x. Output -> Rep Output x)
-> (forall x. Rep Output x -> Output) -> Generic Output
forall x. Rep Output x -> Output
forall x. Output -> Rep Output x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Output x -> Output
$cfrom :: forall x. Output -> Rep Output x
Prelude.Generic)

-- |
-- Create a value of 'Output' 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:
--
-- 'captionDescriptionNames', 'output_captionDescriptionNames' - The names of the CaptionDescriptions used as caption sources for this
-- output.
--
-- 'videoDescriptionName', 'output_videoDescriptionName' - The name of the VideoDescription used as the source for this output.
--
-- 'outputName', 'output_outputName' - The name used to identify an output.
--
-- 'audioDescriptionNames', 'output_audioDescriptionNames' - The names of the AudioDescriptions used as audio sources for this
-- output.
--
-- 'outputSettings', 'output_outputSettings' - Output type-specific settings.
newOutput ::
  -- | 'outputSettings'
  OutputSettings ->
  Output
newOutput :: OutputSettings -> Output
newOutput OutputSettings
pOutputSettings_ =
  Output' :: Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> OutputSettings
-> Output
Output'
    { $sel:captionDescriptionNames:Output' :: Maybe [Text]
captionDescriptionNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:videoDescriptionName:Output' :: Maybe Text
videoDescriptionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:outputName:Output' :: Maybe Text
outputName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:audioDescriptionNames:Output' :: Maybe [Text]
audioDescriptionNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:outputSettings:Output' :: OutputSettings
outputSettings = OutputSettings
pOutputSettings_
    }

-- | The names of the CaptionDescriptions used as caption sources for this
-- output.
output_captionDescriptionNames :: Lens.Lens' Output (Prelude.Maybe [Prelude.Text])
output_captionDescriptionNames :: (Maybe [Text] -> f (Maybe [Text])) -> Output -> f Output
output_captionDescriptionNames = (Output -> Maybe [Text])
-> (Output -> Maybe [Text] -> Output)
-> Lens Output Output (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Output' {Maybe [Text]
captionDescriptionNames :: Maybe [Text]
$sel:captionDescriptionNames:Output' :: Output -> Maybe [Text]
captionDescriptionNames} -> Maybe [Text]
captionDescriptionNames) (\s :: Output
s@Output' {} Maybe [Text]
a -> Output
s {$sel:captionDescriptionNames:Output' :: Maybe [Text]
captionDescriptionNames = Maybe [Text]
a} :: Output) ((Maybe [Text] -> f (Maybe [Text])) -> Output -> f Output)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Output
-> f Output
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the VideoDescription used as the source for this output.
output_videoDescriptionName :: Lens.Lens' Output (Prelude.Maybe Prelude.Text)
output_videoDescriptionName :: (Maybe Text -> f (Maybe Text)) -> Output -> f Output
output_videoDescriptionName = (Output -> Maybe Text)
-> (Output -> Maybe Text -> Output)
-> Lens Output Output (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Output' {Maybe Text
videoDescriptionName :: Maybe Text
$sel:videoDescriptionName:Output' :: Output -> Maybe Text
videoDescriptionName} -> Maybe Text
videoDescriptionName) (\s :: Output
s@Output' {} Maybe Text
a -> Output
s {$sel:videoDescriptionName:Output' :: Maybe Text
videoDescriptionName = Maybe Text
a} :: Output)

-- | The name used to identify an output.
output_outputName :: Lens.Lens' Output (Prelude.Maybe Prelude.Text)
output_outputName :: (Maybe Text -> f (Maybe Text)) -> Output -> f Output
output_outputName = (Output -> Maybe Text)
-> (Output -> Maybe Text -> Output)
-> Lens Output Output (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Output' {Maybe Text
outputName :: Maybe Text
$sel:outputName:Output' :: Output -> Maybe Text
outputName} -> Maybe Text
outputName) (\s :: Output
s@Output' {} Maybe Text
a -> Output
s {$sel:outputName:Output' :: Maybe Text
outputName = Maybe Text
a} :: Output)

-- | The names of the AudioDescriptions used as audio sources for this
-- output.
output_audioDescriptionNames :: Lens.Lens' Output (Prelude.Maybe [Prelude.Text])
output_audioDescriptionNames :: (Maybe [Text] -> f (Maybe [Text])) -> Output -> f Output
output_audioDescriptionNames = (Output -> Maybe [Text])
-> (Output -> Maybe [Text] -> Output)
-> Lens Output Output (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Output' {Maybe [Text]
audioDescriptionNames :: Maybe [Text]
$sel:audioDescriptionNames:Output' :: Output -> Maybe [Text]
audioDescriptionNames} -> Maybe [Text]
audioDescriptionNames) (\s :: Output
s@Output' {} Maybe [Text]
a -> Output
s {$sel:audioDescriptionNames:Output' :: Maybe [Text]
audioDescriptionNames = Maybe [Text]
a} :: Output) ((Maybe [Text] -> f (Maybe [Text])) -> Output -> f Output)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Output
-> f Output
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Output type-specific settings.
output_outputSettings :: Lens.Lens' Output OutputSettings
output_outputSettings :: (OutputSettings -> f OutputSettings) -> Output -> f Output
output_outputSettings = (Output -> OutputSettings)
-> (Output -> OutputSettings -> Output)
-> Lens Output Output OutputSettings OutputSettings
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Output' {OutputSettings
outputSettings :: OutputSettings
$sel:outputSettings:Output' :: Output -> OutputSettings
outputSettings} -> OutputSettings
outputSettings) (\s :: Output
s@Output' {} OutputSettings
a -> Output
s {$sel:outputSettings:Output' :: OutputSettings
outputSettings = OutputSettings
a} :: Output)

instance Core.FromJSON Output where
  parseJSON :: Value -> Parser Output
parseJSON =
    String -> (Object -> Parser Output) -> Value -> Parser Output
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Output"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> OutputSettings
-> Output
Output'
            (Maybe [Text]
 -> Maybe Text
 -> Maybe Text
 -> Maybe [Text]
 -> OutputSettings
 -> Output)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe [Text] -> OutputSettings -> Output)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"captionDescriptionNames"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe [Text] -> OutputSettings -> Output)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe [Text] -> OutputSettings -> Output)
forall (f :: * -> *) a b. Applicative f => 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
"videoDescriptionName")
            Parser (Maybe Text -> Maybe [Text] -> OutputSettings -> Output)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> OutputSettings -> Output)
forall (f :: * -> *) a b. Applicative f => 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
"outputName")
            Parser (Maybe [Text] -> OutputSettings -> Output)
-> Parser (Maybe [Text]) -> Parser (OutputSettings -> Output)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"audioDescriptionNames"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (OutputSettings -> Output)
-> Parser OutputSettings -> Parser Output
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser OutputSettings
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"outputSettings")
      )

instance Prelude.Hashable Output

instance Prelude.NFData Output

instance Core.ToJSON Output where
  toJSON :: Output -> Value
toJSON Output' {Maybe [Text]
Maybe Text
OutputSettings
outputSettings :: OutputSettings
audioDescriptionNames :: Maybe [Text]
outputName :: Maybe Text
videoDescriptionName :: Maybe Text
captionDescriptionNames :: Maybe [Text]
$sel:outputSettings:Output' :: Output -> OutputSettings
$sel:audioDescriptionNames:Output' :: Output -> Maybe [Text]
$sel:outputName:Output' :: Output -> Maybe Text
$sel:videoDescriptionName:Output' :: Output -> Maybe Text
$sel:captionDescriptionNames:Output' :: Output -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"captionDescriptionNames" 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]
captionDescriptionNames,
            (Text
"videoDescriptionName" 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
videoDescriptionName,
            (Text
"outputName" 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
outputName,
            (Text
"audioDescriptionNames" 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]
audioDescriptionNames,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"outputSettings" Text -> OutputSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= OutputSettings
outputSettings)
          ]
      )