{-# 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.AppSync.CreateType
(
CreateType (..),
newCreateType,
createType_apiId,
createType_definition,
createType_format,
CreateTypeResponse (..),
newCreateTypeResponse,
createTypeResponse_type,
createTypeResponse_httpStatus,
)
where
import Amazonka.AppSync.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 CreateType = CreateType'
{
CreateType -> Text
apiId :: Prelude.Text,
CreateType -> Text
definition :: Prelude.Text,
CreateType -> TypeDefinitionFormat
format :: TypeDefinitionFormat
}
deriving (CreateType -> CreateType -> Bool
(CreateType -> CreateType -> Bool)
-> (CreateType -> CreateType -> Bool) -> Eq CreateType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateType -> CreateType -> Bool
$c/= :: CreateType -> CreateType -> Bool
== :: CreateType -> CreateType -> Bool
$c== :: CreateType -> CreateType -> Bool
Prelude.Eq, ReadPrec [CreateType]
ReadPrec CreateType
Int -> ReadS CreateType
ReadS [CreateType]
(Int -> ReadS CreateType)
-> ReadS [CreateType]
-> ReadPrec CreateType
-> ReadPrec [CreateType]
-> Read CreateType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateType]
$creadListPrec :: ReadPrec [CreateType]
readPrec :: ReadPrec CreateType
$creadPrec :: ReadPrec CreateType
readList :: ReadS [CreateType]
$creadList :: ReadS [CreateType]
readsPrec :: Int -> ReadS CreateType
$creadsPrec :: Int -> ReadS CreateType
Prelude.Read, Int -> CreateType -> ShowS
[CreateType] -> ShowS
CreateType -> String
(Int -> CreateType -> ShowS)
-> (CreateType -> String)
-> ([CreateType] -> ShowS)
-> Show CreateType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateType] -> ShowS
$cshowList :: [CreateType] -> ShowS
show :: CreateType -> String
$cshow :: CreateType -> String
showsPrec :: Int -> CreateType -> ShowS
$cshowsPrec :: Int -> CreateType -> ShowS
Prelude.Show, (forall x. CreateType -> Rep CreateType x)
-> (forall x. Rep CreateType x -> CreateType) -> Generic CreateType
forall x. Rep CreateType x -> CreateType
forall x. CreateType -> Rep CreateType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateType x -> CreateType
$cfrom :: forall x. CreateType -> Rep CreateType x
Prelude.Generic)
newCreateType ::
Prelude.Text ->
Prelude.Text ->
TypeDefinitionFormat ->
CreateType
newCreateType :: Text -> Text -> TypeDefinitionFormat -> CreateType
newCreateType Text
pApiId_ Text
pDefinition_ TypeDefinitionFormat
pFormat_ =
CreateType' :: Text -> Text -> TypeDefinitionFormat -> CreateType
CreateType'
{ $sel:apiId:CreateType' :: Text
apiId = Text
pApiId_,
$sel:definition:CreateType' :: Text
definition = Text
pDefinition_,
$sel:format:CreateType' :: TypeDefinitionFormat
format = TypeDefinitionFormat
pFormat_
}
createType_apiId :: Lens.Lens' CreateType Prelude.Text
createType_apiId :: (Text -> f Text) -> CreateType -> f CreateType
createType_apiId = (CreateType -> Text)
-> (CreateType -> Text -> CreateType)
-> Lens CreateType CreateType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateType' {Text
apiId :: Text
$sel:apiId:CreateType' :: CreateType -> Text
apiId} -> Text
apiId) (\s :: CreateType
s@CreateType' {} Text
a -> CreateType
s {$sel:apiId:CreateType' :: Text
apiId = Text
a} :: CreateType)
createType_definition :: Lens.Lens' CreateType Prelude.Text
createType_definition :: (Text -> f Text) -> CreateType -> f CreateType
createType_definition = (CreateType -> Text)
-> (CreateType -> Text -> CreateType)
-> Lens CreateType CreateType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateType' {Text
definition :: Text
$sel:definition:CreateType' :: CreateType -> Text
definition} -> Text
definition) (\s :: CreateType
s@CreateType' {} Text
a -> CreateType
s {$sel:definition:CreateType' :: Text
definition = Text
a} :: CreateType)
createType_format :: Lens.Lens' CreateType TypeDefinitionFormat
createType_format :: (TypeDefinitionFormat -> f TypeDefinitionFormat)
-> CreateType -> f CreateType
createType_format = (CreateType -> TypeDefinitionFormat)
-> (CreateType -> TypeDefinitionFormat -> CreateType)
-> Lens
CreateType CreateType TypeDefinitionFormat TypeDefinitionFormat
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateType' {TypeDefinitionFormat
format :: TypeDefinitionFormat
$sel:format:CreateType' :: CreateType -> TypeDefinitionFormat
format} -> TypeDefinitionFormat
format) (\s :: CreateType
s@CreateType' {} TypeDefinitionFormat
a -> CreateType
s {$sel:format:CreateType' :: TypeDefinitionFormat
format = TypeDefinitionFormat
a} :: CreateType)
instance Core.AWSRequest CreateType where
type AWSResponse CreateType = CreateTypeResponse
request :: CreateType -> Request CreateType
request = Service -> CreateType -> Request CreateType
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateType
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateType)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateType))
-> Logger
-> Service
-> Proxy CreateType
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateType)))
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 ->
Maybe Type -> Int -> CreateTypeResponse
CreateTypeResponse'
(Maybe Type -> Int -> CreateTypeResponse)
-> Either String (Maybe Type)
-> Either String (Int -> CreateTypeResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Type)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"type")
Either String (Int -> CreateTypeResponse)
-> Either String Int -> Either String CreateTypeResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable CreateType
instance Prelude.NFData CreateType
instance Core.ToHeaders CreateType where
toHeaders :: CreateType -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateType -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreateType where
toJSON :: CreateType -> Value
toJSON CreateType' {Text
TypeDefinitionFormat
format :: TypeDefinitionFormat
definition :: Text
apiId :: Text
$sel:format:CreateType' :: CreateType -> TypeDefinitionFormat
$sel:definition:CreateType' :: CreateType -> Text
$sel:apiId:CreateType' :: CreateType -> 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
"definition" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
definition),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"format" Text -> TypeDefinitionFormat -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TypeDefinitionFormat
format)
]
)
instance Core.ToPath CreateType where
toPath :: CreateType -> ByteString
toPath CreateType' {Text
TypeDefinitionFormat
format :: TypeDefinitionFormat
definition :: Text
apiId :: Text
$sel:format:CreateType' :: CreateType -> TypeDefinitionFormat
$sel:definition:CreateType' :: CreateType -> Text
$sel:apiId:CreateType' :: CreateType -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/v1/apis/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
apiId, ByteString
"/types"]
instance Core.ToQuery CreateType where
toQuery :: CreateType -> QueryString
toQuery = QueryString -> CreateType -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateTypeResponse = CreateTypeResponse'
{
CreateTypeResponse -> Maybe Type
type' :: Prelude.Maybe Type,
CreateTypeResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateTypeResponse -> CreateTypeResponse -> Bool
(CreateTypeResponse -> CreateTypeResponse -> Bool)
-> (CreateTypeResponse -> CreateTypeResponse -> Bool)
-> Eq CreateTypeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTypeResponse -> CreateTypeResponse -> Bool
$c/= :: CreateTypeResponse -> CreateTypeResponse -> Bool
== :: CreateTypeResponse -> CreateTypeResponse -> Bool
$c== :: CreateTypeResponse -> CreateTypeResponse -> Bool
Prelude.Eq, ReadPrec [CreateTypeResponse]
ReadPrec CreateTypeResponse
Int -> ReadS CreateTypeResponse
ReadS [CreateTypeResponse]
(Int -> ReadS CreateTypeResponse)
-> ReadS [CreateTypeResponse]
-> ReadPrec CreateTypeResponse
-> ReadPrec [CreateTypeResponse]
-> Read CreateTypeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTypeResponse]
$creadListPrec :: ReadPrec [CreateTypeResponse]
readPrec :: ReadPrec CreateTypeResponse
$creadPrec :: ReadPrec CreateTypeResponse
readList :: ReadS [CreateTypeResponse]
$creadList :: ReadS [CreateTypeResponse]
readsPrec :: Int -> ReadS CreateTypeResponse
$creadsPrec :: Int -> ReadS CreateTypeResponse
Prelude.Read, Int -> CreateTypeResponse -> ShowS
[CreateTypeResponse] -> ShowS
CreateTypeResponse -> String
(Int -> CreateTypeResponse -> ShowS)
-> (CreateTypeResponse -> String)
-> ([CreateTypeResponse] -> ShowS)
-> Show CreateTypeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTypeResponse] -> ShowS
$cshowList :: [CreateTypeResponse] -> ShowS
show :: CreateTypeResponse -> String
$cshow :: CreateTypeResponse -> String
showsPrec :: Int -> CreateTypeResponse -> ShowS
$cshowsPrec :: Int -> CreateTypeResponse -> ShowS
Prelude.Show, (forall x. CreateTypeResponse -> Rep CreateTypeResponse x)
-> (forall x. Rep CreateTypeResponse x -> CreateTypeResponse)
-> Generic CreateTypeResponse
forall x. Rep CreateTypeResponse x -> CreateTypeResponse
forall x. CreateTypeResponse -> Rep CreateTypeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTypeResponse x -> CreateTypeResponse
$cfrom :: forall x. CreateTypeResponse -> Rep CreateTypeResponse x
Prelude.Generic)
newCreateTypeResponse ::
Prelude.Int ->
CreateTypeResponse
newCreateTypeResponse :: Int -> CreateTypeResponse
newCreateTypeResponse Int
pHttpStatus_ =
CreateTypeResponse' :: Maybe Type -> Int -> CreateTypeResponse
CreateTypeResponse'
{ $sel:type':CreateTypeResponse' :: Maybe Type
type' = Maybe Type
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateTypeResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createTypeResponse_type :: Lens.Lens' CreateTypeResponse (Prelude.Maybe Type)
createTypeResponse_type :: (Maybe Type -> f (Maybe Type))
-> CreateTypeResponse -> f CreateTypeResponse
createTypeResponse_type = (CreateTypeResponse -> Maybe Type)
-> (CreateTypeResponse -> Maybe Type -> CreateTypeResponse)
-> Lens
CreateTypeResponse CreateTypeResponse (Maybe Type) (Maybe Type)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTypeResponse' {Maybe Type
type' :: Maybe Type
$sel:type':CreateTypeResponse' :: CreateTypeResponse -> Maybe Type
type'} -> Maybe Type
type') (\s :: CreateTypeResponse
s@CreateTypeResponse' {} Maybe Type
a -> CreateTypeResponse
s {$sel:type':CreateTypeResponse' :: Maybe Type
type' = Maybe Type
a} :: CreateTypeResponse)
createTypeResponse_httpStatus :: Lens.Lens' CreateTypeResponse Prelude.Int
createTypeResponse_httpStatus :: (Int -> f Int) -> CreateTypeResponse -> f CreateTypeResponse
createTypeResponse_httpStatus = (CreateTypeResponse -> Int)
-> (CreateTypeResponse -> Int -> CreateTypeResponse)
-> Lens CreateTypeResponse CreateTypeResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTypeResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateTypeResponse' :: CreateTypeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateTypeResponse
s@CreateTypeResponse' {} Int
a -> CreateTypeResponse
s {$sel:httpStatus:CreateTypeResponse' :: Int
httpStatus = Int
a} :: CreateTypeResponse)
instance Prelude.NFData CreateTypeResponse