{-# 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.DefaultSegmentDeliveryConfiguration
-- 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.DefaultSegmentDeliveryConfiguration 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 optional configuration for a server that serves segments. Use this
-- if you want the segment delivery server to be different from the source
-- location server. For example, you can configure your source location
-- server to be an origination server, such as MediaPackage, and the
-- segment delivery server to be a content delivery network (CDN), such as
-- CloudFront. If you don\'t specify a segment delivery server, then the
-- source location server is used.
--
-- /See:/ 'newDefaultSegmentDeliveryConfiguration' smart constructor.
data DefaultSegmentDeliveryConfiguration = DefaultSegmentDeliveryConfiguration'
  { -- | The hostname of the server that will be used to serve segments. This
    -- string must include the protocol, such as __https:\/\/__.
    DefaultSegmentDeliveryConfiguration -> Maybe Text
baseUrl :: Prelude.Maybe Prelude.Text
  }
  deriving (DefaultSegmentDeliveryConfiguration
-> DefaultSegmentDeliveryConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefaultSegmentDeliveryConfiguration
-> DefaultSegmentDeliveryConfiguration -> Bool
$c/= :: DefaultSegmentDeliveryConfiguration
-> DefaultSegmentDeliveryConfiguration -> Bool
== :: DefaultSegmentDeliveryConfiguration
-> DefaultSegmentDeliveryConfiguration -> Bool
$c== :: DefaultSegmentDeliveryConfiguration
-> DefaultSegmentDeliveryConfiguration -> Bool
Prelude.Eq, ReadPrec [DefaultSegmentDeliveryConfiguration]
ReadPrec DefaultSegmentDeliveryConfiguration
Int -> ReadS DefaultSegmentDeliveryConfiguration
ReadS [DefaultSegmentDeliveryConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DefaultSegmentDeliveryConfiguration]
$creadListPrec :: ReadPrec [DefaultSegmentDeliveryConfiguration]
readPrec :: ReadPrec DefaultSegmentDeliveryConfiguration
$creadPrec :: ReadPrec DefaultSegmentDeliveryConfiguration
readList :: ReadS [DefaultSegmentDeliveryConfiguration]
$creadList :: ReadS [DefaultSegmentDeliveryConfiguration]
readsPrec :: Int -> ReadS DefaultSegmentDeliveryConfiguration
$creadsPrec :: Int -> ReadS DefaultSegmentDeliveryConfiguration
Prelude.Read, Int -> DefaultSegmentDeliveryConfiguration -> ShowS
[DefaultSegmentDeliveryConfiguration] -> ShowS
DefaultSegmentDeliveryConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DefaultSegmentDeliveryConfiguration] -> ShowS
$cshowList :: [DefaultSegmentDeliveryConfiguration] -> ShowS
show :: DefaultSegmentDeliveryConfiguration -> String
$cshow :: DefaultSegmentDeliveryConfiguration -> String
showsPrec :: Int -> DefaultSegmentDeliveryConfiguration -> ShowS
$cshowsPrec :: Int -> DefaultSegmentDeliveryConfiguration -> ShowS
Prelude.Show, forall x.
Rep DefaultSegmentDeliveryConfiguration x
-> DefaultSegmentDeliveryConfiguration
forall x.
DefaultSegmentDeliveryConfiguration
-> Rep DefaultSegmentDeliveryConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DefaultSegmentDeliveryConfiguration x
-> DefaultSegmentDeliveryConfiguration
$cfrom :: forall x.
DefaultSegmentDeliveryConfiguration
-> Rep DefaultSegmentDeliveryConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'DefaultSegmentDeliveryConfiguration' 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:
--
-- 'baseUrl', 'defaultSegmentDeliveryConfiguration_baseUrl' - The hostname of the server that will be used to serve segments. This
-- string must include the protocol, such as __https:\/\/__.
newDefaultSegmentDeliveryConfiguration ::
  DefaultSegmentDeliveryConfiguration
newDefaultSegmentDeliveryConfiguration :: DefaultSegmentDeliveryConfiguration
newDefaultSegmentDeliveryConfiguration =
  DefaultSegmentDeliveryConfiguration'
    { $sel:baseUrl:DefaultSegmentDeliveryConfiguration' :: Maybe Text
baseUrl =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The hostname of the server that will be used to serve segments. This
-- string must include the protocol, such as __https:\/\/__.
defaultSegmentDeliveryConfiguration_baseUrl :: Lens.Lens' DefaultSegmentDeliveryConfiguration (Prelude.Maybe Prelude.Text)
defaultSegmentDeliveryConfiguration_baseUrl :: Lens' DefaultSegmentDeliveryConfiguration (Maybe Text)
defaultSegmentDeliveryConfiguration_baseUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefaultSegmentDeliveryConfiguration' {Maybe Text
baseUrl :: Maybe Text
$sel:baseUrl:DefaultSegmentDeliveryConfiguration' :: DefaultSegmentDeliveryConfiguration -> Maybe Text
baseUrl} -> Maybe Text
baseUrl) (\s :: DefaultSegmentDeliveryConfiguration
s@DefaultSegmentDeliveryConfiguration' {} Maybe Text
a -> DefaultSegmentDeliveryConfiguration
s {$sel:baseUrl:DefaultSegmentDeliveryConfiguration' :: Maybe Text
baseUrl = Maybe Text
a} :: DefaultSegmentDeliveryConfiguration)

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

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

instance
  Prelude.NFData
    DefaultSegmentDeliveryConfiguration
  where
  rnf :: DefaultSegmentDeliveryConfiguration -> ()
rnf DefaultSegmentDeliveryConfiguration' {Maybe Text
baseUrl :: Maybe Text
$sel:baseUrl:DefaultSegmentDeliveryConfiguration' :: DefaultSegmentDeliveryConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
baseUrl

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