Google Apps Script Library for Google Drive API

The advanced Google Drive API offers access to functionality that is not available with the Drive API inside Google Apps Script. For instance, the Drive API offers Revisions that helps you monitor file changes. Google has published a library for the Drive API that makes it easy to use the API inside Google Scripts.

Spencer has published a wrapper library that makes it easy to use the advanced Google Drive API inside Google Apps Script.

/**
* Google Apps Script Library for the drive API
*
* Credit: +SpencerEaston 
* Source: https://drive.google.com/folderview?id=0B_j9_-NbJQQDcUNEckk2WGhETms 
* 
* OAuth2 Scopes
* https://www.googleapis.com/auth/drive
* https://www.googleapis.com/auth/drive.appdata
* https://www.googleapis.com/auth/drive.apps.readonly
* https://www.googleapis.com/auth/drive.file
* https://www.googleapis.com/auth/drive.metadata
* https://www.googleapis.com/auth/drive.metadata.readonly
* https://www.googleapis.com/auth/drive.photos.readonly
* https://www.googleapis.com/auth/drive.readonly
* https://www.googleapis.com/auth/drive.scripts
*/

var BASEURL_="https://www.googleapis.com/drive/v2/";
var tokenService_;

/*
* Stores the function passed that is invoked to get a OAuth2 token;
* @param {function} service The function used to get the OAuth2 token;
*
*/
function setTokenService(service){
  tokenService_ = service;
}

/*
* Returns an OAuth2 token from your TokenService as a test
* @return {string} An OAuth2 token
*
*/
function testTokenService(){
 return tokenService_();
}

/**
 * Performs a Fetch
 * @param {string} url The endpoint for the URL with parameters
 * @param {Object.<string, string>} options Options to override default fetch options
 * @returns {Object.<string,string>} the fetch results
 * @private
 */
function CALL_(path,options){
  var fetchOptions = {method:"",muteHttpExceptions:true, contentType:"application/json", headers:{Authorization:"Bearer "+tokenService_()}}
  var url = BASEURL_ + path;
  
  for(option in options){
    fetchOptions[option] = options[option];
  }
  
  var response = UrlFetchApp.fetch(url, fetchOptions)
  if(response.getResponseCode() != 200){
    throw new Error(response.getContentText())
  }else{
    return JSON.parse(response.getContentText());
  }
}

/**
 * Performs a Fetch and accumulation using pageToken parameter of the returned results
 * @param {string} url The endpoint for the URL with parameters
 * @param {Object.<string, string>} options Options to override default fetch options
 * @param {string} returnParamPath The path of the parameter to be accumulated
 * @returns {Array.Object.<string,string>} An array of objects
 * @private
 */
function CALLPAGE_(path,options, returnParamPath){
  var fetchOptions = {method:"",muteHttpExceptions:true, contentType:"application/json", headers:{Authorization:"Bearer "+tokenService_()}}
  for(option in options){
    fetchOptions[option] = options[option];
  }
  var url = BASEURL_ + path;
  var returnArray = [];
  var nextPageToken;
  do{
    if(nextPageToken){
      url += "?pageToken=" + nextPageToken;
    }
    var results = UrlFetchApp.fetch(url, fetchOptions);
    if(results.getResponseCode() != 200){
      throw new Error(results.getContentText());
    }else{
      var resp = JSON.parse(results.getContentText())
      nextPageToken = resp.nextPageToken;
      returnArray  = returnArray.concat(resp[returnParamPath])
    }
  }while(nextPageToken);
  return returnArray;
}

/**
 * Builds a complete URL from a base URL and a map of URL parameters.
 * @param {string} url The base URL.
 * @param {Object.<string, string>} params The URL parameters and values.
 * @returns {string} The complete URL.
 * @private
 */
function buildUrl_(url, params) {
  var params = params || {}; //allow for NULL options
  var paramString = Object.keys(params).map(function(key) {
    return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
  }).join('&');
  return url + (url.indexOf('?') >= 0 ? '&' : '?') + paramString;
}

/**
* Gets the information about the current user along with Drive API settings
*
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned AboutResource object
*/
function aboutGet(options){
  var path = buildUrl_("about",options);
  var callOptions = {method:"GET"};
  var AboutResource = CALL_(path,callOptions);
  return AboutResource;
}

