{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreatePrefetchSchedule
-- 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)
--
-- Creates a new prefetch schedule for the specified playback
-- configuration.
module Amazonka.MediaTailor.CreatePrefetchSchedule
  ( -- * Creating a Request
    CreatePrefetchSchedule (..),
    newCreatePrefetchSchedule,

    -- * Request Lenses
    createPrefetchSchedule_streamId,
    createPrefetchSchedule_name,
    createPrefetchSchedule_playbackConfigurationName,
    createPrefetchSchedule_consumption,
    createPrefetchSchedule_retrieval,

    -- * Destructuring the Response
    CreatePrefetchScheduleResponse (..),
    newCreatePrefetchScheduleResponse,

    -- * Response Lenses
    createPrefetchScheduleResponse_arn,
    createPrefetchScheduleResponse_playbackConfigurationName,
    createPrefetchScheduleResponse_retrieval,
    createPrefetchScheduleResponse_name,
    createPrefetchScheduleResponse_consumption,
    createPrefetchScheduleResponse_streamId,
    createPrefetchScheduleResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaTailor.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreatePrefetchSchedule' smart constructor.
data CreatePrefetchSchedule = CreatePrefetchSchedule'
  { -- | An optional stream identifier that MediaTailor uses to prefetch ads for
    -- multiple streams that use the same playback configuration. If StreamId
    -- is specified, MediaTailor returns all of the prefetch schedules with an
    -- exact match on StreamId. If not specified, MediaTailor returns all of
    -- the prefetch schedules for the playback configuration, regardless of
    -- StreamId.
    CreatePrefetchSchedule -> Maybe Text
streamId :: Prelude.Maybe Prelude.Text,
    -- | The identifier for the playback configuration.
    CreatePrefetchSchedule -> Text
name :: Prelude.Text,
    -- | The name of the playback configuration.
    CreatePrefetchSchedule -> Text
playbackConfigurationName :: Prelude.Text,
    -- | The configuration settings for MediaTailor\'s /consumption/ of the
    -- prefetched ads from the ad decision server. Each consumption
    -- configuration contains an end time and an optional start time that
    -- define the /consumption window/. Prefetch schedules automatically expire
    -- no earlier than seven days after the end time.
    CreatePrefetchSchedule -> PrefetchConsumption
consumption :: PrefetchConsumption,
    -- | The configuration settings for retrieval of prefetched ads from the ad
    -- decision server. Only one set of prefetched ads will be retrieved and
    -- subsequently consumed for each ad break.
    CreatePrefetchSchedule -> PrefetchRetrieval
retrieval :: PrefetchRetrieval
  }
  deriving (CreatePrefetchSchedule -> CreatePrefetchSchedule -> Bool
(CreatePrefetchSchedule -> CreatePrefetchSchedule -> Bool)
-> (CreatePrefetchSchedule -> CreatePrefetchSchedule -> Bool)
-> Eq CreatePrefetchSchedule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePrefetchSchedule -> CreatePrefetchSchedule -> Bool
$c/= :: CreatePrefetchSchedule -> CreatePrefetchSchedule -> Bool
== :: CreatePrefetchSchedule -> CreatePrefetchSchedule -> Bool
$c== :: CreatePrefetchSchedule -> CreatePrefetchSchedule -> Bool
Prelude.Eq, ReadPrec [CreatePrefetchSchedule]
ReadPrec CreatePrefetchSchedule
Int -> ReadS CreatePrefetchSchedule
ReadS [CreatePrefetchSchedule]
(Int -> ReadS CreatePrefetchSchedule)
-> ReadS [CreatePrefetchSchedule]
-> ReadPrec CreatePrefetchSchedule
-> ReadPrec [CreatePrefetchSchedule]
-> Read CreatePrefetchSchedule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePrefetchSchedule]
$creadListPrec :: ReadPrec [CreatePrefetchSchedule]
readPrec :: ReadPrec CreatePrefetchSchedule
$creadPrec :: ReadPrec CreatePrefetchSchedule
readList :: ReadS [CreatePrefetchSchedule]
$creadList :: ReadS [CreatePrefetchSchedule]
readsPrec :: Int -> ReadS CreatePrefetchSchedule
$creadsPrec :: Int -> ReadS CreatePrefetchSchedule
Prelude.Read, Int -> CreatePrefetchSchedule -> ShowS
[CreatePrefetchSchedule] -> ShowS
CreatePrefetchSchedule -> String
(Int -> CreatePrefetchSchedule -> ShowS)
-> (CreatePrefetchSchedule -> String)
-> ([CreatePrefetchSchedule] -> ShowS)
-> Show CreatePrefetchSchedule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePrefetchSchedule] -> ShowS
$cshowList :: [CreatePrefetchSchedule] -> ShowS
show :: CreatePrefetchSchedule -> String
$cshow :: CreatePrefetchSchedule -> String
showsPrec :: Int -> CreatePrefetchSchedule -> ShowS
$cshowsPrec :: Int -> CreatePrefetchSchedule -> ShowS
Prelude.Show, (forall x. CreatePrefetchSchedule -> Rep CreatePrefetchSchedule x)
-> (forall x.
    Rep CreatePrefetchSchedule x -> CreatePrefetchSchedule)
-> Generic CreatePrefetchSchedule
forall x. Rep CreatePrefetchSchedule x -> CreatePrefetchSchedule
forall x. CreatePrefetchSchedule -> Rep CreatePrefetchSchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreatePrefetchSchedule x -> CreatePrefetchSchedule
$cfrom :: forall x. CreatePrefetchSchedule -> Rep CreatePrefetchSchedule x
Prelude.Generic)

-- |
-- Create a value of 'CreatePrefetchSchedule' 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', 'createPrefetchSchedule_streamId' - An optional stream identifier that MediaTailor uses to prefetch ads for
-- multiple streams that use the same playback configuration. If StreamId
-- is specified, MediaTailor returns all of the prefetch schedules with an
-- exact match on StreamId. If not specified, MediaTailor returns all of
-- the prefetch schedules for the playback configuration, regardless of
-- StreamId.
--
-- 'name', 'createPrefetchSchedule_name' - The identifier for the playback configuration.
--
-- 'playbackConfigurationName', 'createPrefetchSchedule_playbackConfigurationName' - The name of the playback configuration.
--
-- 'consumption', 'createPrefetchSchedule_consumption' - The configuration settings for MediaTailor\'s /consumption/ of the
-- prefetched ads from the ad decision server. Each consumption
-- configuration contains an end time and an optional start time that
-- define the /consumption window/. Prefetch schedules automatically expire
-- no earlier than seven days after the end time.
--
-- 'retrieval', 'createPrefetchSchedule_retrieval' - The configuration settings for retrieval of prefetched ads from the ad
-- decision server. Only one set of prefetched ads will be retrieved and
-- subsequently consumed for each ad break.
newCreatePrefetchSchedule ::
  -- | 'name'
  Prelude.Text ->
  -- | 'playbackConfigurationName'
  Prelude.Text ->
  -- | 'consumption'
  PrefetchConsumption ->
  -- | 'retrieval'
  PrefetchRetrieval ->
  CreatePrefetchSchedule
newCreatePrefetchSchedule :: Text
-> Text
-> PrefetchConsumption
-> PrefetchRetrieval
-> CreatePrefetchSchedule
newCreatePrefetchSchedule
  Text
pName_
  Text
pPlaybackConfigurationName_
  PrefetchConsumption
pConsumption_
  PrefetchRetrieval
pRetrieval_ =
    CreatePrefetchSchedule' :: Maybe Text
-> Text
-> Text
-> PrefetchConsumption
-> PrefetchRetrieval
-> CreatePrefetchSchedule
CreatePrefetchSchedule'
      { $sel:streamId:CreatePrefetchSchedule' :: Maybe Text
streamId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:name:CreatePrefetchSchedule' :: Text
name = Text
pName_,
        $sel:playbackConfigurationName:CreatePrefetchSchedule' :: Text
playbackConfigurationName =
          Text
pPlaybackConfigurationName_,
        $sel:consumption:CreatePrefetchSchedule' :: PrefetchConsumption
consumption = PrefetchConsumption
pConsumption_,
        $sel:retrieval:CreatePrefetchSchedule' :: PrefetchRetrieval
retrieval = PrefetchRetrieval
pRetrieval_
      }

