{-# 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.LexModels.GetIntents
(
getIntents
, GetIntents
, giNameContains
, giNextToken
, giMaxResults
, getIntentsResponse
, GetIntentsResponse
, gisrsIntents
, gisrsNextToken
, gisrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.LexModels.Types
import Network.AWS.LexModels.Types.Product
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data GetIntents = GetIntents'
{ _giNameContains :: !(Maybe Text)
, _giNextToken :: !(Maybe Text)
, _giMaxResults :: !(Maybe Nat)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getIntents
:: GetIntents
getIntents =
GetIntents'
{_giNameContains = Nothing, _giNextToken = Nothing, _giMaxResults = Nothing}
giNameContains :: Lens' GetIntents (Maybe Text)
giNameContains = lens _giNameContains (\ s a -> s{_giNameContains = a})
giNextToken :: Lens' GetIntents (Maybe Text)
giNextToken = lens _giNextToken (\ s a -> s{_giNextToken = a})
giMaxResults :: Lens' GetIntents (Maybe Natural)
giMaxResults = lens _giMaxResults (\ s a -> s{_giMaxResults = a}) . mapping _Nat
instance AWSPager GetIntents where
page rq rs
| stop (rs ^. gisrsNextToken) = Nothing
| stop (rs ^. gisrsIntents) = Nothing
| otherwise =
Just $ rq & giNextToken .~ rs ^. gisrsNextToken
instance AWSRequest GetIntents where
type Rs GetIntents = GetIntentsResponse
request = get lexModels
response
= receiveJSON
(\ s h x ->
GetIntentsResponse' <$>
(x .?> "intents" .!@ mempty) <*> (x .?> "nextToken")
<*> (pure (fromEnum s)))
instance Hashable GetIntents where
instance NFData GetIntents where
instance ToHeaders GetIntents where
toHeaders
= const
(mconcat
["Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToPath GetIntents where
toPath = const "/intents/"
instance ToQuery GetIntents where
toQuery GetIntents'{..}
= mconcat
["nameContains" =: _giNameContains,
"nextToken" =: _giNextToken,
"maxResults" =: _giMaxResults]
data GetIntentsResponse = GetIntentsResponse'
{ _gisrsIntents :: !(Maybe [IntentMetadata])
, _gisrsNextToken :: !(Maybe Text)
, _gisrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getIntentsResponse
:: Int
-> GetIntentsResponse
getIntentsResponse pResponseStatus_ =
GetIntentsResponse'
{ _gisrsIntents = Nothing
, _gisrsNextToken = Nothing
, _gisrsResponseStatus = pResponseStatus_
}
gisrsIntents :: Lens' GetIntentsResponse [IntentMetadata]
gisrsIntents = lens _gisrsIntents (\ s a -> s{_gisrsIntents = a}) . _Default . _Coerce
gisrsNextToken :: Lens' GetIntentsResponse (Maybe Text)
gisrsNextToken = lens _gisrsNextToken (\ s a -> s{_gisrsNextToken = a})
gisrsResponseStatus :: Lens' GetIntentsResponse Int
gisrsResponseStatus = lens _gisrsResponseStatus (\ s a -> s{_gisrsResponseStatus = a})
instance NFData GetIntentsResponse where