{-# 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.MediaTailor.Types.ManifestProcessingRules
-- 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.MediaTailor.Types.ManifestProcessingRules where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaTailor.Types.AdMarkerPassthrough
import qualified Amazonka.Prelude as Prelude

-- | The configuration for manifest processing rules. Manifest processing
-- rules enable customization of the personalized manifests created by
-- MediaTailor.
--
-- /See:/ 'newManifestProcessingRules' smart constructor.
data ManifestProcessingRules = ManifestProcessingRules'
  { -- | For HLS, when set to true, MediaTailor passes through EXT-X-CUE-IN,
    -- EXT-X-CUE-OUT, and EXT-X-SPLICEPOINT-SCTE35 ad markers from the origin
    -- manifest to the MediaTailor personalized manifest.
    --
    -- No logic is applied to these ad markers. For example, if EXT-X-CUE-OUT
    -- has a value of 60, but no ads are filled for that ad break, MediaTailor
    -- will not set the value to 0.
    ManifestProcessingRules -> Maybe AdMarkerPassthrough
adMarkerPassthrough :: Prelude.Maybe AdMarkerPassthrough
  }
  deriving (ManifestProcessingRules -> ManifestProcessingRules -> Bool
(ManifestProcessingRules -> ManifestProcessingRules -> Bool)
-> (ManifestProcessingRules -> ManifestProcessingRules -> Bool)
-> Eq ManifestProcessingRules
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ManifestProcessingRules -> ManifestProcessingRules -> Bool
$c/= :: ManifestProcessingRules -> ManifestProcessingRules -> Bool
== :: ManifestProcessingRules -> ManifestProcessingRules -> Bool
$c== :: ManifestProcessingRules -> ManifestProcessingRules -> Bool
Prelude.Eq, ReadPrec [ManifestProcessingRules]
ReadPrec ManifestProcessingRules
Int -> ReadS ManifestProcessingRules
ReadS [ManifestProcessingRules]
(Int -> ReadS ManifestProcessingRules)
-> ReadS [ManifestProcessingRules]
-> ReadPrec ManifestProcessingRules
-> ReadPrec [ManifestProcessingRules]
-> Read ManifestProcessingRules
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ManifestProcessingRules]
$creadListPrec :: ReadPrec [ManifestProcessingRules]
readPrec :: ReadPrec ManifestProcessingRules
$creadPrec :: ReadPrec ManifestProcessingRules
readList :: ReadS [ManifestProcessingRules]
$creadList :: ReadS [ManifestProcessingRules]
readsPrec :: Int -> ReadS ManifestProcessingRules
$creadsPrec :: Int -> ReadS ManifestProcessingRules
Prelude.Read, Int -> ManifestProcessingRules -> ShowS
[ManifestProcessingRules] -> ShowS
ManifestProcessingRules -> String
(Int -> ManifestProcessingRules -> ShowS)
-> (ManifestProcessingRules -> String)
-> ([ManifestProcessingRules] -> ShowS)
-> Show ManifestProcessingRules
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ManifestProcessingRules] -> ShowS
$cshowList :: [ManifestProcessingRules] -> ShowS
show :: ManifestProcessingRules -> String
$cshow :: ManifestProcessingRules -> String
showsPrec :: Int -> ManifestProcessingRules -> ShowS
$cshowsPrec :: Int -> ManifestProcessingRules -> ShowS
Prelude.Show, (forall x.
 ManifestProcessingRules -> Rep ManifestProcessingRules x)
-> (forall x.
    Rep ManifestProcessingRules x -> ManifestProcessingRules)
-> Generic ManifestProcessingRules
forall x. Rep ManifestProcessingRules x -> ManifestProcessingRules
forall x. ManifestProcessingRules -> Rep ManifestProcessingRules x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ManifestProcessingRules x -> ManifestProcessingRules
$cfrom :: forall x. ManifestProcessingRules -> Rep ManifestProcessingRules x
Prelude.Generic)

