{-# 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.SegmentDeliveryConfiguration
-- 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.SegmentDeliveryConfiguration 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 segment delivery configuration settings.
--
-- /See:/ 'newSegmentDeliveryConfiguration' smart constructor.
data SegmentDeliveryConfiguration = SegmentDeliveryConfiguration'
  { -- | The base URL of the host or path of the segment delivery server that
    -- you\'re using to serve segments. This is typically a content delivery
    -- network (CDN). The URL can be absolute or relative. To use an absolute
    -- URL include the protocol, such as @https:\/\/example.com\/some\/path@.
    -- To use a relative URL specify the relative path, such as
    -- @\/some\/path*@.
    SegmentDeliveryConfiguration -> Maybe Text
baseUrl :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier used to distinguish between multiple segment
    -- delivery configurations in a source location.
    SegmentDeliveryConfiguration -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (SegmentDeliveryConfiguration
-> SegmentDeliveryConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SegmentDeliveryConfiguration
-> SegmentDeliveryConfiguration -> Bool
$c/= :: SegmentDeliveryConfiguration
-> SegmentDeliveryConfiguration -> Bool
== :: SegmentDeliveryConfiguration
-> SegmentDeliveryConfiguration -> Bool
$c== :: SegmentDeliveryConfiguration
-> SegmentDeliveryConfiguration -> Bool
Prelude.Eq, ReadPrec [SegmentDeliveryConfiguration]
ReadPrec SegmentDeliveryConfiguration
Int -> ReadS SegmentDeliveryConfiguration
ReadS [SegmentDeliveryConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SegmentDeliveryConfiguration]
$creadListPrec :: ReadPrec [SegmentDeliveryConfiguration]
readPrec :: ReadPrec SegmentDeliveryConfiguration
$creadPrec :: ReadPrec SegmentDeliveryConfiguration
readList :: ReadS [SegmentDeliveryConfiguration]
$creadList :: ReadS [SegmentDeliveryConfiguration]
readsPrec :: Int -> ReadS SegmentDeliveryConfiguration
$creadsPrec :: Int -> ReadS SegmentDeliveryConfiguration
Prelude.Read, Int -> SegmentDeliveryConfiguration -> ShowS
[SegmentDeliveryConfiguration] -> ShowS
SegmentDeliveryConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SegmentDeliveryConfiguration] -> ShowS
$cshowList :: [SegmentDeliveryConfiguration] -> ShowS
show :: SegmentDeliveryConfiguration -> String
$cshow :: SegmentDeliveryConfiguration -> String
showsPrec :: Int -> SegmentDeliveryConfiguration -> ShowS
$cshowsPrec :: Int -> SegmentDeliveryConfiguration -> ShowS
Prelude.Show, forall x.
Rep SegmentDeliveryConfiguration x -> SegmentDeliveryConfiguration
forall x.
SegmentDeliveryConfiguration -> Rep SegmentDeliveryConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SegmentDeliveryConfiguration x -> SegmentDeliveryConfiguration
$cfrom :: forall x.
SegmentDeliveryConfiguration -> Rep SegmentDeliveryConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SegmentDeliveryConfiguration' 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', 'segmentDeliveryConfiguration_baseUrl' - The base URL of the host or path of the segment delivery server that
-- you\'re using to serve segments. This is typically a content delivery
-- network (CDN). The URL can be absolute or relative. To use an absolute
-- URL include the protocol, such as @https:\/\/example.com\/some\/path@.
-- To use a relative URL specify the relative path, such as
-- @\/some\/path*@.
--
-- 'name', 'segmentDeliveryConfiguration_name' - A unique identifier used to distinguish between multiple segment
-- delivery configurations in a source location.
newSegmentDeliveryConfiguration ::
  SegmentDeliveryConfiguration
newSegmentDeliveryConfiguration :: SegmentDeliveryConfiguration
newSegmentDeliveryConfiguration =
  SegmentDeliveryConfiguration'
    { $sel:baseUrl:SegmentDeliveryConfiguration' :: Maybe Text
baseUrl =
        forall a. Maybe a
Prelude.Nothing,
      $sel:name:SegmentDeliveryConfiguration' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | The base URL of the host or path of the segment delivery server that
-- you\'re using to serve segments. This is typically a content delivery
-- network (CDN). The URL can be absolute or relative. To use an absolute
-- URL include the protocol, such as @https:\/\/example.com\/some\/path@.
-- To use a relative URL specify the relative path, such as
-- @\/some\/path*@.
segmentDeliveryConfiguration_baseUrl :: Lens.Lens' SegmentDeliveryConfiguration (Prelude.Maybe Prelude.Text)
segmentDeliveryConfiguration_baseUrl :: Lens' SegmentDeliveryConfiguration (Maybe Text)
segmentDeliveryConfiguration_baseUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentDeliveryConfiguration' {Maybe Text
baseUrl :: Maybe Text
$sel:baseUrl:SegmentDeliveryConfiguration' :: SegmentDeliveryConfiguration -> Maybe Text
baseUrl} -> Maybe Text
baseUrl) (\s :: SegmentDeliveryConfiguration
s@SegmentDeliveryConfiguration' {} Maybe Text
a -> SegmentDeliveryConfiguration
s {$sel:baseUrl:SegmentDeliveryConfiguration' :: Maybe Text
baseUrl = Maybe Text
a} :: SegmentDeliveryConfiguration)

-- | A unique identifier used to distinguish between multiple segment
-- delivery configurations in a source location.
segmentDeliveryConfiguration_name :: Lens.Lens' SegmentDeliveryConfiguration (Prelude.Maybe Prelude.Text)
segmentDeliveryConfiguration_name :: Lens' SegmentDeliveryConfiguration (Maybe Text)
segmentDeliveryConfiguration_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentDeliveryConfiguration' {Maybe Text
name :: Maybe Text
$sel:name:SegmentDeliveryConfiguration' :: SegmentDeliveryConfiguration -> Maybe Text
name} -> Maybe Text
name) (\s :: SegmentDeliveryConfiguration
s@SegmentDeliveryConfiguration' {} Maybe Text
a -> SegmentDeliveryConfiguration
s {$sel:name:SegmentDeliveryConfiguration' :: Maybe Text
name = Maybe Text
a} :: SegmentDeliveryConfiguration)

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

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

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

instance Data.ToJSON SegmentDeliveryConfiguration where
  toJSON :: SegmentDeliveryConfiguration -> Value
toJSON SegmentDeliveryConfiguration' {Maybe Text
name :: Maybe Text
baseUrl :: Maybe Text
$sel:name:SegmentDeliveryConfiguration' :: SegmentDeliveryConfiguration -> Maybe Text
$sel:baseUrl:SegmentDeliveryConfiguration' :: SegmentDeliveryConfiguration -> 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,
            (Key
"Name" 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
name
          ]
      )