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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(LivePreRollConfiguration -> LivePreRollConfiguration -> Bool)
-> (LivePreRollConfiguration -> LivePreRollConfiguration -> Bool)
-> Eq LivePreRollConfiguration
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]
(Int -> ReadS LivePreRollConfiguration)
-> ReadS [LivePreRollConfiguration]
-> ReadPrec LivePreRollConfiguration
-> ReadPrec [LivePreRollConfiguration]
-> Read 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
(Int -> LivePreRollConfiguration -> ShowS)
-> (LivePreRollConfiguration -> String)
-> ([LivePreRollConfiguration] -> ShowS)
-> Show LivePreRollConfiguration
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.
 LivePreRollConfiguration -> Rep LivePreRollConfiguration x)
-> (forall x.
    Rep LivePreRollConfiguration x -> LivePreRollConfiguration)
-> Generic LivePreRollConfiguration
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' :: Maybe Text -> Maybe Int -> LivePreRollConfiguration
LivePreRollConfiguration'
    { $sel:adDecisionServerUrl:LivePreRollConfiguration' :: Maybe Text
adDecisionServerUrl =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxDurationSeconds:LivePreRollConfiguration' :: Maybe Int
maxDurationSeconds = Maybe Int
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 :: (Maybe Text -> f (Maybe Text))
-> LivePreRollConfiguration -> f LivePreRollConfiguration
livePreRollConfiguration_adDecisionServerUrl = (LivePreRollConfiguration -> Maybe Text)
-> (LivePreRollConfiguration
    -> Maybe Text -> LivePreRollConfiguration)
-> Lens
     LivePreRollConfiguration
     LivePreRollConfiguration
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Int -> f (Maybe Int))
-> LivePreRollConfiguration -> f LivePreRollConfiguration
livePreRollConfiguration_maxDurationSeconds = (LivePreRollConfiguration -> Maybe Int)
-> (LivePreRollConfiguration
    -> Maybe Int -> LivePreRollConfiguration)
-> Lens
     LivePreRollConfiguration
     LivePreRollConfiguration
     (Maybe Int)
     (Maybe Int)
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 Core.FromJSON LivePreRollConfiguration where
  parseJSON :: Value -> Parser LivePreRollConfiguration
parseJSON =
    String
-> (Object -> Parser LivePreRollConfiguration)
-> Value
-> Parser LivePreRollConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LivePreRollConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe Int -> LivePreRollConfiguration
LivePreRollConfiguration'
            (Maybe Text -> Maybe Int -> LivePreRollConfiguration)
-> Parser (Maybe Text)
-> Parser (Maybe Int -> LivePreRollConfiguration)
forall (f :: * -> *) a b. Functor 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
"AdDecisionServerUrl")
            Parser (Maybe Int -> LivePreRollConfiguration)
-> Parser (Maybe Int) -> Parser LivePreRollConfiguration
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
"MaxDurationSeconds")
      )

instance Prelude.Hashable LivePreRollConfiguration

instance Prelude.NFData LivePreRollConfiguration

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AdDecisionServerUrl" 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
adDecisionServerUrl,
            (Text
"MaxDurationSeconds" 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
maxDurationSeconds
          ]
      )