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

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

-- | Splice insert message configuration.
--
-- /See:/ 'newSpliceInsertMessage' smart constructor.
data SpliceInsertMessage = SpliceInsertMessage'
  { -- | This is written to splice_insert.avail_num, as defined in section
    -- 9.7.3.1 of the SCTE-35 specification. The default value is 0. Values
    -- must be between 0 and 256, inclusive.
    SpliceInsertMessage -> Maybe Int
availNum :: Prelude.Maybe Prelude.Int,
    -- | This is written to splice_insert.unique_program_id, as defined in
    -- section 9.7.3.1 of the SCTE-35 specification. The default value is 0.
    -- Values must be between 0 and 256, inclusive.
    SpliceInsertMessage -> Maybe Int
uniqueProgramId :: Prelude.Maybe Prelude.Int,
    -- | This is written to splice_insert.avails_expected, as defined in section
    -- 9.7.3.1 of the SCTE-35 specification. The default value is 0. Values
    -- must be between 0 and 256, inclusive.
    SpliceInsertMessage -> Maybe Int
availsExpected :: Prelude.Maybe Prelude.Int,
    -- | This is written to splice_insert.splice_event_id, as defined in section
    -- 9.7.3.1 of the SCTE-35 specification. The default value is 1.
    SpliceInsertMessage -> Maybe Int
spliceEventId :: Prelude.Maybe Prelude.Int
  }
  deriving (SpliceInsertMessage -> SpliceInsertMessage -> Bool
(SpliceInsertMessage -> SpliceInsertMessage -> Bool)
-> (SpliceInsertMessage -> SpliceInsertMessage -> Bool)
-> Eq SpliceInsertMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SpliceInsertMessage -> SpliceInsertMessage -> Bool
$c/= :: SpliceInsertMessage -> SpliceInsertMessage -> Bool
== :: SpliceInsertMessage -> SpliceInsertMessage -> Bool
$c== :: SpliceInsertMessage -> SpliceInsertMessage -> Bool
Prelude.Eq, ReadPrec [SpliceInsertMessage]
ReadPrec SpliceInsertMessage
Int -> ReadS SpliceInsertMessage
ReadS [SpliceInsertMessage]
(Int -> ReadS SpliceInsertMessage)
-> ReadS [SpliceInsertMessage]
-> ReadPrec SpliceInsertMessage
-> ReadPrec [SpliceInsertMessage]
-> Read SpliceInsertMessage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SpliceInsertMessage]
$creadListPrec :: ReadPrec [SpliceInsertMessage]
readPrec :: ReadPrec SpliceInsertMessage
$creadPrec :: ReadPrec SpliceInsertMessage
readList :: ReadS [SpliceInsertMessage]
$creadList :: ReadS [SpliceInsertMessage]
readsPrec :: Int -> ReadS SpliceInsertMessage
$creadsPrec :: Int -> ReadS SpliceInsertMessage
Prelude.Read, Int -> SpliceInsertMessage -> ShowS
[SpliceInsertMessage] -> ShowS
SpliceInsertMessage -> String
(Int -> SpliceInsertMessage -> ShowS)
-> (SpliceInsertMessage -> String)
-> ([SpliceInsertMessage] -> ShowS)
-> Show SpliceInsertMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SpliceInsertMessage] -> ShowS
$cshowList :: [SpliceInsertMessage] -> ShowS
show :: SpliceInsertMessage -> String
$cshow :: SpliceInsertMessage -> String
showsPrec :: Int -> SpliceInsertMessage -> ShowS
$cshowsPrec :: Int -> SpliceInsertMessage -> ShowS
Prelude.Show, (forall x. SpliceInsertMessage -> Rep SpliceInsertMessage x)
-> (forall x. Rep SpliceInsertMessage x -> SpliceInsertMessage)
-> Generic SpliceInsertMessage
forall x. Rep SpliceInsertMessage x -> SpliceInsertMessage
forall x. SpliceInsertMessage -> Rep SpliceInsertMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SpliceInsertMessage x -> SpliceInsertMessage
$cfrom :: forall x. SpliceInsertMessage -> Rep SpliceInsertMessage x
Prelude.Generic)

