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

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

-- | The configuration for avail suppression, also known as ad suppression.
-- For more information about ad suppression, see
-- <https://docs.aws.amazon.com/mediatailor/latest/ug/ad-behavior.html Ad Suppression>.
--
-- /See:/ 'newAvailSuppression' smart constructor.
data AvailSuppression = AvailSuppression'
  { -- | A live edge offset time in HH:MM:SS. MediaTailor won\'t fill ad breaks
    -- on or behind this time in the manifest lookback window. If Value is set
    -- to 00:00:00, it is in sync with the live edge, and MediaTailor won\'t
    -- fill any ad breaks on or behind the live edge. If you set a Value time,
    -- MediaTailor won\'t fill any ad breaks on or behind this time in the
    -- manifest lookback window. For example, if you set 00:45:00, then
    -- MediaTailor will fill ad breaks that occur within 45 minutes behind the
    -- live edge, but won\'t fill ad breaks on or behind 45 minutes behind the
    -- live edge.
    AvailSuppression -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | Sets the ad suppression mode. By default, ad suppression is off and all
    -- ad breaks are filled with ads or slate. When Mode is set to
    -- BEHIND_LIVE_EDGE, ad suppression is active and MediaTailor won\'t fill
    -- ad breaks on or behind the ad suppression Value time in the manifest
    -- lookback window.
    AvailSuppression -> Maybe Mode
mode :: Prelude.Maybe Mode
  }
  deriving (AvailSuppression -> AvailSuppression -> Bool
(AvailSuppression -> AvailSuppression -> Bool)
-> (AvailSuppression -> AvailSuppression -> Bool)
-> Eq AvailSuppression
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AvailSuppression -> AvailSuppression -> Bool
$c/= :: AvailSuppression -> AvailSuppression -> Bool
== :: AvailSuppression -> AvailSuppression -> Bool
$c== :: AvailSuppression -> AvailSuppression -> Bool
Prelude.Eq, ReadPrec [AvailSuppression]
ReadPrec AvailSuppression
Int -> ReadS AvailSuppression
ReadS [AvailSuppression]
(Int -> ReadS AvailSuppression)
-> ReadS [AvailSuppression]
-> ReadPrec AvailSuppression
-> ReadPrec [AvailSuppression]
-> Read AvailSuppression
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AvailSuppression]
$creadListPrec :: ReadPrec [AvailSuppression]
readPrec :: ReadPrec AvailSuppression
$creadPrec :: ReadPrec AvailSuppression
readList :: ReadS [AvailSuppression]
$creadList :: ReadS [AvailSuppression]
readsPrec :: Int -> ReadS AvailSuppression
$creadsPrec :: Int -> ReadS AvailSuppression
Prelude.Read, Int -> AvailSuppression -> ShowS
[AvailSuppression] -> ShowS
AvailSuppression -> String
(Int -> AvailSuppression -> ShowS)
-> (AvailSuppression -> String)
-> ([AvailSuppression] -> ShowS)
-> Show AvailSuppression
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AvailSuppression] -> ShowS
$cshowList :: [AvailSuppression] -> ShowS
show :: AvailSuppression -> String
$cshow :: AvailSuppression -> String
showsPrec :: Int -> AvailSuppression -> ShowS
$cshowsPrec :: Int -> AvailSuppression -> ShowS
Prelude.Show, (forall x. AvailSuppression -> Rep AvailSuppression x)
-> (forall x. Rep AvailSuppression x -> AvailSuppression)
-> Generic AvailSuppression
forall x. Rep AvailSuppression x -> AvailSuppression
forall x. AvailSuppression -> Rep AvailSuppression x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AvailSuppression x -> AvailSuppression
$cfrom :: forall x. AvailSuppression -> Rep AvailSuppression x
Prelude.Generic)

-- |
-- Create a value of 'AvailSuppression' 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:
--
-- 'value', 'availSuppression_value' - A live edge offset time in HH:MM:SS. MediaTailor won\'t fill ad breaks
-- on or behind this time in the manifest lookback window. If Value is set
-- to 00:00:00, it is in sync with the live edge, and MediaTailor won\'t
-- fill any ad breaks on or behind the live edge. If you set a Value time,
-- MediaTailor won\'t fill any ad breaks on or behind this time in the
-- manifest lookback window. For example, if you set 00:45:00, then
-- MediaTailor will fill ad breaks that occur within 45 minutes behind the
-- live edge, but won\'t fill ad breaks on or behind 45 minutes behind the
-- live edge.
--
-- 'mode', 'availSuppression_mode' - Sets the ad suppression mode. By default, ad suppression is off and all
-- ad breaks are filled with ads or slate. When Mode is set to
-- BEHIND_LIVE_EDGE, ad suppression is active and MediaTailor won\'t fill
-- ad breaks on or behind the ad suppression Value time in the manifest
-- lookback window.
newAvailSuppression ::
  AvailSuppression
