Grouping ACL requests for Google Docs through the API is pretty slow

I am using version 3 (yes, I know there is a Google API) and I am trying to execute ACL requests as per here .

I ran a test on the google play area (as well as in my own code) to add 150 users as a β€œwriter” (role) to the document.

xml looks something like this:

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl="http://schemas.google.com/acl/2007" xmlns:batch="http://schemas.google.com/gdata/batch"> <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/acl/2007#accessRule"/> <entry> <id>https://docs.google.com/feeds/default/private/full/document:1111/acl/user: owner@example.com </id> <batch:operation type="query"/> </entry> <entry><batch:id>1</batch:id><batch:operation type="insert"/><gAcl:role value="writer"/><gAcl:scope type="user" value=" test1@example.com "/></entry> <entry><batch:id>2</batch:id><batch:operation type="insert"/><gAcl:role value="writer"/><gAcl:scope type="user" value=" test2@example.com "/></entry> .... <entry><batch:id>150</batch:id><batch:operation type="insert"/><gAcl:role value="writer"/><gAcl:scope type="user" value=" test150@example.com "/></entry> </feed> 

Processing takes about 60 seconds, and then the response returns with an error of 500. It seems to add all 150, but it takes time. If I immediately added 150 email addresses to the text area right in the google sharing dialog, it takes a shorter period (8-10).

Am I using the API incorrectly? Is the google sharing API compatible?

UPDATE: looking at this, it looks like the batch api really just saves you time β€œby wire,” but on the server side (google) it just sends requests one at a time. I see that if I directly add 150 email addresses in the text area right in the google sharing dialog, it will take 8-10 seconds, and then if I add 151 it will take 8-10 seconds. This tells me that Google is checking the new entry for an existing list. With direct online interaction, it takes all 150 at the same time; with a frequency that he takes one at a time and checks after each, which gives out up to 5 + minutes of total time.

+4
source share
1 answer

If you make these changes to a large number of files, and the list of added users is at least sometimes the same, you should consider adding users to the Google group. Then you can simply add the google group to the ACL file, significantly reducing the number of API calls and time.

So, if 2 files should be accessible to 150 users, using your current method will take the equivalent of 150 API calls (even if network traffic is loading). This results in approximately 300 API calls.

If 2 files are separated using the group method, sharing the 1st file will take 152 API calls (1 API call to provide the group, 150 API calls to add users as members and 1 API call to share the file with the group). But sharing the second file will only take 1 API call. This results in only 153 API calls.

You can also group your files in collections and share the collection instead of individual files to reduce the number of API calls needed.

The groupware API call is documented at: https://developers.google.com/google-apps/provisioning/#creating_a_group

The "Add Member to API Group" call is documented at: https://developers.google.com/google-apps/provisioning/#adding_a_member_to_a_group

0
source

Source: https://habr.com/ru/post/1446105/


All Articles