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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaTailor.Types.PrefetchConsumption
import Amazonka.MediaTailor.Types.PrefetchRetrieval
import qualified Amazonka.Prelude as Prelude

-- | A complex type that contains prefetch schedule information.
--
-- /See:/ 'newPrefetchSchedule' smart constructor.
data PrefetchSchedule = PrefetchSchedule'
  { -- | An optional stream identifier that you can specify in order to prefetch
    -- for multiple streams that use the same playback configuration.
    PrefetchSchedule -> Maybe Text
streamId :: Prelude.Maybe Prelude.Text,
    -- | A complex type that contains settings for prefetch retrieval from the ad
    -- decision server (ADS).
    PrefetchSchedule -> PrefetchRetrieval
retrieval :: PrefetchRetrieval,
    -- | Consumption settings determine how, and when, MediaTailor places the
    -- prefetched ads into ad breaks. Ad consumption occurs within a span of
    -- time that you define, called a /consumption window/. You can designate
    -- which ad breaks that MediaTailor fills with prefetch ads by setting
    -- avail matching criteria.
    PrefetchSchedule -> PrefetchConsumption
consumption :: PrefetchConsumption,
    -- | The Amazon Resource Name (ARN) of the prefetch schedule.
    PrefetchSchedule -> Text
arn :: Prelude.Text,
    -- | The name of the playback configuration to create the prefetch schedule
    -- for.
    PrefetchSchedule -> Text
playbackConfigurationName :: Prelude.Text,
    -- | The name of the prefetch schedule. The name must be unique among all
    -- prefetch schedules that are associated with the specified playback
    -- configuration.
    PrefetchSchedule -> Text
name :: Prelude.Text
  }
  deriving (PrefetchSchedule -> PrefetchSchedule -> Bool
(PrefetchSchedule -> PrefetchSchedule -> Bool)
-> (PrefetchSchedule -> PrefetchSchedule -> Bool)
-> Eq PrefetchSchedule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PrefetchSchedule -> PrefetchSchedule -> Bool
$c/= :: PrefetchSchedule -> PrefetchSchedule -> Bool
== :: PrefetchSchedule -> PrefetchSchedule -> Bool
$c== :: PrefetchSchedule -> PrefetchSchedule -> Bool
Prelude.Eq, ReadPrec [PrefetchSchedule]
ReadPrec PrefetchSchedule
Int -> ReadS PrefetchSchedule
ReadS [PrefetchSchedule]
(Int -> ReadS PrefetchSchedule)
-> ReadS [PrefetchSchedule]
-> ReadPrec PrefetchSchedule
-> ReadPrec [PrefetchSchedule]
-> Read PrefetchSchedule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PrefetchSchedule]
$creadListPrec :: ReadPrec [PrefetchSchedule]
readPrec :: ReadPrec PrefetchSchedule
$creadPrec :: ReadPrec PrefetchSchedule
readList :: ReadS [PrefetchSchedule]
$creadList :: ReadS [PrefetchSchedule]
readsPrec :: Int -> ReadS PrefetchSchedule
$creadsPrec :: Int -> ReadS PrefetchSchedule
Prelude.Read, Int -> PrefetchSchedule -> ShowS
[PrefetchSchedule] -> ShowS
PrefetchSchedule -> String
(Int -> PrefetchSchedule -> ShowS)
-> (PrefetchSchedule -> String)
-> ([PrefetchSchedule] -> ShowS)
-> Show PrefetchSchedule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PrefetchSchedule] -> ShowS
$cshowList :: [PrefetchSchedule] -> ShowS
show :: PrefetchSchedule -> String
$cshow :: PrefetchSchedule -> String
showsPrec :: Int -> PrefetchSchedule -> ShowS
$cshowsPrec :: Int -> PrefetchSchedule -> ShowS
Prelude.Show, (forall x. PrefetchSchedule -> Rep PrefetchSchedule x)
-> (forall x. Rep PrefetchSchedule x -> PrefetchSchedule)
-> Generic PrefetchSchedule
forall x. Rep PrefetchSchedule x -> PrefetchSchedule
forall x. PrefetchSchedule -> Rep PrefetchSchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PrefetchSchedule x -> PrefetchSchedule
$cfrom :: forall x. PrefetchSchedule -> Rep PrefetchSchedule x
Prelude.Generic)

-- |
-- Create a value of 'PrefetchSchedule' 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:
--
-- 'streamId', 'prefetchSchedule_streamId' - An optional stream identifier that you can specify in order to prefetch
-- for multiple streams that use the same playback configuration.
--
-- 'retrieval', 'prefetchSchedule_retrieval' - A complex type that contains settings for prefetch retrieval from the ad
-- decision server (ADS).
--
-- 'consumption', 'prefetchSchedule_consumption' - Consumption settings determine how, and when, MediaTailor places the
-- prefetched ads into ad breaks. Ad consumption occurs within a span of
-- time that you define, called a /consumption window/. You can designate
-- which ad breaks that MediaTailor fills with prefetch ads by setting
-- avail matching criteria.
--
-- 'arn', 'prefetchSchedule_arn' - The Amazon Resource Name (ARN) of the prefetch schedule.
--
-- 'playbackConfigurationName', 'prefetchSchedule_playbackConfigurationName' - The name of the playback configuration to create the prefetch schedule
-- for.
--
-- 'name', 'prefetchSchedule_name' - The name of the prefetch schedule. The name must be unique among all
-- prefetch schedules that are associated with the specified playback
-- configuration.
newPrefetchSchedule ::
  -- | 'retrieval'
  PrefetchRetrieval ->
  -- | 'consumption'
  PrefetchConsumption ->
  -- | 'arn'
  Prelude.Text ->
  -- | 'playbackConfigurationName'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  PrefetchSchedule
newPrefetchSchedule :: PrefetchRetrieval
-> PrefetchConsumption -> Text -> Text -> Text -> PrefetchSchedule
newPrefetchSchedule
  PrefetchRetrieval
pRetrieval_
  PrefetchConsumption
pConsumption_
  Text
pArn_
  Text
pPlaybackConfigurationName_
  Text
pName_ =
    PrefetchSchedule' :: Maybe Text
-> PrefetchRetrieval
-> PrefetchConsumption
-> Text
-> Text
-> Text
-> PrefetchSchedule
PrefetchSchedule'
      { $sel:streamId:PrefetchSchedule' :: Maybe Text
streamId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:retrieval:PrefetchSchedule' :: PrefetchRetrieval
retrieval = PrefetchRetrieval
pRetrieval_,
        $sel:consumption:PrefetchSchedule' :: PrefetchConsumption
consumption = PrefetchConsumption
pConsumption_,
        $sel:arn:PrefetchSchedule' :: Text
arn = Text
pArn_,
        $sel:playbackConfigurationName:PrefetchSchedule' :: Text
playbackConfigurationName =
          Text
pPlaybackConfigurationName_,
        $sel:name:PrefetchSchedule' :: Text
name = Text
pName_
      }

-- | An optional stream identifier that you can specify in order to prefetch
-- for multiple streams that use the same playback configuration.
prefetchSchedule_streamId :: Lens.Lens' PrefetchSchedule (Prelude.Maybe Prelude.Text)
prefetchSchedule_streamId :: (Maybe Text -> f (Maybe Text))
-> PrefetchSchedule -> f PrefetchSchedule
prefetchSchedule_streamId = (PrefetchSchedule -> Maybe Text)
-> (PrefetchSchedule -> Maybe Text -> PrefetchSchedule)
-> Lens PrefetchSchedule PrefetchSchedule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrefetchSchedule' {Maybe Text
streamId :: Maybe Text
$sel:streamId:PrefetchSchedule' :: PrefetchSchedule -> Maybe Text
streamId} -> Maybe Text
streamId) (\s :: PrefetchSchedule
s@PrefetchSchedule' {} Maybe Text
a -> PrefetchSchedule
s {$sel:streamId:PrefetchSchedule' :: Maybe Text
streamId = Maybe Text
a} :: PrefetchSchedule)

-- | A complex type that contains settings for prefetch retrieval from the ad
-- decision server (ADS).
prefetchSchedule_retrieval :: Lens.Lens' PrefetchSchedule PrefetchRetrieval
prefetchSchedule_retrieval :: (PrefetchRetrieval -> f PrefetchRetrieval)
-> PrefetchSchedule -> f PrefetchSchedule
prefetchSchedule_retrieval = (PrefetchSchedule -> PrefetchRetrieval)
-> (PrefetchSchedule -> PrefetchRetrieval -> PrefetchSchedule)
-> Lens
     PrefetchSchedule
     PrefetchSchedule
     PrefetchRetrieval
     PrefetchRetrieval
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrefetchSchedule' {PrefetchRetrieval
retrieval :: PrefetchRetrieval
$sel:retrieval:PrefetchSchedule' :: PrefetchSchedule -> PrefetchRetrieval
retrieval} -> PrefetchRetrieval
retrieval) (\s :: PrefetchSchedule
s@PrefetchSchedule' {} PrefetchRetrieval
a -> PrefetchSchedule
s {$sel:retrieval:PrefetchSchedule' :: PrefetchRetrieval
retrieval = PrefetchRetrieval
a} :: PrefetchSchedule)

-- | Consumption settings determine how, and when, MediaTailor places the
-- prefetched ads into ad breaks. Ad consumption occurs within a span of
-- time that you define, called a /consumption window/. You can designate
-- which ad breaks that MediaTailor fills with prefetch ads by setting
-- avail matching criteria.
prefetchSchedule_consumption :: Lens.Lens' PrefetchSchedule PrefetchConsumption
prefetchSchedule_consumption :: (PrefetchConsumption -> f PrefetchConsumption)
-> PrefetchSchedule -> f PrefetchSchedule
prefetchSchedule_consumption = (PrefetchSchedule -> PrefetchConsumption)
-> (PrefetchSchedule -> PrefetchConsumption -> PrefetchSchedule)
-> Lens
     PrefetchSchedule
     PrefetchSchedule
     PrefetchConsumption
     PrefetchConsumption
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrefetchSchedule' {PrefetchConsumption
consumption :: PrefetchConsumption
$sel:consumption:PrefetchSchedule' :: PrefetchSchedule -> PrefetchConsumption
consumption} -> PrefetchConsumption
consumption) (\s :: PrefetchSchedule
s@PrefetchSchedule' {} PrefetchConsumption
a -> PrefetchSchedule
s {$sel:consumption:PrefetchSchedule' :: PrefetchConsumption
consumption = PrefetchConsumption
a} :: PrefetchSchedule)

-- | The Amazon Resource Name (ARN) of the prefetch schedule.
prefetchSchedule_arn :: Lens.Lens' PrefetchSchedule Prelude.Text
prefetchSchedule_arn :: (Text -> f Text) -> PrefetchSchedule -> f PrefetchSchedule
prefetchSchedule_arn = (PrefetchSchedule -> Text)
-> (PrefetchSchedule -> Text -> PrefetchSchedule)
-> Lens PrefetchSchedule PrefetchSchedule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrefetchSchedule' {Text
arn :: Text
$sel:arn:PrefetchSchedule' :: PrefetchSchedule -> Text
arn} -> Text
arn) (\s :: PrefetchSchedule
s@PrefetchSchedule' {} Text
a -> PrefetchSchedule
s {$sel:arn:PrefetchSchedule' :: Text
arn = Text
a} :: PrefetchSchedule)

