list method

Future<FileList> list({
  1. String? corpora,
  2. String? corpus,
  3. String? driveId,
  4. bool? includeItemsFromAllDrives,
  5. String? includeLabels,
  6. String? includePermissionsForView,
  7. bool? includeTeamDriveItems,
  8. String? orderBy,
  9. int? pageSize,
  10. String? pageToken,
  11. String? q,
  12. String? spaces,
  13. bool? supportsAllDrives,
  14. bool? supportsTeamDrives,
  15. String? teamDriveId,
  16. String? $fields,
})

Lists the user's files.

For more information, see [Search for files and folders](/workspace/drive/api/guides/search-files). This method accepts the q parameter, which is a search query combining one or more search terms. This method returns all files by default, including trashed files. If you don't want trashed files to appear in the list, use the trashed=false query parameter to remove trashed files from the results.

Request parameters:

corpora - Bodies of items (files or documents) to which the query applies. Supported bodies are: * user * domain * drive * allDrives Prefer user or drive to allDrives for efficiency. By default, corpora is set to user. However, this can change depending on the filter set through the q parameter. For more information, see File organization.

corpus - Deprecated: The source of files to list. Use corpora instead. Possible string values are:

  • "domain" : Files shared to the user's domain.
  • "user" : Files owned by or shared to the user.

driveId - ID of the shared drive to search.

includeItemsFromAllDrives - Whether both My Drive and shared drive items should be included in results.

includeLabels - A comma-separated list of IDs of labels to include in the labelInfo part of the response.

includePermissionsForView - Specifies which additional view's permissions to include in the response. Only published is supported.

includeTeamDriveItems - Deprecated: Use includeItemsFromAllDrives instead.

orderBy - A comma-separated list of sort keys. Valid keys are: * createdTime: When the file was created. * folder: The folder ID. This field is sorted using alphabetical ordering. * modifiedByMeTime: The last time the file was modified by the user. * modifiedTime: The last time the file was modified by anyone. * name: The name of the file. This field is sorted using alphabetical ordering, so 1, 12, 2, 22. * name_natural: The name of the file. This field is sorted using natural sort ordering, so 1, 2, 12, 22. * quotaBytesUsed: The number of storage quota bytes used by the file. * recency: The most recent timestamp from the file's date-time fields. * sharedWithMeTime: When the file was shared with the user, if applicable. * starred: Whether the user has starred the file. * viewedByMeTime: The last time the file was viewed by the user. Each key sorts ascending by default, but can be reversed with the desc modifier. Example usage: ?orderBy=folder,modifiedTime desc,name.

pageSize - The maximum number of files to return per page. Partial or empty result pages are possible even before the end of the files list has been reached. Value must be between "1" and "1000".

pageToken - The token for continuing a previous list request on the next page. This should be set to the value of nextPageToken from the previous response.

q - A query for filtering the file results. For supported syntax, see [Search for files and folders](/workspace/drive/api/guides/search-files).

spaces - A comma-separated list of spaces to query within the corpora. Supported values are drive and appDataFolder. For more information, see File organization.

supportsAllDrives - Whether the requesting application supports both My Drives and shared drives.

supportsTeamDrives - Deprecated: Use supportsAllDrives instead.

teamDriveId - Deprecated: Use driveId instead.

$fields - Selector specifying which fields to include in a partial response.

Completes with a FileList.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<FileList> list({
  core.String? corpora,
  core.String? corpus,
  core.String? driveId,
  core.bool? includeItemsFromAllDrives,
  core.String? includeLabels,
  core.String? includePermissionsForView,
  core.bool? includeTeamDriveItems,
  core.String? orderBy,
  core.int? pageSize,
  core.String? pageToken,
  core.String? q,
  core.String? spaces,
  core.bool? supportsAllDrives,
  core.bool? supportsTeamDrives,
  core.String? teamDriveId,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (corpora != null) 'corpora': [corpora],
    if (corpus != null) 'corpus': [corpus],
    if (driveId != null) 'driveId': [driveId],
    if (includeItemsFromAllDrives != null)
      'includeItemsFromAllDrives': ['${includeItemsFromAllDrives}'],
    if (includeLabels != null) 'includeLabels': [includeLabels],
    if (includePermissionsForView != null)
      'includePermissionsForView': [includePermissionsForView],
    if (includeTeamDriveItems != null)
      'includeTeamDriveItems': ['${includeTeamDriveItems}'],
    if (orderBy != null) 'orderBy': [orderBy],
    if (pageSize != null) 'pageSize': ['${pageSize}'],
    if (pageToken != null) 'pageToken': [pageToken],
    if (q != null) 'q': [q],
    if (spaces != null) 'spaces': [spaces],
    if (supportsAllDrives != null)
      'supportsAllDrives': ['${supportsAllDrives}'],
    if (supportsTeamDrives != null)
      'supportsTeamDrives': ['${supportsTeamDrives}'],
    if (teamDriveId != null) 'teamDriveId': [teamDriveId],
    if ($fields != null) 'fields': [$fields],
  };

  const url_ = 'files';

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return FileList.fromJson(response_ as core.Map<core.String, core.dynamic>);
}