{-# 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-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.AvailSuppression 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.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'
  { -- | 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,
    -- | 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
  }
  deriving (AvailSuppression -> AvailSuppression -> Bool
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]
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
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. 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:
--
-- '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.
--
-- '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.
newAvailSuppression ::
  AvailSuppression
newAvailSuppression :: AvailSuppression
newAvailSuppression =
  AvailSuppression'
    { $sel:mode:AvailSuppression' :: Maybe Mode
mode = forall a. Maybe a
Prelude.Nothing,
      $sel:value:AvailSuppression' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' AvailSuppression (Maybe Mode)
availSuppression_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)

-- | 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 :: Lens' AvailSuppression (Maybe Text)
availSuppression_value = 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)

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

instance Prelude.Hashable AvailSuppression where
  hashWithSalt :: Int -> AvailSuppression -> Int
hashWithSalt Int
_salt AvailSuppression' {Maybe Text
Maybe Mode
value :: Maybe Text
mode :: Maybe Mode
$sel:value:AvailSuppression' :: AvailSuppression -> Maybe Text
$sel:mode:AvailSuppression' :: AvailSuppression -> Maybe Mode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Mode
mode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData AvailSuppression where
  rnf :: AvailSuppression -> ()
rnf AvailSuppression' {Maybe Text
Maybe Mode
value :: Maybe Text
mode :: Maybe Mode
$sel:value:AvailSuppression' :: AvailSuppression -> Maybe Text
$sel:mode:AvailSuppression' :: AvailSuppression -> Maybe Mode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Mode
mode seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

instance Data.ToJSON AvailSuppression where
  toJSON :: AvailSuppression -> Value
toJSON AvailSuppression' {Maybe Text
Maybe Mode
value :: Maybe Text
mode :: Maybe Mode
$sel:value:AvailSuppression' :: AvailSuppression -> Maybe Text
$sel:mode:AvailSuppression' :: AvailSuppression -> Maybe Mode
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Mode" 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 Mode
mode,
            (Key
"Value" 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
value
          ]
      )