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

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

-- | The configuration for pre-roll ad insertion.
--
-- /See:/ 'newLivePreRollConfiguration' smart constructor.
data LivePreRollConfiguration = LivePreRollConfiguration'
  { -- | The URL for the ad decision server (ADS) for pre-roll ads. This includes
    -- the specification of static parameters and placeholders for dynamic
    -- parameters. AWS Elemental MediaTailor substitutes player-specific and
    -- session-specific parameters as needed when calling the ADS. Alternately,
    -- for testing, you can provide a static VAST URL. The maximum length is
    -- 25,000 characters.
    LivePreRollConfiguration -> Maybe Text
adDecisionServerUrl :: Prelude.Maybe Prelude.Text,
    -- | The maximum allowed duration for the pre-roll ad avail. AWS Elemental
    -- MediaTailor won\'t play pre-roll ads to exceed this duration, regardless
    -- of the total duration of ads that the ADS returns.
    LivePreRollConfiguration -> Maybe Int
maxDurationSeconds :: Prelude.Maybe Prelude.Int
  }
  deriving (LivePreRollConfiguration -> LivePreRollConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LivePreRollConfiguration -> LivePreRollConfiguration -> Bool
$c/= :: LivePreRollConfiguration -> LivePreRollConfiguration -> Bool
== :: LivePreRollConfiguration -> LivePreRollConfiguration -> Bool
$c== :: LivePreRollConfiguration -> LivePreRollConfiguration -> Bool
Prelude.Eq, ReadPrec [LivePreRollConfiguration]
ReadPrec LivePreRollConfiguration
Int -> ReadS LivePreRollConfiguration
ReadS [LivePreRollConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LivePreRollConfiguration]
$creadListPrec :: ReadPrec [LivePreRollConfiguration]
readPrec :: ReadPrec LivePreRollConfiguration
$creadPrec :: ReadPrec LivePreRollConfiguration
readList :: ReadS [LivePreRollConfiguration]
$creadList :: ReadS [LivePreRollConfiguration]
readsPrec :: Int -> ReadS LivePreRollConfiguration
$creadsPrec :: Int -> ReadS LivePreRollConfiguration
Prelude.Read, Int -> LivePreRollConfiguration -> ShowS
[LivePreRollConfiguration] -> ShowS
LivePreRollConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LivePreRollConfiguration] -> ShowS
$cshowList :: [LivePreRollConfiguration] -> ShowS
show :: LivePreRollConfiguration -> String
$cshow :: LivePreRollConfiguration -> String
showsPrec :: Int -> LivePreRollConfiguration -> ShowS
$cshowsPrec :: Int -> LivePreRollConfiguration -> ShowS
Prelude.Show, forall x.
Rep LivePreRollConfiguration x -> LivePreRollConfiguration
forall x.
LivePreRollConfiguration -> Rep LivePreRollConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LivePreRollConfiguration x -> LivePreRollConfiguration
$cfrom :: forall x.
LivePreRollConfiguration -> Rep LivePreRollConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'LivePreRollConfiguration' 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:
--
-- 'adDecisionServerUrl', 'livePreRollConfiguration_adDecisionServerUrl' - The URL for the ad decision server (ADS) for pre-roll ads. This includes
-- the specification of static parameters and placeholders for dynamic
-- parameters. AWS Elemental MediaTailor substitutes player-specific and
-- session-specific parameters as needed when calling the ADS. Alternately,
-- for testing, you can provide a static VAST URL. The maximum length is
-- 25,000 characters.
--
-- 'maxDurationSeconds', 'livePreRollConfiguration_maxDurationSeconds' - The maximum allowed duration for the pre-roll ad avail. AWS Elemental
-- MediaTailor won\'t play pre-roll ads to exceed this duration, regardless
-- of the total duration of ads that the ADS returns.
newLivePreRollConfiguration ::
  LivePreRollConfiguration
newLivePreRollConfiguration :: LivePreRollConfiguration
newLivePreRollConfiguration =
  LivePreRollConfiguration'
    { $sel:adDecisionServerUrl:LivePreRollConfiguration' :: Maybe Text
adDecisionServerUrl =
        forall a. Maybe a
Prelude.Nothing,
      $sel:maxDurationSeconds:LivePreRollConfiguration' :: Maybe Int
maxDurationSeconds = forall a. Maybe a
Prelude.Nothing
    }

