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

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

-- | The configuration for using a content delivery network (CDN), like
-- Amazon CloudFront, for content and ad segment management.
--
-- /See:/ 'newCdnConfiguration' smart constructor.
data CdnConfiguration = CdnConfiguration'
  { -- | A non-default content delivery network (CDN) to serve ad segments. By
    -- default, AWS Elemental MediaTailor uses Amazon CloudFront with default
    -- cache settings as its CDN for ad segments. To set up an alternate CDN,
    -- create a rule in your CDN for the origin
    -- ads.mediatailor.&lt;region>.amazonaws.com. Then specify the rule\'s name
    -- in this AdSegmentUrlPrefix. When AWS Elemental MediaTailor serves a
    -- manifest, it reports your CDN as the source for ad segments.
    CdnConfiguration -> Maybe Text
adSegmentUrlPrefix :: Prelude.Maybe Prelude.Text,
    -- | A content delivery network (CDN) to cache content segments, so that
    -- content requests don’t always have to go to the origin server. First,
    -- create a rule in your CDN for the content segment origin server. Then
    -- specify the rule\'s name in this ContentSegmentUrlPrefix. When AWS
    -- Elemental MediaTailor serves a manifest, it reports your CDN as the
    -- source for content segments.
    CdnConfiguration -> Maybe Text
contentSegmentUrlPrefix :: Prelude.Maybe Prelude.Text
  }
  deriving (CdnConfiguration -> CdnConfiguration -> Bool
(CdnConfiguration -> CdnConfiguration -> Bool)
-> (CdnConfiguration -> CdnConfiguration -> Bool)
-> Eq CdnConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CdnConfiguration -> CdnConfiguration -> Bool
$c/= :: CdnConfiguration -> CdnConfiguration -> Bool
== :: CdnConfiguration -> CdnConfiguration -> Bool
$c== :: CdnConfiguration -> CdnConfiguration -> Bool
Prelude.Eq, ReadPrec [CdnConfiguration]
ReadPrec CdnConfiguration
Int -> ReadS CdnConfiguration
ReadS [CdnConfiguration]
(Int -> ReadS CdnConfiguration)
-> ReadS [CdnConfiguration]
-> ReadPrec CdnConfiguration
-> ReadPrec [CdnConfiguration]
-> Read CdnConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CdnConfiguration]
$creadListPrec :: ReadPrec [CdnConfiguration]
readPrec :: ReadPrec CdnConfiguration
$creadPrec :: ReadPrec CdnConfiguration
readList :: ReadS [CdnConfiguration]
$creadList :: ReadS [CdnConfiguration]
readsPrec :: Int -> ReadS CdnConfiguration
$creadsPrec :: Int -> ReadS CdnConfiguration
Prelude.Read, Int -> CdnConfiguration -> ShowS
[CdnConfiguration] -> ShowS
CdnConfiguration -> String
(Int -> CdnConfiguration -> ShowS)
-> (CdnConfiguration -> String)
-> ([CdnConfiguration] -> ShowS)
-> Show CdnConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CdnConfiguration] -> ShowS
$cshowList :: [CdnConfiguration] -> ShowS
show :: CdnConfiguration -> String
$cshow :: CdnConfiguration -> String
showsPrec :: Int -> CdnConfiguration -> ShowS
$cshowsPrec :: Int -> CdnConfiguration -> ShowS
Prelude.Show, (forall x. CdnConfiguration -> Rep CdnConfiguration x)
-> (forall x. Rep CdnConfiguration x -> CdnConfiguration)
-> Generic CdnConfiguration
forall x. Rep CdnConfiguration x -> CdnConfiguration
forall x. CdnConfiguration -> Rep CdnConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CdnConfiguration x -> CdnConfiguration
$cfrom :: forall x. CdnConfiguration -> Rep CdnConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'CdnConfiguration' 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:
--
-- 'adSegmentUrlPrefix', 'cdnConfiguration_adSegmentUrlPrefix' - A non-default content delivery network (CDN) to serve ad segments. By
-- default, AWS Elemental MediaTailor uses Amazon CloudFront with default
-- cache settings as its CDN for ad segments. To set up an alternate CDN,
-- create a rule in your CDN for the origin
-- ads.mediatailor.&lt;region>.amazonaws.com. Then specify the rule\'s name
-- in this AdSegmentUrlPrefix. When AWS Elemental MediaTailor serves a
-- manifest, it reports your CDN as the source for ad segments.
--
-- 'contentSegmentUrlPrefix', 'cdnConfiguration_contentSegmentUrlPrefix' - A content delivery network (CDN) to cache content segments, so that
-- content requests don’t always have to go to the origin server. First,
-- create a rule in your CDN for the content segment origin server. Then
-- specify the rule\'s name in this ContentSegmentUrlPrefix. When AWS
-- Elemental MediaTailor serves a manifest, it reports your CDN as the
-- source for content segments.
newCdnConfiguration ::
  CdnConfiguration
