{-# 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.APIGateway.Types.BasePathMapping
-- 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.APIGateway.Types.BasePathMapping where

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

-- | Represents the base path that callers of the API must provide as part of
-- the URL after the domain name.
--
-- A custom domain name plus a @BasePathMapping@ specification identifies a
-- deployed RestApi in a given stage of the owner Account.
--
-- <https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html Use Custom Domain Names>
--
-- /See:/ 'newBasePathMapping' smart constructor.
data BasePathMapping = BasePathMapping'
  { -- | The name of the associated stage.
    BasePathMapping -> Maybe Text
stage :: Prelude.Maybe Prelude.Text,
    -- | The base path name that callers of the API must provide as part of the
    -- URL after the domain name.
    BasePathMapping -> Maybe Text
basePath :: Prelude.Maybe Prelude.Text,
    -- | The string identifier of the associated RestApi.
    BasePathMapping -> Maybe Text
restApiId :: Prelude.Maybe Prelude.Text
  }
  deriving (BasePathMapping -> BasePathMapping -> Bool
(BasePathMapping -> BasePathMapping -> Bool)
-> (BasePathMapping -> BasePathMapping -> Bool)
-> Eq BasePathMapping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BasePathMapping -> BasePathMapping -> Bool
$c/= :: BasePathMapping -> BasePathMapping -> Bool
== :: BasePathMapping -> BasePathMapping -> Bool
$c== :: BasePathMapping -> BasePathMapping -> Bool
Prelude.Eq, ReadPrec [BasePathMapping]
ReadPrec BasePathMapping
Int -> ReadS BasePathMapping
ReadS [BasePathMapping]
(Int -> ReadS BasePathMapping)
-> ReadS [BasePathMapping]
-> ReadPrec BasePathMapping
-> ReadPrec [BasePathMapping]
-> Read BasePathMapping
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BasePathMapping]
$creadListPrec :: ReadPrec [BasePathMapping]
readPrec :: ReadPrec BasePathMapping
$creadPrec :: ReadPrec BasePathMapping
readList :: ReadS [BasePathMapping]
$creadList :: ReadS [BasePathMapping]
readsPrec :: Int -> ReadS BasePathMapping
$creadsPrec :: Int -> ReadS BasePathMapping
Prelude.Read, Int -> BasePathMapping -> ShowS
[BasePathMapping] -> ShowS
BasePathMapping -> String
(Int -> BasePathMapping -> ShowS)
-> (BasePathMapping -> String)
-> ([BasePathMapping] -> ShowS)
-> Show BasePathMapping
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BasePathMapping] -> ShowS
$cshowList :: [BasePathMapping] -> ShowS
show :: BasePathMapping -> String
$cshow :: BasePathMapping -> String
showsPrec :: Int -> BasePathMapping -> ShowS
$cshowsPrec :: Int -> BasePathMapping -> ShowS
Prelude.Show, (forall x. BasePathMapping -> Rep BasePathMapping x)
-> (forall x. Rep BasePathMapping x -> BasePathMapping)
-> Generic BasePathMapping
forall x. Rep BasePathMapping x -> BasePathMapping
forall x. BasePathMapping -> Rep BasePathMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BasePathMapping x -> BasePathMapping
$cfrom :: forall x. BasePathMapping -> Rep BasePathMapping x
Prelude.Generic)

-- |
-- Create a value of 'BasePathMapping' 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:
--
-- 'stage', 'basePathMapping_stage' - The name of the associated stage.
--
-- 'basePath', 'basePathMapping_basePath' - The base path name that callers of the API must provide as part of the
-- URL after the domain name.
--
-- 'restApiId', 'basePathMapping_restApiId' - The string identifier of the associated RestApi.
newBasePathMapping ::
  BasePathMapping
newBasePathMapping :: BasePathMapping
newBasePathMapping =
  BasePathMapping' :: Maybe Text -> Maybe Text -> Maybe Text -> BasePathMapping