-- | An optional stream identifier that MediaTailor uses to prefetch ads for
-- multiple streams that use the same playback configuration. If StreamId
-- is specified, MediaTailor returns all of the prefetch schedules with an
-- exact match on StreamId. If not specified, MediaTailor returns all of
-- the prefetch schedules for the playback configuration, regardless of
-- StreamId.
createPrefetchSchedule_streamId :: Lens.Lens' CreatePrefetchSchedule (Prelude.Maybe Prelude.Text)
createPrefetchSchedule_streamId :: (Maybe Text -> f (Maybe Text))
-> CreatePrefetchSchedule -> f CreatePrefetchSchedule
createPrefetchSchedule_streamId = (CreatePrefetchSchedule -> Maybe Text)
-> (CreatePrefetchSchedule -> Maybe Text -> CreatePrefetchSchedule)
-> Lens
     CreatePrefetchSchedule
     CreatePrefetchSchedule
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePrefetchSchedule' {Maybe Text
streamId :: Maybe Text
$sel:streamId:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> Maybe Text
streamId} -> Maybe Text
streamId) (\s :: CreatePrefetchSchedule
s@CreatePrefetchSchedule' {} Maybe Text
a -> CreatePrefetchSchedule
s {$sel:streamId:CreatePrefetchSchedule' :: Maybe Text
streamId = Maybe Text
a} :: CreatePrefetchSchedule)

-- | The identifier for the playback configuration.
createPrefetchSchedule_name :: Lens.Lens' CreatePrefetchSchedule Prelude.Text
createPrefetchSchedule_name :: (Text -> f Text)
-> CreatePrefetchSchedule -> f CreatePrefetchSchedule
createPrefetchSchedule_name = (CreatePrefetchSchedule -> Text)
-> (CreatePrefetchSchedule -> Text -> CreatePrefetchSchedule)
-> Lens CreatePrefetchSchedule CreatePrefetchSchedule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePrefetchSchedule' {Text
name :: Text
$sel:name:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> Text
name} -> Text
name) (\s :: CreatePrefetchSchedule
s@CreatePrefetchSchedule' {} Text
a -> CreatePrefetchSchedule
s {$sel:name:CreatePrefetchSchedule' :: Text
name = Text
a} :: CreatePrefetchSchedule)

-- | The name of the playback configuration.
createPrefetchSchedule_playbackConfigurationName :: Lens.Lens' CreatePrefetchSchedule Prelude.Text
createPrefetchSchedule_playbackConfigurationName :: (Text -> f Text)
-> CreatePrefetchSchedule -> f CreatePrefetchSchedule
createPrefetchSchedule_playbackConfigurationName = (CreatePrefetchSchedule -> Text)
-> (CreatePrefetchSchedule -> Text -> CreatePrefetchSchedule)
-> Lens CreatePrefetchSchedule CreatePrefetchSchedule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePrefetchSchedule' {Text
playbackConfigurationName :: Text
$sel:playbackConfigurationName:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> Text
playbackConfigurationName} -> Text
playbackConfigurationName) (\s :: CreatePrefetchSchedule
s@CreatePrefetchSchedule' {} Text
a -> CreatePrefetchSchedule
s {$sel:playbackConfigurationName:CreatePrefetchSchedule' :: Text
playbackConfigurationName = Text
a} :: CreatePrefetchSchedule)

-- | The configuration settings for MediaTailor\'s /consumption/ of the
-- prefetched ads from the ad decision server. Each consumption
-- configuration contains an end time and an optional start time that
-- define the /consumption window/. Prefetch schedules automatically expire
-- no earlier than seven days after the end time.
createPrefetchSchedule_consumption :: Lens.Lens' CreatePrefetchSchedule PrefetchConsumption
createPrefetchSchedule_consumption :: (PrefetchConsumption -> f PrefetchConsumption)
-> CreatePrefetchSchedule -> f CreatePrefetchSchedule
createPrefetchSchedule_consumption = (CreatePrefetchSchedule -> PrefetchConsumption)
-> (CreatePrefetchSchedule
    -> PrefetchConsumption -> CreatePrefetchSchedule)
-> Lens
     CreatePrefetchSchedule
     CreatePrefetchSchedule
     PrefetchConsumption
     PrefetchConsumption
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePrefetchSchedule' {PrefetchConsumption
consumption :: PrefetchConsumption
$sel:consumption:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> PrefetchConsumption
consumption} -> PrefetchConsumption
consumption) (\s :: CreatePrefetchSchedule
s@CreatePrefetchSchedule' {} PrefetchConsumption
a -> CreatePrefetchSchedule
s {$sel:consumption:CreatePrefetchSchedule' :: PrefetchConsumption
consumption = PrefetchConsumption
a} :: CreatePrefetchSchedule)

-- | The configuration settings for retrieval of prefetched ads from the ad
-- decision server. Only one set of prefetched ads will be retrieved and
-- subsequently consumed for each ad break.
createPrefetchSchedule_retrieval :: Lens.Lens' CreatePrefetchSchedule PrefetchRetrieval
createPrefetchSchedule_retrieval :: (PrefetchRetrieval -> f PrefetchRetrieval)
-> CreatePrefetchSchedule -> f CreatePrefetchSchedule
createPrefetchSchedule_retrieval = (CreatePrefetchSchedule -> PrefetchRetrieval)
-> (CreatePrefetchSchedule
    -> PrefetchRetrieval -> CreatePrefetchSchedule)
-> Lens
     CreatePrefetchSchedule
     CreatePrefetchSchedule
     PrefetchRetrieval
     PrefetchRetrieval
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePrefetchSchedule' {PrefetchRetrieval
retrieval :: PrefetchRetrieval
$sel:retrieval:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> PrefetchRetrieval
retrieval} -> PrefetchRetrieval
retrieval) (\s :: CreatePrefetchSchedule
s@CreatePrefetchSchedule' {} PrefetchRetrieval
a -> CreatePrefetchSchedule
s {$sel:retrieval:CreatePrefetchSchedule' :: PrefetchRetrieval
retrieval = PrefetchRetrieval
a} :: CreatePrefetchSchedule)

instance Core.AWSRequest CreatePrefetchSchedule where
  type
    AWSResponse CreatePrefetchSchedule =
      CreatePrefetchScheduleResponse
  request :: CreatePrefetchSchedule -> Request CreatePrefetchSchedule
request = Service -> CreatePrefetchSchedule -> Request CreatePrefetchSchedule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreatePrefetchSchedule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreatePrefetchSchedule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreatePrefetchSchedule))
-> Logger
-> Service
-> Proxy CreatePrefetchSchedule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreatePrefetchSchedule)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe PrefetchRetrieval
-> Maybe Text
-> Maybe PrefetchConsumption
-> Maybe Text
-> Int
-> CreatePrefetchScheduleResponse
CreatePrefetchScheduleResponse'
            (Maybe Text
 -> Maybe Text
 -> Maybe PrefetchRetrieval
 -> Maybe Text
 -> Maybe PrefetchConsumption
 -> Maybe Text
 -> Int
 -> CreatePrefetchScheduleResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe PrefetchRetrieval
      -> Maybe Text
      -> Maybe PrefetchConsumption
      -> Maybe Text
      -> Int
      -> CreatePrefetchScheduleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Arn")
            Either
  String
  (Maybe Text
   -> Maybe PrefetchRetrieval
   -> Maybe Text
   -> Maybe PrefetchConsumption
   -> Maybe Text
   -> Int
   -> CreatePrefetchScheduleResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe PrefetchRetrieval
      -> Maybe Text
      -> Maybe PrefetchConsumption
      -> Maybe Text
      -> Int
      -> CreatePrefetchScheduleResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PlaybackConfigurationName")
            Either
  String
  (Maybe PrefetchRetrieval
   -> Maybe Text
   -> Maybe PrefetchConsumption
   -> Maybe Text
   -> Int
   -> CreatePrefetchScheduleResponse)
-> Either String (Maybe PrefetchRetrieval)
-> Either
     String
     (Maybe Text
      -> Maybe PrefetchConsumption
      -> Maybe Text
      -> Int
      -> CreatePrefetchScheduleResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe PrefetchRetrieval)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Retrieval")
            Either
  String
  (Maybe Text
   -> Maybe PrefetchConsumption
   -> Maybe Text
   -> Int
   -> CreatePrefetchScheduleResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe PrefetchConsumption
      -> Maybe Text -> Int -> CreatePrefetchScheduleResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Name")
            Either
  String
  (Maybe PrefetchConsumption
   -> Maybe Text -> Int -> CreatePrefetchScheduleResponse)
-> Either String (Maybe PrefetchConsumption)
-> Either
     String (Maybe Text -> Int -> CreatePrefetchScheduleResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe PrefetchConsumption)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Consumption")
            Either String (Maybe Text -> Int -> CreatePrefetchScheduleResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreatePrefetchScheduleResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"StreamId")
            Either String (Int -> CreatePrefetchScheduleResponse)
-> Either String Int
-> Either String CreatePrefetchScheduleResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreatePrefetchSchedule

instance Prelude.NFData CreatePrefetchSchedule

instance Core.ToHeaders CreatePrefetchSchedule where
  toHeaders :: CreatePrefetchSchedule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreatePrefetchSchedule -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreatePrefetchSchedule where
  toJSON :: CreatePrefetchSchedule -> Value
toJSON CreatePrefetchSchedule' {Maybe Text
Text
PrefetchConsumption
PrefetchRetrieval
retrieval :: PrefetchRetrieval
consumption :: PrefetchConsumption
playbackConfigurationName :: Text
name :: Text
streamId :: Maybe Text
$sel:retrieval:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> PrefetchRetrieval
$sel:consumption:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> PrefetchConsumption
$sel:playbackConfigurationName:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> Text
$sel:name:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> Text
$sel:streamId:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StreamId" 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
streamId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Consumption" Text -> PrefetchConsumption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PrefetchConsumption
consumption),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Retrieval" Text -> PrefetchRetrieval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PrefetchRetrieval
retrieval)
          ]
      )

instance Core.ToPath CreatePrefetchSchedule where
  toPath :: CreatePrefetchSchedule -> ByteString
toPath CreatePrefetchSchedule' {Maybe Text
Text
PrefetchConsumption
PrefetchRetrieval
retrieval :: PrefetchRetrieval
consumption :: PrefetchConsumption
playbackConfigurationName :: Text
name :: Text
streamId :: Maybe Text
$sel:retrieval:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> PrefetchRetrieval
$sel:consumption:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> PrefetchConsumption
$sel:playbackConfigurationName:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> Text
$sel:name:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> Text
$sel:streamId:CreatePrefetchSchedule' :: CreatePrefetchSchedule -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/prefetchSchedule/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
playbackConfigurationName,
        ByteString
"/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name
      ]

instance Core.ToQuery CreatePrefetchSchedule where
  toQuery :: CreatePrefetchSchedule -> QueryString
toQuery = QueryString -> CreatePrefetchSchedule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreatePrefetchScheduleResponse' smart constructor.
data CreatePrefetchScheduleResponse = CreatePrefetchScheduleResponse'
  { -- | The Amazon Resource Name (ARN) of the prefetch schedule.
    CreatePrefetchScheduleResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The name of the playback configuration to create the prefetch schedule
    -- for.
    CreatePrefetchScheduleResponse -> Maybe Text
playbackConfigurationName :: Prelude.Maybe Prelude.Text,
    -- | A complex type that contains settings for prefetch retrieval from the ad
    -- decision server (ADS).
    CreatePrefetchScheduleResponse -> Maybe PrefetchRetrieval
retrieval :: Prelude.Maybe PrefetchRetrieval,
    -- | The name of the prefetch schedule. The name must be unique among all
    -- prefetch schedules that are associated with the specified playback
    -- configuration.
    CreatePrefetchScheduleResponse -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | 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.
    CreatePrefetchScheduleResponse -> Maybe PrefetchConsumption
consumption :: Prelude.Maybe PrefetchConsumption,
    -- | An optional stream identifier that you can specify in order to prefetch
    -- for multiple streams that use the same playback configuration.
    CreatePrefetchScheduleResponse -> Maybe Text
streamId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreatePrefetchScheduleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreatePrefetchScheduleResponse
-> CreatePrefetchScheduleResponse -> Bool
(CreatePrefetchScheduleResponse
 -> CreatePrefetchScheduleResponse -> Bool)
-> (CreatePrefetchScheduleResponse
    -> CreatePrefetchScheduleResponse -> Bool)
-> Eq CreatePrefetchScheduleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePrefetchScheduleResponse
-> CreatePrefetchScheduleResponse -> Bool
$c/= :: CreatePrefetchScheduleResponse
-> CreatePrefetchScheduleResponse -> Bool
== :: CreatePrefetchScheduleResponse
-> CreatePrefetchScheduleResponse -> Bool
$c== :: CreatePrefetchScheduleResponse
-> CreatePrefetchScheduleResponse -> Bool
Prelude.Eq, ReadPrec [CreatePrefetchScheduleResponse]
ReadPrec CreatePrefetchScheduleResponse
Int -> ReadS CreatePrefetchScheduleResponse
ReadS [CreatePrefetchScheduleResponse]
(Int -> ReadS CreatePrefetchScheduleResponse)
-> ReadS [CreatePrefetchScheduleResponse]
-> ReadPrec CreatePrefetchScheduleResponse
-> ReadPrec [CreatePrefetchScheduleResponse]
-> Read CreatePrefetchScheduleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePrefetchScheduleResponse]
$creadListPrec :: ReadPrec [CreatePrefetchScheduleResponse]
readPrec :: ReadPrec CreatePrefetchScheduleResponse
$creadPrec :: ReadPrec CreatePrefetchScheduleResponse
readList :: ReadS [CreatePrefetchScheduleResponse]
$creadList :: ReadS [CreatePrefetchScheduleResponse]
readsPrec :: Int -> ReadS CreatePrefetchScheduleResponse
$creadsPrec :: Int -> ReadS CreatePrefetchScheduleResponse
Prelude.Read, Int -> CreatePrefetchScheduleResponse -> ShowS
[CreatePrefetchScheduleResponse] -> ShowS
CreatePrefetchScheduleResponse -> String
(Int -> CreatePrefetchScheduleResponse -> ShowS)
-> (CreatePrefetchScheduleResponse -> String)
-> ([CreatePrefetchScheduleResponse] -> ShowS)
-> Show CreatePrefetchScheduleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePrefetchScheduleResponse] -> ShowS
$cshowList :: [CreatePrefetchScheduleResponse] -> ShowS
show :: CreatePrefetchScheduleResponse -> String
$cshow :: CreatePrefetchScheduleResponse -> String
showsPrec :: Int -> CreatePrefetchScheduleResponse -> ShowS
$cshowsPrec :: Int -> CreatePrefetchScheduleResponse -> ShowS
Prelude.Show, (forall x.
 CreatePrefetchScheduleResponse
 -> Rep CreatePrefetchScheduleResponse x)
