IPWorks Cloud 2020 C++ Builder Edition

Questions / Feedback?

ListResources Method

Lists files and folders.

Syntax

void __fastcall ListResources();

Remarks

This method is used to list file and folders. Calling this method will fire the ResourceList event once for each resource, and will also populate the Resource* properties.

If there are still more resources available to list when this method returns, the ResourceMarker property will be populated. Continue to call this method until ResourceMarker is empty to accumulate all pages of results in the Resource* properties.

Listing Resources

By default, all files and folders in the scope specified by the ListResourcesScope property will be returned. The ListResourcesMode configuration setting can be used to specify that only files or only folders should be returned. Refer to the "Result Scopes" section, below, for more information about what the results for each scope are comprised of.

To simply list the children or parents of specific resources, use ListChildren or ListParents. To retrieve information about specific resources, use GetResourceInfo.

For more complex queries, refer to the Google Drive API documentation for information on how to construct a search query, then use the AddQueryParam method to add a query parameter named "q" to the QueryParam* properties before calling this method.

Result Scopes

There are a number of different search scopes which the results of this method can be drawn from, some of which are exclusive to shared drives.

When ListResources is called with ListResourcesScope set to the default of lrsUser (0), the results will consist of items that are in the current user's "My Drive" and "Shared with me" spaces.

If ListResourcesScope is set to lrsDomain (1), the results will instead consist of items which have been shared to the current user's domain, whether or not the user has actually accessed them.

(To clarify, items shared to a user's domain are only added to their "Shared with me" space once the user accesses them for the first time. So, items shared to a user's domain that they have not actually accessed before would not show up when ListResourcesScope is set to lrsUser (0), but would show up when it is set to lrsDomain (1).)

When ListResourcesScope is set to lrsSharedDrive (2), the SharedDrive property must be set to the resource Id of a shared drive, and the results of this method will consist only of items within that shared drive.

When ListResourcesScope is set to lrsAllDrives (3), the results will consist of anything in the user's "My Drive" and "Shared with me" spaces, and all items in all shared drives which the user is a member of.

Note: Under some circumstances, if a user is a member of many shared drives, using the lrsAllDrives (3) will not yield a complete set of results (even with paged results). This is a direct limitation of the Google Drive API, and the only solution is to use a narrower scope. When using the lrsAllDrives (3) scope, you should check the SearchIncomplete configuration setting after calling ListResources; it will return "True" if the result set is incomplete.

How Shared Drives Work

Shared drives are, more than anything else, very similar to a normal user account. Once this is understood, it becomes much easier to understand how shared drives fit into the overall Google Drive architecture.

Just like a real user, a shared drive itself owns the files in its storage space (this is why the permissions for members of a shared drive use the "file organizer" and "organizer" roles instead of the "owner" role). Also like a real user, a shared drive's files can be explicitly shared with other users (even if they aren't members of the shared drive), and with the overall domain.

The difference, of course, is that a shared drive has a defined set of members, all of which have access to everything in the shared drive (though with varying capabilities). Refer to UpdatePermissions, AddSharedDriveMember, UpdateSharedDriveMember, and RemoveSharedDriveMember for more information.

// ResourceList event handler.
googledrive.OnResourceList += (s, e) => {
  Console.WriteLine(e.Name);
};

// List all of the current user's resources.
googledrive.ListResourcesScope = GoogledriveListResourcesScopes.lrsUser;
do {
  googledrive.ListResources();

  for (int i = 0; i < googledrive.Resources.Count; i++) {
    // Process resources here.
  }
} while (!string.IsNullOrEmpty(googledrive.ResourceMarker));

// List all of the resources in the specified shared drive.
googledrive.SharedDrive = "wfsr789vusijfv";
googledrive.ListResourcesScope = GoogledriveListResourcesScopes.lrsSharedDrive;
do {
  googledrive.ListResources();

  for (int i = 0; i < googledrive.Resources.Count; i++) {
    // Process resources here.
  }
} while (!string.IsNullOrEmpty(googledrive.ResourceMarker));

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Cloud 2020 C++ Builder Edition - Version 20.0 [Build 8265]