{-# 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.APIGateway.CreateRestAPI
(
createRestAPI
, CreateRestAPI
, craBinaryMediaTypes
, craVersion
, craCloneFrom
, craDescription
, craName
, restAPI
, RestAPI
, raBinaryMediaTypes
, raWarnings
, raCreatedDate
, raName
, raVersion
, raId
, raDescription
) where
import Network.AWS.APIGateway.Types
import Network.AWS.APIGateway.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateRestAPI = CreateRestAPI'
{ _craBinaryMediaTypes :: !(Maybe [Text])
, _craVersion :: !(Maybe Text)
, _craCloneFrom :: !(Maybe Text)
, _craDescription :: !(Maybe Text)
, _craName :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createRestAPI
:: Text
-> CreateRestAPI
createRestAPI pName_ =
CreateRestAPI'
{ _craBinaryMediaTypes = Nothing
, _craVersion = Nothing
, _craCloneFrom = Nothing
, _craDescription = Nothing
, _craName = pName_
}
craBinaryMediaTypes :: Lens' CreateRestAPI [Text]
craBinaryMediaTypes = lens _craBinaryMediaTypes (\ s a -> s{_craBinaryMediaTypes = a}) . _Default . _Coerce;
craVersion :: Lens' CreateRestAPI (Maybe Text)
craVersion = lens _craVersion (\ s a -> s{_craVersion = a});
craCloneFrom :: Lens' CreateRestAPI (Maybe Text)
craCloneFrom = lens _craCloneFrom (\ s a -> s{_craCloneFrom = a});
craDescription :: Lens' CreateRestAPI (Maybe Text)
craDescription = lens _craDescription (\ s a -> s{_craDescription = a});
craName :: Lens' CreateRestAPI Text
craName = lens _craName (\ s a -> s{_craName = a});
instance AWSRequest CreateRestAPI where
type Rs CreateRestAPI = RestAPI
request = postJSON apiGateway
response = receiveJSON (\ s h x -> eitherParseJSON x)
instance Hashable CreateRestAPI
instance NFData CreateRestAPI
instance ToHeaders CreateRestAPI where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToJSON CreateRestAPI where
toJSON CreateRestAPI'{..}
= object
(catMaybes
[("binaryMediaTypes" .=) <$> _craBinaryMediaTypes,
("version" .=) <$> _craVersion,
("cloneFrom" .=) <$> _craCloneFrom,
("description" .=) <$> _craDescription,
Just ("name" .= _craName)])
instance ToPath CreateRestAPI where
toPath = const "/restapis"
instance ToQuery CreateRestAPI where
toQuery = const mempty