Update google drive API typing

This commit is contained in:
Alex Cason 2018-03-27 14:52:06 +01:00
parent 10148d8d11
commit ecd09a22a9
3 changed files with 111 additions and 61 deletions

View File

@ -43,15 +43,15 @@ gapi.load('client', () => {
async function run() {
/** Gets information about the user, the user's Drive, and system capabilities. */
await gapi.client.about.get({
await gapi.client.drive.about.get({
});
/** Gets the starting pageToken for listing future changes. */
await gapi.client.changes.getStartPageToken({
await gapi.client.drive.changes.getStartPageToken({
supportsTeamDrives: true,
teamDriveId: "teamDriveId",
});
/** Lists the changes for a user or Team Drive. */
await gapi.client.changes.list({
await gapi.client.drive.changes.list({
includeCorpusRemovals: true,
includeRemoved: true,
includeTeamDriveItems: true,
@ -63,7 +63,7 @@ gapi.load('client', () => {
teamDriveId: "teamDriveId",
});
/** Subscribes to changes for a user. */
await gapi.client.changes.watch({
await gapi.client.drive.changes.watch({
includeCorpusRemovals: true,
includeRemoved: true,
includeTeamDriveItems: true,
@ -75,25 +75,25 @@ gapi.load('client', () => {
teamDriveId: "teamDriveId",
});
/** Stop watching resources through this channel */
await gapi.client.channels.stop({
await gapi.client.drive.channels.stop({
});
/** Creates a new comment on a file. */
await gapi.client.comments.create({
await gapi.client.drive.comments.create({
fileId: "fileId",
});
/** Deletes a comment. */
await gapi.client.comments.delete({
await gapi.client.drive.comments.delete({
commentId: "commentId",
fileId: "fileId",
});
/** Gets a comment by ID. */
await gapi.client.comments.get({
await gapi.client.drive.comments.get({
commentId: "commentId",
fileId: "fileId",
includeDeleted: true,
});
/** Lists a file's comments. */
await gapi.client.comments.list({
await gapi.client.drive.comments.list({
fileId: "fileId",
includeDeleted: true,
pageSize: 3,
@ -101,12 +101,12 @@ gapi.load('client', () => {
startModifiedTime: "startModifiedTime",
});
/** Updates a comment with patch semantics. */
await gapi.client.comments.update({
await gapi.client.drive.comments.update({
commentId: "commentId",
fileId: "fileId",
});
/** Creates a copy of a file and applies any requested updates with patch semantics. */
await gapi.client.files.copy({
await gapi.client.drive.files.copy({
fileId: "fileId",
ignoreDefaultVisibility: true,
keepRevisionForever: true,
@ -114,7 +114,7 @@ gapi.load('client', () => {
supportsTeamDrives: true,
});
/** Creates a new file. */
await gapi.client.files.create({
await gapi.client.drive.files.create({
ignoreDefaultVisibility: true,
keepRevisionForever: true,
ocrLanguage: "ocrLanguage",
@ -125,31 +125,31 @@ gapi.load('client', () => {
* Permanently deletes a file owned by the user without moving it to the trash. If the file belongs to a Team Drive the user must be an organizer on the
* parent. If the target is a folder, all descendants owned by the user are also deleted.
*/
await gapi.client.files.delete({
await gapi.client.drive.files.delete({
fileId: "fileId",
supportsTeamDrives: true,
});
/** Permanently deletes all of the user's trashed files. */
await gapi.client.files.emptyTrash({
await gapi.client.drive.files.emptyTrash({
});
/** Exports a Google Doc to the requested MIME type and returns the exported content. Please note that the exported content is limited to 10MB. */
await gapi.client.files.export({
await gapi.client.drive.files.export({
fileId: "fileId",
mimeType: "mimeType",
});
/** Generates a set of file IDs which can be provided in create requests. */
await gapi.client.files.generateIds({
await gapi.client.drive.files.generateIds({
count: 1,
space: "space",
});
/** Gets a file's metadata or content by ID. */
await gapi.client.files.get({
await gapi.client.drive.files.get({
acknowledgeAbuse: true,
fileId: "fileId",
supportsTeamDrives: true,
});
/** Lists or searches files. */
await gapi.client.files.list({
await gapi.client.drive.files.list({
corpora: "corpora",
corpus: "corpus",
includeTeamDriveItems: true,
@ -162,7 +162,7 @@ gapi.load('client', () => {
teamDriveId: "teamDriveId",
});
/** Updates a file's metadata and/or content with patch semantics. */
await gapi.client.files.update({
await gapi.client.drive.files.update({
addParents: "addParents",
fileId: "fileId",
keepRevisionForever: true,
@ -172,66 +172,71 @@ gapi.load('client', () => {
useContentAsIndexableText: true,
});
/** Subscribes to changes to a file */
await gapi.client.files.watch({
await gapi.client.drive.files.watch({
acknowledgeAbuse: true,
fileId: "fileId",
supportsTeamDrives: true,
});
/** Creates a permission for a file or Team Drive. */
await gapi.client.permissions.create({
await gapi.client.drive.permissions.create({
emailMessage: "emailMessage",
fileId: "fileId",
sendNotificationEmail: true,
supportsTeamDrives: true,
transferOwnership: true,
useDomainAdminAccess: true,
});
/** Deletes a permission. */
await gapi.client.permissions.delete({
await gapi.client.drive.permissions.delete({
fileId: "fileId",
permissionId: "permissionId",
supportsTeamDrives: true,
useDomainAdminAccess: true,
});
/** Gets a permission by ID. */
await gapi.client.permissions.get({
await gapi.client.drive.permissions.get({
fileId: "fileId",
permissionId: "permissionId",
supportsTeamDrives: true,
useDomainAdminAccess: true,
});
/** Lists a file's or Team Drive's permissions. */
await gapi.client.permissions.list({
await gapi.client.drive.permissions.list({
fileId: "fileId",
pageSize: 2,
pageToken: "pageToken",
supportsTeamDrives: true,
useDomainAdminAccess: true,
});
/** Updates a permission with patch semantics. */
await gapi.client.permissions.update({
await gapi.client.drive.permissions.update({
fileId: "fileId",
permissionId: "permissionId",
removeExpiration: true,
supportsTeamDrives: true,
transferOwnership: true,
useDomainAdminAccess: true,
});
/** Creates a new reply to a comment. */
await gapi.client.replies.create({
await gapi.client.drive.replies.create({
commentId: "commentId",
fileId: "fileId",
});
/** Deletes a reply. */
await gapi.client.replies.delete({
await gapi.client.drive.replies.delete({
commentId: "commentId",
fileId: "fileId",
replyId: "replyId",
});
/** Gets a reply by ID. */
await gapi.client.replies.get({
await gapi.client.drive.replies.get({
commentId: "commentId",
fileId: "fileId",
includeDeleted: true,
replyId: "replyId",
});
/** Lists a comment's replies. */
await gapi.client.replies.list({
await gapi.client.drive.replies.list({
commentId: "commentId",
fileId: "fileId",
includeDeleted: true,
@ -239,52 +244,55 @@ gapi.load('client', () => {
pageToken: "pageToken",
});
/** Updates a reply with patch semantics. */
await gapi.client.replies.update({
await gapi.client.drive.replies.update({
commentId: "commentId",
fileId: "fileId",
replyId: "replyId",
});
/** Permanently deletes a revision. This method is only applicable to files with binary content in Drive. */
await gapi.client.revisions.delete({
await gapi.client.drive.revisions.delete({
fileId: "fileId",
revisionId: "revisionId",
});
/** Gets a revision's metadata or content by ID. */
await gapi.client.revisions.get({
await gapi.client.drive.revisions.get({
acknowledgeAbuse: true,
fileId: "fileId",
revisionId: "revisionId",
});
/** Lists a file's revisions. */
await gapi.client.revisions.list({
await gapi.client.drive.revisions.list({
fileId: "fileId",
pageSize: 2,
pageToken: "pageToken",
});
/** Updates a revision with patch semantics. */
await gapi.client.revisions.update({
await gapi.client.drive.revisions.update({
fileId: "fileId",
revisionId: "revisionId",
});
/** Creates a new Team Drive. */
await gapi.client.teamdrives.create({
await gapi.client.drive.teamdrives.create({
requestId: "requestId",
});
/** Permanently deletes a Team Drive for which the user is an organizer. The Team Drive cannot contain any untrashed items. */
await gapi.client.teamdrives.delete({
await gapi.client.drive.teamdrives.delete({
teamDriveId: "teamDriveId",
});
/** Gets a Team Drive's metadata by ID. */
await gapi.client.teamdrives.get({
await gapi.client.drive.teamdrives.get({
teamDriveId: "teamDriveId",
useDomainAdminAccess: true,
});
/** Lists the user's Team Drives. */
await gapi.client.teamdrives.list({
await gapi.client.drive.teamdrives.list({
pageSize: 1,
pageToken: "pageToken",
q: "q",
useDomainAdminAccess: true,
});
/** Updates a Team Drive's metadata */
await gapi.client.teamdrives.update({
await gapi.client.drive.teamdrives.update({
teamDriveId: "teamDriveId",
});
}

View File

@ -16,28 +16,12 @@ declare namespace gapi.client {
function load(name: "drive", version: "v3"): PromiseLike<void>;
function load(name: "drive", version: "v3", callback: () => any): void;
const about: drive.AboutResource;
const changes: drive.ChangesResource;
const channels: drive.ChannelsResource;
const comments: drive.CommentsResource;
const files: drive.FilesResource;
const permissions: drive.PermissionsResource;
const replies: drive.RepliesResource;
const revisions: drive.RevisionsResource;
const teamdrives: drive.TeamdrivesResource;
namespace drive {
interface About {
/** Whether the user has installed the requesting app. */
appInstalled?: boolean;
/** Whether the user can create Team Drives. */
canCreateTeamDrives?: boolean;
/** A map of source MIME type to possible targets for all supported exports. */
exportFormats?: Record<string, string[]>;
/** The currently supported folder colors as RGB hex strings. */
@ -363,8 +347,9 @@ declare namespace gapi.client {
owners?: User[];
/**
* The IDs of the parent folders which contain the file.
* If not specified as part of a create request, the file will be placed directly in the My Drive folder. Update requests must use the addParents and
* removeParents parameters to modify the values.
* If not specified as part of a create request, the file will be placed directly in the user's My Drive folder. If not specified as part of a copy
* request, the file will inherit any discoverable parents of the source file. Update requests must use the addParents and removeParents parameters to
* modify the parents list.
*/
parents?: string[];
/** List of permission IDs for users with access to this file. */
@ -683,6 +668,8 @@ declare namespace gapi.client {
};
/** The color of this Team Drive as an RGB hex string. It can only be set on a drive.teamdrives.update request that does not set themeId. */
colorRgb?: string;
/** The time at which the Team Drive was created (RFC 3339 date-time). */
createdTime?: string;
/** The ID of this Team Drive which is also the ID of the top level folder for this Team Drive. */
id?: string;
/** Identifies what kind of resource this is. Value: the fixed string "drive#teamDrive". */
@ -1322,7 +1309,7 @@ declare namespace gapi.client {
create(request: {
/** Data format for the response. */
alt?: string;
/** A custom message to include in the notification email. */
/** A plain text custom message to include in the notification email. */
emailMessage?: string;
/** Selector specifying which fields to include in a partial response. */
fields?: string;
@ -1351,6 +1338,11 @@ declare namespace gapi.client {
* the side effect.
*/
transferOwnership?: boolean;
/**
* Whether the request should be treated as if it was issued by a domain administrator; if set to true, then the requester will be granted access if they
* are an administrator of the domain to which the item belongs.
*/
useDomainAdminAccess?: boolean;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<Permission>;
@ -1377,6 +1369,11 @@ declare namespace gapi.client {
quotaUser?: string;
/** Whether the requesting application supports Team Drives. */
supportsTeamDrives?: boolean;
/**
* Whether the request should be treated as if it was issued by a domain administrator; if set to true, then the requester will be granted access if they
* are an administrator of the domain to which the item belongs.
*/
useDomainAdminAccess?: boolean;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<void>;
@ -1403,6 +1400,11 @@ declare namespace gapi.client {
quotaUser?: string;
/** Whether the requesting application supports Team Drives. */
supportsTeamDrives?: boolean;
/**
* Whether the request should be treated as if it was issued by a domain administrator; if set to true, then the requester will be granted access if they
* are an administrator of the domain to which the item belongs.
*/
useDomainAdminAccess?: boolean;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<Permission>;
@ -1434,6 +1436,11 @@ declare namespace gapi.client {
quotaUser?: string;
/** Whether the requesting application supports Team Drives. */
supportsTeamDrives?: boolean;
/**
* Whether the request should be treated as if it was issued by a domain administrator; if set to true, then the requester will be granted access if they
* are an administrator of the domain to which the item belongs.
*/
useDomainAdminAccess?: boolean;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<PermissionList>;
@ -1467,6 +1474,11 @@ declare namespace gapi.client {
* the side effect.
*/
transferOwnership?: boolean;
/**
* Whether the request should be treated as if it was issued by a domain administrator; if set to true, then the requester will be granted access if they
* are an administrator of the domain to which the item belongs.
*/
useDomainAdminAccess?: boolean;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<Permission>;
@ -1777,6 +1789,11 @@ declare namespace gapi.client {
quotaUser?: string;
/** The ID of the Team Drive */
teamDriveId: string;
/**
* Whether the request should be treated as if it was issued by a domain administrator; if set to true, then the requester will be granted access if they
* are an administrator of the domain to which the Team Drive belongs.
*/
useDomainAdminAccess?: boolean;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<TeamDrive>;
@ -1796,11 +1813,18 @@ declare namespace gapi.client {
pageToken?: string;
/** Returns response with indentations and line breaks. */
prettyPrint?: boolean;
/** Query string for searching Team Drives. */
q?: string;
/**
* Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* Overrides userIp if both are provided.
*/
quotaUser?: string;
/**
* Whether the request should be treated as if it was issued by a domain administrator; if set to true, then all Team Drives of the domain in which the
* requester is an administrator are returned.
*/
useDomainAdminAccess?: boolean;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<TeamDriveList>;
@ -1827,5 +1851,23 @@ declare namespace gapi.client {
userIp?: string;
}): Request<TeamDrive>;
}
const about: drive.AboutResource;
const changes: drive.ChangesResource;
const channels: drive.ChannelsResource;
const comments: drive.CommentsResource;
const files: drive.FilesResource;
const permissions: drive.PermissionsResource;
const replies: drive.RepliesResource;
const revisions: drive.RevisionsResource;
const teamdrives: drive.TeamdrivesResource;
}
}

View File

@ -14,7 +14,7 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [