{-# 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.CloudDirectory.ListObjectParentPaths
(
listObjectParentPaths
, ListObjectParentPaths
, loppNextToken
, loppMaxResults
, loppDirectoryARN
, loppObjectReference
, listObjectParentPathsResponse
, ListObjectParentPathsResponse
, lopprsPathToObjectIdentifiersList
, lopprsNextToken
, lopprsResponseStatus
) where
import Network.AWS.CloudDirectory.Types
import Network.AWS.CloudDirectory.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data ListObjectParentPaths = ListObjectParentPaths'
{ _loppNextToken :: !(Maybe Text)
, _loppMaxResults :: !(Maybe Nat)
, _loppDirectoryARN :: !Text
, _loppObjectReference :: !ObjectReference
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listObjectParentPaths
:: Text
-> ObjectReference
-> ListObjectParentPaths
listObjectParentPaths pDirectoryARN_ pObjectReference_ =
ListObjectParentPaths'
{ _loppNextToken = Nothing
, _loppMaxResults = Nothing
, _loppDirectoryARN = pDirectoryARN_
, _loppObjectReference = pObjectReference_
}
loppNextToken :: Lens' ListObjectParentPaths (Maybe Text)
loppNextToken = lens _loppNextToken (\ s a -> s{_loppNextToken = a})
loppMaxResults :: Lens' ListObjectParentPaths (Maybe Natural)
loppMaxResults = lens _loppMaxResults (\ s a -> s{_loppMaxResults = a}) . mapping _Nat
loppDirectoryARN :: Lens' ListObjectParentPaths Text
loppDirectoryARN = lens _loppDirectoryARN (\ s a -> s{_loppDirectoryARN = a})
loppObjectReference :: Lens' ListObjectParentPaths ObjectReference
loppObjectReference = lens _loppObjectReference (\ s a -> s{_loppObjectReference = a})
instance AWSPager ListObjectParentPaths where
page rq rs
| stop (rs ^. lopprsNextToken) = Nothing
| stop (rs ^. lopprsPathToObjectIdentifiersList) =
Nothing
| otherwise =
Just $ rq & loppNextToken .~ rs ^. lopprsNextToken
instance AWSRequest ListObjectParentPaths where
type Rs ListObjectParentPaths =
ListObjectParentPathsResponse
request = postJSON cloudDirectory
response
= receiveJSON
(\ s h x ->
ListObjectParentPathsResponse' <$>
(x .?> "PathToObjectIdentifiersList" .!@ mempty) <*>
(x .?> "NextToken")
<*> (pure (fromEnum s)))
instance Hashable ListObjectParentPaths where
instance NFData ListObjectParentPaths where
instance ToHeaders ListObjectParentPaths where
toHeaders ListObjectParentPaths'{..}
= mconcat
["x-amz-data-partition" =# _loppDirectoryARN]
instance ToJSON ListObjectParentPaths where
toJSON ListObjectParentPaths'{..}
= object
(catMaybes
[("NextToken" .=) <$> _loppNextToken,
("MaxResults" .=) <$> _loppMaxResults,
Just ("ObjectReference" .= _loppObjectReference)])
instance ToPath ListObjectParentPaths where
toPath
= const
"/amazonclouddirectory/2017-01-11/object/parentpaths"
instance ToQuery ListObjectParentPaths where
toQuery = const mempty
data ListObjectParentPathsResponse = ListObjectParentPathsResponse'
{ _lopprsPathToObjectIdentifiersList :: !(Maybe [PathToObjectIdentifiers])
, _lopprsNextToken :: !(Maybe Text)
, _lopprsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listObjectParentPathsResponse
:: Int
-> ListObjectParentPathsResponse
listObjectParentPathsResponse pResponseStatus_ =
ListObjectParentPathsResponse'
{ _lopprsPathToObjectIdentifiersList = Nothing
, _lopprsNextToken = Nothing
, _lopprsResponseStatus = pResponseStatus_
}
lopprsPathToObjectIdentifiersList :: Lens' ListObjectParentPathsResponse [PathToObjectIdentifiers]
lopprsPathToObjectIdentifiersList = lens _lopprsPathToObjectIdentifiersList (\ s a -> s{_lopprsPathToObjectIdentifiersList = a}) . _Default . _Coerce
lopprsNextToken :: Lens' ListObjectParentPathsResponse (Maybe Text)
lopprsNextToken = lens _lopprsNextToken (\ s a -> s{_lopprsNextToken = a})
lopprsResponseStatus :: Lens' ListObjectParentPathsResponse Int
lopprsResponseStatus = lens _lopprsResponseStatus (\ s a -> s{_lopprsResponseStatus = a})
instance NFData ListObjectParentPathsResponse where