-> (forall x.
    Rep CreatePrefetchScheduleResponse x
    -> CreatePrefetchScheduleResponse)
-> Generic CreatePrefetchScheduleResponse
forall x.
Rep CreatePrefetchScheduleResponse x
-> CreatePrefetchScheduleResponse
forall x.
CreatePrefetchScheduleResponse
-> Rep CreatePrefetchScheduleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreatePrefetchScheduleResponse x
-> CreatePrefetchScheduleResponse
$cfrom :: forall x.
CreatePrefetchScheduleResponse
-> Rep CreatePrefetchScheduleResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreatePrefetchScheduleResponse' 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:
--
-- 'arn', 'createPrefetchScheduleResponse_arn' - The Amazon Resource Name (ARN) of the prefetch schedule.
--
-- 'playbackConfigurationName', 'createPrefetchScheduleResponse_playbackConfigurationName' - The name of the playback configuration to create the prefetch schedule
-- for.
--
-- 'retrieval', 'createPrefetchScheduleResponse_retrieval' - A complex type that contains settings for prefetch retrieval from the ad
-- decision server (ADS).
--
-- 'name', 'createPrefetchScheduleResponse_name' - The name of the prefetch schedule. The name must be unique among all
-- prefetch schedules that are associated with the specified playback
-- configuration.
--
-- 'consumption', 'createPrefetchScheduleResponse_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.
--
-- 'streamId', 'createPrefetchScheduleResponse_streamId' - An optional stream identifier that you can specify in order to prefetch
-- for multiple streams that use the same playback configuration.
--
-- 'httpStatus', 'createPrefetchScheduleResponse_httpStatus' - The response's http status code.
newCreatePrefetchScheduleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreatePrefetchScheduleResponse
newCreatePrefetchScheduleResponse :: Int -> CreatePrefetchScheduleResponse
newCreatePrefetchScheduleResponse Int
pHttpStatus_ =
  CreatePrefetchScheduleResponse' :: Maybe Text
