{-# 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.CreateModel
(
CreateModel (..),
newCreateModel,
createModel_schema,
createModel_description,
createModel_restApiId,
createModel_name,
createModel_contentType,
Model (..),
newModel,
model_schema,
model_name,
model_id,
model_description,
model_contentType,
)
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 CreateModel = CreateModel'
{
CreateModel -> Maybe Text
schema :: Prelude.Maybe Prelude.Text,
CreateModel -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreateModel -> Text
restApiId :: Prelude.Text,
CreateModel -> Text
name :: Prelude.Text,
CreateModel -> Text
contentType :: Prelude.Text
}
deriving (CreateModel -> CreateModel -> Bool
(CreateModel -> CreateModel -> Bool)
-> (CreateModel -> CreateModel -> Bool) -> Eq CreateModel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateModel -> CreateModel -> Bool
$c/= :: CreateModel -> CreateModel -> Bool
== :: CreateModel -> CreateModel -> Bool
$c== :: CreateModel -> CreateModel -> Bool
Prelude.Eq, ReadPrec [CreateModel]
ReadPrec CreateModel
Int -> ReadS CreateModel
ReadS [CreateModel]
(Int -> ReadS CreateModel)
-> ReadS [CreateModel]
-> ReadPrec CreateModel
-> ReadPrec [CreateModel]
-> Read CreateModel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateModel]
$creadListPrec :: ReadPrec [CreateModel]
readPrec :: ReadPrec CreateModel
$creadPrec :: ReadPrec CreateModel
readList :: ReadS [CreateModel]
$creadList :: ReadS [CreateModel]
readsPrec :: Int -> ReadS CreateModel
$creadsPrec :: Int -> ReadS CreateModel
Prelude.Read, Int -> CreateModel -> ShowS
[CreateModel] -> ShowS
CreateModel -> String
(Int -> CreateModel -> ShowS)
-> (CreateModel -> String)
-> ([CreateModel] -> ShowS)
-> Show CreateModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateModel] -> ShowS
$cshowList :: [CreateModel] -> ShowS
show :: CreateModel -> String
$cshow :: CreateModel -> String
showsPrec :: Int -> CreateModel -> ShowS
$cshowsPrec :: Int -> CreateModel -> ShowS
Prelude.Show, (forall x. CreateModel -> Rep CreateModel x)
-> (forall x. Rep CreateModel x -> CreateModel)
-> Generic CreateModel
forall x. Rep CreateModel x -> CreateModel
forall x. CreateModel -> Rep CreateModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateModel x -> CreateModel
$cfrom :: forall x. CreateModel -> Rep CreateModel x
Prelude.Generic)
newCreateModel ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
CreateModel
newCreateModel :: Text -> Text -> Text -> CreateModel
newCreateModel Text
pRestApiId_ Text
pName_ Text
pContentType_ =
CreateModel' :: Maybe Text -> Maybe Text -> Text -> Text -> Text -> CreateModel
CreateModel'
{ $sel:schema:CreateModel' :: Maybe Text
schema = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:description:CreateModel' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:restApiId:CreateModel' :: Text
restApiId = Text
pRestApiId_,
$sel:name:CreateModel' :: Text
name = Text
pName_,
$sel:contentType:CreateModel' :: Text
contentType = Text
pContentType_
}
createModel_schema :: Lens.Lens' CreateModel (Prelude.Maybe Prelude.Text)
createModel_schema :: (Maybe Text -> f (Maybe Text)) -> CreateModel -> f CreateModel
createModel_schema = (CreateModel -> Maybe Text)
-> (CreateModel -> Maybe Text -> CreateModel)
-> Lens CreateModel CreateModel (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {Maybe Text
schema :: Maybe Text
$sel:schema:CreateModel' :: CreateModel -> Maybe Text
schema} -> Maybe Text
schema) (\s :: CreateModel
s@CreateModel' {} Maybe Text
a -> CreateModel
s {$sel:schema:CreateModel' :: Maybe Text
schema = Maybe Text
a} :: CreateModel)
createModel_description :: Lens.Lens' CreateModel (Prelude.Maybe Prelude.Text)
createModel_description :: (Maybe Text -> f (Maybe Text)) -> CreateModel -> f CreateModel
createModel_description = (CreateModel -> Maybe Text)
-> (CreateModel -> Maybe Text -> CreateModel)
-> Lens CreateModel CreateModel (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {Maybe Text
description :: Maybe Text
$sel:description:CreateModel' :: CreateModel -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateModel
s@CreateModel' {} Maybe Text
a -> CreateModel
s {$sel:description:CreateModel' :: Maybe Text
description = Maybe Text
a} :: CreateModel)
createModel_restApiId :: Lens.Lens' CreateModel Prelude.Text
createModel_restApiId :: (Text -> f Text) -> CreateModel -> f CreateModel
createModel_restApiId = (CreateModel -> Text)
-> (CreateModel -> Text -> CreateModel)
-> Lens CreateModel CreateModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {Text
restApiId :: Text
$sel:restApiId:CreateModel' :: CreateModel -> Text
restApiId} -> Text
restApiId) (\s :: CreateModel
s@CreateModel' {} Text
a -> CreateModel
s {$sel:restApiId:CreateModel' :: Text
restApiId = Text
a} :: CreateModel)
createModel_name :: Lens.Lens' CreateModel Prelude.Text
createModel_name :: (Text -> f Text) -> CreateModel -> f CreateModel
createModel_name = (CreateModel -> Text)
-> (CreateModel -> Text -> CreateModel)
-> Lens CreateModel CreateModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {Text
name :: Text
$sel:name:CreateModel' :: CreateModel -> Text
name} -> Text
name) (\s :: CreateModel
s@CreateModel' {} Text
a -> CreateModel
s {$sel:name:CreateModel' :: Text
name = Text
a} :: CreateModel)
createModel_contentType :: Lens.Lens' CreateModel Prelude.Text
createModel_contentType :: (Text -> f Text) -> CreateModel -> f CreateModel
createModel_contentType = (CreateModel -> Text)
-> (CreateModel -> Text -> CreateModel)
-> Lens CreateModel CreateModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {Text
contentType :: Text
$sel:contentType:CreateModel' :: CreateModel -> Text
contentType} -> Text
contentType) (\s :: CreateModel
s@CreateModel' {} Text
a -> CreateModel
s {$sel:contentType:CreateModel' :: Text
contentType = Text
a} :: CreateModel)
instance Core.AWSRequest CreateModel where
type AWSResponse CreateModel = Model
request :: CreateModel -> Request CreateModel
request = Service -> CreateModel -> Request CreateModel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateModel)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateModel))
-> Logger
-> Service
-> Proxy CreateModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateModel)))
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 Model
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
instance Prelude.Hashable CreateModel
instance Prelude.NFData CreateModel
instance Core.ToHeaders CreateModel where
toHeaders :: CreateModel -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateModel -> 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 CreateModel where
toJSON :: CreateModel -> Value
toJSON CreateModel' {Maybe Text
Text
contentType :: Text
name :: Text
restApiId :: Text
description :: Maybe Text
schema :: Maybe Text
$sel:contentType:CreateModel' :: CreateModel -> Text
$sel:name:CreateModel' :: CreateModel -> Text
$sel:restApiId:CreateModel' :: CreateModel -> Text
$sel:description:CreateModel' :: CreateModel -> Maybe Text
$sel:schema:CreateModel' :: CreateModel -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"schema" 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
schema,
(Text
"description" 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
description,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"contentType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contentType)
]
)
instance Core.ToPath CreateModel where
toPath :: CreateModel -> ByteString
toPath CreateModel' {Maybe Text
Text
contentType :: Text
name :: Text
restApiId :: Text
description :: Maybe Text
schema :: Maybe Text
$sel:contentType:CreateModel' :: CreateModel -> Text
$sel:name:CreateModel' :: CreateModel -> Text
$sel:restApiId:CreateModel' :: CreateModel -> Text
$sel:description:CreateModel' :: CreateModel -> Maybe Text
$sel:schema:CreateModel' :: CreateModel -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/restapis/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
restApiId, ByteString
"/models"]
instance Core.ToQuery CreateModel where
toQuery :: CreateModel -> QueryString
toQuery = QueryString -> CreateModel -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty