module Network.AWS.CognitoSync.UpdateRecords
(
updateRecords
, UpdateRecords
, urRecordPatches
, urDeviceId
, urClientContext
, urIdentityPoolId
, urIdentityId
, urDatasetName
, urSyncSessionToken
, updateRecordsResponse
, UpdateRecordsResponse
, urrsRecords
, urrsResponseStatus
) where
import Network.AWS.CognitoSync.Types
import Network.AWS.CognitoSync.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data UpdateRecords = UpdateRecords'
{ _urRecordPatches :: !(Maybe [RecordPatch])
, _urDeviceId :: !(Maybe Text)
, _urClientContext :: !(Maybe Text)
, _urIdentityPoolId :: !Text
, _urIdentityId :: !Text
, _urDatasetName :: !Text
, _urSyncSessionToken :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
updateRecords
:: Text
-> Text
-> Text
-> Text
-> UpdateRecords
updateRecords pIdentityPoolId_ pIdentityId_ pDatasetName_ pSyncSessionToken_ =
UpdateRecords'
{ _urRecordPatches = Nothing
, _urDeviceId = Nothing
, _urClientContext = Nothing
, _urIdentityPoolId = pIdentityPoolId_
, _urIdentityId = pIdentityId_
, _urDatasetName = pDatasetName_
, _urSyncSessionToken = pSyncSessionToken_
}
urRecordPatches :: Lens' UpdateRecords [RecordPatch]
urRecordPatches = lens _urRecordPatches (\ s a -> s{_urRecordPatches = a}) . _Default . _Coerce;
urDeviceId :: Lens' UpdateRecords (Maybe Text)
urDeviceId = lens _urDeviceId (\ s a -> s{_urDeviceId = a});
urClientContext :: Lens' UpdateRecords (Maybe Text)
urClientContext = lens _urClientContext (\ s a -> s{_urClientContext = a});
urIdentityPoolId :: Lens' UpdateRecords Text
urIdentityPoolId = lens _urIdentityPoolId (\ s a -> s{_urIdentityPoolId = a});
urIdentityId :: Lens' UpdateRecords Text
urIdentityId = lens _urIdentityId (\ s a -> s{_urIdentityId = a});
urDatasetName :: Lens' UpdateRecords Text
urDatasetName = lens _urDatasetName (\ s a -> s{_urDatasetName = a});
urSyncSessionToken :: Lens' UpdateRecords Text
urSyncSessionToken = lens _urSyncSessionToken (\ s a -> s{_urSyncSessionToken = a});
instance AWSRequest UpdateRecords where
type Rs UpdateRecords = UpdateRecordsResponse
request = postJSON cognitoSync
response
= receiveJSON
(\ s h x ->
UpdateRecordsResponse' <$>
(x .?> "Records" .!@ mempty) <*> (pure (fromEnum s)))
instance Hashable UpdateRecords
instance ToHeaders UpdateRecords where
toHeaders UpdateRecords'{..}
= mconcat
["x-amz-Client-Context" =# _urClientContext,
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)]
instance ToJSON UpdateRecords where
toJSON UpdateRecords'{..}
= object
(catMaybes
[("RecordPatches" .=) <$> _urRecordPatches,
("DeviceId" .=) <$> _urDeviceId,
Just ("SyncSessionToken" .= _urSyncSessionToken)])
instance ToPath UpdateRecords where
toPath UpdateRecords'{..}
= mconcat
["/identitypools/", toBS _urIdentityPoolId,
"/identities/", toBS _urIdentityId, "/datasets/",
toBS _urDatasetName]
instance ToQuery UpdateRecords where
toQuery = const mempty
data UpdateRecordsResponse = UpdateRecordsResponse'
{ _urrsRecords :: !(Maybe [Record])
, _urrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
updateRecordsResponse
:: Int
-> UpdateRecordsResponse
updateRecordsResponse pResponseStatus_ =
UpdateRecordsResponse'
{ _urrsRecords = Nothing
, _urrsResponseStatus = pResponseStatus_
}
urrsRecords :: Lens' UpdateRecordsResponse [Record]
urrsRecords = lens _urrsRecords (\ s a -> s{_urrsRecords = a}) . _Default . _Coerce;
urrsResponseStatus :: Lens' UpdateRecordsResponse Int
urrsResponseStatus = lens _urrsResponseStatus (\ s a -> s{_urrsResponseStatus = a});