-> Maybe Text
-> Maybe PrefetchRetrieval
-> Maybe Text
-> Maybe PrefetchConsumption
-> Maybe Text
-> Int
-> CreatePrefetchScheduleResponse
CreatePrefetchScheduleResponse'
    { $sel:arn:CreatePrefetchScheduleResponse' :: Maybe Text
arn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:playbackConfigurationName:CreatePrefetchScheduleResponse' :: Maybe Text
playbackConfigurationName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:retrieval:CreatePrefetchScheduleResponse' :: Maybe PrefetchRetrieval
retrieval = Maybe PrefetchRetrieval
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreatePrefetchScheduleResponse' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:consumption:CreatePrefetchScheduleResponse' :: Maybe PrefetchConsumption
consumption = Maybe PrefetchConsumption
forall a. Maybe a
Prelude.Nothing,
      $sel:streamId:CreatePrefetchScheduleResponse' :: Maybe Text
streamId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreatePrefetchScheduleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

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

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

-- | 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.
createPrefetchScheduleResponse_consumption :: Lens.Lens' CreatePrefetchScheduleResponse (Prelude.Maybe PrefetchConsumption)
createPrefetchScheduleResponse_consumption :: (Maybe PrefetchConsumption -> f (Maybe PrefetchConsumption))
-> CreatePrefetchScheduleResponse
-> f CreatePrefetchScheduleResponse
createPrefetchScheduleResponse_consumption = (CreatePrefetchScheduleResponse -> Maybe PrefetchConsumption)
-> (CreatePrefetchScheduleResponse
    -> Maybe PrefetchConsumption -> CreatePrefetchScheduleResponse)
-> Lens
     CreatePrefetchScheduleResponse
     CreatePrefetchScheduleResponse
     (Maybe PrefetchConsumption)
     (Maybe PrefetchConsumption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePrefetchScheduleResponse' {Maybe PrefetchConsumption
consumption :: Maybe PrefetchConsumption
$sel:consumption:CreatePrefetchScheduleResponse' :: CreatePrefetchScheduleResponse -> Maybe PrefetchConsumption
consumption} -> Maybe PrefetchConsumption
consumption) (\s :: CreatePrefetchScheduleResponse
s@CreatePrefetchScheduleResponse' {} Maybe PrefetchConsumption
a -> CreatePrefetchScheduleResponse
s {$sel:consumption:CreatePrefetchScheduleResponse' :: Maybe PrefetchConsumption
consumption = Maybe PrefetchConsumption
a} :: CreatePrefetchScheduleResponse)

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

-- | The response's http status code.
createPrefetchScheduleResponse_httpStatus :: Lens.Lens' CreatePrefetchScheduleResponse Prelude.Int
createPrefetchScheduleResponse_httpStatus :: (Int -> f Int)
-> CreatePrefetchScheduleResponse
-> f CreatePrefetchScheduleResponse
createPrefetchScheduleResponse_httpStatus = (CreatePrefetchScheduleResponse -> Int)
-> (CreatePrefetchScheduleResponse
    -> Int -> CreatePrefetchScheduleResponse)
-> Lens
     CreatePrefetchScheduleResponse
     CreatePrefetchScheduleResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePrefetchScheduleResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreatePrefetchScheduleResponse' :: CreatePrefetchScheduleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreatePrefetchScheduleResponse
s@CreatePrefetchScheduleResponse' {} Int
a -> CreatePrefetchScheduleResponse
s {$sel:httpStatus:CreatePrefetchScheduleResponse' :: Int
httpStatus = Int
a} :: CreatePrefetchScheduleResponse)

instance
  Prelude.NFData
    CreatePrefetchScheduleResponse