-- |
-- Create a value of 'SpliceInsertMessage' 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:
--
-- 'availNum', 'spliceInsertMessage_availNum' - This is written to splice_insert.avail_num, as defined in section
-- 9.7.3.1 of the SCTE-35 specification. The default value is 0. Values
-- must be between 0 and 256, inclusive.
--
-- 'uniqueProgramId', 'spliceInsertMessage_uniqueProgramId' - This is written to splice_insert.unique_program_id, as defined in
-- section 9.7.3.1 of the SCTE-35 specification. The default value is 0.
-- Values must be between 0 and 256, inclusive.
--
-- 'availsExpected', 'spliceInsertMessage_availsExpected' - This is written to splice_insert.avails_expected, as defined in section
-- 9.7.3.1 of the SCTE-35 specification. The default value is 0. Values
-- must be between 0 and 256, inclusive.
--
-- 'spliceEventId', 'spliceInsertMessage_spliceEventId' - This is written to splice_insert.splice_event_id, as defined in section
-- 9.7.3.1 of the SCTE-35 specification. The default value is 1.
newSpliceInsertMessage ::
  SpliceInsertMessage
newSpliceInsertMessage :: SpliceInsertMessage
newSpliceInsertMessage =
  SpliceInsertMessage' :: Maybe Int
-> Maybe Int -> Maybe Int -> Maybe Int -> SpliceInsertMessage
SpliceInsertMessage'
    { $sel:availNum:SpliceInsertMessage' :: Maybe Int
availNum = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:uniqueProgramId:SpliceInsertMessage' :: Maybe Int
uniqueProgramId = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:availsExpected:SpliceInsertMessage' :: Maybe Int
availsExpected = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:spliceEventId:SpliceInsertMessage' :: Maybe Int
spliceEventId = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | This is written to splice_insert.avail_num, as defined in section
-- 9.7.3.1 of the SCTE-35 specification. The default value is 0. Values
-- must be between 0 and 256, inclusive.
spliceInsertMessage_availNum :: Lens.Lens' SpliceInsertMessage (Prelude.Maybe Prelude.Int)
spliceInsertMessage_availNum :: (Maybe Int -> f (Maybe Int))
-> SpliceInsertMessage -> f SpliceInsertMessage
spliceInsertMessage_availNum = (SpliceInsertMessage -> Maybe Int)
-> (SpliceInsertMessage -> Maybe Int -> SpliceInsertMessage)
-> Lens
     SpliceInsertMessage SpliceInsertMessage (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpliceInsertMessage' {Maybe Int
availNum :: Maybe Int
$sel:availNum:SpliceInsertMessage' :: SpliceInsertMessage -> Maybe Int
availNum} -> Maybe Int
availNum) (\s :: SpliceInsertMessage
s@SpliceInsertMessage' {} Maybe Int
a -> SpliceInsertMessage
s {$sel:availNum:SpliceInsertMessage' :: Maybe Int
availNum = Maybe Int
a} :: SpliceInsertMessage)

-- | This is written to splice_insert.unique_program_id, as defined in
-- section 9.7.3.1 of the SCTE-35 specification. The default value is 0.
-- Values must be between 0 and 256, inclusive.
spliceInsertMessage_uniqueProgramId :: Lens.Lens' SpliceInsertMessage (Prelude.Maybe Prelude.Int)
spliceInsertMessage_uniqueProgramId :: (Maybe Int -> f (Maybe Int))
-> SpliceInsertMessage -> f SpliceInsertMessage
spliceInsertMessage_uniqueProgramId = (SpliceInsertMessage -> Maybe Int)
-> (SpliceInsertMessage -> Maybe Int -> SpliceInsertMessage)
-> Lens
     SpliceInsertMessage SpliceInsertMessage (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpliceInsertMessage' {Maybe Int
uniqueProgramId :: Maybe Int
$sel:uniqueProgramId:SpliceInsertMessage' :: SpliceInsertMessage -> Maybe Int
uniqueProgramId} -> Maybe Int
uniqueProgramId) (\s :: SpliceInsertMessage
s@SpliceInsertMessage' {} Maybe Int
a -> SpliceInsertMessage
s {$sel:uniqueProgramId:SpliceInsertMessage' :: Maybe Int
uniqueProgramId = Maybe Int
a} :: SpliceInsertMessage)

