{-# 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.Transition
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaTailor.Types.Transition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaTailor.Types.RelativePosition
import qualified Amazonka.Prelude as Prelude

-- | Program transition configuration.
--
-- /See:/ 'newTransition' smart constructor.
data Transition = Transition'
  { -- | The duration of the live program in seconds.
    Transition -> Maybe Integer
durationMillis :: Prelude.Maybe Prelude.Integer,
    -- | The name of the program that this program will be inserted next to, as
    -- defined by @RelativePosition@.
    Transition -> Maybe Text
relativeProgram :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the program is scheduled to start, in epoch
    -- milliseconds.
    Transition -> Maybe Integer
scheduledStartTimeMillis :: Prelude.Maybe Prelude.Integer,
    -- | The position where this program will be inserted relative to the
    -- @RelativePosition@.
    Transition -> RelativePosition
relativePosition :: RelativePosition,
    -- | Defines when the program plays in the schedule. You can set the value to
    -- @ABSOLUTE@ or @RELATIVE@.
    --
    -- @ABSOLUTE@ - The program plays at a specific wall clock time. This
    -- setting can only be used for channels using the @LINEAR@ @PlaybackMode@.
    --
    -- Note the following considerations when using @ABSOLUTE@ transitions:
    --
    -- If the preceding program in the schedule has a duration that extends
    -- past the wall clock time, MediaTailor truncates the preceding program on
    -- a common segment boundary.
    --
    -- If there are gaps in playback, MediaTailor plays the @FillerSlate@ you
    -- configured for your linear channel.
    --
    -- @RELATIVE@ - The program is inserted into the schedule either before or
    -- after a program that you specify via @RelativePosition@.
    Transition -> Text
type' :: Prelude.Text
  }
  deriving (Transition -> Transition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Transition -> Transition -> Bool
$c/= :: Transition -> Transition -> Bool
== :: Transition -> Transition -> Bool
$c== :: Transition -> Transition -> Bool
Prelude.Eq, ReadPrec [Transition]
ReadPrec Transition
Int -> ReadS Transition
ReadS [Transition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Transition]
$creadListPrec :: ReadPrec [Transition]
readPrec :: ReadPrec Transition
$creadPrec :: ReadPrec Transition
readList :: ReadS [Transition]
$creadList :: ReadS [Transition]
readsPrec :: Int -> ReadS Transition
$creadsPrec :: Int -> ReadS Transition
Prelude.Read, Int -> Transition -> ShowS
[Transition] -> ShowS
Transition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Transition] -> ShowS
$cshowList :: [Transition] -> ShowS
show :: Transition -> String
$cshow :: Transition -> String
showsPrec :: Int -> Transition -> ShowS
$cshowsPrec :: Int -> Transition -> ShowS
Prelude.Show, forall x. Rep Transition x -> Transition
forall x. Transition -> Rep Transition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Transition x -> Transition
$cfrom :: forall x. Transition -> Rep Transition x
Prelude.Generic)

-- |
-- Create a value of 'Transition' 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:
--
-- 'durationMillis', 'transition_durationMillis' - The duration of the live program in seconds.
--
-- 'relativeProgram', 'transition_relativeProgram' - The name of the program that this program will be inserted next to, as
-- defined by @RelativePosition@.
--
-- 'scheduledStartTimeMillis', 'transition_scheduledStartTimeMillis' - The date and time that the program is scheduled to start, in epoch
-- milliseconds.
--
-- 'relativePosition', 'transition_relativePosition' - The position where this program will be inserted relative to the
-- @RelativePosition@.
--
-- 'type'', 'transition_type' - Defines when the program plays in the schedule. You can set the value to
-- @ABSOLUTE@ or @RELATIVE@.
--
-- @ABSOLUTE@ - The program plays at a specific wall clock time. This
-- setting can only be used for channels using the @LINEAR@ @PlaybackMode@.
--
-- Note the following considerations when using @ABSOLUTE@ transitions:
--
-- If the preceding program in the schedule has a duration that extends
-- past the wall clock time, MediaTailor truncates the preceding program on
-- a common segment boundary.
--
-- If there are gaps in playback, MediaTailor plays the @FillerSlate@ you
-- configured for your linear channel.
--
-- @RELATIVE@ - The program is inserted into the schedule either before or
-- after a program that you specify via @RelativePosition@.
newTransition ::
  -- | 'relativePosition'
  RelativePosition ->
  -- | 'type''
  Prelude.Text ->
  Transition
