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

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

-- | The HTTP configuration for the source location.
--
-- /See:/ 'newHttpConfiguration' smart constructor.
data HttpConfiguration = HttpConfiguration'
  { -- | The base URL for the source location host server. This string must
    -- include the protocol, such as __https:\/\/__.
    HttpConfiguration -> Text
baseUrl :: Prelude.Text
  }
  deriving (HttpConfiguration -> HttpConfiguration -> Bool
(HttpConfiguration -> HttpConfiguration -> Bool)
-> (HttpConfiguration -> HttpConfiguration -> Bool)
-> Eq HttpConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpConfiguration -> HttpConfiguration -> Bool
$c/= :: HttpConfiguration -> HttpConfiguration -> Bool
== :: HttpConfiguration -> HttpConfiguration -> Bool
$c== :: HttpConfiguration -> HttpConfiguration -> Bool
Prelude.Eq, ReadPrec [HttpConfiguration]
ReadPrec HttpConfiguration
Int -> ReadS HttpConfiguration
ReadS [HttpConfiguration]
(Int -> ReadS HttpConfiguration)
-> ReadS [HttpConfiguration]
-> ReadPrec HttpConfiguration
-> ReadPrec [HttpConfiguration]
-> Read HttpConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HttpConfiguration]
$creadListPrec :: ReadPrec [HttpConfiguration]
readPrec :: ReadPrec HttpConfiguration
$creadPrec :: ReadPrec HttpConfiguration
readList :: ReadS [HttpConfiguration]
$creadList :: ReadS [HttpConfiguration]
readsPrec :: Int -> ReadS HttpConfiguration
$creadsPrec :: Int -> ReadS HttpConfiguration
Prelude.Read, Int -> HttpConfiguration -> ShowS
[HttpConfiguration] -> ShowS
HttpConfiguration -> String
(Int -> HttpConfiguration -> ShowS)
-> (HttpConfiguration -> String)
-> ([HttpConfiguration] -> ShowS)
-> Show HttpConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpConfiguration] -> ShowS
$cshowList :: [HttpConfiguration] -> ShowS
show :: HttpConfiguration -> String
$cshow :: HttpConfiguration -> String
showsPrec :: Int -> HttpConfiguration -> ShowS
$cshowsPrec :: Int -> HttpConfiguration -> ShowS
Prelude.Show, (forall x. HttpConfiguration -> Rep HttpConfiguration x)
-> (forall x. Rep HttpConfiguration x -> HttpConfiguration)
-> Generic HttpConfiguration
forall x. Rep HttpConfiguration x -> HttpConfiguration
forall x. HttpConfiguration -> Rep HttpConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HttpConfiguration x -> HttpConfiguration
$cfrom :: forall x. HttpConfiguration -> Rep HttpConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'HttpConfiguration' 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', 'httpConfiguration_baseUrl' - The base URL for the source location host server. This string must
-- include the protocol, such as __https:\/\/__.
newHttpConfiguration ::
  -- | 'baseUrl'
  Prelude.Text ->
  HttpConfiguration
newHttpConfiguration :: Text -> HttpConfiguration
newHttpConfiguration Text
pBaseUrl_ =
  HttpConfiguration' :: Text -> HttpConfiguration
HttpConfiguration' {$sel:baseUrl:HttpConfiguration' :: Text
baseUrl = Text
pBaseUrl_}

-- | The base URL for the source location host server. This string must
-- include the protocol, such as __https:\/\/__.
httpConfiguration_baseUrl :: Lens.Lens' HttpConfiguration Prelude.Text
httpConfiguration_baseUrl :: (Text -> f Text) -> HttpConfiguration -> f HttpConfiguration
httpConfiguration_baseUrl = (HttpConfiguration -> Text)
-> (HttpConfiguration -> Text -> HttpConfiguration)
-> Lens HttpConfiguration HttpConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpConfiguration' {Text
baseUrl :: Text
$sel:baseUrl:HttpConfiguration' :: HttpConfiguration -> Text
baseUrl} -> Text
baseUrl) (\s :: HttpConfiguration
s@HttpConfiguration' {} Text
a -> HttpConfiguration
s {$sel:baseUrl:HttpConfiguration' :: Text
baseUrl = Text
a} :: HttpConfiguration)

instance Core.FromJSON HttpConfiguration where
  parseJSON :: Value -> Parser HttpConfiguration
parseJSON =
    String
-> (Object -> Parser HttpConfiguration)
-> Value
-> Parser HttpConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HttpConfiguration"
      ( \Object
x ->
          Text -> HttpConfiguration
HttpConfiguration' (Text -> HttpConfiguration)
-> Parser Text -> Parser HttpConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"BaseUrl")
      )

instance Prelude.Hashable HttpConfiguration

instance Prelude.NFData HttpConfiguration

instance Core.ToJSON HttpConfiguration where
  toJSON :: HttpConfiguration -> Value
toJSON HttpConfiguration' {Text
baseUrl :: Text
$sel:baseUrl:HttpConfiguration' :: HttpConfiguration -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BaseUrl" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
baseUrl)]
      )