{-# 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.MediaPackage.Types.MssPackage
-- 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.MediaPackage.Types.MssPackage where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaPackage.Types.MssEncryption
import Amazonka.MediaPackage.Types.StreamSelection
import qualified Amazonka.Prelude as Prelude

-- | A Microsoft Smooth Streaming (MSS) packaging configuration.
--
-- /See:/ 'newMssPackage' smart constructor.
data MssPackage = MssPackage'
  { -- | The duration (in seconds) of each segment.
    MssPackage -> Maybe Int
segmentDurationSeconds :: Prelude.Maybe Prelude.Int,
    MssPackage -> Maybe StreamSelection
streamSelection :: Prelude.Maybe StreamSelection,
    MssPackage -> Maybe MssEncryption
encryption :: Prelude.Maybe MssEncryption,
    -- | The time window (in seconds) contained in each manifest.
    MssPackage -> Maybe Int
manifestWindowSeconds :: Prelude.Maybe Prelude.Int
  }
  deriving (MssPackage -> MssPackage -> Bool
(MssPackage -> MssPackage -> Bool)
-> (MssPackage -> MssPackage -> Bool) -> Eq MssPackage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MssPackage -> MssPackage -> Bool
$c/= :: MssPackage -> MssPackage -> Bool
== :: MssPackage -> MssPackage -> Bool
$c== :: MssPackage -> MssPackage -> Bool
Prelude.Eq, ReadPrec [MssPackage]
ReadPrec MssPackage
Int -> ReadS MssPackage
ReadS [MssPackage]
(Int -> ReadS MssPackage)
-> ReadS [MssPackage]
-> ReadPrec MssPackage
-> ReadPrec [MssPackage]
-> Read MssPackage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MssPackage]
$creadListPrec :: ReadPrec [MssPackage]
readPrec :: ReadPrec MssPackage
$creadPrec :: ReadPrec MssPackage
readList :: ReadS [MssPackage]
$creadList :: ReadS [MssPackage]
readsPrec :: Int -> ReadS MssPackage
$creadsPrec :: Int -> ReadS MssPackage
Prelude.Read, Int -> MssPackage -> ShowS
[MssPackage] -> ShowS
MssPackage -> String
(Int -> MssPackage -> ShowS)
-> (MssPackage -> String)
-> ([MssPackage] -> ShowS)
-> Show MssPackage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MssPackage] -> ShowS
$cshowList :: [MssPackage] -> ShowS
show :: MssPackage -> String
$cshow :: MssPackage -> String
showsPrec :: Int -> MssPackage -> ShowS
$cshowsPrec :: Int -> MssPackage -> ShowS
Prelude.Show, (forall x. MssPackage -> Rep MssPackage x)
-> (forall x. Rep MssPackage x -> MssPackage) -> Generic MssPackage
forall x. Rep MssPackage x -> MssPackage
forall x. MssPackage -> Rep MssPackage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MssPackage x -> MssPackage
$cfrom :: forall x. MssPackage -> Rep MssPackage x
Prelude.Generic)

-- |
-- Create a value of 'MssPackage' 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:
--
-- 'segmentDurationSeconds', 'mssPackage_segmentDurationSeconds' - The duration (in seconds) of each segment.
--
-- 'streamSelection', 'mssPackage_streamSelection' - Undocumented member.
--
-- 'encryption', 'mssPackage_encryption' - Undocumented member.
--
-- 'manifestWindowSeconds', 'mssPackage_manifestWindowSeconds' - The time window (in seconds) contained in each manifest.
newMssPackage ::
  MssPackage
newMssPackage :: MssPackage
newMssPackage =
  MssPackage' :: Maybe Int
-> Maybe StreamSelection
-> Maybe MssEncryption
-> Maybe Int
-> MssPackage
MssPackage'
    { $sel:segmentDurationSeconds:MssPackage' :: Maybe Int
segmentDurationSeconds =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:streamSelection:MssPackage' :: Maybe StreamSelection
streamSelection = Maybe StreamSelection
forall a. Maybe a
Prelude.Nothing,
      $sel:encryption:MssPackage' :: Maybe MssEncryption
encryption = Maybe MssEncryption
forall a. Maybe a
Prelude.Nothing,
      $sel:manifestWindowSeconds:MssPackage' :: Maybe Int
manifestWindowSeconds = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The duration (in seconds) of each segment.
mssPackage_segmentDurationSeconds :: Lens.Lens' MssPackage (Prelude.Maybe Prelude.Int)
mssPackage_segmentDurationSeconds :: (Maybe Int -> f (Maybe Int)) -> MssPackage -> f MssPackage
mssPackage_segmentDurationSeconds = (MssPackage -> Maybe Int)
-> (MssPackage -> Maybe Int -> MssPackage)
-> Lens MssPackage MssPackage (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MssPackage' {Maybe Int
segmentDurationSeconds :: Maybe Int
$sel:segmentDurationSeconds:MssPackage' :: MssPackage -> Maybe Int
segmentDurationSeconds} -> Maybe Int
segmentDurationSeconds) (\s :: MssPackage
s@MssPackage' {} Maybe Int
a -> MssPackage
s {$sel:segmentDurationSeconds:MssPackage' :: Maybe Int
segmentDurationSeconds = Maybe Int
a} :: MssPackage)

-- | Undocumented member.
mssPackage_streamSelection :: Lens.Lens' MssPackage (Prelude.Maybe StreamSelection)
mssPackage_streamSelection :: (Maybe StreamSelection -> f (Maybe StreamSelection))
-> MssPackage -> f MssPackage
mssPackage_streamSelection = (MssPackage -> Maybe StreamSelection)
-> (MssPackage -> Maybe StreamSelection -> MssPackage)
-> Lens
     MssPackage
     MssPackage
     (Maybe StreamSelection)
     (Maybe StreamSelection)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MssPackage' {Maybe StreamSelection
streamSelection :: Maybe StreamSelection
$sel:streamSelection:MssPackage' :: MssPackage -> Maybe StreamSelection
streamSelection} -> Maybe StreamSelection
streamSelection) (\s :: MssPackage
s@MssPackage' {} Maybe StreamSelection
a -> MssPackage
s {$sel:streamSelection:MssPackage' :: Maybe StreamSelection
streamSelection = Maybe StreamSelection
a} :: MssPackage)

-- | Undocumented member.
mssPackage_encryption :: Lens.Lens' MssPackage (Prelude.Maybe MssEncryption)
mssPackage_encryption :: (Maybe MssEncryption -> f (Maybe MssEncryption))
-> MssPackage -> f MssPackage
mssPackage_encryption = (MssPackage -> Maybe MssEncryption)
-> (MssPackage -> Maybe MssEncryption -> MssPackage)
-> Lens
     MssPackage MssPackage (Maybe MssEncryption) (Maybe MssEncryption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MssPackage' {Maybe MssEncryption
encryption :: Maybe MssEncryption
$sel:encryption:MssPackage' :: MssPackage -> Maybe MssEncryption
encryption} -> Maybe MssEncryption
encryption) (\s :: MssPackage
s@MssPackage' {} Maybe MssEncryption
a -> MssPackage
s {$sel:encryption:MssPackage' :: Maybe MssEncryption
encryption = Maybe MssEncryption
a} :: MssPackage)

-- | The time window (in seconds) contained in each manifest.
mssPackage_manifestWindowSeconds :: Lens.Lens' MssPackage (Prelude.Maybe Prelude.Int)
mssPackage_manifestWindowSeconds :: (Maybe Int -> f (Maybe Int)) -> MssPackage -> f MssPackage
mssPackage_manifestWindowSeconds = (MssPackage -> Maybe Int)
-> (MssPackage -> Maybe Int -> MssPackage)
-> Lens MssPackage MssPackage (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MssPackage' {Maybe Int
manifestWindowSeconds :: Maybe Int
$sel:manifestWindowSeconds:MssPackage' :: MssPackage -> Maybe Int
manifestWindowSeconds} -> Maybe Int
manifestWindowSeconds) (\s :: MssPackage
s@MssPackage' {} Maybe Int
a -> MssPackage
s {$sel:manifestWindowSeconds:MssPackage' :: Maybe Int
manifestWindowSeconds = Maybe Int
a} :: MssPackage)

instance Core.FromJSON MssPackage where
  parseJSON :: Value -> Parser MssPackage
parseJSON =
    String
-> (Object -> Parser MssPackage) -> Value -> Parser MssPackage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MssPackage"
      ( \Object
x ->
          Maybe Int
-> Maybe StreamSelection
-> Maybe MssEncryption
-> Maybe Int
-> MssPackage
MssPackage'
            (Maybe Int
 -> Maybe StreamSelection
 -> Maybe MssEncryption
 -> Maybe Int
 -> MssPackage)
-> Parser (Maybe Int)
-> Parser
     (Maybe StreamSelection
      -> Maybe MssEncryption -> Maybe Int -> MssPackage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"segmentDurationSeconds")
            Parser
  (Maybe StreamSelection
   -> Maybe MssEncryption -> Maybe Int -> MssPackage)
-> Parser (Maybe StreamSelection)
-> Parser (Maybe MssEncryption -> Maybe Int -> MssPackage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe StreamSelection)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"streamSelection")
            Parser (Maybe MssEncryption -> Maybe Int -> MssPackage)
-> Parser (Maybe MssEncryption) -> Parser (Maybe Int -> MssPackage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MssEncryption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"encryption")
            Parser (Maybe Int -> MssPackage)
-> Parser (Maybe Int) -> Parser MssPackage
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"manifestWindowSeconds")
      )

instance Prelude.Hashable MssPackage

instance Prelude.NFData MssPackage

instance Core.ToJSON MssPackage where
  toJSON :: MssPackage -> Value
toJSON MssPackage' {Maybe Int
Maybe MssEncryption
Maybe StreamSelection
manifestWindowSeconds :: Maybe Int
encryption :: Maybe MssEncryption
streamSelection :: Maybe StreamSelection
segmentDurationSeconds :: Maybe Int
$sel:manifestWindowSeconds:MssPackage' :: MssPackage -> Maybe Int
$sel:encryption:MssPackage' :: MssPackage -> Maybe MssEncryption
$sel:streamSelection:MssPackage' :: MssPackage -> Maybe StreamSelection
$sel:segmentDurationSeconds:MssPackage' :: MssPackage -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"segmentDurationSeconds" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
segmentDurationSeconds,
            (Text
"streamSelection" Text -> StreamSelection -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (StreamSelection -> Pair) -> Maybe StreamSelection -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StreamSelection
streamSelection,
            (Text
"encryption" Text -> MssEncryption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (MssEncryption -> Pair) -> Maybe MssEncryption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MssEncryption
encryption,
            (Text
"manifestWindowSeconds" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
manifestWindowSeconds
          ]
      )