1

I'm attempting to set multiple ACLs in one batch request from appengine (JAVA). I am not sure what the URL should be for making the request. The documentation states "/batch". Are there anymore examples available? AFAIK this is not possible to test from the API explorer.

Patrick Jackson
  • 18,766
  • 22
  • 81
  • 141
  • You're right, the APIs Explorer does not currently support batch requests, which makes this a bit more difficult to try out. I would suggest using the Java client library for Cloud Storage, which supports batch requests. https://code.google.com/p/google-api-java-client/wiki/Batch + https://code.google.com/p/google-api-java-client/wiki/APIs#Cloud_Storage_API – Jason Hall Nov 30 '12 at 21:35

1 Answers1

6

Using the google-api-java-client library and the Storage JSON API, a batch request would look like this:

// Create the Storage service object
Storage storage = new Storage(httpTransport, jsonFactory, credential);

// Create a new batch request
BatchRequest batch = storage.batch();

// Add some requests to the batch request
storage.objectAccessControls().insert("bucket-name", "object-key1",
    new ObjectAccessControl().setEntity("user-123423423").setRole("READER"))
    .queue(batch, callback);
storage.objectAccessControls().insert("bucket-name", "object-key2",
    new ObjectAccessControl().setEntity("user-guy@example.com").setRole("READER"))
    .queue(batch, callback);
storage.objectAccessControls().insert("bucket-name", "object-key3",
    new ObjectAccessControl().setEntity("group-foo@googlegroups.com").setRole("OWNER"))
    .queue(batch, callback);

// Execute the batch request. The individual callbacks will be called when requests finish.
batch.execute();

Note that you'll have to request access to the Storage JSON API at the moment, as it's in limited beta.

Relevant API documentation is here: https://developers.google.com/storage/docs/json_api/v1/objectAccessControls

Documentation about batch requests in the Java client library: https://code.google.com/p/google-api-java-client/wiki/Batch

JavaDoc for the Storage Java client library: https://google-api-client-libraries.appspot.com/documentation/storage/v1beta1/java/latest/index.html

Brandon Yarbrough
  • 37,021
  • 23
  • 116
  • 145
Jason Hall
  • 20,632
  • 4
  • 50
  • 57
  • 1
    One caveat: If you are using the same resource (bucket or object) and making several batch ACL edit (insert/update) requests against it, you will cause contention on that resource, as batch requests all happen in parallel. If you need to do that, until such time as we can address that issue, you can edit the acl property of the resource itself, which is a list of these ACLs. – Nathan Herring Dec 20 '12 at 20:16