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

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

-- | Program transition configuration.
--
-- /See:/ 'newTransition' smart constructor.
data Transition = Transition'
  { -- | The date and time that the program is scheduled to start, in epoch
    -- milliseconds.
    Transition -> Maybe Integer
scheduledStartTimeMillis :: 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,
    -- | 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,
    -- | The position where this program will be inserted relative to the
    -- RelativePosition.
    Transition -> RelativePosition
relativePosition :: RelativePosition
  }
  deriving (Transition -> Transition -> Bool
(Transition -> Transition -> Bool)
-> (Transition -> Transition -> Bool) -> Eq Transition
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]
(Int -> ReadS Transition)
-> ReadS [Transition]
-> ReadPrec Transition
-> ReadPrec [Transition]
-> Read 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
(Int -> Transition -> ShowS)
-> (Transition -> String)
-> ([Transition] -> ShowS)
-> Show Transition
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. Transition -> Rep Transition x)
-> (forall x. Rep Transition x -> Transition) -> Generic Transition
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:
--
-- 'scheduledStartTimeMillis', 'transition_scheduledStartTimeMillis' - The date and time that the program is scheduled to start, in epoch
-- milliseconds.
--
-- 'relativeProgram', 'transition_relativeProgram' - The name of the program that this program will be inserted next to, as
-- defined by 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.
--
-- 'relativePosition', 'transition_relativePosition' - The position where this program will be inserted relative to the
-- RelativePosition.
newTransition ::
  -- | 'type''
  Prelude.Text ->
  -- | 'relativePosition'
  RelativePosition ->
  Transition
newTransition :: Text -> RelativePosition -> Transition
newTransition Text
pType_ RelativePosition
pRelativePosition_ =
  Transition' :: Maybe Integer
-> Maybe Text -> Text -> RelativePosition -> Transition
Transition'
    { $sel:scheduledStartTimeMillis:Transition' :: Maybe Integer
scheduledStartTimeMillis =
        Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:relativeProgram:Transition' :: Maybe Text
relativeProgram = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Transition' :: Text
type' = Text
pType_,
      $sel:relativePosition:Transition' :: RelativePosition
relativePosition = RelativePosition
pRelativePosition_
    }

-- | 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 :: (Maybe Integer -> f (Maybe Integer)) -> Transition -> f Transition
transition_scheduledStartTimeMillis = (Transition -> Maybe Integer)
-> (Transition -> Maybe Integer -> Transition)
-> Lens Transition Transition (Maybe Integer) (Maybe Integer)
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 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 :: (Maybe Text -> f (Maybe Text)) -> Transition -> f Transition
transition_relativeProgram = (Transition -> Maybe Text)
-> (Transition -> Maybe Text -> Transition)
-> Lens Transition Transition (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Text -> f Text) -> Transition -> f Transition
transition_type = (Transition -> Text)
-> (Transition -> Text -> Transition)
-> Lens Transition Transition Text Text
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)

-- | The position where this program will be inserted relative to the
-- RelativePosition.
transition_relativePosition :: Lens.Lens' Transition RelativePosition
transition_relativePosition :: (RelativePosition -> f RelativePosition)
-> Transition -> f Transition
transition_relativePosition = (Transition -> RelativePosition)
-> (Transition -> RelativePosition -> Transition)
-> Lens Transition Transition RelativePosition 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)

instance Prelude.Hashable Transition

instance Prelude.NFData Transition

instance Core.ToJSON Transition where
  toJSON :: Transition -> Value
toJSON Transition' {Maybe Integer
Maybe Text
Text
RelativePosition
relativePosition :: RelativePosition
type' :: Text
relativeProgram :: Maybe Text
scheduledStartTimeMillis :: Maybe Integer
$sel:relativePosition:Transition' :: Transition -> RelativePosition
$sel:type':Transition' :: Transition -> Text
$sel:relativeProgram:Transition' :: Transition -> Maybe Text
$sel:scheduledStartTimeMillis:Transition' :: Transition -> Maybe Integer
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ScheduledStartTimeMillis" 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
scheduledStartTimeMillis,
            (Text
"RelativeProgram" 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
relativeProgram,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
type'),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"RelativePosition" Text -> RelativePosition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RelativePosition
relativePosition)
          ]
      )