{-# 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.AlexaBusiness.SearchProfiles
(
searchProfiles
, SearchProfiles
, spFilters
, spSortCriteria
, spNextToken
, spMaxResults
, searchProfilesResponse
, SearchProfilesResponse
, sprsProfiles
, sprsNextToken
, sprsTotalCount
, sprsResponseStatus
) where
import Network.AWS.AlexaBusiness.Types
import Network.AWS.AlexaBusiness.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data SearchProfiles = SearchProfiles'
{ _spFilters :: !(Maybe [Filter])
, _spSortCriteria :: !(Maybe [Sort])
, _spNextToken :: !(Maybe Text)
, _spMaxResults :: !(Maybe Nat)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
searchProfiles
:: SearchProfiles
searchProfiles =
SearchProfiles'
{ _spFilters = Nothing
, _spSortCriteria = Nothing
, _spNextToken = Nothing
, _spMaxResults = Nothing
}
spFilters :: Lens' SearchProfiles [Filter]
spFilters = lens _spFilters (\ s a -> s{_spFilters = a}) . _Default . _Coerce
spSortCriteria :: Lens' SearchProfiles [Sort]
spSortCriteria = lens _spSortCriteria (\ s a -> s{_spSortCriteria = a}) . _Default . _Coerce
spNextToken :: Lens' SearchProfiles (Maybe Text)
spNextToken = lens _spNextToken (\ s a -> s{_spNextToken = a})
spMaxResults :: Lens' SearchProfiles (Maybe Natural)
spMaxResults = lens _spMaxResults (\ s a -> s{_spMaxResults = a}) . mapping _Nat
instance AWSPager SearchProfiles where
page rq rs
| stop (rs ^. sprsNextToken) = Nothing
| stop (rs ^. sprsProfiles) = Nothing
| otherwise =
Just $ rq & spNextToken .~ rs ^. sprsNextToken
instance AWSRequest SearchProfiles where
type Rs SearchProfiles = SearchProfilesResponse
request = postJSON alexaBusiness
response
= receiveJSON
(\ s h x ->
SearchProfilesResponse' <$>
(x .?> "Profiles" .!@ mempty) <*> (x .?> "NextToken")
<*> (x .?> "TotalCount")
<*> (pure (fromEnum s)))
instance Hashable SearchProfiles where
instance NFData SearchProfiles where
instance ToHeaders SearchProfiles where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AlexaForBusiness.SearchProfiles" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON SearchProfiles where
toJSON SearchProfiles'{..}
= object
(catMaybes
[("Filters" .=) <$> _spFilters,
("SortCriteria" .=) <$> _spSortCriteria,
("NextToken" .=) <$> _spNextToken,
("MaxResults" .=) <$> _spMaxResults])
instance ToPath SearchProfiles where
toPath = const "/"
instance ToQuery SearchProfiles where
toQuery = const mempty
data SearchProfilesResponse = SearchProfilesResponse'
{ _sprsProfiles :: !(Maybe [ProfileData])
, _sprsNextToken :: !(Maybe Text)
, _sprsTotalCount :: !(Maybe Int)
, _sprsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
searchProfilesResponse
:: Int
-> SearchProfilesResponse
searchProfilesResponse pResponseStatus_ =
SearchProfilesResponse'
{ _sprsProfiles = Nothing
, _sprsNextToken = Nothing
, _sprsTotalCount = Nothing
, _sprsResponseStatus = pResponseStatus_
}
sprsProfiles :: Lens' SearchProfilesResponse [ProfileData]
sprsProfiles = lens _sprsProfiles (\ s a -> s{_sprsProfiles = a}) . _Default . _Coerce
sprsNextToken :: Lens' SearchProfilesResponse (Maybe Text)
sprsNextToken = lens _sprsNextToken (\ s a -> s{_sprsNextToken = a})
sprsTotalCount :: Lens' SearchProfilesResponse (Maybe Int)
sprsTotalCount = lens _sprsTotalCount (\ s a -> s{_sprsTotalCount = a})
sprsResponseStatus :: Lens' SearchProfilesResponse Int
sprsResponseStatus = lens _sprsResponseStatus (\ s a -> s{_sprsResponseStatus = a})
instance NFData SearchProfilesResponse where