-- | The name of the playback configuration to create the prefetch schedule
-- for.
prefetchSchedule_playbackConfigurationName :: Lens.Lens' PrefetchSchedule Prelude.Text
prefetchSchedule_playbackConfigurationName :: (Text -> f Text) -> PrefetchSchedule -> f PrefetchSchedule
prefetchSchedule_playbackConfigurationName = (PrefetchSchedule -> Text)
-> (PrefetchSchedule -> Text -> PrefetchSchedule)
-> Lens PrefetchSchedule PrefetchSchedule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrefetchSchedule' {Text
playbackConfigurationName :: Text
$sel:playbackConfigurationName:PrefetchSchedule' :: PrefetchSchedule -> Text
playbackConfigurationName} -> Text
playbackConfigurationName) (\s :: PrefetchSchedule
s@PrefetchSchedule' {} Text
a -> PrefetchSchedule
s {$sel:playbackConfigurationName:PrefetchSchedule' :: Text
playbackConfigurationName = Text
a} :: PrefetchSchedule)

-- | The name of the prefetch schedule. The name must be unique among all
-- prefetch schedules that are associated with the specified playback
-- configuration.
prefetchSchedule_name :: Lens.Lens' PrefetchSchedule Prelude.Text
prefetchSchedule_name :: (Text -> f Text) -> PrefetchSchedule -> f PrefetchSchedule
prefetchSchedule_name = (PrefetchSchedule -> Text)
-> (PrefetchSchedule -> Text -> PrefetchSchedule)
-> Lens PrefetchSchedule PrefetchSchedule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrefetchSchedule' {Text
name :: Text
$sel:name:PrefetchSchedule' :: PrefetchSchedule -> Text
name} -> Text
name) (\s :: PrefetchSchedule
s@PrefetchSchedule' {} Text
a -> PrefetchSchedule
s {$sel:name:PrefetchSchedule' :: Text
name = Text
a} :: PrefetchSchedule)

instance Core.FromJSON PrefetchSchedule where
  parseJSON :: Value -> Parser PrefetchSchedule
parseJSON =
    String
-> (Object -> Parser PrefetchSchedule)
-> Value
-> Parser PrefetchSchedule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PrefetchSchedule"
      ( \Object
x ->
          Maybe Text
-> PrefetchRetrieval
-> PrefetchConsumption
-> Text
-> Text
-> Text
-> PrefetchSchedule
PrefetchSchedule'
            (Maybe Text
 -> PrefetchRetrieval
 -> PrefetchConsumption
 -> Text
 -> Text
 -> Text
 -> PrefetchSchedule)
-> Parser (Maybe Text)
-> Parser
     (PrefetchRetrieval
      -> PrefetchConsumption -> Text -> Text -> Text -> PrefetchSchedule)
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
"StreamId")
            Parser
  (PrefetchRetrieval
   -> PrefetchConsumption -> Text -> Text -> Text -> PrefetchSchedule)
-> Parser PrefetchRetrieval
-> Parser
     (PrefetchConsumption -> Text -> Text -> Text -> PrefetchSchedule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PrefetchRetrieval
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Retrieval")
            Parser
  (PrefetchConsumption -> Text -> Text -> Text -> PrefetchSchedule)
-> Parser PrefetchConsumption
-> Parser (Text -> Text -> Text -> PrefetchSchedule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PrefetchConsumption
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Consumption")
            Parser (Text -> Text -> Text -> PrefetchSchedule)
-> Parser Text -> Parser (Text -> Text -> PrefetchSchedule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Arn")
            Parser (Text -> Text -> PrefetchSchedule)
-> Parser Text -> Parser (Text -> PrefetchSchedule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"PlaybackConfigurationName")
            Parser (Text -> PrefetchSchedule)
-> Parser Text -> Parser PrefetchSchedule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
      )

instance Prelude.Hashable PrefetchSchedule

instance Prelude.NFData PrefetchSchedule