/**
* Gets a specific app.
*
* @param {string} appId The ID of the app.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned AppResource object
*/
function appsGet(appId,options){
  var path = buildUrl_("apps/"+appId,options);
  var callOptions = {method:"GET"};
  var AppResource = CALL_(path,callOptions);
  return AppResource;
}

/**
* Lists a user's installed apps.
*
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned AppListResource object
*/
function appsList(options){
  var path = buildUrl_("apps",options);
  var callOptions = {method:"GET"};
  var AppListResource = CALL_(path,callOptions);
  return AppListResource;
}

/**
* Gets a specific change.
*
* @param {string} changeId The ID of the change.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned ChangeResource object
*/
function changesGet(changeId,options){
  var path = buildUrl_("changes/"+changeId,options);
  var callOptions = {method:"GET"};
  var ChangeResource = CALL_(path,callOptions);
  return ChangeResource;
}

/**
* Lists the changes for a user.
*
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned ChangeListResource object
*/
function changesList(options){
  var path = buildUrl_("changes",options);
  var callOptions = {method:"GET"};
  var ChangeListItems = CALLPAGE_(path,callOptions,"items");
  return ChangeListItems;
}

/**
* Subscribe to changes for a user.
*
* @param {object} ChannelResource An object containing the ChannelResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned ChannelResource object
*/
function changesWatch(ChannelResource,options){
  var path = buildUrl_("changes/watch",options);
  var callOptions = {method:"POST",payload:JSON.stringify(ChannelResource)};
  var ChannelItems = CALLPAGE_(path,callOptions,"items");
  return ChannelItems;
}

/**
* Stop watching resources through this channel
*
* @param {object} ChannelResource An object containing the ChannelResource for this method
* @param {object} options Keypair of all optional parameters for this call
*/
function channelsStop(ChannelResource,options){
  var path = buildUrl_("channels/stop",options);
  var callOptions = {method:"POST",payload:JSON.stringify(ChannelResource)};
  var removeResource = CALL_(path,callOptions);
  return removeResource;
}

/**
* Removes a child from a folder.
*
* @param {string} folderId The ID of the folder.
* @param {string} childId The ID of the child.
* @param {object} options Keypair of all optional parameters for this call
*/
function childrenDelete(folderId,childId,options){
  var path = buildUrl_("files/"+folderId+"/children/"+childId,options);
  var callOptions = {method:"DELETE"};
  var removeResource = CALL_(path,callOptions);
  return removeResource;
}

/**
* Gets a specific child reference.
*
* @param {string} folderId The ID of the folder.
* @param {string} childId The ID of the child.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned ChildReferenceResource object
*/
function childrenGet(folderId,childId,options){
  var path = buildUrl_("files/"+folderId+"/children/"+childId,options);
  var callOptions = {method:"GET"};
  var ChildReferenceResource = CALL_(path,callOptions);
  return ChildReferenceResource;
}

/**
* Inserts a file into a folder.
*
* @param {string} folderId The ID of the folder.
* @param {object} ChildReferenceResource An object containing the ChildReferenceResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned ChildReferenceResource object
*/
function childrenInsert(folderId,ChildReferenceResource,options){
  var path = buildUrl_("files/"+folderId+"/children",options);
  var callOptions = {method:"POST",payload:JSON.stringify(ChildReferenceResource)};
  var ChildReferenceResource = CALL_(path,callOptions);
  return ChildReferenceResource;
}

/**
* Lists a folder's children.
*
* @param {string} folderId The ID of the folder.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned ChildListResource object
*/
function childrenList(folderId,options){
  var path = buildUrl_("files/"+folderId+"/children",options);
  var callOptions = {method:"GET"};
  var ChildListItems = CALLPAGE_(path,callOptions,"items");
  return ChildListItems;
}

/**
* Deletes a comment.
*
* @param {string} fileId The ID of the file.
* @param {string} commentId The ID of the comment.
* @param {object} options Keypair of all optional parameters for this call
*/
function commentsDelete(fileId,commentId,options){
  var path = buildUrl_("files/"+fileId+"/comments/"+commentId,options);
  var callOptions = {method:"DELETE"};
  var removeResource = CALL_(path,callOptions);
  return removeResource;
}

/**
* Gets a comment by ID.
*
* @param {string} fileId The ID of the file.
* @param {string} commentId The ID of the comment.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned CommentResource object
*/
function commentsGet(fileId,commentId,options){
  var path = buildUrl_("files/"+fileId+"/comments/"+commentId,options);
  var callOptions = {method:"GET"};
  var CommentResource = CALL_(path,callOptions);
  return CommentResource;
}

/**
* Creates a new comment on the given file.
*
* @param {string} fileId The ID of the file.
* @param {object} CommentResource An object containing the CommentResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned CommentResource object
*/
function commentsInsert(fileId,CommentResource,options){
  var path = buildUrl_("files/"+fileId+"/comments",options);
  var callOptions = {method:"POST",payload:JSON.stringify(CommentResource)};
  var CommentResource = CALL_(path,callOptions);
  return CommentResource;
}

/**
* Lists a file's comments.
*
* @param {string} fileId The ID of the file.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned CommentListResource object
*/
function commentsList(fileId,options){
  var path = buildUrl_("files/"+fileId+"/comments",options);
  var callOptions = {method:"GET"};
  var CommentListItems = CALLPAGE_(path,callOptions,"items");
  return CommentListItems;
}

/**
* Updates an existing comment. This method supports patch semantics.
*
* @param {string} fileId The ID of the file.
* @param {string} commentId The ID of the comment.
* @param {object} CommentResource An object containing the CommentResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned CommentResource object
*/
function commentsPatch(fileId,commentId,CommentResource,options){
  var path = buildUrl_("files/"+fileId+"/comments/"+commentId,options);
  var callOptions = {method:"PATCH",payload:JSON.stringify(CommentResource)};
  var CommentResource = CALL_(path,callOptions);
  return CommentResource;
}

/**
* Updates an existing comment.
*
* @param {string} fileId The ID of the file.
* @param {string} commentId The ID of the comment.
* @param {object} CommentResource An object containing the CommentResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned CommentResource object
*/
function commentsUpdate(fileId,commentId,CommentResource,options){
  var path = buildUrl_("files/"+fileId+"/comments/"+commentId,options);
  var callOptions = {method:"PUT",payload:JSON.stringify(CommentResource)};
  var CommentResource = CALL_(path,callOptions);
  return CommentResource;
}

/**
* Creates a copy of the specified file.
*
* @param {string} fileId The ID of the file to copy.
* @param {object} FileResource An object containing the FileResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned FileResource object
*/
function filesCopy(fileId,FileResource,options){
  var path = buildUrl_("files/"+fileId+"/copy",options);
  var callOptions = {method:"POST",payload:JSON.stringify(FileResource)};
  var FileResource = CALL_(path,callOptions);
  return FileResource;
}

/**
* Permanently deletes a file by ID. Skips the trash. The currently authenticated user must own the file.
*
* @param {string} fileId The ID of the file to delete.
* @param {object} options Keypair of all optional parameters for this call
*/
function filesDelete(fileId,options){
  var path = buildUrl_("files/"+fileId,options);
  var callOptions = {method:"DELETE"};
  var removeResource = CALL_(path,callOptions);
  return removeResource;
}

/**
* Permanently deletes all of the user's trashed files.
*
* @param {object} options Keypair of all optional parameters for this call
*/
function filesEmptyTrash(options){
  var path = buildUrl_("files/trash",options);
  var callOptions = {method:"DELETE"};
  var removeResource = CALL_(path,callOptions);
  return removeResource;
}

/**
* Generates a set of file IDs which can be provided in insert requests.
*
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned GeneratedIdsResource object
*/
function filesGenerateIds(options){
  var path = buildUrl_("files/generateIds",options);
  var callOptions = {method:"GET"};
  var GeneratedIdsResource = CALL_(path,callOptions);
  return GeneratedIdsResource;
}

/**
* Gets a file's metadata by ID.
*
* @param {string} fileId The ID for the file in question.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned FileResource object
*/
function filesGet(fileId,options){
  var path = buildUrl_("files/"+fileId,options);
  var callOptions = {method:"GET"};
  var FileResource = CALL_(path,callOptions);
  return FileResource;
}

/**
* Insert a new file.
*
* @param {object} FileResource An object containing the FileResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned FileResource object
*/
function filesInsert(FileResource,options){
  var path = buildUrl_("files",options);
  var callOptions = {method:"POST",payload:JSON.stringify(FileResource)};
  var FileResource = CALL_(path,callOptions);
  return FileResource;
}

