module Network.AWS.APIGateway.TestInvokeMethod
(
testInvokeMethod
, TestInvokeMethod
, timPathWithQueryString
, timBody
, timClientCertificateId
, timStageVariables
, timHeaders
, timRestAPIId
, timResourceId
, timHttpMethod
, testInvokeMethodResponse
, TestInvokeMethodResponse
, timrsLog
, timrsStatus
, timrsBody
, timrsLatency
, timrsHeaders
, timrsResponseStatus
) 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 TestInvokeMethod = TestInvokeMethod'
{ _timPathWithQueryString :: !(Maybe Text)
, _timBody :: !(Maybe Text)
, _timClientCertificateId :: !(Maybe Text)
, _timStageVariables :: !(Maybe (Map Text Text))
, _timHeaders :: !(Maybe (Map Text Text))
, _timRestAPIId :: !Text
, _timResourceId :: !Text
, _timHttpMethod :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
testInvokeMethod
:: Text
-> Text
-> Text
-> TestInvokeMethod
testInvokeMethod pRestAPIId_ pResourceId_ pHttpMethod_ =
TestInvokeMethod'
{ _timPathWithQueryString = Nothing
, _timBody = Nothing
, _timClientCertificateId = Nothing
, _timStageVariables = Nothing
, _timHeaders = Nothing
, _timRestAPIId = pRestAPIId_
, _timResourceId = pResourceId_
, _timHttpMethod = pHttpMethod_
}
timPathWithQueryString :: Lens' TestInvokeMethod (Maybe Text)
timPathWithQueryString = lens _timPathWithQueryString (\ s a -> s{_timPathWithQueryString = a});
timBody :: Lens' TestInvokeMethod (Maybe Text)
timBody = lens _timBody (\ s a -> s{_timBody = a});
timClientCertificateId :: Lens' TestInvokeMethod (Maybe Text)
timClientCertificateId = lens _timClientCertificateId (\ s a -> s{_timClientCertificateId = a});
timStageVariables :: Lens' TestInvokeMethod (HashMap Text Text)
timStageVariables = lens _timStageVariables (\ s a -> s{_timStageVariables = a}) . _Default . _Map;
timHeaders :: Lens' TestInvokeMethod (HashMap Text Text)
timHeaders = lens _timHeaders (\ s a -> s{_timHeaders = a}) . _Default . _Map;
timRestAPIId :: Lens' TestInvokeMethod Text
timRestAPIId = lens _timRestAPIId (\ s a -> s{_timRestAPIId = a});
timResourceId :: Lens' TestInvokeMethod Text
timResourceId = lens _timResourceId (\ s a -> s{_timResourceId = a});
timHttpMethod :: Lens' TestInvokeMethod Text
timHttpMethod = lens _timHttpMethod (\ s a -> s{_timHttpMethod = a});
instance AWSRequest TestInvokeMethod where
type Rs TestInvokeMethod = TestInvokeMethodResponse
request = postJSON apiGateway
response
= receiveJSON
(\ s h x ->
TestInvokeMethodResponse' <$>
(x .?> "log") <*> (x .?> "status") <*> (x .?> "body")
<*> (x .?> "latency")
<*> (x .?> "headers" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable TestInvokeMethod
instance NFData TestInvokeMethod
instance ToHeaders TestInvokeMethod where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToJSON TestInvokeMethod where
toJSON TestInvokeMethod'{..}
= object
(catMaybes
[("pathWithQueryString" .=) <$>
_timPathWithQueryString,
("body" .=) <$> _timBody,
("clientCertificateId" .=) <$>
_timClientCertificateId,
("stageVariables" .=) <$> _timStageVariables,
("headers" .=) <$> _timHeaders])
instance ToPath TestInvokeMethod where
toPath TestInvokeMethod'{..}
= mconcat
["/restapis/", toBS _timRestAPIId, "/resources/",
toBS _timResourceId, "/methods/",
toBS _timHttpMethod]
instance ToQuery TestInvokeMethod where
toQuery = const mempty
data TestInvokeMethodResponse = TestInvokeMethodResponse'
{ _timrsLog :: !(Maybe Text)
, _timrsStatus :: !(Maybe Int)
, _timrsBody :: !(Maybe Text)
, _timrsLatency :: !(Maybe Integer)
, _timrsHeaders :: !(Maybe (Map Text Text))
, _timrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
testInvokeMethodResponse
:: Int
-> TestInvokeMethodResponse
testInvokeMethodResponse pResponseStatus_ =
TestInvokeMethodResponse'
{ _timrsLog = Nothing
, _timrsStatus = Nothing
, _timrsBody = Nothing
, _timrsLatency = Nothing
, _timrsHeaders = Nothing
, _timrsResponseStatus = pResponseStatus_
}
timrsLog :: Lens' TestInvokeMethodResponse (Maybe Text)
timrsLog = lens _timrsLog (\ s a -> s{_timrsLog = a});
timrsStatus :: Lens' TestInvokeMethodResponse (Maybe Int)
timrsStatus = lens _timrsStatus (\ s a -> s{_timrsStatus = a});
timrsBody :: Lens' TestInvokeMethodResponse (Maybe Text)
timrsBody = lens _timrsBody (\ s a -> s{_timrsBody = a});
timrsLatency :: Lens' TestInvokeMethodResponse (Maybe Integer)
timrsLatency = lens _timrsLatency (\ s a -> s{_timrsLatency = a});
timrsHeaders :: Lens' TestInvokeMethodResponse (HashMap Text Text)
timrsHeaders = lens _timrsHeaders (\ s a -> s{_timrsHeaders = a}) . _Default . _Map;
timrsResponseStatus :: Lens' TestInvokeMethodResponse Int
timrsResponseStatus = lens _timrsResponseStatus (\ s a -> s{_timrsResponseStatus = a});
instance NFData TestInvokeMethodResponse