{-# 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.ListAttachedIndices
(
listAttachedIndices
, ListAttachedIndices
, laiConsistencyLevel
, laiNextToken
, laiMaxResults
, laiDirectoryARN
, laiTargetReference
, listAttachedIndicesResponse
, ListAttachedIndicesResponse
, lairsIndexAttachments
, lairsNextToken
, lairsResponseStatus
) 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 ListAttachedIndices = ListAttachedIndices'
{ _laiConsistencyLevel :: !(Maybe ConsistencyLevel)
, _laiNextToken :: !(Maybe Text)
, _laiMaxResults :: !(Maybe Nat)
, _laiDirectoryARN :: !Text
, _laiTargetReference :: !ObjectReference
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listAttachedIndices
:: Text
-> ObjectReference
-> ListAttachedIndices
listAttachedIndices pDirectoryARN_ pTargetReference_ =
ListAttachedIndices'
{ _laiConsistencyLevel = Nothing
, _laiNextToken = Nothing
, _laiMaxResults = Nothing
, _laiDirectoryARN = pDirectoryARN_
, _laiTargetReference = pTargetReference_
}
laiConsistencyLevel :: Lens' ListAttachedIndices (Maybe ConsistencyLevel)
laiConsistencyLevel = lens _laiConsistencyLevel (\ s a -> s{_laiConsistencyLevel = a})
laiNextToken :: Lens' ListAttachedIndices (Maybe Text)
laiNextToken = lens _laiNextToken (\ s a -> s{_laiNextToken = a})
laiMaxResults :: Lens' ListAttachedIndices (Maybe Natural)
laiMaxResults = lens _laiMaxResults (\ s a -> s{_laiMaxResults = a}) . mapping _Nat
laiDirectoryARN :: Lens' ListAttachedIndices Text
laiDirectoryARN = lens _laiDirectoryARN (\ s a -> s{_laiDirectoryARN = a})
laiTargetReference :: Lens' ListAttachedIndices ObjectReference
laiTargetReference = lens _laiTargetReference (\ s a -> s{_laiTargetReference = a})
instance AWSPager ListAttachedIndices where
page rq rs
| stop (rs ^. lairsNextToken) = Nothing
| stop (rs ^. lairsIndexAttachments) = Nothing
| otherwise =
Just $ rq & laiNextToken .~ rs ^. lairsNextToken
instance AWSRequest ListAttachedIndices where
type Rs ListAttachedIndices =
ListAttachedIndicesResponse
request = postJSON cloudDirectory
response
= receiveJSON
(\ s h x ->
ListAttachedIndicesResponse' <$>
(x .?> "IndexAttachments" .!@ mempty) <*>
(x .?> "NextToken")
<*> (pure (fromEnum s)))
instance Hashable ListAttachedIndices where
instance NFData ListAttachedIndices where
instance ToHeaders ListAttachedIndices where
toHeaders ListAttachedIndices'{..}
= mconcat
["x-amz-consistency-level" =# _laiConsistencyLevel,
"x-amz-data-partition" =# _laiDirectoryARN]
instance ToJSON ListAttachedIndices where
toJSON ListAttachedIndices'{..}
= object
(catMaybes
[("NextToken" .=) <$> _laiNextToken,
("MaxResults" .=) <$> _laiMaxResults,
Just ("TargetReference" .= _laiTargetReference)])
instance ToPath ListAttachedIndices where
toPath
= const
"/amazonclouddirectory/2017-01-11/object/indices"
instance ToQuery ListAttachedIndices where
toQuery = const mempty
data ListAttachedIndicesResponse = ListAttachedIndicesResponse'
{ _lairsIndexAttachments :: !(Maybe [IndexAttachment])
, _lairsNextToken :: !(Maybe Text)
, _lairsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listAttachedIndicesResponse
:: Int
-> ListAttachedIndicesResponse
listAttachedIndicesResponse pResponseStatus_ =
ListAttachedIndicesResponse'
{ _lairsIndexAttachments = Nothing
, _lairsNextToken = Nothing
, _lairsResponseStatus = pResponseStatus_
}
lairsIndexAttachments :: Lens' ListAttachedIndicesResponse [IndexAttachment]
lairsIndexAttachments = lens _lairsIndexAttachments (\ s a -> s{_lairsIndexAttachments = a}) . _Default . _Coerce
lairsNextToken :: Lens' ListAttachedIndicesResponse (Maybe Text)
lairsNextToken = lens _lairsNextToken (\ s a -> s{_lairsNextToken = a})
lairsResponseStatus :: Lens' ListAttachedIndicesResponse Int
lairsResponseStatus = lens _lairsResponseStatus (\ s a -> s{_lairsResponseStatus = a})
instance NFData ListAttachedIndicesResponse where