-- |
-- Create a value of 'ManifestProcessingRules' 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:
--
-- 'adMarkerPassthrough', 'manifestProcessingRules_adMarkerPassthrough' - For HLS, when set to true, MediaTailor passes through EXT-X-CUE-IN,
-- EXT-X-CUE-OUT, and EXT-X-SPLICEPOINT-SCTE35 ad markers from the origin
-- manifest to the MediaTailor personalized manifest.
--
-- No logic is applied to these ad markers. For example, if EXT-X-CUE-OUT
-- has a value of 60, but no ads are filled for that ad break, MediaTailor
-- will not set the value to 0.
newManifestProcessingRules ::
  ManifestProcessingRules
newManifestProcessingRules :: ManifestProcessingRules
newManifestProcessingRules =
  ManifestProcessingRules' :: Maybe AdMarkerPassthrough -> ManifestProcessingRules
ManifestProcessingRules'
    { $sel:adMarkerPassthrough:ManifestProcessingRules' :: Maybe AdMarkerPassthrough
adMarkerPassthrough =
        Maybe AdMarkerPassthrough
forall a. Maybe a
Prelude.Nothing
    }

-- | For HLS, when set to true, MediaTailor passes through EXT-X-CUE-IN,
-- EXT-X-CUE-OUT, and EXT-X-SPLICEPOINT-SCTE35 ad markers from the origin
-- manifest to the MediaTailor personalized manifest.
--
-- No logic is applied to these ad markers. For example, if EXT-X-CUE-OUT
-- has a value of 60, but no ads are filled for that ad break, MediaTailor
-- will not set the value to 0.
manifestProcessingRules_adMarkerPassthrough :: Lens.Lens' ManifestProcessingRules (Prelude.Maybe AdMarkerPassthrough)
manifestProcessingRules_adMarkerPassthrough :: (Maybe AdMarkerPassthrough -> f (Maybe AdMarkerPassthrough))
-> ManifestProcessingRules -> f ManifestProcessingRules
manifestProcessingRules_adMarkerPassthrough = (ManifestProcessingRules -> Maybe AdMarkerPassthrough)
-> (ManifestProcessingRules
    -> Maybe AdMarkerPassthrough -> ManifestProcessingRules)
-> Lens
     ManifestProcessingRules
     ManifestProcessingRules
     (Maybe AdMarkerPassthrough)
     (Maybe AdMarkerPassthrough)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManifestProcessingRules' {Maybe AdMarkerPassthrough
adMarkerPassthrough :: Maybe AdMarkerPassthrough
$sel:adMarkerPassthrough:ManifestProcessingRules' :: ManifestProcessingRules -> Maybe AdMarkerPassthrough
adMarkerPassthrough} -> Maybe AdMarkerPassthrough
adMarkerPassthrough) (\s :: ManifestProcessingRules
s@ManifestProcessingRules' {} Maybe AdMarkerPassthrough
a -> ManifestProcessingRules
s {$sel:adMarkerPassthrough:ManifestProcessingRules' :: Maybe AdMarkerPassthrough
adMarkerPassthrough = Maybe AdMarkerPassthrough
a} :: ManifestProcessingRules)

instance Core.FromJSON ManifestProcessingRules where
  parseJSON :: Value -> Parser ManifestProcessingRules
parseJSON =
    String
-> (Object -> Parser ManifestProcessingRules)
-> Value
-> Parser ManifestProcessingRules
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ManifestProcessingRules"
      ( \Object
x ->
          Maybe AdMarkerPassthrough -> ManifestProcessingRules
ManifestProcessingRules'
            (Maybe AdMarkerPassthrough -> ManifestProcessingRules)
-> Parser (Maybe AdMarkerPassthrough)
-> Parser ManifestProcessingRules
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AdMarkerPassthrough)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AdMarkerPassthrough")
      )

instance Prelude.Hashable ManifestProcessingRules

instance Prelude.NFData ManifestProcessingRules

instance Core.ToJSON ManifestProcessingRules where
  toJSON :: ManifestProcessingRules -> Value
toJSON ManifestProcessingRules' {Maybe AdMarkerPassthrough
adMarkerPassthrough :: Maybe AdMarkerPassthrough
$sel:adMarkerPassthrough:ManifestProcessingRules' :: ManifestProcessingRules -> Maybe AdMarkerPassthrough
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AdMarkerPassthrough" Text -> AdMarkerPassthrough -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AdMarkerPassthrough -> Pair)
-> Maybe AdMarkerPassthrough -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AdMarkerPassthrough
adMarkerPassthrough
          ]
      )