module Network.AWS.CloudDirectory.CreateIndex
(
createIndex
, CreateIndex
, ciParentReference
, ciLinkName
, ciDirectoryARN
, ciOrderedIndexedAttributeList
, ciIsUnique
, createIndexResponse
, CreateIndexResponse
, cirsObjectIdentifier
, cirsResponseStatus
) where
import Network.AWS.CloudDirectory.Types
import Network.AWS.CloudDirectory.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateIndex = CreateIndex'
{ _ciParentReference :: !(Maybe ObjectReference)
, _ciLinkName :: !(Maybe Text)
, _ciDirectoryARN :: !Text
, _ciOrderedIndexedAttributeList :: ![AttributeKey]
, _ciIsUnique :: !Bool
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createIndex
:: Text
-> Bool
-> CreateIndex
createIndex pDirectoryARN_ pIsUnique_ =
CreateIndex'
{ _ciParentReference = Nothing
, _ciLinkName = Nothing
, _ciDirectoryARN = pDirectoryARN_
, _ciOrderedIndexedAttributeList = mempty
, _ciIsUnique = pIsUnique_
}
ciParentReference :: Lens' CreateIndex (Maybe ObjectReference)
ciParentReference = lens _ciParentReference (\ s a -> s{_ciParentReference = a});
ciLinkName :: Lens' CreateIndex (Maybe Text)
ciLinkName = lens _ciLinkName (\ s a -> s{_ciLinkName = a});
ciDirectoryARN :: Lens' CreateIndex Text
ciDirectoryARN = lens _ciDirectoryARN (\ s a -> s{_ciDirectoryARN = a});
ciOrderedIndexedAttributeList :: Lens' CreateIndex [AttributeKey]
ciOrderedIndexedAttributeList = lens _ciOrderedIndexedAttributeList (\ s a -> s{_ciOrderedIndexedAttributeList = a}) . _Coerce;
ciIsUnique :: Lens' CreateIndex Bool
ciIsUnique = lens _ciIsUnique (\ s a -> s{_ciIsUnique = a});
instance AWSRequest CreateIndex where
type Rs CreateIndex = CreateIndexResponse
request = putJSON cloudDirectory
response
= receiveJSON
(\ s h x ->
CreateIndexResponse' <$>
(x .?> "ObjectIdentifier") <*> (pure (fromEnum s)))
instance Hashable CreateIndex where
instance NFData CreateIndex where
instance ToHeaders CreateIndex where
toHeaders CreateIndex'{..}
= mconcat ["x-amz-data-partition" =# _ciDirectoryARN]
instance ToJSON CreateIndex where
toJSON CreateIndex'{..}
= object
(catMaybes
[("ParentReference" .=) <$> _ciParentReference,
("LinkName" .=) <$> _ciLinkName,
Just
("OrderedIndexedAttributeList" .=
_ciOrderedIndexedAttributeList),
Just ("IsUnique" .= _ciIsUnique)])
instance ToPath CreateIndex where
toPath
= const "/amazonclouddirectory/2017-01-11/index"
instance ToQuery CreateIndex where
toQuery = const mempty
data CreateIndexResponse = CreateIndexResponse'
{ _cirsObjectIdentifier :: !(Maybe Text)
, _cirsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createIndexResponse
:: Int
-> CreateIndexResponse
createIndexResponse pResponseStatus_ =
CreateIndexResponse'
{_cirsObjectIdentifier = Nothing, _cirsResponseStatus = pResponseStatus_}
cirsObjectIdentifier :: Lens' CreateIndexResponse (Maybe Text)
cirsObjectIdentifier = lens _cirsObjectIdentifier (\ s a -> s{_cirsObjectIdentifier = a});
cirsResponseStatus :: Lens' CreateIndexResponse Int
cirsResponseStatus = lens _cirsResponseStatus (\ s a -> s{_cirsResponseStatus = a});
instance NFData CreateIndexResponse where