{-# 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 #-} -- Derived from AWS service descriptions, licensed under Apache 2.0. -- | -- Module : Network.AWS.DeviceFarm.ListProjects -- Copyright : (c) 2013-2017 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Gets information about projects. -- -- -- -- This operation returns paginated results. module Network.AWS.DeviceFarm.ListProjects ( -- * Creating a Request listProjects , ListProjects -- * Request Lenses , lpArn , lpNextToken -- * Destructuring the Response , listProjectsResponse , ListProjectsResponse -- * Response Lenses , lprsNextToken , lprsProjects , lprsResponseStatus ) 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 -- | Represents a request to the list projects operation. -- -- -- -- /See:/ 'listProjects' smart constructor. data ListProjects = ListProjects' { _lpArn :: !(Maybe Text) , _lpNextToken :: !(Maybe Text) } deriving (Eq, Read, Show, Data, Typeable, Generic) -- | Creates a value of 'ListProjects' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'lpArn' - Optional. If no Amazon Resource Name (ARN) is specified, then AWS Device Farm returns a list of all projects for the AWS account. You can also specify a project ARN. -- -- * 'lpNextToken' - An identifier that was returned from the previous call to this operation, which can be used to return the next set of items in the list. listProjects :: ListProjects listProjects = ListProjects' {_lpArn = Nothing, _lpNextToken = Nothing} -- | Optional. If no Amazon Resource Name (ARN) is specified, then AWS Device Farm returns a list of all projects for the AWS account. You can also specify a project ARN. lpArn :: Lens' ListProjects (Maybe Text) lpArn = lens _lpArn (\ s a -> s{_lpArn = a}); -- | An identifier that was returned from the previous call to this operation, which can be used to return the next set of items in the list. lpNextToken :: Lens' ListProjects (Maybe Text) lpNextToken = lens _lpNextToken (\ s a -> s{_lpNextToken = a}); instance AWSPager ListProjects where page rq rs | stop (rs ^. lprsNextToken) = Nothing | stop (rs ^. lprsProjects) = Nothing | otherwise = Just $ rq & lpNextToken .~ rs ^. lprsNextToken instance AWSRequest ListProjects where type Rs ListProjects = ListProjectsResponse request = postJSON deviceFarm response = receiveJSON (\ s h x -> ListProjectsResponse' <$> (x .?> "nextToken") <*> (x .?> "projects" .!@ mempty) <*> (pure (fromEnum s))) instance Hashable ListProjects where instance NFData ListProjects where instance ToHeaders ListProjects where toHeaders = const (mconcat ["X-Amz-Target" =# ("DeviceFarm_20150623.ListProjects" :: ByteString), "Content-Type" =# ("application/x-amz-json-1.1" :: ByteString)]) instance ToJSON ListProjects where toJSON ListProjects'{..} = object (catMaybes [("arn" .=) <$> _lpArn, ("nextToken" .=) <$> _lpNextToken]) instance ToPath ListProjects where toPath = const "/" instance ToQuery ListProjects where toQuery = const mempty -- | Represents the result of a list projects request. -- -- -- -- /See:/ 'listProjectsResponse' smart constructor. data ListProjectsResponse = ListProjectsResponse' { _lprsNextToken :: !(Maybe Text) , _lprsProjects :: !(Maybe [Project]) , _lprsResponseStatus :: !Int } deriving (Eq, Read, Show, Data, Typeable, Generic) -- | Creates a value of 'ListProjectsResponse' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'lprsNextToken' - If the number of items that are returned is significantly large, this is an identifier that is also returned, which can be used in a subsequent call to this operation to return the next set of items in the list. -- -- * 'lprsProjects' - Information about the projects. -- -- * 'lprsResponseStatus' - -- | The response status code. listProjectsResponse :: Int -- ^ 'lprsResponseStatus' -> ListProjectsResponse listProjectsResponse pResponseStatus_ = ListProjectsResponse' { _lprsNextToken = Nothing , _lprsProjects = Nothing , _lprsResponseStatus = pResponseStatus_ } -- | If the number of items that are returned is significantly large, this is an identifier that is also returned, which can be used in a subsequent call to this operation to return the next set of items in the list. lprsNextToken :: Lens' ListProjectsResponse (Maybe Text) lprsNextToken = lens _lprsNextToken (\ s a -> s{_lprsNextToken = a}); -- | Information about the projects. lprsProjects :: Lens' ListProjectsResponse [Project] lprsProjects = lens _lprsProjects (\ s a -> s{_lprsProjects = a}) . _Default . _Coerce; -- | -- | The response status code. lprsResponseStatus :: Lens' ListProjectsResponse Int lprsResponseStatus = lens _lprsResponseStatus (\ s a -> s{_lprsResponseStatus = a}); instance NFData ListProjectsResponse where