Skip to content

update_records async

update_records(
    identity_pool_id: IdentityPoolId,
    identity_id: IdentityId,
    dataset_name: DatasetName,
    sync_session_token: SyncSessionToken,
    *,
    config_overrides: Optional[AsyncCognitoSyncClientConfig] = None,
    device_id: Optional[DeviceId] = None,
    record_patches: Optional[RecordPatchList] = None,
    client_context: Optional[ClientContext] = None,
) -> UpdateRecordsResponse

Posts updates to records and adds and deletes records for a dataset and user.

The sync count in the record patch is your last known sync count for that record. The server will reject an UpdateRecords request with a ResourceConflictException if you try to patch a record with a new value but a stale sync count.

For example, if the sync count on the server is 5 for a key called highScore and you try and submit a new highScore with sync count of 4, the request will be rejected. To obtain the current sync count for a record, call ListRecords. On a successful update of the record, the response returns the new sync count for that record. You should present that sync count the next time you try to update that same record. When the record does not exist, specify the sync count as 0.

This API can be called with temporary user credentials provided by Cognito Identity or with developer credentials.

Parameters:

  • identity_pool_id (IdentityPoolId) –

    A name-spaced GUID (for example, us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon Cognito. GUID generation is unique within a region.

  • identity_id (IdentityId) –

    A name-spaced GUID (for example, us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon Cognito. GUID generation is unique within a region.

  • dataset_name (DatasetName) –

    A string of up to 128 characters. Allowed characters are a-z, A-Z, 0-9, '_' (underscore), '-' (dash), and '.' (dot).

  • device_id (Optional[DeviceId], default: None ) –

    The unique ID generated for this device by Cognito.

  • record_patches (Optional[RecordPatchList], default: None ) –

    A list of patch operations.

  • sync_session_token (SyncSessionToken) –

    The SyncSessionToken returned by a previous call to ListRecords for this dataset and identity.

  • client_context (Optional[ClientContext], default: None ) –

    Intended to supply a device ID that will populate the lastModifiedBy field referenced in other methods. The ClientContext field is not yet implemented.

Raises:

Source code in docs_src/capo_cognito_sync/_services/async_cognito_sync.py
async def update_records(
    self,
    identity_pool_id: "capo_cognito_sync.types.identity_pool_id.IdentityPoolId",
    identity_id: "capo_cognito_sync.types.identity_id.IdentityId",
    dataset_name: "capo_cognito_sync.types.dataset_name.DatasetName",
    sync_session_token: "capo_cognito_sync.types.sync_session_token.SyncSessionToken",
    *,
    config_overrides: Optional[AsyncCognitoSyncClientConfig] = None,
    device_id: Optional["capo_cognito_sync.types.device_id.DeviceId"] = None,
    record_patches: Optional[
        "capo_cognito_sync.types.record_patch_list.RecordPatchList"
    ] = None,
    client_context: Optional[
        "capo_cognito_sync.types.client_context.ClientContext"
    ] = None,
) -> "capo_cognito_sync.types.update_records_response.UpdateRecordsResponse":
    """<p>Posts updates to records and adds and deletes records for a dataset and user.</p> <p>The sync count in the record patch is your last known sync count for that record. The server will reject an UpdateRecords request with a ResourceConflictException if you try to patch a record with a new value but a stale sync count.</p><p>For example, if the sync count on the server is 5 for a key called highScore and you try and submit a new highScore with sync count of 4, the request will be rejected. To obtain the current sync count for a record, call ListRecords. On a successful update of the record, the response returns the new sync count for that record. You should present that sync count the next time you try to update that same record. When the record does not exist, specify the sync count as 0.</p> <p>This API can be called with temporary user credentials provided by Cognito Identity or with developer credentials.</p>

    Args:
        identity_pool_id: A name-spaced GUID (for example, us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon Cognito. GUID generation is unique within a region.
        identity_id: A name-spaced GUID (for example, us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon Cognito. GUID generation is unique within a region.
        dataset_name: A string of up to 128 characters. Allowed characters are a-z, A-Z, 0-9, '_' (underscore), '-' (dash), and '.' (dot).
        device_id: <p>The unique ID generated for this device by Cognito.</p>
        record_patches: A list of patch operations.
        sync_session_token: The SyncSessionToken returned by a previous call to ListRecords for this dataset and identity.
        client_context: Intended to supply a device ID that will populate the lastModifiedBy field referenced in other methods. The ClientContext field is not yet implemented.

    Raises:
        capo_cognito_sync.errors.internal_error_exception.InternalErrorException: Indicates an internal service error.
        capo_cognito_sync.errors.invalid_lambda_function_output_exception.InvalidLambdaFunctionOutputException: <p>The AWS Lambda function returned invalid output or an exception.</p>
        capo_cognito_sync.errors.invalid_parameter_exception.InvalidParameterException: Thrown when a request parameter does not comply with the associated constraints.
        capo_cognito_sync.errors.lambda_throttled_exception.LambdaThrottledException: <p>AWS Lambda throttled your account, please contact AWS Support</p>
        capo_cognito_sync.errors.limit_exceeded_exception.LimitExceededException: Thrown when the limit on the number of objects or operations has been exceeded.
        capo_cognito_sync.errors.not_authorized_exception.NotAuthorizedException: Thrown when a user is not authorized to access the requested resource.
        capo_cognito_sync.errors.resource_conflict_exception.ResourceConflictException: Thrown if an update can't be applied because the resource was changed by another call and this would result in a conflict.
        capo_cognito_sync.errors.resource_not_found_exception.ResourceNotFoundException: Thrown if the resource doesn't exist.
        capo_cognito_sync.errors.too_many_requests_exception.TooManyRequestsException: Thrown if the request is throttled.
        capo_cognito_sync.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cognito_sync.types.update_records_request.UpdateRecordsRequest]",
    ) -> AsyncOperationResponse[
        "capo_cognito_sync.types.update_records_response.UpdateRecordsResponse"
    ]:
        import capo_cognito_sync._operations.aws_cognito_sync_service.update_records

        (
            output,
            http_response,
        ) = await capo_cognito_sync._operations.aws_cognito_sync_service.update_records.async_update_records(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateRecords")
    )
    input_: capo_cognito_sync.types.update_records_request.UpdateRecordsRequest = {
        "identity_pool_id": identity_pool_id,
        "identity_id": identity_id,
        "dataset_name": dataset_name,
        "sync_session_token": sync_session_token,
    }
    if device_id is not None:
        input_["device_id"] = device_id
    if record_patches is not None:
        input_["record_patches"] = record_patches
    if client_context is not None:
        input_["client_context"] = client_context

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output