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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(DefaultSegmentDeliveryConfiguration
 -> DefaultSegmentDeliveryConfiguration -> Bool)
-> (DefaultSegmentDeliveryConfiguration
    -> DefaultSegmentDeliveryConfiguration -> Bool)
-> Eq DefaultSegmentDeliveryConfiguration
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]
(Int -> ReadS DefaultSegmentDeliveryConfiguration)
-> ReadS [DefaultSegmentDeliveryConfiguration]
-> ReadPrec DefaultSegmentDeliveryConfiguration
-> ReadPrec [DefaultSegmentDeliveryConfiguration]
-> Read 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
(Int -> DefaultSegmentDeliveryConfiguration -> ShowS)
-> (DefaultSegmentDeliveryConfiguration -> String)
-> ([DefaultSegmentDeliveryConfiguration] -> ShowS)
-> Show DefaultSegmentDeliveryConfiguration
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.
 DefaultSegmentDeliveryConfiguration
 -> Rep DefaultSegmentDeliveryConfiguration x)
-> (forall x.
    Rep DefaultSegmentDeliveryConfiguration x
    -> DefaultSegmentDeliveryConfiguration)
-> Generic DefaultSegmentDeliveryConfiguration
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' :: Maybe Text -> DefaultSegmentDeliveryConfiguration
DefaultSegmentDeliveryConfiguration'
    { $sel:baseUrl:DefaultSegmentDeliveryConfiguration' :: Maybe Text
baseUrl =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DefaultSegmentDeliveryConfiguration
-> f DefaultSegmentDeliveryConfiguration
defaultSegmentDeliveryConfiguration_baseUrl = (DefaultSegmentDeliveryConfiguration -> Maybe Text)
-> (DefaultSegmentDeliveryConfiguration
    -> Maybe Text -> DefaultSegmentDeliveryConfiguration)
-> Lens
     DefaultSegmentDeliveryConfiguration
     DefaultSegmentDeliveryConfiguration
     (Maybe Text)
     (Maybe Text)
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
  Core.FromJSON
    DefaultSegmentDeliveryConfiguration
  where
  parseJSON :: Value -> Parser DefaultSegmentDeliveryConfiguration
parseJSON =
    String
-> (Object -> Parser DefaultSegmentDeliveryConfiguration)
-> Value
-> Parser DefaultSegmentDeliveryConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DefaultSegmentDeliveryConfiguration"
      ( \Object
x ->
          Maybe Text -> DefaultSegmentDeliveryConfiguration
DefaultSegmentDeliveryConfiguration'
            (Maybe Text -> DefaultSegmentDeliveryConfiguration)
-> Parser (Maybe Text)
-> Parser DefaultSegmentDeliveryConfiguration
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
"BaseUrl")
      )

instance
  Prelude.Hashable
    DefaultSegmentDeliveryConfiguration

instance
  Prelude.NFData
    DefaultSegmentDeliveryConfiguration

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