{-# 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.DeviceFarm.ListDevices
(
listDevices
, ListDevices
, ldArn
, ldNextToken
, listDevicesResponse
, ListDevicesResponse
, ldrsNextToken
, ldrsDevices
, ldrsResponseStatus
) where
import Network.AWS.DeviceFarm.Types
import Network.AWS.DeviceFarm.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data ListDevices = ListDevices'
{ _ldArn :: !(Maybe Text)
, _ldNextToken :: !(Maybe Text)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listDevices
:: ListDevices
listDevices = ListDevices' {_ldArn = Nothing, _ldNextToken = Nothing}
ldArn :: Lens' ListDevices (Maybe Text)
ldArn = lens _ldArn (\ s a -> s{_ldArn = a})
ldNextToken :: Lens' ListDevices (Maybe Text)
ldNextToken = lens _ldNextToken (\ s a -> s{_ldNextToken = a})
instance AWSPager ListDevices where
page rq rs
| stop (rs ^. ldrsNextToken) = Nothing
| stop (rs ^. ldrsDevices) = Nothing
| otherwise =
Just $ rq & ldNextToken .~ rs ^. ldrsNextToken
instance AWSRequest ListDevices where
type Rs ListDevices = ListDevicesResponse
request = postJSON deviceFarm
response
= receiveJSON
(\ s h x ->
ListDevicesResponse' <$>
(x .?> "nextToken") <*> (x .?> "devices" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable ListDevices where
instance NFData ListDevices where
instance ToHeaders ListDevices where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("DeviceFarm_20150623.ListDevices" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListDevices where
toJSON ListDevices'{..}
= object
(catMaybes
[("arn" .=) <$> _ldArn,
("nextToken" .=) <$> _ldNextToken])
instance ToPath ListDevices where
toPath = const "/"
instance ToQuery ListDevices where
toQuery = const mempty
data ListDevicesResponse = ListDevicesResponse'
{ _ldrsNextToken :: !(Maybe Text)
, _ldrsDevices :: !(Maybe [Device])
, _ldrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listDevicesResponse
:: Int
-> ListDevicesResponse
listDevicesResponse pResponseStatus_ =
ListDevicesResponse'
{ _ldrsNextToken = Nothing
, _ldrsDevices = Nothing
, _ldrsResponseStatus = pResponseStatus_
}
ldrsNextToken :: Lens' ListDevicesResponse (Maybe Text)
ldrsNextToken = lens _ldrsNextToken (\ s a -> s{_ldrsNextToken = a})
ldrsDevices :: Lens' ListDevicesResponse [Device]
ldrsDevices = lens _ldrsDevices (\ s a -> s{_ldrsDevices = a}) . _Default . _Coerce
ldrsResponseStatus :: Lens' ListDevicesResponse Int
ldrsResponseStatus = lens _ldrsResponseStatus (\ s a -> s{_ldrsResponseStatus = a})
instance NFData ListDevicesResponse where