newCdnConfiguration :: CdnConfiguration
newCdnConfiguration =
  CdnConfiguration' :: Maybe Text -> Maybe Text -> CdnConfiguration
CdnConfiguration'
    { $sel:adSegmentUrlPrefix:CdnConfiguration' :: Maybe Text
adSegmentUrlPrefix =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contentSegmentUrlPrefix:CdnConfiguration' :: Maybe Text
contentSegmentUrlPrefix = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A non-default content delivery network (CDN) to serve ad segments. By
-- default, AWS Elemental MediaTailor uses Amazon CloudFront with default
-- cache settings as its CDN for ad segments. To set up an alternate CDN,
-- create a rule in your CDN for the origin
-- ads.mediatailor.&lt;region>.amazonaws.com. Then specify the rule\'s name
-- in this AdSegmentUrlPrefix. When AWS Elemental MediaTailor serves a
-- manifest, it reports your CDN as the source for ad segments.
cdnConfiguration_adSegmentUrlPrefix :: Lens.Lens' CdnConfiguration (Prelude.Maybe Prelude.Text)
cdnConfiguration_adSegmentUrlPrefix :: (Maybe Text -> f (Maybe Text))
-> CdnConfiguration -> f CdnConfiguration
cdnConfiguration_adSegmentUrlPrefix = (CdnConfiguration -> Maybe Text)
-> (CdnConfiguration -> Maybe Text -> CdnConfiguration)
-> Lens CdnConfiguration CdnConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CdnConfiguration' {Maybe Text
adSegmentUrlPrefix :: Maybe Text
$sel:adSegmentUrlPrefix:CdnConfiguration' :: CdnConfiguration -> Maybe Text
adSegmentUrlPrefix} -> Maybe Text
adSegmentUrlPrefix) (\s :: CdnConfiguration
s@CdnConfiguration' {} Maybe Text
a -> CdnConfiguration
s {$sel:adSegmentUrlPrefix:CdnConfiguration' :: Maybe Text
adSegmentUrlPrefix = Maybe Text
a} :: CdnConfiguration)

-- | A content delivery network (CDN) to cache content segments, so that
-- content requests don’t always have to go to the origin server. First,
-- create a rule in your CDN for the content segment origin server. Then
-- specify the rule\'s name in this ContentSegmentUrlPrefix. When AWS
-- Elemental MediaTailor serves a manifest, it reports your CDN as the
-- source for content segments.
cdnConfiguration_contentSegmentUrlPrefix :: Lens.Lens' CdnConfiguration (Prelude.Maybe Prelude.Text)
cdnConfiguration_contentSegmentUrlPrefix :: (Maybe Text -> f (Maybe Text))
-> CdnConfiguration -> f CdnConfiguration
cdnConfiguration_contentSegmentUrlPrefix = (CdnConfiguration -> Maybe Text)
-> (CdnConfiguration -> Maybe Text -> CdnConfiguration)
-> Lens CdnConfiguration CdnConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CdnConfiguration' {Maybe Text
contentSegmentUrlPrefix :: Maybe Text
$sel:contentSegmentUrlPrefix:CdnConfiguration' :: CdnConfiguration -> Maybe Text
contentSegmentUrlPrefix} -> Maybe Text
contentSegmentUrlPrefix) (\s :: CdnConfiguration
s@CdnConfiguration' {} Maybe Text
a -> CdnConfiguration
s {$sel:contentSegmentUrlPrefix:CdnConfiguration' :: Maybe Text
contentSegmentUrlPrefix = Maybe Text
a} :: CdnConfiguration)

instance Core.FromJSON CdnConfiguration where
  parseJSON :: Value -> Parser CdnConfiguration
parseJSON =
    String
-> (Object -> Parser CdnConfiguration)
-> Value
-> Parser CdnConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CdnConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> CdnConfiguration
CdnConfiguration'
            (Maybe Text -> Maybe Text -> CdnConfiguration)
-> Parser (Maybe Text) -> Parser (Maybe Text -> CdnConfiguration)
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
"AdSegmentUrlPrefix")
            Parser (Maybe Text -> CdnConfiguration)
-> Parser (Maybe Text) -> Parser CdnConfiguration
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
"ContentSegmentUrlPrefix")
      )

instance Prelude.Hashable CdnConfiguration

instance Prelude.NFData CdnConfiguration

instance Core.ToJSON CdnConfiguration where
  toJSON :: CdnConfiguration -> Value
toJSON CdnConfiguration' {Maybe Text
contentSegmentUrlPrefix :: Maybe Text
adSegmentUrlPrefix :: Maybe Text
$sel:contentSegmentUrlPrefix:CdnConfiguration' :: CdnConfiguration -> Maybe Text
$sel:adSegmentUrlPrefix:CdnConfiguration' :: CdnConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AdSegmentUrlPrefix" 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
adSegmentUrlPrefix,
            (Text
"ContentSegmentUrlPrefix" 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
contentSegmentUrlPrefix
          ]
      )