{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.APIGateway.CreateBasePathMapping
(
CreateBasePathMapping (..),
newCreateBasePathMapping,
createBasePathMapping_stage,
createBasePathMapping_basePath,
createBasePathMapping_domainName,
createBasePathMapping_restApiId,
BasePathMapping (..),
newBasePathMapping,
basePathMapping_stage,
basePathMapping_basePath,
basePathMapping_restApiId,
)
where
import Amazonka.APIGateway.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateBasePathMapping = CreateBasePathMapping'
{
CreateBasePathMapping -> Maybe Text
stage :: Prelude.Maybe Prelude.Text,
CreateBasePathMapping -> Maybe Text
basePath :: Prelude.Maybe Prelude.Text,
CreateBasePathMapping -> Text
domainName :: Prelude.Text,
CreateBasePathMapping -> Text
restApiId :: Prelude.Text
}
deriving (CreateBasePathMapping -> CreateBasePathMapping -> Bool
(CreateBasePathMapping -> CreateBasePathMapping -> Bool)
-> (CreateBasePathMapping -> CreateBasePathMapping -> Bool)
-> Eq CreateBasePathMapping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBasePathMapping -> CreateBasePathMapping -> Bool
$c/= :: CreateBasePathMapping -> CreateBasePathMapping -> Bool
== :: CreateBasePathMapping -> CreateBasePathMapping -> Bool
$c== :: CreateBasePathMapping -> CreateBasePathMapping -> Bool
Prelude.Eq, ReadPrec [CreateBasePathMapping]
ReadPrec CreateBasePathMapping
Int -> ReadS CreateBasePathMapping
ReadS [CreateBasePathMapping]
(Int -> ReadS CreateBasePathMapping)
-> ReadS [CreateBasePathMapping]
-> ReadPrec CreateBasePathMapping
-> ReadPrec [CreateBasePathMapping]
-> Read CreateBasePathMapping
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateBasePathMapping]
$creadListPrec :: ReadPrec [CreateBasePathMapping]
readPrec :: ReadPrec CreateBasePathMapping
$creadPrec :: ReadPrec CreateBasePathMapping
readList :: ReadS [CreateBasePathMapping]
$creadList :: ReadS [CreateBasePathMapping]
readsPrec :: Int -> ReadS CreateBasePathMapping
$creadsPrec :: Int -> ReadS CreateBasePathMapping
Prelude.Read, Int -> CreateBasePathMapping -> ShowS
[CreateBasePathMapping] -> ShowS
CreateBasePathMapping -> String
(Int -> CreateBasePathMapping -> ShowS)
-> (CreateBasePathMapping -> String)
-> ([CreateBasePathMapping] -> ShowS)
-> Show CreateBasePathMapping
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBasePathMapping] -> ShowS
$cshowList :: [CreateBasePathMapping] -> ShowS
show :: CreateBasePathMapping -> String
$cshow :: CreateBasePathMapping -> String
showsPrec :: Int -> CreateBasePathMapping -> ShowS
$cshowsPrec :: Int -> CreateBasePathMapping -> ShowS
Prelude.Show, (forall x. CreateBasePathMapping -> Rep CreateBasePathMapping x)
-> (forall x. Rep CreateBasePathMapping x -> CreateBasePathMapping)
-> Generic CreateBasePathMapping
forall x. Rep CreateBasePathMapping x -> CreateBasePathMapping
forall x. CreateBasePathMapping -> Rep CreateBasePathMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateBasePathMapping x -> CreateBasePathMapping
$cfrom :: forall x. CreateBasePathMapping -> Rep CreateBasePathMapping x
Prelude.Generic)
newCreateBasePathMapping ::
Prelude.Text ->
Prelude.Text ->
CreateBasePathMapping
newCreateBasePathMapping :: Text -> Text -> CreateBasePathMapping
newCreateBasePathMapping Text
pDomainName_ Text
pRestApiId_ =
CreateBasePathMapping' :: Maybe Text -> Maybe Text -> Text -> Text -> CreateBasePathMapping
CreateBasePathMapping'
{ $sel:stage:CreateBasePathMapping' :: Maybe Text
stage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:basePath:CreateBasePathMapping' :: Maybe Text
basePath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:domainName:CreateBasePathMapping' :: Text
domainName = Text
pDomainName_,
$sel:restApiId:CreateBasePathMapping' :: Text
restApiId = Text
pRestApiId_
}
createBasePathMapping_stage :: Lens.Lens' CreateBasePathMapping (Prelude.Maybe Prelude.Text)
createBasePathMapping_stage :: (Maybe Text -> f (Maybe Text))
-> CreateBasePathMapping -> f CreateBasePathMapping
createBasePathMapping_stage = (CreateBasePathMapping -> Maybe Text)
-> (CreateBasePathMapping -> Maybe Text -> CreateBasePathMapping)
-> Lens
CreateBasePathMapping
CreateBasePathMapping
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBasePathMapping' {Maybe Text
stage :: Maybe Text
$sel:stage:CreateBasePathMapping' :: CreateBasePathMapping -> Maybe Text
stage} -> Maybe Text
stage) (\s :: CreateBasePathMapping
s@CreateBasePathMapping' {} Maybe Text
a -> CreateBasePathMapping
s {$sel:stage:CreateBasePathMapping' :: Maybe Text
stage = Maybe Text
a} :: CreateBasePathMapping)
createBasePathMapping_basePath :: Lens.Lens' CreateBasePathMapping (Prelude.Maybe Prelude.Text)
createBasePathMapping_basePath :: (Maybe Text -> f (Maybe Text))
-> CreateBasePathMapping -> f CreateBasePathMapping
createBasePathMapping_basePath = (CreateBasePathMapping -> Maybe Text)
-> (CreateBasePathMapping -> Maybe Text -> CreateBasePathMapping)
-> Lens
CreateBasePathMapping
CreateBasePathMapping
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBasePathMapping' {Maybe Text
basePath :: Maybe Text
$sel:basePath:CreateBasePathMapping' :: CreateBasePathMapping -> Maybe Text
basePath} -> Maybe Text
basePath) (\s :: CreateBasePathMapping
s@CreateBasePathMapping' {} Maybe Text
a -> CreateBasePathMapping
s {$sel:basePath:CreateBasePathMapping' :: Maybe Text
basePath = Maybe Text
a} :: CreateBasePathMapping)
createBasePathMapping_domainName :: Lens.Lens' CreateBasePathMapping Prelude.Text
createBasePathMapping_domainName :: (Text -> f Text)
-> CreateBasePathMapping -> f CreateBasePathMapping
createBasePathMapping_domainName = (CreateBasePathMapping -> Text)
-> (CreateBasePathMapping -> Text -> CreateBasePathMapping)
-> Lens CreateBasePathMapping CreateBasePathMapping Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBasePathMapping' {Text
domainName :: Text
$sel:domainName:CreateBasePathMapping' :: CreateBasePathMapping -> Text
domainName} -> Text
domainName) (\s :: CreateBasePathMapping
s@CreateBasePathMapping' {} Text
a -> CreateBasePathMapping
s {$sel:domainName:CreateBasePathMapping' :: Text
domainName = Text
a} :: CreateBasePathMapping)
createBasePathMapping_restApiId :: Lens.Lens' CreateBasePathMapping Prelude.Text
createBasePathMapping_restApiId :: (Text -> f Text)
-> CreateBasePathMapping -> f CreateBasePathMapping
createBasePathMapping_restApiId = (CreateBasePathMapping -> Text)
-> (CreateBasePathMapping -> Text -> CreateBasePathMapping)
-> Lens CreateBasePathMapping CreateBasePathMapping Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBasePathMapping' {Text
restApiId :: Text
$sel:restApiId:CreateBasePathMapping' :: CreateBasePathMapping -> Text
restApiId} -> Text
restApiId) (\s :: CreateBasePathMapping
s@CreateBasePathMapping' {} Text
a -> CreateBasePathMapping
s {$sel:restApiId:CreateBasePathMapping' :: Text
restApiId = Text
a} :: CreateBasePathMapping)
instance Core.AWSRequest CreateBasePathMapping where
type
AWSResponse CreateBasePathMapping =
BasePathMapping
request :: CreateBasePathMapping -> Request CreateBasePathMapping
request = Service -> CreateBasePathMapping -> Request CreateBasePathMapping
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateBasePathMapping
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateBasePathMapping)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateBasePathMapping))
-> Logger
-> Service
-> Proxy CreateBasePathMapping
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateBasePathMapping)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
(\Int
s ResponseHeaders
h Object
x -> Object -> Either String BasePathMapping
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
instance Prelude.Hashable CreateBasePathMapping
instance Prelude.NFData CreateBasePathMapping
instance Core.ToHeaders CreateBasePathMapping where
toHeaders :: CreateBasePathMapping -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateBasePathMapping -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Accept"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"application/json" :: Prelude.ByteString)
]
)
instance Core.ToJSON CreateBasePathMapping where
toJSON :: CreateBasePathMapping -> Value
toJSON CreateBasePathMapping' {Maybe Text
Text
restApiId :: Text
domainName :: Text
basePath :: Maybe Text
stage :: Maybe Text
$sel:restApiId:CreateBasePathMapping' :: CreateBasePathMapping -> Text
$sel:domainName:CreateBasePathMapping' :: CreateBasePathMapping -> Text
$sel:basePath:CreateBasePathMapping' :: CreateBasePathMapping -> Maybe Text
$sel:stage:CreateBasePathMapping' :: CreateBasePathMapping -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"stage" 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
stage,
(Text
"basePath" 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
basePath,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"restApiId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
restApiId)
]
)
instance Core.ToPath CreateBasePathMapping where
toPath :: CreateBasePathMapping -> ByteString
toPath CreateBasePathMapping' {Maybe Text
Text
restApiId :: Text
domainName :: Text
basePath :: Maybe Text
stage :: Maybe Text
$sel:restApiId:CreateBasePathMapping' :: CreateBasePathMapping -> Text
$sel:domainName:CreateBasePathMapping' :: CreateBasePathMapping -> Text
$sel:basePath:CreateBasePathMapping' :: CreateBasePathMapping -> Maybe Text
$sel:stage:CreateBasePathMapping' :: CreateBasePathMapping -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/domainnames/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
domainName,
ByteString
"/basepathmappings"
]
instance Core.ToQuery CreateBasePathMapping where
toQuery :: CreateBasePathMapping -> QueryString
toQuery = QueryString -> CreateBasePathMapping -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty