{-# 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.SearchFaces
(
searchFaces
, SearchFaces
, sfFaceMatchThreshold
, sfMaxFaces
, sfCollectionId
, sfFaceId
, searchFacesResponse
, SearchFacesResponse
, sfrsFaceMatches
, sfrsFaceModelVersion
, sfrsSearchedFaceId
, sfrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Rekognition.Types
import Network.AWS.Rekognition.Types.Product
import Network.AWS.Request
import Network.AWS.Response
data SearchFaces = SearchFaces'
{ _sfFaceMatchThreshold :: !(Maybe Double)
, _sfMaxFaces :: !(Maybe Nat)
, _sfCollectionId :: !Text
, _sfFaceId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
searchFaces
:: Text
-> Text
-> SearchFaces
searchFaces pCollectionId_ pFaceId_ =
SearchFaces'
{ _sfFaceMatchThreshold = Nothing
, _sfMaxFaces = Nothing
, _sfCollectionId = pCollectionId_
, _sfFaceId = pFaceId_
}
sfFaceMatchThreshold :: Lens' SearchFaces (Maybe Double)
sfFaceMatchThreshold = lens _sfFaceMatchThreshold (\ s a -> s{_sfFaceMatchThreshold = a})
sfMaxFaces :: Lens' SearchFaces (Maybe Natural)
sfMaxFaces = lens _sfMaxFaces (\ s a -> s{_sfMaxFaces = a}) . mapping _Nat
sfCollectionId :: Lens' SearchFaces Text
sfCollectionId = lens _sfCollectionId (\ s a -> s{_sfCollectionId = a})
sfFaceId :: Lens' SearchFaces Text
sfFaceId = lens _sfFaceId (\ s a -> s{_sfFaceId = a})
instance AWSRequest SearchFaces where
type Rs SearchFaces = SearchFacesResponse
request = postJSON rekognition
response
= receiveJSON
(\ s h x ->
SearchFacesResponse' <$>
(x .?> "FaceMatches" .!@ mempty) <*>
(x .?> "FaceModelVersion")
<*> (x .?> "SearchedFaceId")
<*> (pure (fromEnum s)))
instance Hashable SearchFaces where
instance NFData SearchFaces where
instance ToHeaders SearchFaces where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("RekognitionService.SearchFaces" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON SearchFaces where
toJSON SearchFaces'{..}
= object
(catMaybes
[("FaceMatchThreshold" .=) <$> _sfFaceMatchThreshold,
("MaxFaces" .=) <$> _sfMaxFaces,
Just ("CollectionId" .= _sfCollectionId),
Just ("FaceId" .= _sfFaceId)])
instance ToPath SearchFaces where
toPath = const "/"
instance ToQuery SearchFaces where
toQuery = const mempty
data SearchFacesResponse = SearchFacesResponse'
{ _sfrsFaceMatches :: !(Maybe [FaceMatch])
, _sfrsFaceModelVersion :: !(Maybe Text)
, _sfrsSearchedFaceId :: !(Maybe Text)
, _sfrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
searchFacesResponse
:: Int
-> SearchFacesResponse
searchFacesResponse pResponseStatus_ =
SearchFacesResponse'
{ _sfrsFaceMatches = Nothing
, _sfrsFaceModelVersion = Nothing
, _sfrsSearchedFaceId = Nothing
, _sfrsResponseStatus = pResponseStatus_
}
sfrsFaceMatches :: Lens' SearchFacesResponse [FaceMatch]
sfrsFaceMatches = lens _sfrsFaceMatches (\ s a -> s{_sfrsFaceMatches = a}) . _Default . _Coerce
sfrsFaceModelVersion :: Lens' SearchFacesResponse (Maybe Text)
sfrsFaceModelVersion = lens _sfrsFaceModelVersion (\ s a -> s{_sfrsFaceModelVersion = a})
sfrsSearchedFaceId :: Lens' SearchFacesResponse (Maybe Text)
sfrsSearchedFaceId = lens _sfrsSearchedFaceId (\ s a -> s{_sfrsSearchedFaceId = a})
sfrsResponseStatus :: Lens' SearchFacesResponse Int
sfrsResponseStatus = lens _sfrsResponseStatus (\ s a -> s{_sfrsResponseStatus = a})
instance NFData SearchFacesResponse where