/**
* Lists the user's files.
*
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned FileListResource object
*/
function filesList(options){
  var path = buildUrl_("files",options);
  var callOptions = {method:"GET"};
  var FileListItems = CALLPAGE_(path,callOptions,"items");
  return FileListItems;
}

/**
* Updates file metadata and/or content. This method supports patch semantics.
*
* @param {string} fileId The ID of the file to update.
* @param {object} FileResource An object containing the FileResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned FileResource object
*/
function filesPatch(fileId,FileResource,options){
  var path = buildUrl_("files/"+fileId,options);
  var callOptions = {method:"PATCH",payload:JSON.stringify(FileResource)};
  var FileResource = CALL_(path,callOptions);
  return FileResource;
}

/**
* Set the file's updated time to the current server time.
*
* @param {string} fileId The ID of the file to update.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned FileResource object
*/
function filesTouch(fileId,options){
  var path = buildUrl_("files/"+fileId+"/touch",options);
  var callOptions = {method:"POST"};
  var FileResource = CALL_(path,callOptions);
  return FileResource;
}

/**
* Moves a file to the trash. The currently authenticated user must own the file.
*
* @param {string} fileId The ID of the file to trash.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned FileResource object
*/
function filesTrash(fileId,options){
  var path = buildUrl_("files/"+fileId+"/trash",options);
  var callOptions = {method:"POST"};
  var FileResource = CALL_(path,callOptions);
  return FileResource;
}

/**
* Restores a file from the trash.
*
* @param {string} fileId The ID of the file to untrash.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned FileResource object
*/
function filesUntrash(fileId,options){
  var path = buildUrl_("files/"+fileId+"/untrash",options);
  var callOptions = {method:"POST"};
  var FileResource = CALL_(path,callOptions);
  return FileResource;
}

/**
* Updates file metadata and/or content.
*
* @param {string} fileId The ID of the file to update.
* @param {object} FileResource An object containing the FileResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned FileResource object
*/
function filesUpdate(fileId,FileResource,options){
  var path = buildUrl_("files/"+fileId,options);
  var callOptions = {method:"PUT",payload:JSON.stringify(FileResource)};
  var FileResource = CALL_(path,callOptions);
  return FileResource;
}

/**
* Subscribe to changes on a file
*
* @param {string} fileId The ID for the file in question.
* @param {object} ChannelResource An object containing the ChannelResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned ChannelResource object
*/
function filesWatch(fileId,ChannelResource,options){
  var path = buildUrl_("files/"+fileId+"/watch",options);
  var callOptions = {method:"POST",payload:JSON.stringify(ChannelResource)};
  var ChannelResource = CALL_(path,callOptions);
  return ChannelResource;
}

/**
* Removes a parent from a file.
*
* @param {string} fileId The ID of the file.
* @param {string} parentId The ID of the parent.
* @param {object} options Keypair of all optional parameters for this call
*/
function parentsDelete(fileId,parentId,options){
  var path = buildUrl_("files/"+fileId+"/parents/"+parentId,options);
  var callOptions = {method:"DELETE"};
  var removeResource = CALL_(path,callOptions);
  return removeResource;
}

/**
* Gets a specific parent reference.
*
* @param {string} fileId The ID of the file.
* @param {string} parentId The ID of the parent.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned ParentReferenceResource object
*/
function parentsGet(fileId,parentId,options){
  var path = buildUrl_("files/"+fileId+"/parents/"+parentId,options);
  var callOptions = {method:"GET"};
  var ParentReferenceResource = CALL_(path,callOptions);
  return ParentReferenceResource;
}

/**
* Adds a parent folder for a file.
*
* @param {string} fileId The ID of the file.
* @param {object} ParentReferenceResource An object containing the ParentReferenceResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned ParentReferenceResource object
*/
function parentsInsert(fileId,ParentReferenceResource,options){
  var path = buildUrl_("files/"+fileId+"/parents",options);
  var callOptions = {method:"POST",payload:JSON.stringify(ParentReferenceResource)};
  var ParentReferenceResource = CALL_(path,callOptions);
  return ParentReferenceResource;
}

/**
* Lists a file's parents.
*
* @param {string} fileId The ID of the file.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned ParentListResource object
*/
function parentsList(fileId,options){
  var path = buildUrl_("files/"+fileId+"/parents",options);
  var callOptions = {method:"GET"};
  var ParentListResource = CALL_(path,callOptions);
  return ParentListResource;
}