newTransition :: RelativePosition -> Text -> Transition
newTransition RelativePosition
pRelativePosition_ Text
pType_ =
  Transition'
    { $sel:durationMillis:Transition' :: Maybe Integer
durationMillis = forall a. Maybe a
Prelude.Nothing,
      $sel:relativeProgram:Transition' :: Maybe Text
relativeProgram = forall a. Maybe a
Prelude.Nothing,
      $sel:scheduledStartTimeMillis:Transition' :: Maybe Integer
scheduledStartTimeMillis = forall a. Maybe a
Prelude.Nothing,
      $sel:relativePosition:Transition' :: RelativePosition
relativePosition = RelativePosition
pRelativePosition_,
      $sel:type':Transition' :: Text
type' = Text
pType_
    }

-- | The duration of the live program in seconds.
transition_durationMillis :: Lens.Lens' Transition (Prelude.Maybe Prelude.Integer)
transition_durationMillis :: Lens' Transition (Maybe Integer)
transition_durationMillis = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Transition' {Maybe Integer
durationMillis :: Maybe Integer
$sel:durationMillis:Transition' :: Transition -> Maybe Integer
durationMillis} -> Maybe Integer
durationMillis) (\s :: Transition
s@Transition' {} Maybe Integer
a -> Transition
s {$sel:durationMillis:Transition' :: Maybe Integer
durationMillis = Maybe Integer
a} :: Transition)

-- | The name of the program that this program will be inserted next to, as
-- defined by @RelativePosition@.
transition_relativeProgram :: Lens.Lens' Transition (Prelude.Maybe Prelude.Text)
transition_relativeProgram :: Lens' Transition (Maybe Text)
transition_relativeProgram = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Transition' {Maybe Text
relativeProgram :: Maybe Text
$sel:relativeProgram:Transition' :: Transition -> Maybe Text
relativeProgram} -> Maybe Text
relativeProgram) (\s :: Transition
s@Transition' {} Maybe Text
a -> Transition
s {$sel:relativeProgram:Transition' :: Maybe Text
relativeProgram = Maybe Text
a} :: Transition)

-- | The date and time that the program is scheduled to start, in epoch
-- milliseconds.
transition_scheduledStartTimeMillis :: Lens.Lens' Transition (Prelude.Maybe Prelude.Integer)
transition_scheduledStartTimeMillis :: Lens' Transition (Maybe Integer)
transition_scheduledStartTimeMillis = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Transition' {Maybe Integer
scheduledStartTimeMillis :: Maybe Integer
$sel:scheduledStartTimeMillis:Transition' :: Transition -> Maybe Integer
scheduledStartTimeMillis} -> Maybe Integer
scheduledStartTimeMillis) (\s :: Transition
s@Transition' {} Maybe Integer
a -> Transition
s {$sel:scheduledStartTimeMillis:Transition' :: Maybe Integer
scheduledStartTimeMillis = Maybe Integer
a} :: Transition)

-- | The position where this program will be inserted relative to the
-- @RelativePosition@.
transition_relativePosition :: Lens.Lens' Transition RelativePosition
transition_relativePosition :: Lens' Transition RelativePosition
transition_relativePosition = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Transition' {RelativePosition
relativePosition :: RelativePosition
$sel:relativePosition:Transition' :: Transition -> RelativePosition
relativePosition} -> RelativePosition
relativePosition) (\s :: Transition
s@Transition' {} RelativePosition
a -> Transition
s {$sel:relativePosition:Transition' :: RelativePosition
relativePosition = RelativePosition
a} :: Transition)

