{-# 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.Rekognition.ListFaces
(
listFaces
, ListFaces
, lfNextToken
, lfMaxResults
, lfCollectionId
, listFacesResponse
, ListFacesResponse
, lfrsFaceModelVersion
, lfrsNextToken
, lfrsFaces
, lfrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Rekognition.Types
import Network.AWS.Rekognition.Types.Product
import Network.AWS.Request
import Network.AWS.Response
data ListFaces = ListFaces'
{ _lfNextToken :: !(Maybe Text)
, _lfMaxResults :: !(Maybe Nat)
, _lfCollectionId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listFaces
:: Text
-> ListFaces
listFaces pCollectionId_ =
ListFaces'
{ _lfNextToken = Nothing
, _lfMaxResults = Nothing
, _lfCollectionId = pCollectionId_
}
lfNextToken :: Lens' ListFaces (Maybe Text)
lfNextToken = lens _lfNextToken (\ s a -> s{_lfNextToken = a})
lfMaxResults :: Lens' ListFaces (Maybe Natural)
lfMaxResults = lens _lfMaxResults (\ s a -> s{_lfMaxResults = a}) . mapping _Nat
lfCollectionId :: Lens' ListFaces Text
lfCollectionId = lens _lfCollectionId (\ s a -> s{_lfCollectionId = a})
instance AWSPager ListFaces where
page rq rs
| stop (rs ^. lfrsNextToken) = Nothing
| stop (rs ^. lfrsFaces) = Nothing
| otherwise =
Just $ rq & lfNextToken .~ rs ^. lfrsNextToken
instance AWSRequest ListFaces where
type Rs ListFaces = ListFacesResponse
request = postJSON rekognition
response
= receiveJSON
(\ s h x ->
ListFacesResponse' <$>
(x .?> "FaceModelVersion") <*> (x .?> "NextToken")
<*> (x .?> "Faces" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable ListFaces where
instance NFData ListFaces where
instance ToHeaders ListFaces where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("RekognitionService.ListFaces" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListFaces where
toJSON ListFaces'{..}
= object
(catMaybes
[("NextToken" .=) <$> _lfNextToken,
("MaxResults" .=) <$> _lfMaxResults,
Just ("CollectionId" .= _lfCollectionId)])
instance ToPath ListFaces where
toPath = const "/"
instance ToQuery ListFaces where
toQuery = const mempty
data ListFacesResponse = ListFacesResponse'
{ _lfrsFaceModelVersion :: !(Maybe Text)
, _lfrsNextToken :: !(Maybe Text)
, _lfrsFaces :: !(Maybe [Face])
, _lfrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listFacesResponse
:: Int
-> ListFacesResponse
listFacesResponse pResponseStatus_ =
ListFacesResponse'
{ _lfrsFaceModelVersion = Nothing
, _lfrsNextToken = Nothing
, _lfrsFaces = Nothing
, _lfrsResponseStatus = pResponseStatus_
}
lfrsFaceModelVersion :: Lens' ListFacesResponse (Maybe Text)
lfrsFaceModelVersion = lens _lfrsFaceModelVersion (\ s a -> s{_lfrsFaceModelVersion = a})
lfrsNextToken :: Lens' ListFacesResponse (Maybe Text)
lfrsNextToken = lens _lfrsNextToken (\ s a -> s{_lfrsNextToken = a})
lfrsFaces :: Lens' ListFacesResponse [Face]
lfrsFaces = lens _lfrsFaces (\ s a -> s{_lfrsFaces = a}) . _Default . _Coerce
lfrsResponseStatus :: Lens' ListFacesResponse Int
lfrsResponseStatus = lens _lfrsResponseStatus (\ s a -> s{_lfrsResponseStatus = a})
instance NFData ListFacesResponse where