/**
* Deletes a permission from a file.
*
* @param {string} fileId The ID for the file.
* @param {string} permissionId The ID for the permission.
* @param {object} options Keypair of all optional parameters for this call
*/
function permissionsDelete(fileId,permissionId,options){
  var path = buildUrl_("files/"+fileId+"/permissions/"+permissionId,options);
  var callOptions = {method:"DELETE"};
  var removeResource = CALL_(path,callOptions);
  return removeResource;
}

/**
* Gets a permission by ID.
*
* @param {string} fileId The ID for the file.
* @param {string} permissionId The ID for the permission.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned PermissionResource object
*/
function permissionsGet(fileId,permissionId,options){
  var path = buildUrl_("files/"+fileId+"/permissions/"+permissionId,options);
  var callOptions = {method:"GET"};
  var PermissionResource = CALL_(path,callOptions);
  return PermissionResource;
}

/**
* Returns the permission ID for an email address.
*
* @param {string} email The email address for which to return a permission ID
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned PermissionIdResource object
*/
function permissionsGetIdForEmail(email,options){
  var path = buildUrl_("permissionIds/"+email,options);
  var callOptions = {method:"GET"};
  var PermissionIdResource = CALL_(path,callOptions);
  return PermissionIdResource;
}

/**
* Inserts a permission for a file.
*
* @param {string} fileId The ID for the file.
* @param {object} PermissionResource An object containing the PermissionResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned PermissionResource object
*/
function permissionsInsert(fileId,PermissionResource,options){
  var path = buildUrl_("files/"+fileId+"/permissions",options);
  var callOptions = {method:"POST",payload:JSON.stringify(PermissionResource)};
  var PermissionResource = CALL_(path,callOptions);
  return PermissionResource;
}

/**
* Lists a file's permissions.
*
* @param {string} fileId The ID for the file.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned PermissionListResource object
*/
function permissionsList(fileId,options){
  var path = buildUrl_("files/"+fileId+"/permissions",options);
  var callOptions = {method:"GET"};
  var PermissionListResource = CALL_(path,callOptions);
  return PermissionListResource;
}

/**
* Updates a permission using patch semantics.
*
* @param {string} fileId The ID for the file.
* @param {string} permissionId The ID for the permission.
* @param {object} PermissionResource An object containing the PermissionResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned PermissionResource object
*/
function permissionsPatch(fileId,permissionId,PermissionResource,options){
  var path = buildUrl_("files/"+fileId+"/permissions/"+permissionId,options);
  var callOptions = {method:"PATCH",payload:JSON.stringify(PermissionResource)};
  var PermissionResource = CALL_(path,callOptions);
  return PermissionResource;
}

/**
* Updates a permission.
*
* @param {string} fileId The ID for the file.
* @param {string} permissionId The ID for the permission.
* @param {object} PermissionResource An object containing the PermissionResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned PermissionResource object
*/
function permissionsUpdate(fileId,permissionId,PermissionResource,options){
  var path = buildUrl_("files/"+fileId+"/permissions/"+permissionId,options);
  var callOptions = {method:"PUT",payload:JSON.stringify(PermissionResource)};
  var PermissionResource = CALL_(path,callOptions);
  return PermissionResource;
}

/**
* Deletes a property.
*
* @param {string} fileId The ID of the file.
* @param {string} propertyKey The key of the property.
* @param {object} options Keypair of all optional parameters for this call
*/
function propertiesDelete(fileId,propertyKey,options){
  var path = buildUrl_("files/"+fileId+"/properties/"+propertyKey,options);
  var callOptions = {method:"DELETE"};
  var removeResource = CALL_(path,callOptions);
  return removeResource;
}

/**
* Gets a property by its key.
*
* @param {string} fileId The ID of the file.
* @param {string} propertyKey The key of the property.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned PropertyResource object
*/
function propertiesGet(fileId,propertyKey,options){
  var path = buildUrl_("files/"+fileId+"/properties/"+propertyKey,options);
  var callOptions = {method:"GET"};
  var PropertyResource = CALL_(path,callOptions);
  return PropertyResource;
}

/**
* Adds a property to a file.
*
* @param {string} fileId The ID of the file.
* @param {object} PropertyResource An object containing the PropertyResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned PropertyResource object
*/
function propertiesInsert(fileId,PropertyResource,options){
  var path = buildUrl_("files/"+fileId+"/properties",options);
  var callOptions = {method:"POST",payload:JSON.stringify(PropertyResource)};
  var PropertyResource = CALL_(path,callOptions);
  return PropertyResource;
}

/**
* Lists a file's properties.
*
* @param {string} fileId The ID of the file.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned PropertyListResource object
*/
function propertiesList(fileId,options){
  var path = buildUrl_("files/"+fileId+"/properties",options);
  var callOptions = {method:"GET"};
  var PropertyListResource = CALL_(path,callOptions);
  return PropertyListResource;
}

/**
* Updates a property. This method supports patch semantics.
*
* @param {string} fileId The ID of the file.
* @param {string} propertyKey The key of the property.
* @param {object} PropertyResource An object containing the PropertyResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned PropertyResource object
*/
function propertiesPatch(fileId,propertyKey,PropertyResource,options){
  var path = buildUrl_("files/"+fileId+"/properties/"+propertyKey,options);
  var callOptions = {method:"PATCH",payload:JSON.stringify(PropertyResource)};
  var PropertyResource = CALL_(path,callOptions);
  return PropertyResource;
}

/**
* Updates a property.
*
* @param {string} fileId The ID of the file.
* @param {string} propertyKey The key of the property.
* @param {object} PropertyResource An object containing the PropertyResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned PropertyResource object
*/
function propertiesUpdate(fileId,propertyKey,PropertyResource,options){
  var path = buildUrl_("files/"+fileId+"/properties/"+propertyKey,options);
  var callOptions = {method:"PUT",payload:JSON.stringify(PropertyResource)};
  var PropertyResource = CALL_(path,callOptions);
  return PropertyResource;
}

/**
* Exports the contents of the Realtime API data model associated with this file as JSON.
*
* @param {string} fileId The ID of the file that the Realtime API data model is associated with.
* @param {object} options Keypair of all optional parameters for this call
*/
function realtimeGet(fileId,options){
  var path = buildUrl_("files/"+fileId+"/realtime",options);
  var callOptions = {method:"GET"};
  var removeResource = CALL_(path,callOptions);
  return removeResource;
}

/**
* Overwrites the Realtime API data model associated with this file with the provided JSON data model.
*
* @param {string} fileId The ID of the file that the Realtime API data model is associated with.
* @param {object} options Keypair of all optional parameters for this call
*/
function realtimeUpdate(fileId,options){
  var path = buildUrl_("files/"+fileId+"/realtime",options);
  var callOptions = {method:"PUT"};
  var removeResource = CALL_(path,callOptions);
  return removeResource;
}

/**
* Deletes a reply.
*
* @param {string} fileId The ID of the file.
* @param {string} commentId The ID of the comment.
* @param {string} replyId The ID of the reply.
* @param {object} options Keypair of all optional parameters for this call
*/
function repliesDelete(fileId,commentId,replyId,options){
  var path = buildUrl_("files/"+fileId+"/comments/"+commentId+"/replies/"+replyId,options);
  var callOptions = {method:"DELETE"};
  var removeResource = CALL_(path,callOptions);
  return removeResource;
}

/**
* Gets a reply.
*
* @param {string} fileId The ID of the file.
* @param {string} commentId The ID of the comment.
* @param {string} replyId The ID of the reply.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned CommentReplyResource object
*/
function repliesGet(fileId,commentId,replyId,options){
  var path = buildUrl_("files/"+fileId+"/comments/"+commentId+"/replies/"+replyId,options);
  var callOptions = {method:"GET"};
  var CommentReplyResource = CALL_(path,callOptions);
  return CommentReplyResource;
}

/**
* Creates a new reply to the given comment.
*
* @param {string} fileId The ID of the file.
* @param {string} commentId The ID of the comment.
* @param {object} CommentReplyResource An object containing the CommentReplyResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned CommentReplyResource object
*/
function repliesInsert(fileId,commentId,CommentReplyResource,options){
  var path = buildUrl_("files/"+fileId+"/comments/"+commentId+"/replies",options);
  var callOptions = {method:"POST",payload:JSON.stringify(CommentReplyResource)};
  var CommentReplyResource = CALL_(path,callOptions);
  return CommentReplyResource;
}

