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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaLive.Types.Output
import Amazonka.MediaLive.Types.OutputGroupSettings
import qualified Amazonka.Prelude as Prelude

-- | Output groups for this Live Event. Output groups contain information
-- about where streams should be distributed.
--
-- /See:/ 'newOutputGroup' smart constructor.
data OutputGroup = OutputGroup'
  { -- | Custom output group name optionally defined by the user.
    OutputGroup -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    OutputGroup -> [Output]
outputs :: [Output],
    -- | Settings associated with the output group.
    OutputGroup -> OutputGroupSettings
outputGroupSettings :: OutputGroupSettings
  }
  deriving (OutputGroup -> OutputGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputGroup -> OutputGroup -> Bool
$c/= :: OutputGroup -> OutputGroup -> Bool
== :: OutputGroup -> OutputGroup -> Bool
$c== :: OutputGroup -> OutputGroup -> Bool
Prelude.Eq, ReadPrec [OutputGroup]
ReadPrec OutputGroup
Int -> ReadS OutputGroup
ReadS [OutputGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OutputGroup]
$creadListPrec :: ReadPrec [OutputGroup]
readPrec :: ReadPrec OutputGroup
$creadPrec :: ReadPrec OutputGroup
readList :: ReadS [OutputGroup]
$creadList :: ReadS [OutputGroup]
readsPrec :: Int -> ReadS OutputGroup
$creadsPrec :: Int -> ReadS OutputGroup
Prelude.Read, Int -> OutputGroup -> ShowS
[OutputGroup] -> ShowS
OutputGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputGroup] -> ShowS
$cshowList :: [OutputGroup] -> ShowS
show :: OutputGroup -> String
$cshow :: OutputGroup -> String
showsPrec :: Int -> OutputGroup -> ShowS
$cshowsPrec :: Int -> OutputGroup -> ShowS
Prelude.Show, forall x. Rep OutputGroup x -> OutputGroup
forall x. OutputGroup -> Rep OutputGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OutputGroup x -> OutputGroup
$cfrom :: forall x. OutputGroup -> Rep OutputGroup x
Prelude.Generic)

-- |
-- Create a value of 'OutputGroup' 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', 'outputGroup_name' - Custom output group name optionally defined by the user.
--
-- 'outputs', 'outputGroup_outputs' - Undocumented member.
--
-- 'outputGroupSettings', 'outputGroup_outputGroupSettings' - Settings associated with the output group.
newOutputGroup ::
  -- | 'outputGroupSettings'
  OutputGroupSettings ->
  OutputGroup
newOutputGroup :: OutputGroupSettings -> OutputGroup
newOutputGroup OutputGroupSettings
pOutputGroupSettings_ =
  OutputGroup'
    { $sel:name:OutputGroup' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:outputs:OutputGroup' :: [Output]
outputs = forall a. Monoid a => a
Prelude.mempty,
      $sel:outputGroupSettings:OutputGroup' :: OutputGroupSettings
outputGroupSettings = OutputGroupSettings
pOutputGroupSettings_
    }

-- | Custom output group name optionally defined by the user.
outputGroup_name :: Lens.Lens' OutputGroup (Prelude.Maybe Prelude.Text)
outputGroup_name :: Lens' OutputGroup (Maybe Text)
outputGroup_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputGroup' {Maybe Text
name :: Maybe Text
$sel:name:OutputGroup' :: OutputGroup -> Maybe Text
name} -> Maybe Text
name) (\s :: OutputGroup
s@OutputGroup' {} Maybe Text
a -> OutputGroup
s {$sel:name:OutputGroup' :: Maybe Text
name = Maybe Text
a} :: OutputGroup)

-- | Undocumented member.
outputGroup_outputs :: Lens.Lens' OutputGroup [Output]
outputGroup_outputs :: Lens' OutputGroup [Output]
outputGroup_outputs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputGroup' {[Output]
outputs :: [Output]
$sel:outputs:OutputGroup' :: OutputGroup -> [Output]
outputs} -> [Output]
outputs) (\s :: OutputGroup
s@OutputGroup' {} [Output]
a -> OutputGroup
s {$sel:outputs:OutputGroup' :: [Output]
outputs = [Output]
a} :: OutputGroup) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Settings associated with the output group.
outputGroup_outputGroupSettings :: Lens.Lens' OutputGroup OutputGroupSettings
outputGroup_outputGroupSettings :: Lens' OutputGroup OutputGroupSettings
outputGroup_outputGroupSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputGroup' {OutputGroupSettings
outputGroupSettings :: OutputGroupSettings
$sel:outputGroupSettings:OutputGroup' :: OutputGroup -> OutputGroupSettings
outputGroupSettings} -> OutputGroupSettings
outputGroupSettings) (\s :: OutputGroup
s@OutputGroup' {} OutputGroupSettings
a -> OutputGroup
s {$sel:outputGroupSettings:OutputGroup' :: OutputGroupSettings
outputGroupSettings = OutputGroupSettings
a} :: OutputGroup)

instance Data.FromJSON OutputGroup where
  parseJSON :: Value -> Parser OutputGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OutputGroup"
      ( \Object
x ->
          Maybe Text -> [Output] -> OutputGroupSettings -> OutputGroup
OutputGroup'
            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
"name")
            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
"outputs" 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 a
Data..: Key
"outputGroupSettings")
      )

instance Prelude.Hashable OutputGroup where
  hashWithSalt :: Int -> OutputGroup -> Int
hashWithSalt Int
_salt OutputGroup' {[Output]
Maybe Text
OutputGroupSettings
outputGroupSettings :: OutputGroupSettings
outputs :: [Output]
name :: Maybe Text
$sel:outputGroupSettings:OutputGroup' :: OutputGroup -> OutputGroupSettings
$sel:outputs:OutputGroup' :: OutputGroup -> [Output]
$sel:name:OutputGroup' :: OutputGroup -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Output]
outputs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` OutputGroupSettings
outputGroupSettings

instance Prelude.NFData OutputGroup where
  rnf :: OutputGroup -> ()
rnf OutputGroup' {[Output]
Maybe Text
OutputGroupSettings
outputGroupSettings :: OutputGroupSettings
outputs :: [Output]
name :: Maybe Text
$sel:outputGroupSettings:OutputGroup' :: OutputGroup -> OutputGroupSettings
$sel:outputs:OutputGroup' :: OutputGroup -> [Output]
$sel:name:OutputGroup' :: OutputGroup -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Output]
outputs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf OutputGroupSettings
outputGroupSettings

instance Data.ToJSON OutputGroup where
  toJSON :: OutputGroup -> Value
toJSON OutputGroup' {[Output]
Maybe Text
OutputGroupSettings
outputGroupSettings :: OutputGroupSettings
outputs :: [Output]
name :: Maybe Text
$sel:outputGroupSettings:OutputGroup' :: OutputGroup -> OutputGroupSettings
$sel:outputs:OutputGroup' :: OutputGroup -> [Output]
$sel:name:OutputGroup' :: OutputGroup -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"name" 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
name,
            forall a. a -> Maybe a
Prelude.Just (Key
"outputs" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Output]
outputs),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"outputGroupSettings" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= OutputGroupSettings
outputGroupSettings)
          ]
      )