-- | This is written to splice_insert.avails_expected, as defined in section
-- 9.7.3.1 of the SCTE-35 specification. The default value is 0. Values
-- must be between 0 and 256, inclusive.
spliceInsertMessage_availsExpected :: Lens.Lens' SpliceInsertMessage (Prelude.Maybe Prelude.Int)
spliceInsertMessage_availsExpected :: (Maybe Int -> f (Maybe Int))
-> SpliceInsertMessage -> f SpliceInsertMessage
spliceInsertMessage_availsExpected = (SpliceInsertMessage -> Maybe Int)
-> (SpliceInsertMessage -> Maybe Int -> SpliceInsertMessage)
-> Lens
     SpliceInsertMessage SpliceInsertMessage (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpliceInsertMessage' {Maybe Int
availsExpected :: Maybe Int
$sel:availsExpected:SpliceInsertMessage' :: SpliceInsertMessage -> Maybe Int
availsExpected} -> Maybe Int
availsExpected) (\s :: SpliceInsertMessage
s@SpliceInsertMessage' {} Maybe Int
a -> SpliceInsertMessage
s {$sel:availsExpected:SpliceInsertMessage' :: Maybe Int
availsExpected = Maybe Int
a} :: SpliceInsertMessage)

-- | This is written to splice_insert.splice_event_id, as defined in section
-- 9.7.3.1 of the SCTE-35 specification. The default value is 1.
spliceInsertMessage_spliceEventId :: Lens.Lens' SpliceInsertMessage (Prelude.Maybe Prelude.Int)
spliceInsertMessage_spliceEventId :: (Maybe Int -> f (Maybe Int))
-> SpliceInsertMessage -> f SpliceInsertMessage
spliceInsertMessage_spliceEventId = (SpliceInsertMessage -> Maybe Int)
-> (SpliceInsertMessage -> Maybe Int -> SpliceInsertMessage)
-> Lens
     SpliceInsertMessage SpliceInsertMessage (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpliceInsertMessage' {Maybe Int
spliceEventId :: Maybe Int
$sel:spliceEventId:SpliceInsertMessage' :: SpliceInsertMessage -> Maybe Int
spliceEventId} -> Maybe Int
spliceEventId) (\s :: SpliceInsertMessage
s@SpliceInsertMessage' {} Maybe Int
a -> SpliceInsertMessage
s {$sel:spliceEventId:SpliceInsertMessage' :: Maybe Int
spliceEventId = Maybe Int
a} :: SpliceInsertMessage)

instance Core.FromJSON SpliceInsertMessage where
  parseJSON :: Value -> Parser SpliceInsertMessage
parseJSON =
    String
-> (Object -> Parser SpliceInsertMessage)
-> Value
-> Parser SpliceInsertMessage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SpliceInsertMessage"
      ( \Object
x ->
          Maybe Int
-> Maybe Int -> Maybe Int -> Maybe Int -> SpliceInsertMessage
SpliceInsertMessage'
            (Maybe Int
 -> Maybe Int -> Maybe Int -> Maybe Int -> SpliceInsertMessage)
-> Parser (Maybe Int)
-> Parser
     (Maybe Int -> Maybe Int -> Maybe Int -> SpliceInsertMessage)
forall (f :: * -> *) a b. Functor 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
"AvailNum")
            Parser (Maybe Int -> Maybe Int -> Maybe Int -> SpliceInsertMessage)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> Maybe Int -> SpliceInsertMessage)
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
"UniqueProgramId")
            Parser (Maybe Int -> Maybe Int -> SpliceInsertMessage)
-> Parser (Maybe Int) -> Parser (Maybe Int -> SpliceInsertMessage)
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
"AvailsExpected")
            Parser (Maybe Int -> SpliceInsertMessage)
-> Parser (Maybe Int) -> Parser SpliceInsertMessage
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
"SpliceEventId")
      )

instance Prelude.Hashable SpliceInsertMessage

instance Prelude.NFData SpliceInsertMessage

instance Core.ToJSON SpliceInsertMessage where
  toJSON :: SpliceInsertMessage -> Value
toJSON SpliceInsertMessage' {Maybe Int
spliceEventId :: Maybe Int
availsExpected :: Maybe Int
uniqueProgramId :: Maybe Int
availNum :: Maybe Int
$sel:spliceEventId:SpliceInsertMessage' :: SpliceInsertMessage -> Maybe Int
$sel:availsExpected:SpliceInsertMessage' :: SpliceInsertMessage -> Maybe Int
$sel:uniqueProgramId:SpliceInsertMessage' :: SpliceInsertMessage -> Maybe Int
$sel:availNum:SpliceInsertMessage' :: SpliceInsertMessage -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AvailNum" 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
availNum,
            (Text
"UniqueProgramId" 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
uniqueProgramId,
            (Text
"AvailsExpected" 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
availsExpected,
            (Text
"SpliceEventId" 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
spliceEventId
          ]
      )