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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaTailor.Types.MessageType
import Amazonka.MediaTailor.Types.SlateSource
import Amazonka.MediaTailor.Types.SpliceInsertMessage
import qualified Amazonka.Prelude as Prelude

-- | Ad break configuration parameters.
--
-- /See:/ 'newAdBreak' smart constructor.
data AdBreak = AdBreak'
  { -- | This defines the SCTE-35 splice_insert() message inserted around the ad.
    -- For information about using splice_insert(), see the SCTE-35
    -- specficiaiton, section 9.7.3.1.
    AdBreak -> Maybe SpliceInsertMessage
spliceInsertMessage :: Prelude.Maybe SpliceInsertMessage,
    -- | The SCTE-35 ad insertion type. Accepted value: SPLICE_INSERT.
    AdBreak -> Maybe MessageType
messageType :: Prelude.Maybe MessageType,
    -- | Ad break slate configuration.
    AdBreak -> Maybe SlateSource
slate :: Prelude.Maybe SlateSource,
    -- | How long (in milliseconds) after the beginning of the program that an ad
    -- starts. This value must fall within 100ms of a segment boundary,
    -- otherwise the ad break will be skipped.
    AdBreak -> Maybe Integer
offsetMillis :: Prelude.Maybe Prelude.Integer
  }
  deriving (AdBreak -> AdBreak -> Bool
(AdBreak -> AdBreak -> Bool)
-> (AdBreak -> AdBreak -> Bool) -> Eq AdBreak
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdBreak -> AdBreak -> Bool
$c/= :: AdBreak -> AdBreak -> Bool
== :: AdBreak -> AdBreak -> Bool
$c== :: AdBreak -> AdBreak -> Bool
Prelude.Eq, ReadPrec [AdBreak]
ReadPrec AdBreak
Int -> ReadS AdBreak
ReadS [AdBreak]
(Int -> ReadS AdBreak)
-> ReadS [AdBreak]
-> ReadPrec AdBreak
-> ReadPrec [AdBreak]
-> Read AdBreak
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AdBreak]
$creadListPrec :: ReadPrec [AdBreak]
readPrec :: ReadPrec AdBreak
$creadPrec :: ReadPrec AdBreak
readList :: ReadS [AdBreak]
$creadList :: ReadS [AdBreak]
readsPrec :: Int -> ReadS AdBreak
$creadsPrec :: Int -> ReadS AdBreak
Prelude.Read, Int -> AdBreak -> ShowS
[AdBreak] -> ShowS
AdBreak -> String
(Int -> AdBreak -> ShowS)
-> (AdBreak -> String) -> ([AdBreak] -> ShowS) -> Show AdBreak
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdBreak] -> ShowS
$cshowList :: [AdBreak] -> ShowS
show :: AdBreak -> String
$cshow :: AdBreak -> String
showsPrec :: Int -> AdBreak -> ShowS
$cshowsPrec :: Int -> AdBreak -> ShowS
Prelude.Show, (forall x. AdBreak -> Rep AdBreak x)
-> (forall x. Rep AdBreak x -> AdBreak) -> Generic AdBreak
forall x. Rep AdBreak x -> AdBreak
forall x. AdBreak -> Rep AdBreak x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AdBreak x -> AdBreak
$cfrom :: forall x. AdBreak -> Rep AdBreak x
Prelude.Generic)

-- |
-- Create a value of 'AdBreak' 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:
--
-- 'spliceInsertMessage', 'adBreak_spliceInsertMessage' - This defines the SCTE-35 splice_insert() message inserted around the ad.
-- For information about using splice_insert(), see the SCTE-35
-- specficiaiton, section 9.7.3.1.
--
-- 'messageType', 'adBreak_messageType' - The SCTE-35 ad insertion type. Accepted value: SPLICE_INSERT.
--
-- 'slate', 'adBreak_slate' - Ad break slate configuration.
--
-- 'offsetMillis', 'adBreak_offsetMillis' - How long (in milliseconds) after the beginning of the program that an ad
-- starts. This value must fall within 100ms of a segment boundary,
-- otherwise the ad break will be skipped.
newAdBreak ::
  AdBreak
newAdBreak :: AdBreak
newAdBreak =
  AdBreak' :: Maybe SpliceInsertMessage
-> Maybe MessageType
-> Maybe SlateSource
-> Maybe Integer
-> AdBreak
AdBreak'
    { $sel:spliceInsertMessage:AdBreak' :: Maybe SpliceInsertMessage
spliceInsertMessage = Maybe SpliceInsertMessage
forall a. Maybe a
Prelude.Nothing,
      $sel:messageType:AdBreak' :: Maybe MessageType
messageType = Maybe MessageType
forall a. Maybe a
Prelude.Nothing,
      $sel:slate:AdBreak' :: Maybe SlateSource
slate = Maybe SlateSource
forall a. Maybe a
Prelude.Nothing,
      $sel:offsetMillis:AdBreak' :: Maybe Integer
offsetMillis = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | This defines the SCTE-35 splice_insert() message inserted around the ad.
-- For information about using splice_insert(), see the SCTE-35
-- specficiaiton, section 9.7.3.1.
adBreak_spliceInsertMessage :: Lens.Lens' AdBreak (Prelude.Maybe SpliceInsertMessage)
adBreak_spliceInsertMessage :: (Maybe SpliceInsertMessage -> f (Maybe SpliceInsertMessage))
-> AdBreak -> f AdBreak
adBreak_spliceInsertMessage = (AdBreak -> Maybe SpliceInsertMessage)
-> (AdBreak -> Maybe SpliceInsertMessage -> AdBreak)
-> Lens
     AdBreak
     AdBreak
     (Maybe SpliceInsertMessage)
     (Maybe SpliceInsertMessage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdBreak' {Maybe SpliceInsertMessage
spliceInsertMessage :: Maybe SpliceInsertMessage
$sel:spliceInsertMessage:AdBreak' :: AdBreak -> Maybe SpliceInsertMessage
spliceInsertMessage} -> Maybe SpliceInsertMessage
spliceInsertMessage) (\s :: AdBreak
s@AdBreak' {} Maybe SpliceInsertMessage
a -> AdBreak
s {$sel:spliceInsertMessage:AdBreak' :: Maybe SpliceInsertMessage
spliceInsertMessage = Maybe SpliceInsertMessage
a} :: AdBreak)

-- | The SCTE-35 ad insertion type. Accepted value: SPLICE_INSERT.
adBreak_messageType :: Lens.Lens' AdBreak (Prelude.Maybe MessageType)
adBreak_messageType :: (Maybe MessageType -> f (Maybe MessageType))
-> AdBreak -> f AdBreak
adBreak_messageType = (AdBreak -> Maybe MessageType)
-> (AdBreak -> Maybe MessageType -> AdBreak)
-> Lens AdBreak AdBreak (Maybe MessageType) (Maybe MessageType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdBreak' {Maybe MessageType
messageType :: Maybe MessageType
$sel:messageType:AdBreak' :: AdBreak -> Maybe MessageType
messageType} -> Maybe MessageType
messageType) (\s :: AdBreak
s@AdBreak' {} Maybe MessageType
a -> AdBreak
s {$sel:messageType:AdBreak' :: Maybe MessageType
messageType = Maybe MessageType
a} :: AdBreak)

-- | Ad break slate configuration.
adBreak_slate :: Lens.Lens' AdBreak (Prelude.Maybe SlateSource)
adBreak_slate :: (Maybe SlateSource -> f (Maybe SlateSource))
-> AdBreak -> f AdBreak
adBreak_slate = (AdBreak -> Maybe SlateSource)
-> (AdBreak -> Maybe SlateSource -> AdBreak)
-> Lens AdBreak AdBreak (Maybe SlateSource) (Maybe SlateSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdBreak' {Maybe SlateSource
slate :: Maybe SlateSource
$sel:slate:AdBreak' :: AdBreak -> Maybe SlateSource
slate} -> Maybe SlateSource
slate) (\s :: AdBreak
s@AdBreak' {} Maybe SlateSource
a -> AdBreak
s {$sel:slate:AdBreak' :: Maybe SlateSource
slate = Maybe SlateSource
a} :: AdBreak)