newAvailSuppression :: AvailSuppression
newAvailSuppression =
  AvailSuppression' :: Maybe Text -> Maybe Mode -> AvailSuppression
AvailSuppression'
    { $sel:value:AvailSuppression' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:mode:AvailSuppression' :: Maybe Mode
mode = Maybe Mode
forall a. Maybe a
Prelude.Nothing
    }

-- | A live edge offset time in HH:MM:SS. MediaTailor won\'t fill ad breaks
-- on or behind this time in the manifest lookback window. If Value is set
-- to 00:00:00, it is in sync with the live edge, and MediaTailor won\'t
-- fill any ad breaks on or behind the live edge. If you set a Value time,
-- MediaTailor won\'t fill any ad breaks on or behind this time in the
-- manifest lookback window. For example, if you set 00:45:00, then
-- MediaTailor will fill ad breaks that occur within 45 minutes behind the
-- live edge, but won\'t fill ad breaks on or behind 45 minutes behind the
-- live edge.
availSuppression_value :: Lens.Lens' AvailSuppression (Prelude.Maybe Prelude.Text)
availSuppression_value :: (Maybe Text -> f (Maybe Text))
-> AvailSuppression -> f AvailSuppression
availSuppression_value = (AvailSuppression -> Maybe Text)
-> (AvailSuppression -> Maybe Text -> AvailSuppression)
-> Lens AvailSuppression AvailSuppression (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AvailSuppression' {Maybe Text
value :: Maybe Text
$sel:value:AvailSuppression' :: AvailSuppression -> Maybe Text
value} -> Maybe Text
value) (\s :: AvailSuppression
s@AvailSuppression' {} Maybe Text
a -> AvailSuppression
s {$sel:value:AvailSuppression' :: Maybe Text
value = Maybe Text
a} :: AvailSuppression)

-- | Sets the ad suppression mode. By default, ad suppression is off and all
-- ad breaks are filled with ads or slate. When Mode is set to
-- BEHIND_LIVE_EDGE, ad suppression is active and MediaTailor won\'t fill
-- ad breaks on or behind the ad suppression Value time in the manifest
-- lookback window.
availSuppression_mode :: Lens.Lens' AvailSuppression (Prelude.Maybe Mode)
availSuppression_mode :: (Maybe Mode -> f (Maybe Mode))
-> AvailSuppression -> f AvailSuppression
availSuppression_mode = (AvailSuppression -> Maybe Mode)
-> (AvailSuppression -> Maybe Mode -> AvailSuppression)
-> Lens AvailSuppression AvailSuppression (Maybe Mode) (Maybe Mode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AvailSuppression' {Maybe Mode
mode :: Maybe Mode
$sel:mode:AvailSuppression' :: AvailSuppression -> Maybe Mode
mode} -> Maybe Mode
mode) (\s :: AvailSuppression
s@AvailSuppression' {} Maybe Mode
a -> AvailSuppression
s {$sel:mode:AvailSuppression' :: Maybe Mode
mode = Maybe Mode
a} :: AvailSuppression)

instance Core.FromJSON AvailSuppression where
  parseJSON :: Value -> Parser AvailSuppression
parseJSON =
    String
-> (Object -> Parser AvailSuppression)
-> Value
-> Parser AvailSuppression
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AvailSuppression"
      ( \Object
x ->
          Maybe Text -> Maybe Mode -> AvailSuppression
AvailSuppression'
            (Maybe Text -> Maybe Mode -> AvailSuppression)
-> Parser (Maybe Text) -> Parser (Maybe Mode -> AvailSuppression)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Value") Parser (Maybe Mode -> AvailSuppression)
-> Parser (Maybe Mode) -> Parser AvailSuppression
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Mode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Mode")
      )

instance Prelude.Hashable AvailSuppression

instance Prelude.NFData AvailSuppression

instance Core.ToJSON AvailSuppression where
  toJSON :: AvailSuppression -> Value
toJSON AvailSuppression' {Maybe Text
Maybe Mode
mode :: Maybe Mode
value :: Maybe Text
$sel:mode:AvailSuppression' :: AvailSuppression -> Maybe Mode
$sel:value:AvailSuppression' :: AvailSuppression -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Value" 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
value,
            (Text
"Mode" Text -> Mode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Mode -> Pair) -> Maybe Mode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Mode
mode
          ]
      )