listRecords method

Future<ListRecordsResponse> listRecords({
  1. required String datasetName,
  2. required String identityId,
  3. required String identityPoolId,
  4. int? lastSyncCount,
  5. int? maxResults,
  6. String? nextToken,
  7. String? syncSessionToken,
})

Gets paginated records, optionally changed after a particular sync count for a dataset and identity. With Amazon Cognito Sync, each identity has access only to its own data. Thus, the credentials used to make this API call need to have access to the identity data.

ListRecords can be called with temporary user credentials provided by Cognito Identity or with developer credentials. You should use Cognito Identity credentials to make this API call.

May throw InvalidParameterException. May throw NotAuthorizedException. May throw TooManyRequestsException. May throw InternalErrorException.

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

Parameter 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.

Parameter 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.

Parameter lastSyncCount : The last server sync count for this record.

Parameter maxResults : The maximum number of results to be returned.

Parameter nextToken : A pagination token for obtaining the next page of results.

Parameter syncSessionToken : A token containing a session ID, identity ID, and expiration.

Implementation

Future<ListRecordsResponse> listRecords({
  required String datasetName,
  required String identityId,
  required String identityPoolId,
  int? lastSyncCount,
  int? maxResults,
  String? nextToken,
  String? syncSessionToken,
}) async {
  ArgumentError.checkNotNull(datasetName, 'datasetName');
  _s.validateStringLength(
    'datasetName',
    datasetName,
    1,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(identityId, 'identityId');
  _s.validateStringLength(
    'identityId',
    identityId,
    1,
    55,
    isRequired: true,
  );
  ArgumentError.checkNotNull(identityPoolId, 'identityPoolId');
  _s.validateStringLength(
    'identityPoolId',
    identityPoolId,
    1,
    55,
    isRequired: true,
  );
  final $query = <String, List<String>>{
    if (lastSyncCount != null) 'lastSyncCount': [lastSyncCount.toString()],
    if (maxResults != null) 'maxResults': [maxResults.toString()],
    if (nextToken != null) 'nextToken': [nextToken],
    if (syncSessionToken != null) 'syncSessionToken': [syncSessionToken],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'GET',
    requestUri:
        '/identitypools/${Uri.encodeComponent(identityPoolId)}/identities/${Uri.encodeComponent(identityId)}/datasets/${Uri.encodeComponent(datasetName)}/records',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return ListRecordsResponse.fromJson(response);
}