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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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./\<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
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]
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
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. 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./\<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'
    { $sel:adSegmentUrlPrefix:CdnConfiguration' :: Maybe Text
adSegmentUrlPrefix =
        forall a. Maybe a
Prelude.Nothing,
      $sel:contentSegmentUrlPrefix:CdnConfiguration' :: Maybe Text
contentSegmentUrlPrefix = 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./\<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 :: Lens' CdnConfiguration (Maybe Text)
cdnConfiguration_adSegmentUrlPrefix = 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 :: Lens' CdnConfiguration (Maybe Text)
cdnConfiguration_contentSegmentUrlPrefix = 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 Data.FromJSON CdnConfiguration where
  parseJSON :: Value -> Parser CdnConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CdnConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> CdnConfiguration
CdnConfiguration'
            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
"AdSegmentUrlPrefix")
            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
"ContentSegmentUrlPrefix")
      )

instance Prelude.Hashable CdnConfiguration where
  hashWithSalt :: Int -> CdnConfiguration -> Int
hashWithSalt Int
_salt CdnConfiguration' {Maybe Text
contentSegmentUrlPrefix :: Maybe Text
adSegmentUrlPrefix :: Maybe Text
$sel:contentSegmentUrlPrefix:CdnConfiguration' :: CdnConfiguration -> Maybe Text
$sel:adSegmentUrlPrefix:CdnConfiguration' :: CdnConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
adSegmentUrlPrefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
contentSegmentUrlPrefix

instance Prelude.NFData CdnConfiguration where
  rnf :: CdnConfiguration -> ()
rnf CdnConfiguration' {Maybe Text
contentSegmentUrlPrefix :: Maybe Text
adSegmentUrlPrefix :: Maybe Text
$sel:contentSegmentUrlPrefix:CdnConfiguration' :: CdnConfiguration -> Maybe Text
$sel:adSegmentUrlPrefix:CdnConfiguration' :: CdnConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
adSegmentUrlPrefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contentSegmentUrlPrefix

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AdSegmentUrlPrefix" 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
adSegmentUrlPrefix,
            (Key
"ContentSegmentUrlPrefix" 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
contentSegmentUrlPrefix
          ]
      )