BasePathMapping'
    { $sel:stage:BasePathMapping' :: Maybe Text
stage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:basePath:BasePathMapping' :: Maybe Text
basePath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:restApiId:BasePathMapping' :: Maybe Text
restApiId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the associated stage.
basePathMapping_stage :: Lens.Lens' BasePathMapping (Prelude.Maybe Prelude.Text)
basePathMapping_stage :: (Maybe Text -> f (Maybe Text))
-> BasePathMapping -> f BasePathMapping
basePathMapping_stage = (BasePathMapping -> Maybe Text)
-> (BasePathMapping -> Maybe Text -> BasePathMapping)
-> Lens BasePathMapping BasePathMapping (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BasePathMapping' {Maybe Text
stage :: Maybe Text
$sel:stage:BasePathMapping' :: BasePathMapping -> Maybe Text
stage} -> Maybe Text
stage) (\s :: BasePathMapping
s@BasePathMapping' {} Maybe Text
a -> BasePathMapping
s {$sel:stage:BasePathMapping' :: Maybe Text
stage = Maybe Text
a} :: BasePathMapping)

-- | The base path name that callers of the API must provide as part of the
-- URL after the domain name.
basePathMapping_basePath :: Lens.Lens' BasePathMapping (Prelude.Maybe Prelude.Text)
basePathMapping_basePath :: (Maybe Text -> f (Maybe Text))
-> BasePathMapping -> f BasePathMapping
basePathMapping_basePath = (BasePathMapping -> Maybe Text)
-> (BasePathMapping -> Maybe Text -> BasePathMapping)
-> Lens BasePathMapping BasePathMapping (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BasePathMapping' {Maybe Text
basePath :: Maybe Text
$sel:basePath:BasePathMapping' :: BasePathMapping -> Maybe Text
basePath} -> Maybe Text
basePath) (\s :: BasePathMapping
s@BasePathMapping' {} Maybe Text
a -> BasePathMapping
s {$sel:basePath:BasePathMapping' :: Maybe Text
basePath = Maybe Text
a} :: BasePathMapping)

-- | The string identifier of the associated RestApi.
basePathMapping_restApiId :: Lens.Lens' BasePathMapping (Prelude.Maybe Prelude.Text)
basePathMapping_restApiId :: (Maybe Text -> f (Maybe Text))
-> BasePathMapping -> f BasePathMapping
basePathMapping_restApiId = (BasePathMapping -> Maybe Text)
-> (BasePathMapping -> Maybe Text -> BasePathMapping)
-> Lens BasePathMapping BasePathMapping (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BasePathMapping' {Maybe Text
restApiId :: Maybe Text
$sel:restApiId:BasePathMapping' :: BasePathMapping -> Maybe Text
restApiId} -> Maybe Text
restApiId) (\s :: BasePathMapping
s@BasePathMapping' {} Maybe Text
a -> BasePathMapping
s {$sel:restApiId:BasePathMapping' :: Maybe Text
restApiId = Maybe Text
a} :: BasePathMapping)

instance Core.FromJSON BasePathMapping where
  parseJSON :: Value -> Parser BasePathMapping
parseJSON =
    String
-> (Object -> Parser BasePathMapping)
-> Value
-> Parser BasePathMapping
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BasePathMapping"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> BasePathMapping
BasePathMapping'
            (Maybe Text -> Maybe Text -> Maybe Text -> BasePathMapping)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> BasePathMapping)
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
"stage")
            Parser (Maybe Text -> Maybe Text -> BasePathMapping)
-> Parser (Maybe Text) -> Parser (Maybe Text -> BasePathMapping)
forall (f :: * -> *) a b. Applicative f => 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
"basePath")
            Parser (Maybe Text -> BasePathMapping)
-> Parser (Maybe Text) -> Parser BasePathMapping
forall (f :: * -> *) a b. Applicative f => 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
"restApiId")
      )

instance Prelude.Hashable BasePathMapping

instance Prelude.NFData BasePathMapping