Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Apps Script access Drive SDK API

Is there a way to use the Google Drive API's from Google Apps Script. I am aware of the DocsList Service, which allows you to look at folders and files , however what about all the other API's in Google Drive (Files,About,Changes,Children,Parents,Permissions,Revisions,Apps,Comments,Replies). For example, is there API access to add Comments to files from Google Apps Script.

like image 407
Brian Avatar asked Mar 20 '13 15:03

Brian


People also ask

Is there an API for Google Drive?

The Google Drive API allows you to create apps that leverage Google Drive cloud storage. You can develop applications that integrate with Drive, and create robust functionality in your application using the Drive API.


2 Answers

Apps Script has the ability to access Google API's, but you need to explicitly enable them before they can be used.

In the code editor, choose RESOURCES, ADVANCED GOOGLE SERVICES

Advanced Google Services

Click the OFF button, to turn the service ON.

Before you close the dialog box, click the link at the bottom to open up the API Manager.

API Manager

Once you've completed those two steps, the Drive API is available inside of Apps Script. Type the key word Drive then type a period, and available methods will show up in a list.

Methods

  • get - Gets a file's metadata by ID.
  • insert - Insert a new file.
  • patch - Updates file metadata. This method supports patch semantics.
  • update - Updates file metadata and/or content.
  • copy - Creates a copy of the specified file.
  • delete - Permanently deletes a file by ID. Skips the trash.
  • list - Lists the user's files.
  • touch - Set the file's updated time to the current server time.
  • trash - Moves a file to the trash
  • untrash - Restores a file from the trash.
  • watch - Start watching for changes to a file.
  • emptyTrash - Permanently deletes all of the user's trashed files.

https://developers.google.com/drive/v2/reference/files#methods

like image 74
Alan Wells Avatar answered Nov 15 '22 08:11

Alan Wells


(Google-Apps-Script=GAS) Drive Services added 2013.05.13 (to be announced at the 2013 Google I/O 2 days later) is apparently-exactly designed to replace the prior API(DocsList) and allow GAS to access the Google Drive SDK, though that functionality is currently not mentioned (why?) from those official docs but it is most certainly suggested by the new new API name "Drive" and is stated at as the purpose by Google's great demo video "Integrate Google Drive with Google Apps Script — Google I/O 2013" and "Drive SDK" is mentioned in by the search functions as searchFiles(String).

And Drive Services works (I'm using it; and though I could think of many improvements, haven't found any bugs of memory) including it works for useful apps (see the the video above for one of the most impressive ones I've seen) but it isn't complete (including doesn't expose the full Drive SDK) including:

  1. it doesn't (yet?) allow one to access prior versions of content (as that vide plus (the enhancement request: Google Search for "Issue 2811: Access the document revisions using DriveApp"),
  2. control the indexing status & method of content,
  3. one can't get a list of a file or folder's accessors (apparently deliberately says the video; but using the prior DocsList or Library mentioned seems like it would be a workaround).

I'd have included more links to help out but I'm a new poster here so the editor's telling me "You need at least 10 reputation to post more than 2 links.".

like image 20
Destiny Architect Avatar answered Nov 15 '22 07:11

Destiny Architect