{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.AppSync.CreateType
(
createType
, CreateType
, ctApiId
, ctDefinition
, ctFormat
, createTypeResponse
, CreateTypeResponse
, ctrsType
, ctrsResponseStatus
) where
import Network.AWS.AppSync.Types
import Network.AWS.AppSync.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateType = CreateType'
{ _ctApiId :: !Text
, _ctDefinition :: !Text
, _ctFormat :: !TypeDefinitionFormat
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createType
:: Text
-> Text
-> TypeDefinitionFormat
-> CreateType
createType pApiId_ pDefinition_ pFormat_ =
CreateType'
{_ctApiId = pApiId_, _ctDefinition = pDefinition_, _ctFormat = pFormat_}
ctApiId :: Lens' CreateType Text
ctApiId = lens _ctApiId (\ s a -> s{_ctApiId = a})
ctDefinition :: Lens' CreateType Text
ctDefinition = lens _ctDefinition (\ s a -> s{_ctDefinition = a})
ctFormat :: Lens' CreateType TypeDefinitionFormat
ctFormat = lens _ctFormat (\ s a -> s{_ctFormat = a})
instance AWSRequest CreateType where
type Rs CreateType = CreateTypeResponse
request = postJSON appSync
response
= receiveJSON
(\ s h x ->
CreateTypeResponse' <$>
(x .?> "type") <*> (pure (fromEnum s)))
instance Hashable CreateType where
instance NFData CreateType where
instance ToHeaders CreateType where
toHeaders
= const
(mconcat
["Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateType where
toJSON CreateType'{..}
= object
(catMaybes
[Just ("definition" .= _ctDefinition),
Just ("format" .= _ctFormat)])
instance ToPath CreateType where
toPath CreateType'{..}
= mconcat ["/v1/apis/", toBS _ctApiId, "/types"]
instance ToQuery CreateType where
toQuery = const mempty
data CreateTypeResponse = CreateTypeResponse'
{ _ctrsType :: !(Maybe Type)
, _ctrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createTypeResponse
:: Int
-> CreateTypeResponse
createTypeResponse pResponseStatus_ =
CreateTypeResponse'
{_ctrsType = Nothing, _ctrsResponseStatus = pResponseStatus_}
ctrsType :: Lens' CreateTypeResponse (Maybe Type)
ctrsType = lens _ctrsType (\ s a -> s{_ctrsType = a})
ctrsResponseStatus :: Lens' CreateTypeResponse Int
ctrsResponseStatus = lens _ctrsResponseStatus (\ s a -> s{_ctrsResponseStatus = a})
instance NFData CreateTypeResponse where