/**
* Lists all of the replies to a comment.
*
* @param {string} fileId The ID of the file.
* @param {string} commentId The ID of the comment.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned CommentReplyListResource object
*/
function repliesList(fileId,commentId,options){
  var path = buildUrl_("files/"+fileId+"/comments/"+commentId+"/replies",options);
  var callOptions = {method:"GET"};
  var CommentReplyListItems = CALLPAGE_(path,callOptions,"items");
  return CommentReplyListItems;
}

/**
* Updates an existing reply. This method supports patch semantics.
*
* @param {string} fileId The ID of the file.
* @param {string} commentId The ID of the comment.
* @param {string} replyId The ID of the reply.
* @param {object} CommentReplyResource An object containing the CommentReplyResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned CommentReplyResource object
*/
function repliesPatch(fileId,commentId,replyId,CommentReplyResource,options){
  var path = buildUrl_("files/"+fileId+"/comments/"+commentId+"/replies/"+replyId,options);
  var callOptions = {method:"PATCH",payload:JSON.stringify(CommentReplyResource)};
  var CommentReplyResource = CALL_(path,callOptions);
  return CommentReplyResource;
}

/**
* Updates an existing reply.
*
* @param {string} fileId The ID of the file.
* @param {string} commentId The ID of the comment.
* @param {string} replyId The ID of the reply.
* @param {object} CommentReplyResource An object containing the CommentReplyResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned CommentReplyResource object
*/
function repliesUpdate(fileId,commentId,replyId,CommentReplyResource,options){
  var path = buildUrl_("files/"+fileId+"/comments/"+commentId+"/replies/"+replyId,options);
  var callOptions = {method:"PUT",payload:JSON.stringify(CommentReplyResource)};
  var CommentReplyResource = CALL_(path,callOptions);
  return CommentReplyResource;
}

/**
* Removes a revision.
*
* @param {string} fileId The ID of the file.
* @param {string} revisionId The ID of the revision.
* @param {object} options Keypair of all optional parameters for this call
*/
function revisionsDelete(fileId,revisionId,options){
  var path = buildUrl_("files/"+fileId+"/revisions/"+revisionId,options);
  var callOptions = {method:"DELETE"};
  var removeResource = CALL_(path,callOptions);
  return removeResource;
}

/**
* Gets a specific revision.
*
* @param {string} fileId The ID of the file.
* @param {string} revisionId The ID of the revision.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned RevisionResource object
*/
function revisionsGet(fileId,revisionId,options){
  var path = buildUrl_("files/"+fileId+"/revisions/"+revisionId,options);
  var callOptions = {method:"GET"};
  var RevisionResource = CALL_(path,callOptions);
  return RevisionResource;
}

/**
* Lists a file's revisions.
*
* @param {string} fileId The ID of the file.
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned RevisionListResource object
*/
function revisionsList(fileId,options){
  var path = buildUrl_("files/"+fileId+"/revisions",options);
  var callOptions = {method:"GET"};
  var RevisionListResource = CALL_(path,callOptions);
  return RevisionListResource;
}

/**
* Updates a revision. This method supports patch semantics.
*
* @param {string} fileId The ID for the file.
* @param {string} revisionId The ID for the revision.
* @param {object} RevisionResource An object containing the RevisionResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned RevisionResource object
*/
function revisionsPatch(fileId,revisionId,RevisionResource,options){
  var path = buildUrl_("files/"+fileId+"/revisions/"+revisionId,options);
  var callOptions = {method:"PATCH",payload:JSON.stringify(RevisionResource)};
  var RevisionResource = CALL_(path,callOptions);
  return RevisionResource;
}

/**
* Updates a revision.
*
* @param {string} fileId The ID for the file.
* @param {string} revisionId The ID for the revision.
* @param {object} RevisionResource An object containing the RevisionResource for this method
* @param {object} options Keypair of all optional parameters for this call
* @return {object} The returned RevisionResource object
*/
function revisionsUpdate(fileId,revisionId,RevisionResource,options){
  var path = buildUrl_("files/"+fileId+"/revisions/"+revisionId,options);
  var callOptions = {method:"PUT",payload:JSON.stringify(RevisionResource)};
  var RevisionResource = CALL_(path,callOptions);
  return RevisionResource;
}