{-# 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.CreateGraphqlAPI
(
createGraphqlAPI
, CreateGraphqlAPI
, cgaOpenIdConnectConfig
, cgaUserPoolConfig
, cgaLogConfig
, cgaName
, cgaAuthenticationType
, createGraphqlAPIResponse
, CreateGraphqlAPIResponse
, cgarsGraphqlAPI
, cgarsResponseStatus
) 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 CreateGraphqlAPI = CreateGraphqlAPI'
{ _cgaOpenIdConnectConfig :: !(Maybe OpenIdConnectConfig)
, _cgaUserPoolConfig :: !(Maybe UserPoolConfig)
, _cgaLogConfig :: !(Maybe LogConfig)
, _cgaName :: !Text
, _cgaAuthenticationType :: !AuthenticationType
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createGraphqlAPI
:: Text
-> AuthenticationType
-> CreateGraphqlAPI
createGraphqlAPI pName_ pAuthenticationType_ =
CreateGraphqlAPI'
{ _cgaOpenIdConnectConfig = Nothing
, _cgaUserPoolConfig = Nothing
, _cgaLogConfig = Nothing
, _cgaName = pName_
, _cgaAuthenticationType = pAuthenticationType_
}
cgaOpenIdConnectConfig :: Lens' CreateGraphqlAPI (Maybe OpenIdConnectConfig)
cgaOpenIdConnectConfig = lens _cgaOpenIdConnectConfig (\ s a -> s{_cgaOpenIdConnectConfig = a})
cgaUserPoolConfig :: Lens' CreateGraphqlAPI (Maybe UserPoolConfig)
cgaUserPoolConfig = lens _cgaUserPoolConfig (\ s a -> s{_cgaUserPoolConfig = a})
cgaLogConfig :: Lens' CreateGraphqlAPI (Maybe LogConfig)
cgaLogConfig = lens _cgaLogConfig (\ s a -> s{_cgaLogConfig = a})
cgaName :: Lens' CreateGraphqlAPI Text
cgaName = lens _cgaName (\ s a -> s{_cgaName = a})
cgaAuthenticationType :: Lens' CreateGraphqlAPI AuthenticationType
cgaAuthenticationType = lens _cgaAuthenticationType (\ s a -> s{_cgaAuthenticationType = a})
instance AWSRequest CreateGraphqlAPI where
type Rs CreateGraphqlAPI = CreateGraphqlAPIResponse
request = postJSON appSync
response
= receiveJSON
(\ s h x ->
CreateGraphqlAPIResponse' <$>
(x .?> "graphqlApi") <*> (pure (fromEnum s)))
instance Hashable CreateGraphqlAPI where
instance NFData CreateGraphqlAPI where
instance ToHeaders CreateGraphqlAPI where
toHeaders
= const
(mconcat
["Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateGraphqlAPI where
toJSON CreateGraphqlAPI'{..}
= object
(catMaybes
[("openIDConnectConfig" .=) <$>
_cgaOpenIdConnectConfig,
("userPoolConfig" .=) <$> _cgaUserPoolConfig,
("logConfig" .=) <$> _cgaLogConfig,
Just ("name" .= _cgaName),
Just
("authenticationType" .= _cgaAuthenticationType)])
instance ToPath CreateGraphqlAPI where
toPath = const "/v1/apis"
instance ToQuery CreateGraphqlAPI where
toQuery = const mempty
data CreateGraphqlAPIResponse = CreateGraphqlAPIResponse'
{ _cgarsGraphqlAPI :: !(Maybe GraphqlAPI)
, _cgarsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createGraphqlAPIResponse
:: Int
-> CreateGraphqlAPIResponse
createGraphqlAPIResponse pResponseStatus_ =
CreateGraphqlAPIResponse'
{_cgarsGraphqlAPI = Nothing, _cgarsResponseStatus = pResponseStatus_}
cgarsGraphqlAPI :: Lens' CreateGraphqlAPIResponse (Maybe GraphqlAPI)
cgarsGraphqlAPI = lens _cgarsGraphqlAPI (\ s a -> s{_cgarsGraphqlAPI = a})
cgarsResponseStatus :: Lens' CreateGraphqlAPIResponse Int
cgarsResponseStatus = lens _cgarsResponseStatus (\ s a -> s{_cgarsResponseStatus = a})
instance NFData CreateGraphqlAPIResponse where