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

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

-- | The configuration for bumpers. Bumpers are short audio or video clips
-- that play at the start or before the end of an ad break. To learn more
-- about bumpers, see
-- <https://docs.aws.amazon.com/mediatailor/latest/ug/bumpers.html Bumpers>.
--
-- /See:/ 'newBumper' smart constructor.
data Bumper = Bumper'
  { -- | The URL for the end bumper asset.
    Bumper -> Maybe Text
endUrl :: Prelude.Maybe Prelude.Text,
    -- | The URL for the start bumper asset.
    Bumper -> Maybe Text
startUrl :: Prelude.Maybe Prelude.Text
  }
  deriving (Bumper -> Bumper -> Bool
(Bumper -> Bumper -> Bool)
-> (Bumper -> Bumper -> Bool) -> Eq Bumper
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Bumper -> Bumper -> Bool
$c/= :: Bumper -> Bumper -> Bool
== :: Bumper -> Bumper -> Bool
$c== :: Bumper -> Bumper -> Bool
Prelude.Eq, ReadPrec [Bumper]
ReadPrec Bumper
Int -> ReadS Bumper
ReadS [Bumper]
(Int -> ReadS Bumper)
-> ReadS [Bumper]
-> ReadPrec Bumper
-> ReadPrec [Bumper]
-> Read Bumper
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Bumper]
$creadListPrec :: ReadPrec [Bumper]
readPrec :: ReadPrec Bumper
$creadPrec :: ReadPrec Bumper
readList :: ReadS [Bumper]
$creadList :: ReadS [Bumper]
readsPrec :: Int -> ReadS Bumper
$creadsPrec :: Int -> ReadS Bumper
Prelude.Read, Int -> Bumper -> ShowS
[Bumper] -> ShowS
Bumper -> String
(Int -> Bumper -> ShowS)
-> (Bumper -> String) -> ([Bumper] -> ShowS) -> Show Bumper
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Bumper] -> ShowS
$cshowList :: [Bumper] -> ShowS
show :: Bumper -> String
$cshow :: Bumper -> String
showsPrec :: Int -> Bumper -> ShowS
$cshowsPrec :: Int -> Bumper -> ShowS
Prelude.Show, (forall x. Bumper -> Rep Bumper x)
-> (forall x. Rep Bumper x -> Bumper) -> Generic Bumper
forall x. Rep Bumper x -> Bumper
forall x. Bumper -> Rep Bumper x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Bumper x -> Bumper
$cfrom :: forall x. Bumper -> Rep Bumper x
Prelude.Generic)

-- |
-- Create a value of 'Bumper' 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:
--
-- 'endUrl', 'bumper_endUrl' - The URL for the end bumper asset.
--
-- 'startUrl', 'bumper_startUrl' - The URL for the start bumper asset.
newBumper ::
  Bumper
newBumper :: Bumper
newBumper =
  Bumper' :: Maybe Text -> Maybe Text -> Bumper
Bumper'
    { $sel:endUrl:Bumper' :: Maybe Text
endUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:startUrl:Bumper' :: Maybe Text
startUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The URL for the end bumper asset.
bumper_endUrl :: Lens.Lens' Bumper (Prelude.Maybe Prelude.Text)
bumper_endUrl :: (Maybe Text -> f (Maybe Text)) -> Bumper -> f Bumper
bumper_endUrl = (Bumper -> Maybe Text)
-> (Bumper -> Maybe Text -> Bumper)
-> Lens Bumper Bumper (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Bumper' {Maybe Text
endUrl :: Maybe Text
$sel:endUrl:Bumper' :: Bumper -> Maybe Text
endUrl} -> Maybe Text
endUrl) (\s :: Bumper
s@Bumper' {} Maybe Text
a -> Bumper
s {$sel:endUrl:Bumper' :: Maybe Text
endUrl = Maybe Text
a} :: Bumper)

-- | The URL for the start bumper asset.
bumper_startUrl :: Lens.Lens' Bumper (Prelude.Maybe Prelude.Text)
bumper_startUrl :: (Maybe Text -> f (Maybe Text)) -> Bumper -> f Bumper
bumper_startUrl = (Bumper -> Maybe Text)
-> (Bumper -> Maybe Text -> Bumper)
-> Lens Bumper Bumper (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Bumper' {Maybe Text
startUrl :: Maybe Text
$sel:startUrl:Bumper' :: Bumper -> Maybe Text
startUrl} -> Maybe Text
startUrl) (\s :: Bumper
s@Bumper' {} Maybe Text
a -> Bumper
s {$sel:startUrl:Bumper' :: Maybe Text
startUrl = Maybe Text
a} :: Bumper)

instance Core.FromJSON Bumper where
  parseJSON :: Value -> Parser Bumper
parseJSON =
    String -> (Object -> Parser Bumper) -> Value -> Parser Bumper
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Bumper"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Bumper
Bumper'
            (Maybe Text -> Maybe Text -> Bumper)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Bumper)
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
"EndUrl")
            Parser (Maybe Text -> Bumper)
-> Parser (Maybe Text) -> Parser Bumper
forall (f :: * -> *) a b. Applicative f => 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
"StartUrl")
      )

instance Prelude.Hashable Bumper

instance Prelude.NFData Bumper

instance Core.ToJSON Bumper where
  toJSON :: Bumper -> Value
toJSON Bumper' {Maybe Text
startUrl :: Maybe Text
endUrl :: Maybe Text
$sel:startUrl:Bumper' :: Bumper -> Maybe Text
$sel:endUrl:Bumper' :: Bumper -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EndUrl" 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
endUrl,
            (Text
"StartUrl" 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
startUrl
          ]
      )