-- | Defines when the program plays in the schedule. You can set the value to
-- @ABSOLUTE@ or @RELATIVE@.
--
-- @ABSOLUTE@ - The program plays at a specific wall clock time. This
-- setting can only be used for channels using the @LINEAR@ @PlaybackMode@.
--
-- Note the following considerations when using @ABSOLUTE@ transitions:
--
-- If the preceding program in the schedule has a duration that extends
-- past the wall clock time, MediaTailor truncates the preceding program on
-- a common segment boundary.
--
-- If there are gaps in playback, MediaTailor plays the @FillerSlate@ you
-- configured for your linear channel.
--
-- @RELATIVE@ - The program is inserted into the schedule either before or
-- after a program that you specify via @RelativePosition@.
transition_type :: Lens.Lens' Transition Prelude.Text
transition_type :: Lens' Transition Text
transition_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Transition' {Text
type' :: Text
$sel:type':Transition' :: Transition -> Text
type'} -> Text
type') (\s :: Transition
s@Transition' {} Text
a -> Transition
s {$sel:type':Transition' :: Text
type' = Text
a} :: Transition)

instance Prelude.Hashable Transition where
  hashWithSalt :: Int -> Transition -> Int
hashWithSalt Int
_salt Transition' {Maybe Integer
Maybe Text
Text
RelativePosition
type' :: Text
relativePosition :: RelativePosition
scheduledStartTimeMillis :: Maybe Integer
relativeProgram :: Maybe Text
durationMillis :: Maybe Integer
$sel:type':Transition' :: Transition -> Text
$sel:relativePosition:Transition' :: Transition -> RelativePosition
$sel:scheduledStartTimeMillis:Transition' :: Transition -> Maybe Integer
$sel:relativeProgram:Transition' :: Transition -> Maybe Text
$sel:durationMillis:Transition' :: Transition -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
durationMillis
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
relativeProgram
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
scheduledStartTimeMillis
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RelativePosition
relativePosition
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
type'

instance Prelude.NFData Transition where
  rnf :: Transition -> ()
rnf Transition' {Maybe Integer
Maybe Text
Text
RelativePosition
type' :: Text
relativePosition :: RelativePosition
scheduledStartTimeMillis :: Maybe Integer
relativeProgram :: Maybe Text
durationMillis :: Maybe Integer
$sel:type':Transition' :: Transition -> Text
$sel:relativePosition:Transition' :: Transition -> RelativePosition
$sel:scheduledStartTimeMillis:Transition' :: Transition -> Maybe Integer
$sel:relativeProgram:Transition' :: Transition -> Maybe Text
$sel:durationMillis:Transition' :: Transition -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
durationMillis
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
relativeProgram
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
scheduledStartTimeMillis
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RelativePosition
relativePosition
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
type'

instance Data.ToJSON Transition where
  toJSON :: Transition -> Value
toJSON Transition' {Maybe Integer
Maybe Text
Text
RelativePosition
type' :: Text
relativePosition :: RelativePosition
scheduledStartTimeMillis :: Maybe Integer
relativeProgram :: Maybe Text
durationMillis :: Maybe Integer
$sel:type':Transition' :: Transition -> Text
$sel:relativePosition:Transition' :: Transition -> RelativePosition
$sel:scheduledStartTimeMillis:Transition' :: Transition -> Maybe Integer
$sel:relativeProgram:Transition' :: Transition -> Maybe Text
$sel:durationMillis:Transition' :: Transition -> Maybe Integer
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DurationMillis" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
durationMillis,
            (Key
"RelativeProgram" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
relativeProgram,
            (Key
"ScheduledStartTimeMillis" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
scheduledStartTimeMillis,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"RelativePosition" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RelativePosition
relativePosition),
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
type')
          ]
      )