{-# 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.SearchRooms
(
searchRooms
, SearchRooms
, srFilters
, srSortCriteria
, srNextToken
, srMaxResults
, searchRoomsResponse
, SearchRoomsResponse
, srrsRooms
, srrsNextToken
, srrsTotalCount
, srrsResponseStatus
) 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 SearchRooms = SearchRooms'
{ _srFilters :: !(Maybe [Filter])
, _srSortCriteria :: !(Maybe [Sort])
, _srNextToken :: !(Maybe Text)
, _srMaxResults :: !(Maybe Nat)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
searchRooms
:: SearchRooms
searchRooms =
SearchRooms'
{ _srFilters = Nothing
, _srSortCriteria = Nothing
, _srNextToken = Nothing
, _srMaxResults = Nothing
}
srFilters :: Lens' SearchRooms [Filter]
srFilters = lens _srFilters (\ s a -> s{_srFilters = a}) . _Default . _Coerce
srSortCriteria :: Lens' SearchRooms [Sort]
srSortCriteria = lens _srSortCriteria (\ s a -> s{_srSortCriteria = a}) . _Default . _Coerce
srNextToken :: Lens' SearchRooms (Maybe Text)
srNextToken = lens _srNextToken (\ s a -> s{_srNextToken = a})
srMaxResults :: Lens' SearchRooms (Maybe Natural)
srMaxResults = lens _srMaxResults (\ s a -> s{_srMaxResults = a}) . mapping _Nat
instance AWSPager SearchRooms where
page rq rs
| stop (rs ^. srrsNextToken) = Nothing
| stop (rs ^. srrsRooms) = Nothing
| otherwise =
Just $ rq & srNextToken .~ rs ^. srrsNextToken
instance AWSRequest SearchRooms where
type Rs SearchRooms = SearchRoomsResponse
request = postJSON alexaBusiness
response
= receiveJSON
(\ s h x ->
SearchRoomsResponse' <$>
(x .?> "Rooms" .!@ mempty) <*> (x .?> "NextToken")
<*> (x .?> "TotalCount")
<*> (pure (fromEnum s)))
instance Hashable SearchRooms where
instance NFData SearchRooms where
instance ToHeaders SearchRooms where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AlexaForBusiness.SearchRooms" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON SearchRooms where
toJSON SearchRooms'{..}
= object
(catMaybes
[("Filters" .=) <$> _srFilters,
("SortCriteria" .=) <$> _srSortCriteria,
("NextToken" .=) <$> _srNextToken,
("MaxResults" .=) <$> _srMaxResults])
instance ToPath SearchRooms where
toPath = const "/"
instance ToQuery SearchRooms where
toQuery = const mempty
data SearchRoomsResponse = SearchRoomsResponse'
{ _srrsRooms :: !(Maybe [RoomData])
, _srrsNextToken :: !(Maybe Text)
, _srrsTotalCount :: !(Maybe Int)
, _srrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
searchRoomsResponse
:: Int
-> SearchRoomsResponse
searchRoomsResponse pResponseStatus_ =
SearchRoomsResponse'
{ _srrsRooms = Nothing
, _srrsNextToken = Nothing
, _srrsTotalCount = Nothing
, _srrsResponseStatus = pResponseStatus_
}
srrsRooms :: Lens' SearchRoomsResponse [RoomData]
srrsRooms = lens _srrsRooms (\ s a -> s{_srrsRooms = a}) . _Default . _Coerce
srrsNextToken :: Lens' SearchRoomsResponse (Maybe Text)
srrsNextToken = lens _srrsNextToken (\ s a -> s{_srrsNextToken = a})
srrsTotalCount :: Lens' SearchRoomsResponse (Maybe Int)
srrsTotalCount = lens _srrsTotalCount (\ s a -> s{_srrsTotalCount = a})
srrsResponseStatus :: Lens' SearchRoomsResponse Int
srrsResponseStatus = lens _srrsResponseStatus (\ s a -> s{_srrsResponseStatus = a})
instance NFData SearchRoomsResponse where