module Network.AWS.CognitoSync.UpdateRecords
(
UpdateRecords
, updateRecords
, urClientContext
, urDatasetName
, urDeviceId
, urIdentityId
, urIdentityPoolId
, urRecordPatches
, urSyncSessionToken
, UpdateRecordsResponse
, updateRecordsResponse
, urrRecords
) where
import Network.AWS.Prelude
import Network.AWS.Request.RestJSON
import Network.AWS.CognitoSync.Types
import qualified GHC.Exts
data UpdateRecords = UpdateRecords
{ _urClientContext :: Maybe Text
, _urDatasetName :: Text
, _urDeviceId :: Maybe Text
, _urIdentityId :: Text
, _urIdentityPoolId :: Text
, _urRecordPatches :: List "RecordPatches" RecordPatch
, _urSyncSessionToken :: Text
} deriving (Eq, Read, Show)
updateRecords :: Text
-> Text
-> Text
-> Text
-> UpdateRecords
updateRecords p1 p2 p3 p4 = UpdateRecords
{ _urIdentityPoolId = p1
, _urIdentityId = p2
, _urDatasetName = p3
, _urSyncSessionToken = p4
, _urDeviceId = Nothing
, _urRecordPatches = mempty
, _urClientContext = Nothing
}
urClientContext :: Lens' UpdateRecords (Maybe Text)
urClientContext = lens _urClientContext (\s a -> s { _urClientContext = a })
urDatasetName :: Lens' UpdateRecords Text
urDatasetName = lens _urDatasetName (\s a -> s { _urDatasetName = a })
urDeviceId :: Lens' UpdateRecords (Maybe Text)
urDeviceId = lens _urDeviceId (\s a -> s { _urDeviceId = a })
urIdentityId :: Lens' UpdateRecords Text
urIdentityId = lens _urIdentityId (\s a -> s { _urIdentityId = a })
urIdentityPoolId :: Lens' UpdateRecords Text
urIdentityPoolId = lens _urIdentityPoolId (\s a -> s { _urIdentityPoolId = a })
urRecordPatches :: Lens' UpdateRecords [RecordPatch]
urRecordPatches = lens _urRecordPatches (\s a -> s { _urRecordPatches = a }) . _List
urSyncSessionToken :: Lens' UpdateRecords Text
urSyncSessionToken =
lens _urSyncSessionToken (\s a -> s { _urSyncSessionToken = a })
newtype UpdateRecordsResponse = UpdateRecordsResponse
{ _urrRecords :: List "Records" Record
} deriving (Eq, Read, Show, Monoid, Semigroup)
instance GHC.Exts.IsList UpdateRecordsResponse where
type Item UpdateRecordsResponse = Record
fromList = UpdateRecordsResponse . GHC.Exts.fromList
toList = GHC.Exts.toList . _urrRecords
updateRecordsResponse :: UpdateRecordsResponse
updateRecordsResponse = UpdateRecordsResponse
{ _urrRecords = mempty
}
urrRecords :: Lens' UpdateRecordsResponse [Record]
urrRecords = lens _urrRecords (\s a -> s { _urrRecords = a }) . _List
instance ToPath UpdateRecords where
toPath UpdateRecords{..} = mconcat
[ "/identitypools/"
, toText _urIdentityPoolId
, "/identities/"
, toText _urIdentityId
, "/datasets/"
, toText _urDatasetName
]
instance ToQuery UpdateRecords where
toQuery = const mempty
instance ToHeaders UpdateRecords where
toHeaders UpdateRecords{..} = mconcat
[ "x-amz-Client-Context" =: _urClientContext
]
instance ToJSON UpdateRecords where
toJSON UpdateRecords{..} = object
[ "DeviceId" .= _urDeviceId
, "RecordPatches" .= _urRecordPatches
, "SyncSessionToken" .= _urSyncSessionToken
]
instance AWSRequest UpdateRecords where
type Sv UpdateRecords = CognitoSync
type Rs UpdateRecords = UpdateRecordsResponse
request = post
response = jsonResponse
instance FromJSON UpdateRecordsResponse where
parseJSON = withObject "UpdateRecordsResponse" $ \o -> UpdateRecordsResponse
<$> o .:? "Records" .!= mempty