-- | The URL for the ad decision server (ADS) for pre-roll ads. This includes
-- the specification of static parameters and placeholders for dynamic
-- parameters. AWS Elemental MediaTailor substitutes player-specific and
-- session-specific parameters as needed when calling the ADS. Alternately,
-- for testing, you can provide a static VAST URL. The maximum length is
-- 25,000 characters.
livePreRollConfiguration_adDecisionServerUrl :: Lens.Lens' LivePreRollConfiguration (Prelude.Maybe Prelude.Text)
livePreRollConfiguration_adDecisionServerUrl :: Lens' LivePreRollConfiguration (Maybe Text)
livePreRollConfiguration_adDecisionServerUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LivePreRollConfiguration' {Maybe Text
adDecisionServerUrl :: Maybe Text
$sel:adDecisionServerUrl:LivePreRollConfiguration' :: LivePreRollConfiguration -> Maybe Text
adDecisionServerUrl} -> Maybe Text
adDecisionServerUrl) (\s :: LivePreRollConfiguration
s@LivePreRollConfiguration' {} Maybe Text
a -> LivePreRollConfiguration
s {$sel:adDecisionServerUrl:LivePreRollConfiguration' :: Maybe Text
adDecisionServerUrl = Maybe Text
a} :: LivePreRollConfiguration)

-- | The maximum allowed duration for the pre-roll ad avail. AWS Elemental
-- MediaTailor won\'t play pre-roll ads to exceed this duration, regardless
-- of the total duration of ads that the ADS returns.
livePreRollConfiguration_maxDurationSeconds :: Lens.Lens' LivePreRollConfiguration (Prelude.Maybe Prelude.Int)
livePreRollConfiguration_maxDurationSeconds :: Lens' LivePreRollConfiguration (Maybe Int)
livePreRollConfiguration_maxDurationSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LivePreRollConfiguration' {Maybe Int
maxDurationSeconds :: Maybe Int
$sel:maxDurationSeconds:LivePreRollConfiguration' :: LivePreRollConfiguration -> Maybe Int
maxDurationSeconds} -> Maybe Int
maxDurationSeconds) (\s :: LivePreRollConfiguration
s@LivePreRollConfiguration' {} Maybe Int
a -> LivePreRollConfiguration
s {$sel:maxDurationSeconds:LivePreRollConfiguration' :: Maybe Int
maxDurationSeconds = Maybe Int
a} :: LivePreRollConfiguration)

instance Data.FromJSON LivePreRollConfiguration where
  parseJSON :: Value -> Parser LivePreRollConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LivePreRollConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe Int -> LivePreRollConfiguration
LivePreRollConfiguration'
            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
"AdDecisionServerUrl")
            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
"MaxDurationSeconds")
      )

instance Prelude.Hashable LivePreRollConfiguration where
  hashWithSalt :: Int -> LivePreRollConfiguration -> Int
hashWithSalt Int
_salt LivePreRollConfiguration' {Maybe Int
Maybe Text
maxDurationSeconds :: Maybe Int
adDecisionServerUrl :: Maybe Text
$sel:maxDurationSeconds:LivePreRollConfiguration' :: LivePreRollConfiguration -> Maybe Int
$sel:adDecisionServerUrl:LivePreRollConfiguration' :: LivePreRollConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
adDecisionServerUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maxDurationSeconds

instance Prelude.NFData LivePreRollConfiguration where
  rnf :: LivePreRollConfiguration -> ()
rnf LivePreRollConfiguration' {Maybe Int
Maybe Text
maxDurationSeconds :: Maybe Int
adDecisionServerUrl :: Maybe Text
$sel:maxDurationSeconds:LivePreRollConfiguration' :: LivePreRollConfiguration -> Maybe Int
$sel:adDecisionServerUrl:LivePreRollConfiguration' :: LivePreRollConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
adDecisionServerUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maxDurationSeconds

instance Data.ToJSON LivePreRollConfiguration where
  toJSON :: LivePreRollConfiguration -> Value
toJSON LivePreRollConfiguration' {Maybe Int
Maybe Text
maxDurationSeconds :: Maybe Int
adDecisionServerUrl :: Maybe Text
$sel:maxDurationSeconds:LivePreRollConfiguration' :: LivePreRollConfiguration -> Maybe Int
$sel:adDecisionServerUrl:LivePreRollConfiguration' :: LivePreRollConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AdDecisionServerUrl" 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
adDecisionServerUrl,
            (Key
"MaxDurationSeconds" 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 Int
maxDurationSeconds
          ]
      )