-- | How long (in milliseconds) after the beginning of the program that an ad
-- starts. This value must fall within 100ms of a segment boundary,
-- otherwise the ad break will be skipped.
adBreak_offsetMillis :: Lens.Lens' AdBreak (Prelude.Maybe Prelude.Integer)
adBreak_offsetMillis :: (Maybe Integer -> f (Maybe Integer)) -> AdBreak -> f AdBreak
adBreak_offsetMillis = (AdBreak -> Maybe Integer)
-> (AdBreak -> Maybe Integer -> AdBreak)
-> Lens AdBreak AdBreak (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdBreak' {Maybe Integer
offsetMillis :: Maybe Integer
$sel:offsetMillis:AdBreak' :: AdBreak -> Maybe Integer
offsetMillis} -> Maybe Integer
offsetMillis) (\s :: AdBreak
s@AdBreak' {} Maybe Integer
a -> AdBreak
s {$sel:offsetMillis:AdBreak' :: Maybe Integer
offsetMillis = Maybe Integer
a} :: AdBreak)

instance Core.FromJSON AdBreak where
  parseJSON :: Value -> Parser AdBreak
parseJSON =
    String -> (Object -> Parser AdBreak) -> Value -> Parser AdBreak
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AdBreak"
      ( \Object
x ->
          Maybe SpliceInsertMessage
-> Maybe MessageType
-> Maybe SlateSource
-> Maybe Integer
-> AdBreak
AdBreak'
            (Maybe SpliceInsertMessage
 -> Maybe MessageType
 -> Maybe SlateSource
 -> Maybe Integer
 -> AdBreak)
-> Parser (Maybe SpliceInsertMessage)
-> Parser
     (Maybe MessageType
      -> Maybe SlateSource -> Maybe Integer -> AdBreak)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SpliceInsertMessage)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SpliceInsertMessage")
            Parser
  (Maybe MessageType
   -> Maybe SlateSource -> Maybe Integer -> AdBreak)
-> Parser (Maybe MessageType)
-> Parser (Maybe SlateSource -> Maybe Integer -> AdBreak)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MessageType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MessageType")
            Parser (Maybe SlateSource -> Maybe Integer -> AdBreak)
-> Parser (Maybe SlateSource) -> Parser (Maybe Integer -> AdBreak)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SlateSource)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Slate")
            Parser (Maybe Integer -> AdBreak)
-> Parser (Maybe Integer) -> Parser AdBreak
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OffsetMillis")
      )

instance Prelude.Hashable AdBreak

instance Prelude.NFData AdBreak

instance Core.ToJSON AdBreak where
  toJSON :: AdBreak -> Value
toJSON AdBreak' {Maybe Integer
Maybe MessageType
Maybe SlateSource
Maybe SpliceInsertMessage
offsetMillis :: Maybe Integer
slate :: Maybe SlateSource
messageType :: Maybe MessageType
spliceInsertMessage :: Maybe SpliceInsertMessage
$sel:offsetMillis:AdBreak' :: AdBreak -> Maybe Integer
$sel:slate:AdBreak' :: AdBreak -> Maybe SlateSource
$sel:messageType:AdBreak' :: AdBreak -> Maybe MessageType
$sel:spliceInsertMessage:AdBreak' :: AdBreak -> Maybe SpliceInsertMessage
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SpliceInsertMessage" Text -> SpliceInsertMessage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SpliceInsertMessage -> Pair)
-> Maybe SpliceInsertMessage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SpliceInsertMessage
spliceInsertMessage,
            (Text
"MessageType" Text -> MessageType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (MessageType -> Pair) -> Maybe MessageType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MessageType
messageType,
            (Text
"Slate" Text -> SlateSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SlateSource -> Pair) -> Maybe SlateSource -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SlateSource
slate,
            (Text
"OffsetMillis" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
offsetMillis
          ]
      )