diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index e6f80325..2933cdb1 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,11 +1,17 @@ { "ImportPath": "github.com/prasmussen/gdrive", - "GoVersion": "go1.6", - "GodepVersion": "v61", + "GoVersion": "go1.7", + "GodepVersion": "v80", "Deps": [ + { + "ImportPath": "cloud.google.com/go/compute/metadata", + "Comment": "v0.31.0-30-g5cf8da09", + "Rev": "5cf8da09f0a9d7503337490b32ee587a015e1de5" + }, { "ImportPath": "github.com/sabhiram/go-git-ignore", - "Rev": "228fcfa2a06e870a3ef238d54c45ea847f492a37" + "Comment": "1.0.2", + "Rev": "d3107576ba9425fc1c85f4b3569c4631b805a02e" }, { "ImportPath": "github.com/soniakeys/graph", @@ -14,35 +20,47 @@ }, { "ImportPath": "golang.org/x/net/context", - "Rev": "fb93926129b8ec0056f2f458b1f519654814edf0" + "Rev": "e11730110bbd884bbf19550bfafe9d69519ce29e" }, { "ImportPath": "golang.org/x/net/context/ctxhttp", - "Rev": "fb93926129b8ec0056f2f458b1f519654814edf0" + "Rev": "e11730110bbd884bbf19550bfafe9d69519ce29e" }, { "ImportPath": "golang.org/x/oauth2", - "Rev": "7e9cd5d59563851383f8f81a7fbb01213709387c" + "Rev": "c453e0c757598fd055e170a3a359263c91e13153" + }, + { + "ImportPath": "golang.org/x/oauth2/google", + "Rev": "c453e0c757598fd055e170a3a359263c91e13153" }, { "ImportPath": "golang.org/x/oauth2/internal", - "Rev": "7e9cd5d59563851383f8f81a7fbb01213709387c" + "Rev": "c453e0c757598fd055e170a3a359263c91e13153" + }, + { + "ImportPath": "golang.org/x/oauth2/jws", + "Rev": "c453e0c757598fd055e170a3a359263c91e13153" + }, + { + "ImportPath": "golang.org/x/oauth2/jwt", + "Rev": "c453e0c757598fd055e170a3a359263c91e13153" }, { "ImportPath": "google.golang.org/api/drive/v3", - "Rev": "9737cc9e103c00d06a8f3993361dec083df3d252" + "Rev": "799fe93f827439cfd251917066a18691dc6a7fc1" }, { "ImportPath": "google.golang.org/api/gensupport", - "Rev": "9737cc9e103c00d06a8f3993361dec083df3d252" + "Rev": "799fe93f827439cfd251917066a18691dc6a7fc1" }, { "ImportPath": "google.golang.org/api/googleapi", - "Rev": "9737cc9e103c00d06a8f3993361dec083df3d252" + "Rev": "799fe93f827439cfd251917066a18691dc6a7fc1" }, { "ImportPath": "google.golang.org/api/googleapi/internal/uritemplates", - "Rev": "9737cc9e103c00d06a8f3993361dec083df3d252" + "Rev": "799fe93f827439cfd251917066a18691dc6a7fc1" } ] } diff --git a/drive/changes.go b/drive/changes.go index ffd78242..285776c1 100644 --- a/drive/changes.go +++ b/drive/changes.go @@ -27,7 +27,7 @@ func (self *Drive) ListChanges(args ListChangesArgs) error { return nil } - changeList, err := self.service.Changes.List(args.PageToken).PageSize(args.MaxChanges).RestrictToMyDrive(true).Fields("newStartPageToken", "nextPageToken", "changes(fileId,removed,time,file(id,name,md5Checksum,mimeType,createdTime,modifiedTime))").Do() + changeList, err := self.service.Changes.List(args.PageToken).SupportsTeamDrives(true).PageSize(args.MaxChanges).RestrictToMyDrive(true).Fields("newStartPageToken", "nextPageToken", "changes(fileId,removed,time,file(id,name,md5Checksum,mimeType,createdTime,modifiedTime))").Do() if err != nil { return fmt.Errorf("Failed listing changes: %s", err) } @@ -43,7 +43,7 @@ func (self *Drive) ListChanges(args ListChangesArgs) error { } func (self *Drive) GetChangesStartPageToken() (string, error) { - res, err := self.service.Changes.GetStartPageToken().Do() + res, err := self.service.Changes.GetStartPageToken().SupportsTeamDrives(true).Do() if err != nil { return "", fmt.Errorf("Failed getting start page token: %s", err) } diff --git a/drive/delete.go b/drive/delete.go index 314672ce..fe50c8cb 100644 --- a/drive/delete.go +++ b/drive/delete.go @@ -12,7 +12,7 @@ type DeleteArgs struct { } func (self *Drive) Delete(args DeleteArgs) error { - f, err := self.service.Files.Get(args.Id).Fields("name", "mimeType").Do() + f, err := self.service.Files.Get(args.Id).SupportsTeamDrives(true).Fields("name", "mimeType").Do() if err != nil { return fmt.Errorf("Failed to get file: %s", err) } @@ -21,7 +21,7 @@ func (self *Drive) Delete(args DeleteArgs) error { return fmt.Errorf("'%s' is a directory, use the 'recursive' flag to delete directories", f.Name) } - err = self.service.Files.Delete(args.Id).Do() + err = self.service.Files.Delete(args.Id).SupportsTeamDrives(true).Do() if err != nil { return fmt.Errorf("Failed to delete file: %s", err) } diff --git a/drive/download.go b/drive/download.go index e4a41412..b78d4042 100644 --- a/drive/download.go +++ b/drive/download.go @@ -29,7 +29,7 @@ func (self *Drive) Download(args DownloadArgs) error { return self.downloadRecursive(args) } - f, err := self.service.Files.Get(args.Id).Fields("id", "name", "size", "mimeType", "md5Checksum").Do() + f, err := self.service.Files.Get(args.Id).SupportsTeamDrives(true).Fields("id", "name", "size", "mimeType", "md5Checksum").Do() if err != nil { return fmt.Errorf("Failed to get file: %s", err) } @@ -108,7 +108,7 @@ func (self *Drive) DownloadQuery(args DownloadQueryArgs) error { } func (self *Drive) downloadRecursive(args DownloadArgs) error { - f, err := self.service.Files.Get(args.Id).Fields("id", "name", "size", "mimeType", "md5Checksum").Do() + f, err := self.service.Files.Get(args.Id).SupportsTeamDrives(true).Fields("id", "name", "size", "mimeType", "md5Checksum").Do() if err != nil { return fmt.Errorf("Failed to get file: %s", err) } @@ -127,7 +127,7 @@ func (self *Drive) downloadBinary(f *drive.File, args DownloadArgs) (int64, int6 // Get timeout reader wrapper and context timeoutReaderWrapper, ctx := getTimeoutReaderWrapperContext(args.Timeout) - res, err := self.service.Files.Get(f.Id).Context(ctx).Download() + res, err := self.service.Files.Get(f.Id).SupportsTeamDrives(true).Context(ctx).Download() if err != nil { if isTimeoutError(err) { return 0, 0, fmt.Errorf("Failed to download file: timeout, no data was transferred for %v", args.Timeout) diff --git a/drive/export.go b/drive/export.go index 3fdd45a6..2b7356b9 100644 --- a/drive/export.go +++ b/drive/export.go @@ -25,7 +25,7 @@ type ExportArgs struct { } func (self *Drive) Export(args ExportArgs) error { - f, err := self.service.Files.Get(args.Id).Fields("name", "mimeType").Do() + f, err := self.service.Files.Get(args.Id).SupportsTeamDrives(true).Fields("name", "mimeType").Do() if err != nil { return fmt.Errorf("Failed to get file: %s", err) } diff --git a/drive/info.go b/drive/info.go index c6f44715..c7ce5854 100644 --- a/drive/info.go +++ b/drive/info.go @@ -13,7 +13,7 @@ type FileInfoArgs struct { } func (self *Drive) Info(args FileInfoArgs) error { - f, err := self.service.Files.Get(args.Id).Fields("id", "name", "size", "createdTime", "modifiedTime", "md5Checksum", "mimeType", "parents", "shared", "description", "webContentLink", "webViewLink").Do() + f, err := self.service.Files.Get(args.Id).SupportsTeamDrives(true).Fields("id", "name", "size", "createdTime", "modifiedTime", "md5Checksum", "mimeType", "parents", "shared", "description", "webContentLink", "webViewLink").Do() if err != nil { return fmt.Errorf("Failed to get file: %s", err) } diff --git a/drive/list.go b/drive/list.go index ab8aca56..2a7cabc2 100644 --- a/drive/list.go +++ b/drive/list.go @@ -74,7 +74,7 @@ func (self *Drive) listAllFiles(args listAllFilesArgs) ([]*drive.File, error) { controlledStop := fmt.Errorf("Controlled stop") - err := self.service.Files.List().Q(args.query).Fields(args.fields...).OrderBy(args.sortOrder).PageSize(pageSize).Pages(context.TODO(), func(fl *drive.FileList) error { + err := self.service.Files.List().SupportsTeamDrives(true).IncludeTeamDriveItems(true).Q(args.query).Fields(args.fields...).OrderBy(args.sortOrder).PageSize(pageSize).Pages(context.TODO(), func(fl *drive.FileList) error { files = append(files, fl.Files...) // Stop when we have all the files we need diff --git a/drive/mkdir.go b/drive/mkdir.go index 05d51914..88535ae6 100644 --- a/drive/mkdir.go +++ b/drive/mkdir.go @@ -35,7 +35,7 @@ func (self *Drive) mkdir(args MkdirArgs) (*drive.File, error) { dstFile.Parents = args.Parents // Create directory - f, err := self.service.Files.Create(dstFile).Do() + f, err := self.service.Files.Create(dstFile).SupportsTeamDrives(true).Do() if err != nil { return nil, fmt.Errorf("Failed to create directory: %s", err) } diff --git a/drive/path.go b/drive/path.go index 8043a01d..2839c2b5 100644 --- a/drive/path.go +++ b/drive/path.go @@ -53,7 +53,7 @@ func (self *remotePathfinder) getParent(id string) (*drive.File, error) { } // Fetch file from drive - f, err := self.service.Get(id).Fields("id", "name", "parents").Do() + f, err := self.service.Get(id).SupportsTeamDrives(true).Fields("id", "name", "parents").Do() if err != nil { return nil, fmt.Errorf("Failed to get file: %s", err) } diff --git a/drive/share.go b/drive/share.go index e942c170..9fd03741 100644 --- a/drive/share.go +++ b/drive/share.go @@ -26,7 +26,7 @@ func (self *Drive) Share(args ShareArgs) error { Domain: args.Domain, } - _, err := self.service.Permissions.Create(args.FileId, permission).Do() + _, err := self.service.Permissions.Create(args.FileId, permission).SupportsTeamDrives(true).Do() if err != nil { return fmt.Errorf("Failed to share file: %s", err) } @@ -42,7 +42,7 @@ type RevokePermissionArgs struct { } func (self *Drive) RevokePermission(args RevokePermissionArgs) error { - err := self.service.Permissions.Delete(args.FileId, args.PermissionId).Do() + err := self.service.Permissions.Delete(args.FileId, args.PermissionId).SupportsTeamDrives(true).Do() if err != nil { fmt.Errorf("Failed to revoke permission: %s", err) return err @@ -58,7 +58,7 @@ type ListPermissionsArgs struct { } func (self *Drive) ListPermissions(args ListPermissionsArgs) error { - permList, err := self.service.Permissions.List(args.FileId).Fields("permissions(id,role,type,domain,emailAddress,allowFileDiscovery)").Do() + permList, err := self.service.Permissions.List(args.FileId).SupportsTeamDrives(true).Fields("permissions(id,role,type,domain,emailAddress,allowFileDiscovery)").Do() if err != nil { fmt.Errorf("Failed to list permissions: %s", err) return err @@ -77,7 +77,7 @@ func (self *Drive) shareAnyoneReader(fileId string) error { Type: "anyone", } - _, err := self.service.Permissions.Create(fileId, permission).Do() + _, err := self.service.Permissions.Create(fileId, permission).SupportsTeamDrives(true).Do() if err != nil { return fmt.Errorf("Failed to share file: %s", err) } diff --git a/drive/sync.go b/drive/sync.go index 35ab16eb..3f7f70e6 100644 --- a/drive/sync.go +++ b/drive/sync.go @@ -86,7 +86,7 @@ func (self *Drive) prepareSyncFiles(localPath string, root *drive.File, cmp File } func (self *Drive) isSyncFile(id string) (bool, error) { - f, err := self.service.Files.Get(id).Fields("appProperties").Do() + f, err := self.service.Files.Get(id).SupportsTeamDrives(true).Fields("appProperties").Do() if err != nil { return false, fmt.Errorf("Failed to get file: %s", err) } diff --git a/drive/sync_download.go b/drive/sync_download.go index 58cd49c6..cf9a9166 100644 --- a/drive/sync_download.go +++ b/drive/sync_download.go @@ -85,7 +85,7 @@ func (self *Drive) DownloadSync(args DownloadSyncArgs) error { func (self *Drive) getSyncRoot(rootId string) (*drive.File, error) { fields := []googleapi.Field{"id", "name", "mimeType", "appProperties"} - f, err := self.service.Files.Get(rootId).Fields(fields...).Do() + f, err := self.service.Files.Get(rootId).SupportsTeamDrives(true).Fields(fields...).Do() if err != nil { return nil, fmt.Errorf("Failed to find root dir: %s", err) } @@ -191,7 +191,7 @@ func (self *Drive) downloadRemoteFile(id, fpath string, args DownloadSyncArgs, t // Get timeout reader wrapper and context timeoutReaderWrapper, ctx := getTimeoutReaderWrapperContext(args.Timeout) - res, err := self.service.Files.Get(id).Context(ctx).Download() + res, err := self.service.Files.Get(id).SupportsTeamDrives(true).Context(ctx).Download() if err != nil { if isBackendOrRateLimitError(err) && try < MaxErrorRetries { exponentialBackoffSleep(try) diff --git a/drive/sync_upload.go b/drive/sync_upload.go index f1e43a49..d007605e 100644 --- a/drive/sync_upload.go +++ b/drive/sync_upload.go @@ -96,7 +96,7 @@ func (self *Drive) UploadSync(args UploadSyncArgs) error { func (self *Drive) prepareSyncRoot(args UploadSyncArgs) (*drive.File, error) { fields := []googleapi.Field{"id", "name", "mimeType", "appProperties"} - f, err := self.service.Files.Get(args.RootId).Fields(fields...).Do() + f, err := self.service.Files.Get(args.RootId).SupportsTeamDrives(true).Fields(fields...).Do() if err != nil { return nil, fmt.Errorf("Failed to find root dir: %s", err) } @@ -128,7 +128,7 @@ func (self *Drive) prepareSyncRoot(args UploadSyncArgs) (*drive.File, error) { AppProperties: map[string]string{"sync": "true", "syncRoot": "true"}, } - f, err = self.service.Files.Update(f.Id, dstFile).Fields(fields...).Do() + f, err = self.service.Files.Update(f.Id, dstFile).SupportsTeamDrives(true).Fields(fields...).Do() if err != nil { return nil, fmt.Errorf("Failed to update root directory: %s", err) } @@ -268,7 +268,7 @@ func (self *Drive) createMissingRemoteDir(args createMissingRemoteDirArgs) (*dri return dstFile, nil } - f, err := self.service.Files.Create(dstFile).Do() + f, err := self.service.Files.Create(dstFile).SupportsTeamDrives(true).Do() if err != nil { if isBackendOrRateLimitError(err) && args.try < MaxErrorRetries { exponentialBackoffSleep(args.try) @@ -311,7 +311,7 @@ func (self *Drive) uploadMissingFile(parentId string, lf *LocalFile, args Upload // Wrap reader in timeout reader reader, ctx := getTimeoutReaderContext(progressReader, args.Timeout) - _, err = self.service.Files.Create(dstFile).Fields("id", "name", "size", "md5Checksum").Context(ctx).Media(reader, chunkSize).Do() + _, err = self.service.Files.Create(dstFile).SupportsTeamDrives(true).Fields("id", "name", "size", "md5Checksum").Context(ctx).Media(reader, chunkSize).Do() if err != nil { if isBackendOrRateLimitError(err) && try < MaxErrorRetries { exponentialBackoffSleep(try) @@ -352,7 +352,7 @@ func (self *Drive) updateChangedFile(cf *changedFile, args UploadSyncArgs, try i // Wrap reader in timeout reader reader, ctx := getTimeoutReaderContext(progressReader, args.Timeout) - _, err = self.service.Files.Update(cf.remote.file.Id, dstFile).Context(ctx).Media(reader, chunkSize).Do() + _, err = self.service.Files.Update(cf.remote.file.Id, dstFile).SupportsTeamDrives(true).Context(ctx).Media(reader, chunkSize).Do() if err != nil { if isBackendOrRateLimitError(err) && try < MaxErrorRetries { exponentialBackoffSleep(try) @@ -373,7 +373,7 @@ func (self *Drive) deleteRemoteFile(rf *RemoteFile, args UploadSyncArgs, try int return nil } - err := self.service.Files.Delete(rf.file.Id).Do() + err := self.service.Files.Delete(rf.file.Id).SupportsTeamDrives(true).Do() if err != nil { if isBackendOrRateLimitError(err) && try < MaxErrorRetries { exponentialBackoffSleep(try) @@ -389,7 +389,7 @@ func (self *Drive) deleteRemoteFile(rf *RemoteFile, args UploadSyncArgs, try int func (self *Drive) dirIsEmpty(id string) (bool, error) { query := fmt.Sprintf("'%s' in parents", id) - fileList, err := self.service.Files.List().Q(query).Do() + fileList, err := self.service.Files.List().SupportsTeamDrives(true).Q(query).Do() if err != nil { return false, fmt.Errorf("Empty dir check failed: ", err) } diff --git a/drive/update.go b/drive/update.go index f496f52b..5e47b291 100644 --- a/drive/update.go +++ b/drive/update.go @@ -64,7 +64,7 @@ func (self *Drive) Update(args UpdateArgs) error { fmt.Fprintf(args.Out, "Uploading %s\n", args.Path) started := time.Now() - f, err := self.service.Files.Update(args.Id, dstFile).Fields("id", "name", "size").Context(ctx).Media(reader, chunkSize).Do() + f, err := self.service.Files.Update(args.Id, dstFile).SupportsTeamDrives(true).Fields("id", "name", "size").Context(ctx).Media(reader, chunkSize).Do() if err != nil { if isTimeoutError(err) { return fmt.Errorf("Failed to upload file: timeout, no data was transferred for %v", args.Timeout) diff --git a/drive/upload.go b/drive/upload.go index a4482e20..c15a750e 100644 --- a/drive/upload.go +++ b/drive/upload.go @@ -184,7 +184,7 @@ func (self *Drive) uploadFile(args UploadArgs) (*drive.File, int64, error) { fmt.Fprintf(args.Out, "Uploading %s\n", args.Path) started := time.Now() - f, err := self.service.Files.Create(dstFile).Fields("id", "name", "size", "md5Checksum", "webContentLink").Context(ctx).Media(reader, chunkSize).Do() + f, err := self.service.Files.Create(dstFile).SupportsTeamDrives(true).Fields("id", "name", "size", "md5Checksum", "webContentLink").Context(ctx).Media(reader, chunkSize).Do() if err != nil { if isTimeoutError(err) { return nil, 0, fmt.Errorf("Failed to upload file: timeout, no data was transferred for %v", args.Timeout) @@ -239,7 +239,7 @@ func (self *Drive) UploadStream(args UploadStreamArgs) error { fmt.Fprintf(args.Out, "Uploading %s\n", dstFile.Name) started := time.Now() - f, err := self.service.Files.Create(dstFile).Fields("id", "name", "size", "webContentLink").Context(ctx).Media(reader, chunkSize).Do() + f, err := self.service.Files.Create(dstFile).SupportsTeamDrives(true).Fields("id", "name", "size", "webContentLink").Context(ctx).Media(reader, chunkSize).Do() if err != nil { if isTimeoutError(err) { return fmt.Errorf("Failed to upload file: timeout, no data was transferred for %v", args.Timeout) diff --git a/vendor/cloud.google.com/go/AUTHORS b/vendor/cloud.google.com/go/AUTHORS new file mode 100644 index 00000000..c364af1d --- /dev/null +++ b/vendor/cloud.google.com/go/AUTHORS @@ -0,0 +1,15 @@ +# This is the official list of cloud authors for copyright purposes. +# This file is distinct from the CONTRIBUTORS files. +# See the latter for an explanation. + +# Names should be added to this file as: +# Name or Organization +# The email address is not required for organizations. + +Filippo Valsorda +Google Inc. +Ingo Oeser +Palm Stone Games, Inc. +Paweł Knap +Péter Szilágyi +Tyler Treat diff --git a/vendor/cloud.google.com/go/CONTRIBUTORS b/vendor/cloud.google.com/go/CONTRIBUTORS new file mode 100644 index 00000000..3b3cbed9 --- /dev/null +++ b/vendor/cloud.google.com/go/CONTRIBUTORS @@ -0,0 +1,40 @@ +# People who have agreed to one of the CLAs and can contribute patches. +# The AUTHORS file lists the copyright holders; this file +# lists people. For example, Google employees are listed here +# but not in AUTHORS, because Google holds the copyright. +# +# https://developers.google.com/open-source/cla/individual +# https://developers.google.com/open-source/cla/corporate +# +# Names should be added to this file as: +# Name + +# Keep the list alphabetically sorted. + +Alexis Hunt +Andreas Litt +Andrew Gerrand +Brad Fitzpatrick +Burcu Dogan +Dave Day +David Sansome +David Symonds +Filippo Valsorda +Glenn Lewis +Ingo Oeser +James Hall +Johan Euphrosine +Jonathan Amsterdam +Kunpei Sakai +Luna Duclos +Magnus Hiie +Mario Castro +Michael McGreevy +Omar Jarjur +Paweł Knap +Péter Szilágyi +Sarah Adams +Thanatat Tamtan +Toby Burress +Tuo Shan +Tyler Treat diff --git a/vendor/cloud.google.com/go/LICENSE b/vendor/cloud.google.com/go/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/vendor/cloud.google.com/go/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/cloud.google.com/go/compute/metadata/metadata.go b/vendor/cloud.google.com/go/compute/metadata/metadata.go new file mode 100644 index 00000000..45dd27d3 --- /dev/null +++ b/vendor/cloud.google.com/go/compute/metadata/metadata.go @@ -0,0 +1,503 @@ +// Copyright 2014 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package metadata provides access to Google Compute Engine (GCE) +// metadata and API service accounts. +// +// This package is a wrapper around the GCE metadata service, +// as documented at https://developers.google.com/compute/docs/metadata. +package metadata + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "net" + "net/http" + "net/url" + "os" + "runtime" + "strings" + "sync" + "time" + + "golang.org/x/net/context" + "golang.org/x/net/context/ctxhttp" +) + +const ( + // metadataIP is the documented metadata server IP address. + metadataIP = "169.254.169.254" + + // metadataHostEnv is the environment variable specifying the + // GCE metadata hostname. If empty, the default value of + // metadataIP ("169.254.169.254") is used instead. + // This is variable name is not defined by any spec, as far as + // I know; it was made up for the Go package. + metadataHostEnv = "GCE_METADATA_HOST" + + userAgent = "gcloud-golang/0.1" +) + +type cachedValue struct { + k string + trim bool + mu sync.Mutex + v string +} + +var ( + projID = &cachedValue{k: "project/project-id", trim: true} + projNum = &cachedValue{k: "project/numeric-project-id", trim: true} + instID = &cachedValue{k: "instance/id", trim: true} +) + +var ( + defaultClient = &Client{hc: &http.Client{ + Transport: &http.Transport{ + Dial: (&net.Dialer{ + Timeout: 2 * time.Second, + KeepAlive: 30 * time.Second, + }).Dial, + ResponseHeaderTimeout: 2 * time.Second, + }, + }} + subscribeClient = &Client{hc: &http.Client{ + Transport: &http.Transport{ + Dial: (&net.Dialer{ + Timeout: 2 * time.Second, + KeepAlive: 30 * time.Second, + }).Dial, + }, + }} +) + +// NotDefinedError is returned when requested metadata is not defined. +// +// The underlying string is the suffix after "/computeMetadata/v1/". +// +// This error is not returned if the value is defined to be the empty +// string. +type NotDefinedError string + +func (suffix NotDefinedError) Error() string { + return fmt.Sprintf("metadata: GCE metadata %q not defined", string(suffix)) +} + +func (c *cachedValue) get(cl *Client) (v string, err error) { + defer c.mu.Unlock() + c.mu.Lock() + if c.v != "" { + return c.v, nil + } + if c.trim { + v, err = cl.getTrimmed(c.k) + } else { + v, err = cl.Get(c.k) + } + if err == nil { + c.v = v + } + return +} + +var ( + onGCEOnce sync.Once + onGCE bool +) + +// OnGCE reports whether this process is running on Google Compute Engine. +func OnGCE() bool { + onGCEOnce.Do(initOnGCE) + return onGCE +} + +func initOnGCE() { + onGCE = testOnGCE() +} + +func testOnGCE() bool { + // The user explicitly said they're on GCE, so trust them. + if os.Getenv(metadataHostEnv) != "" { + return true + } + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + resc := make(chan bool, 2) + + // Try two strategies in parallel. + // See https://github.com/GoogleCloudPlatform/google-cloud-go/issues/194 + go func() { + req, _ := http.NewRequest("GET", "http://"+metadataIP, nil) + req.Header.Set("User-Agent", userAgent) + res, err := ctxhttp.Do(ctx, defaultClient.hc, req) + if err != nil { + resc <- false + return + } + defer res.Body.Close() + resc <- res.Header.Get("Metadata-Flavor") == "Google" + }() + + go func() { + addrs, err := net.LookupHost("metadata.google.internal") + if err != nil || len(addrs) == 0 { + resc <- false + return + } + resc <- strsContains(addrs, metadataIP) + }() + + tryHarder := systemInfoSuggestsGCE() + if tryHarder { + res := <-resc + if res { + // The first strategy succeeded, so let's use it. + return true + } + // Wait for either the DNS or metadata server probe to + // contradict the other one and say we are running on + // GCE. Give it a lot of time to do so, since the system + // info already suggests we're running on a GCE BIOS. + timer := time.NewTimer(5 * time.Second) + defer timer.Stop() + select { + case res = <-resc: + return res + case <-timer.C: + // Too slow. Who knows what this system is. + return false + } + } + + // There's no hint from the system info that we're running on + // GCE, so use the first probe's result as truth, whether it's + // true or false. The goal here is to optimize for speed for + // users who are NOT running on GCE. We can't assume that + // either a DNS lookup or an HTTP request to a blackholed IP + // address is fast. Worst case this should return when the + // metaClient's Transport.ResponseHeaderTimeout or + // Transport.Dial.Timeout fires (in two seconds). + return <-resc +} + +// systemInfoSuggestsGCE reports whether the local system (without +// doing network requests) suggests that we're running on GCE. If this +// returns true, testOnGCE tries a bit harder to reach its metadata +// server. +func systemInfoSuggestsGCE() bool { + if runtime.GOOS != "linux" { + // We don't have any non-Linux clues available, at least yet. + return false + } + slurp, _ := ioutil.ReadFile("/sys/class/dmi/id/product_name") + name := strings.TrimSpace(string(slurp)) + return name == "Google" || name == "Google Compute Engine" +} + +// Subscribe calls Client.Subscribe on a client designed for subscribing (one with no +// ResponseHeaderTimeout). +func Subscribe(suffix string, fn func(v string, ok bool) error) error { + return subscribeClient.Subscribe(suffix, fn) +} + +// Get calls Client.Get on the default client. +func Get(suffix string) (string, error) { return defaultClient.Get(suffix) } + +// ProjectID returns the current instance's project ID string. +func ProjectID() (string, error) { return defaultClient.ProjectID() } + +// NumericProjectID returns the current instance's numeric project ID. +func NumericProjectID() (string, error) { return defaultClient.NumericProjectID() } + +// InternalIP returns the instance's primary internal IP address. +func InternalIP() (string, error) { return defaultClient.InternalIP() } + +// ExternalIP returns the instance's primary external (public) IP address. +func ExternalIP() (string, error) { return defaultClient.ExternalIP() } + +// Hostname returns the instance's hostname. This will be of the form +// ".c..internal". +func Hostname() (string, error) { return defaultClient.Hostname() } + +// InstanceTags returns the list of user-defined instance tags, +// assigned when initially creating a GCE instance. +func InstanceTags() ([]string, error) { return defaultClient.InstanceTags() } + +// InstanceID returns the current VM's numeric instance ID. +func InstanceID() (string, error) { return defaultClient.InstanceID() } + +// InstanceName returns the current VM's instance ID string. +func InstanceName() (string, error) { return defaultClient.InstanceName() } + +// Zone returns the current VM's zone, such as "us-central1-b". +func Zone() (string, error) { return defaultClient.Zone() } + +// InstanceAttributes calls Client.InstanceAttributes on the default client. +func InstanceAttributes() ([]string, error) { return defaultClient.InstanceAttributes() } + +// ProjectAttributes calls Client.ProjectAttributes on the default client. +func ProjectAttributes() ([]string, error) { return defaultClient.ProjectAttributes() } + +// InstanceAttributeValue calls Client.InstanceAttributeValue on the default client. +func InstanceAttributeValue(attr string) (string, error) { + return defaultClient.InstanceAttributeValue(attr) +} + +// ProjectAttributeValue calls Client.ProjectAttributeValue on the default client. +func ProjectAttributeValue(attr string) (string, error) { + return defaultClient.ProjectAttributeValue(attr) +} + +// Scopes calls Client.Scopes on the default client. +func Scopes(serviceAccount string) ([]string, error) { return defaultClient.Scopes(serviceAccount) } + +func strsContains(ss []string, s string) bool { + for _, v := range ss { + if v == s { + return true + } + } + return false +} + +// A Client provides metadata. +type Client struct { + hc *http.Client +} + +// NewClient returns a Client that can be used to fetch metadata. All HTTP requests +// will use the given http.Client instead of the default client. +func NewClient(c *http.Client) *Client { + return &Client{hc: c} +} + +// getETag returns a value from the metadata service as well as the associated ETag. +// This func is otherwise equivalent to Get. +func (c *Client) getETag(suffix string) (value, etag string, err error) { + // Using a fixed IP makes it very difficult to spoof the metadata service in + // a container, which is an important use-case for local testing of cloud + // deployments. To enable spoofing of the metadata service, the environment + // variable GCE_METADATA_HOST is first inspected to decide where metadata + // requests shall go. + host := os.Getenv(metadataHostEnv) + if host == "" { + // Using 169.254.169.254 instead of "metadata" here because Go + // binaries built with the "netgo" tag and without cgo won't + // know the search suffix for "metadata" is + // ".google.internal", and this IP address is documented as + // being stable anyway. + host = metadataIP + } + url := "http://" + host + "/computeMetadata/v1/" + suffix + req, _ := http.NewRequest("GET", url, nil) + req.Header.Set("Metadata-Flavor", "Google") + req.Header.Set("User-Agent", userAgent) + res, err := c.hc.Do(req) + if err != nil { + return "", "", err + } + defer res.Body.Close() + if res.StatusCode == http.StatusNotFound { + return "", "", NotDefinedError(suffix) + } + if res.StatusCode != 200 { + return "", "", fmt.Errorf("status code %d trying to fetch %s", res.StatusCode, url) + } + all, err := ioutil.ReadAll(res.Body) + if err != nil { + return "", "", err + } + return string(all), res.Header.Get("Etag"), nil +} + +// Get returns a value from the metadata service. +// The suffix is appended to "http://${GCE_METADATA_HOST}/computeMetadata/v1/". +// +// If the GCE_METADATA_HOST environment variable is not defined, a default of +// 169.254.169.254 will be used instead. +// +// If the requested metadata is not defined, the returned error will +// be of type NotDefinedError. +func (c *Client) Get(suffix string) (string, error) { + val, _, err := c.getETag(suffix) + return val, err +} + +func (c *Client) getTrimmed(suffix string) (s string, err error) { + s, err = c.Get(suffix) + s = strings.TrimSpace(s) + return +} + +func (c *Client) lines(suffix string) ([]string, error) { + j, err := c.Get(suffix) + if err != nil { + return nil, err + } + s := strings.Split(strings.TrimSpace(j), "\n") + for i := range s { + s[i] = strings.TrimSpace(s[i]) + } + return s, nil +} + +// ProjectID returns the current instance's project ID string. +func (c *Client) ProjectID() (string, error) { return projID.get(c) } + +// NumericProjectID returns the current instance's numeric project ID. +func (c *Client) NumericProjectID() (string, error) { return projNum.get(c) } + +// InstanceID returns the current VM's numeric instance ID. +func (c *Client) InstanceID() (string, error) { return instID.get(c) } + +// InternalIP returns the instance's primary internal IP address. +func (c *Client) InternalIP() (string, error) { + return c.getTrimmed("instance/network-interfaces/0/ip") +} + +// ExternalIP returns the instance's primary external (public) IP address. +func (c *Client) ExternalIP() (string, error) { + return c.getTrimmed("instance/network-interfaces/0/access-configs/0/external-ip") +} + +// Hostname returns the instance's hostname. This will be of the form +// ".c..internal". +func (c *Client) Hostname() (string, error) { + return c.getTrimmed("instance/hostname") +} + +// InstanceTags returns the list of user-defined instance tags, +// assigned when initially creating a GCE instance. +func (c *Client) InstanceTags() ([]string, error) { + var s []string + j, err := c.Get("instance/tags") + if err != nil { + return nil, err + } + if err := json.NewDecoder(strings.NewReader(j)).Decode(&s); err != nil { + return nil, err + } + return s, nil +} + +// InstanceName returns the current VM's instance ID string. +func (c *Client) InstanceName() (string, error) { + host, err := c.Hostname() + if err != nil { + return "", err + } + return strings.Split(host, ".")[0], nil +} + +// Zone returns the current VM's zone, such as "us-central1-b". +func (c *Client) Zone() (string, error) { + zone, err := c.getTrimmed("instance/zone") + // zone is of the form "projects//zones/". + if err != nil { + return "", err + } + return zone[strings.LastIndex(zone, "/")+1:], nil +} + +// InstanceAttributes returns the list of user-defined attributes, +// assigned when initially creating a GCE VM instance. The value of an +// attribute can be obtained with InstanceAttributeValue. +func (c *Client) InstanceAttributes() ([]string, error) { return c.lines("instance/attributes/") } + +// ProjectAttributes returns the list of user-defined attributes +// applying to the project as a whole, not just this VM. The value of +// an attribute can be obtained with ProjectAttributeValue. +func (c *Client) ProjectAttributes() ([]string, error) { return c.lines("project/attributes/") } + +// InstanceAttributeValue returns the value of the provided VM +// instance attribute. +// +// If the requested attribute is not defined, the returned error will +// be of type NotDefinedError. +// +// InstanceAttributeValue may return ("", nil) if the attribute was +// defined to be the empty string. +func (c *Client) InstanceAttributeValue(attr string) (string, error) { + return c.Get("instance/attributes/" + attr) +} + +// ProjectAttributeValue returns the value of the provided +// project attribute. +// +// If the requested attribute is not defined, the returned error will +// be of type NotDefinedError. +// +// ProjectAttributeValue may return ("", nil) if the attribute was +// defined to be the empty string. +func (c *Client) ProjectAttributeValue(attr string) (string, error) { + return c.Get("project/attributes/" + attr) +} + +// Scopes returns the service account scopes for the given account. +// The account may be empty or the string "default" to use the instance's +// main account. +func (c *Client) Scopes(serviceAccount string) ([]string, error) { + if serviceAccount == "" { + serviceAccount = "default" + } + return c.lines("instance/service-accounts/" + serviceAccount + "/scopes") +} + +// Subscribe subscribes to a value from the metadata service. +// The suffix is appended to "http://${GCE_METADATA_HOST}/computeMetadata/v1/". +// The suffix may contain query parameters. +// +// Subscribe calls fn with the latest metadata value indicated by the provided +// suffix. If the metadata value is deleted, fn is called with the empty string +// and ok false. Subscribe blocks until fn returns a non-nil error or the value +// is deleted. Subscribe returns the error value returned from the last call to +// fn, which may be nil when ok == false. +func (c *Client) Subscribe(suffix string, fn func(v string, ok bool) error) error { + const failedSubscribeSleep = time.Second * 5 + + // First check to see if the metadata value exists at all. + val, lastETag, err := c.getETag(suffix) + if err != nil { + return err + } + + if err := fn(val, true); err != nil { + return err + } + + ok := true + if strings.ContainsRune(suffix, '?') { + suffix += "&wait_for_change=true&last_etag=" + } else { + suffix += "?wait_for_change=true&last_etag=" + } + for { + val, etag, err := c.getETag(suffix + url.QueryEscape(lastETag)) + if err != nil { + if _, deleted := err.(NotDefinedError); !deleted { + time.Sleep(failedSubscribeSleep) + continue // Retry on other errors. + } + ok = false + } + lastETag = etag + + if err := fn(val, ok); err != nil || !ok { + return err + } + } +} diff --git a/vendor/github.com/sabhiram/go-git-ignore/README.md b/vendor/github.com/sabhiram/go-git-ignore/README.md index fbbb3761..9440d6dd 100644 --- a/vendor/github.com/sabhiram/go-git-ignore/README.md +++ b/vendor/github.com/sabhiram/go-git-ignore/README.md @@ -1,17 +1,15 @@ -# go-git-ignore +# go-gitignore -[![Build Status](https://travis-ci.org/sabhiram/go-git-ignore.svg)](https://travis-ci.org/sabhiram/go-git-ignore) [![Coverage Status](https://coveralls.io/repos/sabhiram/go-git-ignore/badge.png?branch=master)](https://coveralls.io/r/sabhiram/go-git-ignore?branch=master) +[![Build Status](https://travis-ci.org/sabhiram/go-gitignore.svg)](https://travis-ci.org/sabhiram/go-gitignore) [![Coverage Status](https://coveralls.io/repos/github/sabhiram/go-gitignore/badge.svg?branch=master)](https://coveralls.io/github/sabhiram/go-gitignore?branch=master) A gitignore parser for `Go` ## Install ```shell -go get github.com/sabhiram/go-git-ignore +go get github.com/sabhiram/go-gitignore ``` ## Usage -```shell -TODO -``` +For a quick sample of how to use this library, check out the tests under `ignore_test.go`. diff --git a/vendor/github.com/sabhiram/go-git-ignore/ignore.go b/vendor/github.com/sabhiram/go-git-ignore/ignore.go index e3241b2c..846b52cb 100644 --- a/vendor/github.com/sabhiram/go-git-ignore/ignore.go +++ b/vendor/github.com/sabhiram/go-git-ignore/ignore.go @@ -58,20 +58,16 @@ import ( "strings" ) -// An IgnoreParser is an interface which exposes two methods: -// MatchesPath() - Returns true if the path is targeted by the patterns compiled in the GitIgnore structure +//////////////////////////////////////////////////////////// + +// An IgnoreParser is an interface which exposes a single method: +// MatchesPath() - Returns true if the path is targeted by the patterns compiled +// in the GitIgnore structure type IgnoreParser interface { - IncludesPath(f string) bool - IgnoresPath(f string) bool MatchesPath(f string) bool } -// GitIgnore is a struct which contains a slice of regexp.Regexp -// patterns -type GitIgnore struct { - patterns []*regexp.Regexp // List of regexp patterns which this ignore file applies - negate []bool // List of booleans which determine if the pattern is negated -} +//////////////////////////////////////////////////////////// // This function pretty much attempts to mimic the parsing rules // listed above at the start of this file @@ -151,19 +147,32 @@ func getPatternFromLine(line string) (*regexp.Regexp, bool) { return pattern, negatePattern } +//////////////////////////////////////////////////////////// + +// ignorePattern encapsulates a pattern and if it is a negated pattern. +type ignorePattern struct { + pattern *regexp.Regexp + negate bool +} + +// GitIgnore wraps a list of ignore pattern. +type GitIgnore struct { + patterns []*ignorePattern +} + // Accepts a variadic set of strings, and returns a GitIgnore object which // converts and appends the lines in the input to regexp.Regexp patterns // held within the GitIgnore objects "patterns" field func CompileIgnoreLines(lines ...string) (*GitIgnore, error) { - g := new(GitIgnore) + gi := &GitIgnore{} for _, line := range lines { pattern, negatePattern := getPatternFromLine(line) if pattern != nil { - g.patterns = append(g.patterns, pattern) - g.negate = append(g.negate, negatePattern) + ip := &ignorePattern{pattern, negatePattern} + gi.patterns = append(gi.patterns, ip) } } - return g, nil + return gi, nil } // Accepts a ignore file as the input, parses the lines out of the file @@ -177,24 +186,38 @@ func CompileIgnoreFile(fpath string) (*GitIgnore, error) { return nil, error } -// MatchesPath is an interface function for the IgnoreParser interface. -// It returns true if the given GitIgnore structure would target a given -// path string "f" -func (g GitIgnore) MatchesPath(f string) bool { +// Accepts a ignore file as the input, parses the lines out of the file +// and invokes the CompileIgnoreLines method with additional lines +func CompileIgnoreFileAndLines(fpath string, lines ...string) (*GitIgnore, error) { + buffer, error := ioutil.ReadFile(fpath) + if error == nil { + s := strings.Split(string(buffer), "\n") + return CompileIgnoreLines(append(s, lines...)...) + } + return nil, error +} + +//////////////////////////////////////////////////////////// + +// MatchesPath returns true if the given GitIgnore structure would target +// a given path string `f`. +func (gi *GitIgnore) MatchesPath(f string) bool { // Replace OS-specific path separator. f = strings.Replace(f, string(os.PathSeparator), "/", -1) matchesPath := false - for idx, pattern := range g.patterns { - if pattern.MatchString(f) { + for _, ip := range gi.patterns { + if ip.pattern.MatchString(f) { // If this is a regular target (not negated with a gitignore exclude "!" etc) - if !g.negate[idx] { + if !ip.negate { matchesPath = true - // Negated pattern, and matchesPath is already set } else if matchesPath { + // Negated pattern, and matchesPath is already set matchesPath = false } } } return matchesPath } + +//////////////////////////////////////////////////////////// diff --git a/vendor/github.com/sabhiram/go-git-ignore/version_gen.go b/vendor/github.com/sabhiram/go-git-ignore/version_gen.go new file mode 100644 index 00000000..720a0575 --- /dev/null +++ b/vendor/github.com/sabhiram/go-git-ignore/version_gen.go @@ -0,0 +1,12 @@ +package ignore + +// WARNING: Auto generated version file. Do not edit this file by hand. +// WARNING: go get github.com/sabhiram/gover to manage this file. +// Version: 1.0.2 +const ( + Major = 1 + Minor = 0 + Patch = 2 + + Version = "1.0.2" +) diff --git a/vendor/github.com/soniakeys/graph/travis.sh b/vendor/github.com/soniakeys/graph/travis.sh old mode 100644 new mode 100755 diff --git a/vendor/golang.org/x/net/AUTHORS b/vendor/golang.org/x/net/AUTHORS new file mode 100644 index 00000000..15167cd7 --- /dev/null +++ b/vendor/golang.org/x/net/AUTHORS @@ -0,0 +1,3 @@ +# This source code refers to The Go Authors for copyright purposes. +# The master list of authors is in the main Go distribution, +# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/net/CONTRIBUTORS b/vendor/golang.org/x/net/CONTRIBUTORS new file mode 100644 index 00000000..1c4577e9 --- /dev/null +++ b/vendor/golang.org/x/net/CONTRIBUTORS @@ -0,0 +1,3 @@ +# This source code was written by the Go contributors. +# The master list of contributors is in the main Go distribution, +# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/net/context/context.go b/vendor/golang.org/x/net/context/context.go index 56efb95b..839e3a64 100644 --- a/vendor/golang.org/x/net/context/context.go +++ b/vendor/golang.org/x/net/context/context.go @@ -5,9 +5,11 @@ // Package context defines the Context type, which carries deadlines, // cancelation signals, and other request-scoped values across API boundaries // and between processes. +// As of Go 1.7 this package is available in the standard library under the +// name context. https://golang.org/pkg/context. // // Incoming requests to a server should create a Context, and outgoing calls to -// servers should accept a Context. The chain of function calls between must +// servers should accept a Context. The chain of function calls between must // propagate the Context, optionally replacing it with a modified copy created // using WithDeadline, WithTimeout, WithCancel, or WithValue. // @@ -16,14 +18,14 @@ // propagation: // // Do not store Contexts inside a struct type; instead, pass a Context -// explicitly to each function that needs it. The Context should be the first +// explicitly to each function that needs it. The Context should be the first // parameter, typically named ctx: // // func DoSomething(ctx context.Context, arg Arg) error { // // ... use ctx ... // } // -// Do not pass a nil Context, even if a function permits it. Pass context.TODO +// Do not pass a nil Context, even if a function permits it. Pass context.TODO // if you are unsure about which Context to use. // // Use context Values only for request-scoped data that transits processes and @@ -36,112 +38,15 @@ // Contexts. package context -import "time" - -// A Context carries a deadline, a cancelation signal, and other values across -// API boundaries. -// -// Context's methods may be called by multiple goroutines simultaneously. -type Context interface { - // Deadline returns the time when work done on behalf of this context - // should be canceled. Deadline returns ok==false when no deadline is - // set. Successive calls to Deadline return the same results. - Deadline() (deadline time.Time, ok bool) - - // Done returns a channel that's closed when work done on behalf of this - // context should be canceled. Done may return nil if this context can - // never be canceled. Successive calls to Done return the same value. - // - // WithCancel arranges for Done to be closed when cancel is called; - // WithDeadline arranges for Done to be closed when the deadline - // expires; WithTimeout arranges for Done to be closed when the timeout - // elapses. - // - // Done is provided for use in select statements: - // - // // Stream generates values with DoSomething and sends them to out - // // until DoSomething returns an error or ctx.Done is closed. - // func Stream(ctx context.Context, out <-chan Value) error { - // for { - // v, err := DoSomething(ctx) - // if err != nil { - // return err - // } - // select { - // case <-ctx.Done(): - // return ctx.Err() - // case out <- v: - // } - // } - // } - // - // See http://blog.golang.org/pipelines for more examples of how to use - // a Done channel for cancelation. - Done() <-chan struct{} - - // Err returns a non-nil error value after Done is closed. Err returns - // Canceled if the context was canceled or DeadlineExceeded if the - // context's deadline passed. No other values for Err are defined. - // After Done is closed, successive calls to Err return the same value. - Err() error - - // Value returns the value associated with this context for key, or nil - // if no value is associated with key. Successive calls to Value with - // the same key returns the same result. - // - // Use context values only for request-scoped data that transits - // processes and API boundaries, not for passing optional parameters to - // functions. - // - // A key identifies a specific value in a Context. Functions that wish - // to store values in Context typically allocate a key in a global - // variable then use that key as the argument to context.WithValue and - // Context.Value. A key can be any type that supports equality; - // packages should define keys as an unexported type to avoid - // collisions. - // - // Packages that define a Context key should provide type-safe accessors - // for the values stores using that key: - // - // // Package user defines a User type that's stored in Contexts. - // package user - // - // import "golang.org/x/net/context" - // - // // User is the type of value stored in the Contexts. - // type User struct {...} - // - // // key is an unexported type for keys defined in this package. - // // This prevents collisions with keys defined in other packages. - // type key int - // - // // userKey is the key for user.User values in Contexts. It is - // // unexported; clients use user.NewContext and user.FromContext - // // instead of using this key directly. - // var userKey key = 0 - // - // // NewContext returns a new Context that carries value u. - // func NewContext(ctx context.Context, u *User) context.Context { - // return context.WithValue(ctx, userKey, u) - // } - // - // // FromContext returns the User value stored in ctx, if any. - // func FromContext(ctx context.Context) (*User, bool) { - // u, ok := ctx.Value(userKey).(*User) - // return u, ok - // } - Value(key interface{}) interface{} -} - // Background returns a non-nil, empty Context. It is never canceled, has no -// values, and has no deadline. It is typically used by the main function, +// values, and has no deadline. It is typically used by the main function, // initialization, and tests, and as the top-level Context for incoming // requests. func Background() Context { return background } -// TODO returns a non-nil, empty Context. Code should use context.TODO when +// TODO returns a non-nil, empty Context. Code should use context.TODO when // it's unclear which Context to use or it is not yet available (because the // surrounding function has not yet been extended to accept a Context // parameter). TODO is recognized by static analysis tools that determine @@ -149,8 +54,3 @@ func Background() Context { func TODO() Context { return todo } - -// A CancelFunc tells an operation to abandon its work. -// A CancelFunc does not wait for the work to stop. -// After the first call, subsequent calls to a CancelFunc do nothing. -type CancelFunc func() diff --git a/vendor/golang.org/x/net/context/ctxhttp/cancelreq.go b/vendor/golang.org/x/net/context/ctxhttp/cancelreq.go deleted file mode 100644 index e3170e33..00000000 --- a/vendor/golang.org/x/net/context/ctxhttp/cancelreq.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.5 - -package ctxhttp - -import "net/http" - -func canceler(client *http.Client, req *http.Request) func() { - // TODO(djd): Respect any existing value of req.Cancel. - ch := make(chan struct{}) - req.Cancel = ch - - return func() { - close(ch) - } -} diff --git a/vendor/golang.org/x/net/context/ctxhttp/cancelreq_go14.go b/vendor/golang.org/x/net/context/ctxhttp/cancelreq_go14.go deleted file mode 100644 index 56bcbadb..00000000 --- a/vendor/golang.org/x/net/context/ctxhttp/cancelreq_go14.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.5 - -package ctxhttp - -import "net/http" - -type requestCanceler interface { - CancelRequest(*http.Request) -} - -func canceler(client *http.Client, req *http.Request) func() { - rc, ok := client.Transport.(requestCanceler) - if !ok { - return func() {} - } - return func() { - rc.CancelRequest(req) - } -} diff --git a/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go b/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go index e35860a7..22eabffe 100644 --- a/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +++ b/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go @@ -1,7 +1,9 @@ -// Copyright 2015 The Go Authors. All rights reserved. +// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build go1.7 + // Package ctxhttp provides helper functions for performing context-aware HTTP requests. package ctxhttp @@ -14,76 +16,28 @@ import ( "golang.org/x/net/context" ) -func nop() {} - -var ( - testHookContextDoneBeforeHeaders = nop - testHookDoReturned = nop - testHookDidBodyClose = nop -) - -// Do sends an HTTP request with the provided http.Client and returns an HTTP response. +// Do sends an HTTP request with the provided http.Client and returns +// an HTTP response. +// // If the client is nil, http.DefaultClient is used. -// If the context is canceled or times out, ctx.Err() will be returned. +// +// The provided ctx must be non-nil. If it is canceled or times out, +// ctx.Err() will be returned. func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) { if client == nil { client = http.DefaultClient } - - // Request cancelation changed in Go 1.5, see cancelreq.go and cancelreq_go14.go. - cancel := canceler(client, req) - - type responseAndError struct { - resp *http.Response - err error - } - result := make(chan responseAndError, 1) - - // Make local copies of test hooks closed over by goroutines below. - // Prevents data races in tests. - testHookDoReturned := testHookDoReturned - testHookDidBodyClose := testHookDidBodyClose - - go func() { - resp, err := client.Do(req) - testHookDoReturned() - result <- responseAndError{resp, err} - }() - - var resp *http.Response - - select { - case <-ctx.Done(): - testHookContextDoneBeforeHeaders() - cancel() - // Clean up after the goroutine calling client.Do: - go func() { - if r := <-result; r.resp != nil { - testHookDidBodyClose() - r.resp.Body.Close() - } - }() - return nil, ctx.Err() - case r := <-result: - var err error - resp, err = r.resp, r.err - if err != nil { - return resp, err - } - } - - c := make(chan struct{}) - go func() { + resp, err := client.Do(req.WithContext(ctx)) + // If we got an error, and the context has been canceled, + // the context's error is probably more useful. + if err != nil { select { case <-ctx.Done(): - cancel() - case <-c: - // The response's Body is closed. + err = ctx.Err() + default: } - }() - resp.Body = ¬ifyingReader{resp.Body, c} - - return resp, nil + } + return resp, err } // Get issues a GET request via the Do function. @@ -118,28 +72,3 @@ func Post(ctx context.Context, client *http.Client, url string, bodyType string, func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) { return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) } - -// notifyingReader is an io.ReadCloser that closes the notify channel after -// Close is called or a Read fails on the underlying ReadCloser. -type notifyingReader struct { - io.ReadCloser - notify chan<- struct{} -} - -func (r *notifyingReader) Read(p []byte) (int, error) { - n, err := r.ReadCloser.Read(p) - if err != nil && r.notify != nil { - close(r.notify) - r.notify = nil - } - return n, err -} - -func (r *notifyingReader) Close() error { - err := r.ReadCloser.Close() - if r.notify != nil { - close(r.notify) - r.notify = nil - } - return err -} diff --git a/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go b/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go new file mode 100644 index 00000000..7564b203 --- /dev/null +++ b/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go @@ -0,0 +1,147 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !go1.7 + +package ctxhttp + +import ( + "io" + "net/http" + "net/url" + "strings" + + "golang.org/x/net/context" +) + +func nop() {} + +var ( + testHookContextDoneBeforeHeaders = nop + testHookDoReturned = nop + testHookDidBodyClose = nop +) + +// Do sends an HTTP request with the provided http.Client and returns an HTTP response. +// If the client is nil, http.DefaultClient is used. +// If the context is canceled or times out, ctx.Err() will be returned. +func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) { + if client == nil { + client = http.DefaultClient + } + + // TODO(djd): Respect any existing value of req.Cancel. + cancel := make(chan struct{}) + req.Cancel = cancel + + type responseAndError struct { + resp *http.Response + err error + } + result := make(chan responseAndError, 1) + + // Make local copies of test hooks closed over by goroutines below. + // Prevents data races in tests. + testHookDoReturned := testHookDoReturned + testHookDidBodyClose := testHookDidBodyClose + + go func() { + resp, err := client.Do(req) + testHookDoReturned() + result <- responseAndError{resp, err} + }() + + var resp *http.Response + + select { + case <-ctx.Done(): + testHookContextDoneBeforeHeaders() + close(cancel) + // Clean up after the goroutine calling client.Do: + go func() { + if r := <-result; r.resp != nil { + testHookDidBodyClose() + r.resp.Body.Close() + } + }() + return nil, ctx.Err() + case r := <-result: + var err error + resp, err = r.resp, r.err + if err != nil { + return resp, err + } + } + + c := make(chan struct{}) + go func() { + select { + case <-ctx.Done(): + close(cancel) + case <-c: + // The response's Body is closed. + } + }() + resp.Body = ¬ifyingReader{resp.Body, c} + + return resp, nil +} + +// Get issues a GET request via the Do function. +func Get(ctx context.Context, client *http.Client, url string) (*http.Response, error) { + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return nil, err + } + return Do(ctx, client, req) +} + +// Head issues a HEAD request via the Do function. +func Head(ctx context.Context, client *http.Client, url string) (*http.Response, error) { + req, err := http.NewRequest("HEAD", url, nil) + if err != nil { + return nil, err + } + return Do(ctx, client, req) +} + +// Post issues a POST request via the Do function. +func Post(ctx context.Context, client *http.Client, url string, bodyType string, body io.Reader) (*http.Response, error) { + req, err := http.NewRequest("POST", url, body) + if err != nil { + return nil, err + } + req.Header.Set("Content-Type", bodyType) + return Do(ctx, client, req) +} + +// PostForm issues a POST request via the Do function. +func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) { + return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) +} + +// notifyingReader is an io.ReadCloser that closes the notify channel after +// Close is called or a Read fails on the underlying ReadCloser. +type notifyingReader struct { + io.ReadCloser + notify chan<- struct{} +} + +func (r *notifyingReader) Read(p []byte) (int, error) { + n, err := r.ReadCloser.Read(p) + if err != nil && r.notify != nil { + close(r.notify) + r.notify = nil + } + return n, err +} + +func (r *notifyingReader) Close() error { + err := r.ReadCloser.Close() + if r.notify != nil { + close(r.notify) + r.notify = nil + } + return err +} diff --git a/vendor/golang.org/x/net/context/go17.go b/vendor/golang.org/x/net/context/go17.go index f8cda19a..d20f52b7 100644 --- a/vendor/golang.org/x/net/context/go17.go +++ b/vendor/golang.org/x/net/context/go17.go @@ -35,8 +35,8 @@ func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { } // WithDeadline returns a copy of the parent context with the deadline adjusted -// to be no later than d. If the parent's deadline is already earlier than d, -// WithDeadline(parent, d) is semantically equivalent to parent. The returned +// to be no later than d. If the parent's deadline is already earlier than d, +// WithDeadline(parent, d) is semantically equivalent to parent. The returned // context's Done channel is closed when the deadline expires, when the returned // cancel function is called, or when the parent context's Done channel is // closed, whichever happens first. diff --git a/vendor/golang.org/x/net/context/go19.go b/vendor/golang.org/x/net/context/go19.go new file mode 100644 index 00000000..d88bd1db --- /dev/null +++ b/vendor/golang.org/x/net/context/go19.go @@ -0,0 +1,20 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.9 + +package context + +import "context" // standard library's context, as of Go 1.7 + +// A Context carries a deadline, a cancelation signal, and other values across +// API boundaries. +// +// Context's methods may be called by multiple goroutines simultaneously. +type Context = context.Context + +// A CancelFunc tells an operation to abandon its work. +// A CancelFunc does not wait for the work to stop. +// After the first call, subsequent calls to a CancelFunc do nothing. +type CancelFunc = context.CancelFunc diff --git a/vendor/golang.org/x/net/context/pre_go17.go b/vendor/golang.org/x/net/context/pre_go17.go index 5a30acab..0f35592d 100644 --- a/vendor/golang.org/x/net/context/pre_go17.go +++ b/vendor/golang.org/x/net/context/pre_go17.go @@ -13,7 +13,7 @@ import ( "time" ) -// An emptyCtx is never canceled, has no values, and has no deadline. It is not +// An emptyCtx is never canceled, has no values, and has no deadline. It is not // struct{}, since vars of this type must have distinct addresses. type emptyCtx int @@ -104,7 +104,7 @@ func propagateCancel(parent Context, child canceler) { } // parentCancelCtx follows a chain of parent references until it finds a -// *cancelCtx. This function understands how each of the concrete types in this +// *cancelCtx. This function understands how each of the concrete types in this // package represents its parent. func parentCancelCtx(parent Context) (*cancelCtx, bool) { for { @@ -134,14 +134,14 @@ func removeChild(parent Context, child canceler) { p.mu.Unlock() } -// A canceler is a context type that can be canceled directly. The +// A canceler is a context type that can be canceled directly. The // implementations are *cancelCtx and *timerCtx. type canceler interface { cancel(removeFromParent bool, err error) Done() <-chan struct{} } -// A cancelCtx can be canceled. When canceled, it also cancels any children +// A cancelCtx can be canceled. When canceled, it also cancels any children // that implement canceler. type cancelCtx struct { Context @@ -193,8 +193,8 @@ func (c *cancelCtx) cancel(removeFromParent bool, err error) { } // WithDeadline returns a copy of the parent context with the deadline adjusted -// to be no later than d. If the parent's deadline is already earlier than d, -// WithDeadline(parent, d) is semantically equivalent to parent. The returned +// to be no later than d. If the parent's deadline is already earlier than d, +// WithDeadline(parent, d) is semantically equivalent to parent. The returned // context's Done channel is closed when the deadline expires, when the returned // cancel function is called, or when the parent context's Done channel is // closed, whichever happens first. @@ -226,8 +226,8 @@ func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { return c, func() { c.cancel(true, Canceled) } } -// A timerCtx carries a timer and a deadline. It embeds a cancelCtx to -// implement Done and Err. It implements cancel by stopping its timer then +// A timerCtx carries a timer and a deadline. It embeds a cancelCtx to +// implement Done and Err. It implements cancel by stopping its timer then // delegating to cancelCtx.cancel. type timerCtx struct { *cancelCtx @@ -281,7 +281,7 @@ func WithValue(parent Context, key interface{}, val interface{}) Context { return &valueCtx{parent, key, val} } -// A valueCtx carries a key-value pair. It implements Value for that key and +// A valueCtx carries a key-value pair. It implements Value for that key and // delegates all other calls to the embedded Context. type valueCtx struct { Context diff --git a/vendor/golang.org/x/net/context/pre_go19.go b/vendor/golang.org/x/net/context/pre_go19.go new file mode 100644 index 00000000..b105f80b --- /dev/null +++ b/vendor/golang.org/x/net/context/pre_go19.go @@ -0,0 +1,109 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !go1.9 + +package context + +import "time" + +// A Context carries a deadline, a cancelation signal, and other values across +// API boundaries. +// +// Context's methods may be called by multiple goroutines simultaneously. +type Context interface { + // Deadline returns the time when work done on behalf of this context + // should be canceled. Deadline returns ok==false when no deadline is + // set. Successive calls to Deadline return the same results. + Deadline() (deadline time.Time, ok bool) + + // Done returns a channel that's closed when work done on behalf of this + // context should be canceled. Done may return nil if this context can + // never be canceled. Successive calls to Done return the same value. + // + // WithCancel arranges for Done to be closed when cancel is called; + // WithDeadline arranges for Done to be closed when the deadline + // expires; WithTimeout arranges for Done to be closed when the timeout + // elapses. + // + // Done is provided for use in select statements: + // + // // Stream generates values with DoSomething and sends them to out + // // until DoSomething returns an error or ctx.Done is closed. + // func Stream(ctx context.Context, out chan<- Value) error { + // for { + // v, err := DoSomething(ctx) + // if err != nil { + // return err + // } + // select { + // case <-ctx.Done(): + // return ctx.Err() + // case out <- v: + // } + // } + // } + // + // See http://blog.golang.org/pipelines for more examples of how to use + // a Done channel for cancelation. + Done() <-chan struct{} + + // Err returns a non-nil error value after Done is closed. Err returns + // Canceled if the context was canceled or DeadlineExceeded if the + // context's deadline passed. No other values for Err are defined. + // After Done is closed, successive calls to Err return the same value. + Err() error + + // Value returns the value associated with this context for key, or nil + // if no value is associated with key. Successive calls to Value with + // the same key returns the same result. + // + // Use context values only for request-scoped data that transits + // processes and API boundaries, not for passing optional parameters to + // functions. + // + // A key identifies a specific value in a Context. Functions that wish + // to store values in Context typically allocate a key in a global + // variable then use that key as the argument to context.WithValue and + // Context.Value. A key can be any type that supports equality; + // packages should define keys as an unexported type to avoid + // collisions. + // + // Packages that define a Context key should provide type-safe accessors + // for the values stores using that key: + // + // // Package user defines a User type that's stored in Contexts. + // package user + // + // import "golang.org/x/net/context" + // + // // User is the type of value stored in the Contexts. + // type User struct {...} + // + // // key is an unexported type for keys defined in this package. + // // This prevents collisions with keys defined in other packages. + // type key int + // + // // userKey is the key for user.User values in Contexts. It is + // // unexported; clients use user.NewContext and user.FromContext + // // instead of using this key directly. + // var userKey key = 0 + // + // // NewContext returns a new Context that carries value u. + // func NewContext(ctx context.Context, u *User) context.Context { + // return context.WithValue(ctx, userKey, u) + // } + // + // // FromContext returns the User value stored in ctx, if any. + // func FromContext(ctx context.Context) (*User, bool) { + // u, ok := ctx.Value(userKey).(*User) + // return u, ok + // } + Value(key interface{}) interface{} +} + +// A CancelFunc tells an operation to abandon its work. +// A CancelFunc does not wait for the work to stop. +// After the first call, subsequent calls to a CancelFunc do nothing. +type CancelFunc func() diff --git a/vendor/golang.org/x/oauth2/.travis.yml b/vendor/golang.org/x/oauth2/.travis.yml index a035125c..fa139db2 100644 --- a/vendor/golang.org/x/oauth2/.travis.yml +++ b/vendor/golang.org/x/oauth2/.travis.yml @@ -1,8 +1,7 @@ language: go go: - - 1.3 - - 1.4 + - tip install: - export GOPATH="$HOME/gopath" diff --git a/vendor/golang.org/x/oauth2/CONTRIBUTING.md b/vendor/golang.org/x/oauth2/CONTRIBUTING.md index 46aa2b12..dfbed62c 100644 --- a/vendor/golang.org/x/oauth2/CONTRIBUTING.md +++ b/vendor/golang.org/x/oauth2/CONTRIBUTING.md @@ -4,16 +4,15 @@ Go is an open source project. It is the work of hundreds of contributors. We appreciate your help! - ## Filing issues When [filing an issue](https://github.com/golang/oauth2/issues), make sure to answer these five questions: -1. What version of Go are you using (`go version`)? -2. What operating system and processor architecture are you using? -3. What did you do? -4. What did you expect to see? -5. What did you see instead? +1. What version of Go are you using (`go version`)? +2. What operating system and processor architecture are you using? +3. What did you do? +4. What did you expect to see? +5. What did you see instead? General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. The gophers there will answer or ask you to file an issue if you've tripped over a bug. @@ -23,9 +22,5 @@ The gophers there will answer or ask you to file an issue if you've tripped over Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) before sending patches. -**We do not accept GitHub pull requests** -(we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). - Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file. - diff --git a/vendor/golang.org/x/oauth2/LICENSE b/vendor/golang.org/x/oauth2/LICENSE index d02f24fd..6a66aea5 100644 --- a/vendor/golang.org/x/oauth2/LICENSE +++ b/vendor/golang.org/x/oauth2/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The oauth2 Authors. All rights reserved. +Copyright (c) 2009 The Go Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are diff --git a/vendor/golang.org/x/oauth2/README.md b/vendor/golang.org/x/oauth2/README.md index 0d514173..94ffd732 100644 --- a/vendor/golang.org/x/oauth2/README.md +++ b/vendor/golang.org/x/oauth2/README.md @@ -1,6 +1,7 @@ # OAuth2 for Go [![Build Status](https://travis-ci.org/golang/oauth2.svg?branch=master)](https://travis-ci.org/golang/oauth2) +[![GoDoc](https://godoc.org/golang.org/x/oauth2?status.svg)](https://godoc.org/golang.org/x/oauth2) oauth2 package contains a client implementation for OAuth 2.0 spec. @@ -10,6 +11,9 @@ oauth2 package contains a client implementation for OAuth 2.0 spec. go get golang.org/x/oauth2 ~~~~ +Or you can manually git clone the repository to +`$(go env GOPATH)/src/golang.org/x/oauth2`. + See godoc for further documentation and examples. * [godoc.org/golang.org/x/oauth2](http://godoc.org/golang.org/x/oauth2) @@ -18,11 +22,13 @@ See godoc for further documentation and examples. ## App Engine -In change 96e89be (March 2015) we removed the `oauth2.Context2` type in favor +In change 96e89be (March 2015), we removed the `oauth2.Context2` type in favor of the [`context.Context`](https://golang.org/x/net/context#Context) type from -the `golang.org/x/net/context` package +the `golang.org/x/net/context` package. Later replaced by the standard `context` package +of the [`context.Context`](https://golang.org/pkg/context#Context) type. + -This means its no longer possible to use the "Classic App Engine" +This means it's no longer possible to use the "Classic App Engine" `appengine.Context` type with the `oauth2` package. (You're using Classic App Engine if you import the package `"appengine"`.) @@ -38,27 +44,36 @@ If you don't want to update your entire app to use the new App Engine packages, you may use both sets of packages in parallel, using only the new packages with the `oauth2` package. - import ( - "golang.org/x/net/context" - "golang.org/x/oauth2" - "golang.org/x/oauth2/google" - newappengine "google.golang.org/appengine" - newurlfetch "google.golang.org/appengine/urlfetch" - - "appengine" - ) - - func handler(w http.ResponseWriter, r *http.Request) { - var c appengine.Context = appengine.NewContext(r) - c.Infof("Logging a message with the old package") - - var ctx context.Context = newappengine.NewContext(r) - client := &http.Client{ - Transport: &oauth2.Transport{ - Source: google.AppEngineTokenSource(ctx, "scope"), - Base: &newurlfetch.Transport{Context: ctx}, - }, - } - client.Get("...") +```go +import ( + "context" + "golang.org/x/oauth2" + "golang.org/x/oauth2/google" + newappengine "google.golang.org/appengine" + newurlfetch "google.golang.org/appengine/urlfetch" + + "appengine" +) + +func handler(w http.ResponseWriter, r *http.Request) { + var c appengine.Context = appengine.NewContext(r) + c.Infof("Logging a message with the old package") + + var ctx context.Context = newappengine.NewContext(r) + client := &http.Client{ + Transport: &oauth2.Transport{ + Source: google.AppEngineTokenSource(ctx, "scope"), + Base: &newurlfetch.Transport{Context: ctx}, + }, } + client.Get("...") +} +``` + +## Report Issues / Send Patches + +This repository uses Gerrit for code changes. To learn how to submit changes to +this repository, see https://golang.org/doc/contribute.html. +The main issue tracker for the oauth2 repository is located at +https://github.com/golang/oauth2/issues. diff --git a/vendor/golang.org/x/oauth2/client_appengine.go b/vendor/golang.org/x/oauth2/client_appengine.go deleted file mode 100644 index 8962c49d..00000000 --- a/vendor/golang.org/x/oauth2/client_appengine.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build appengine - -// App Engine hooks. - -package oauth2 - -import ( - "net/http" - - "golang.org/x/net/context" - "golang.org/x/oauth2/internal" - "google.golang.org/appengine/urlfetch" -) - -func init() { - internal.RegisterContextClientFunc(contextClientAppEngine) -} - -func contextClientAppEngine(ctx context.Context) (*http.Client, error) { - return urlfetch.Client(ctx), nil -} diff --git a/vendor/golang.org/x/oauth2/google/appengine.go b/vendor/golang.org/x/oauth2/google/appengine.go new file mode 100644 index 00000000..feb1157b --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/appengine.go @@ -0,0 +1,38 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package google + +import ( + "context" + "time" + + "golang.org/x/oauth2" +) + +// Set at init time by appengine_gen1.go. If nil, we're not on App Engine standard first generation (<= Go 1.9) or App Engine flexible. +var appengineTokenFunc func(c context.Context, scopes ...string) (token string, expiry time.Time, err error) + +// Set at init time by appengine_gen1.go. If nil, we're not on App Engine standard first generation (<= Go 1.9) or App Engine flexible. +var appengineAppIDFunc func(c context.Context) string + +// AppEngineTokenSource returns a token source that fetches tokens from either +// the current application's service account or from the metadata server, +// depending on the App Engine environment. See below for environment-specific +// details. If you are implementing a 3-legged OAuth 2.0 flow on App Engine that +// involves user accounts, see oauth2.Config instead. +// +// First generation App Engine runtimes (<= Go 1.9): +// AppEngineTokenSource returns a token source that fetches tokens issued to the +// current App Engine application's service account. The provided context must have +// come from appengine.NewContext. +// +// Second generation App Engine runtimes (>= Go 1.11) and App Engine flexible: +// AppEngineTokenSource is DEPRECATED on second generation runtimes and on the +// flexible environment. It delegates to ComputeTokenSource, and the provided +// context and scopes are not used. Please use DefaultTokenSource (or ComputeTokenSource, +// which DefaultTokenSource will use in this case) instead. +func AppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource { + return appEngineTokenSource(ctx, scope...) +} diff --git a/vendor/golang.org/x/oauth2/google/appengine_gen1.go b/vendor/golang.org/x/oauth2/google/appengine_gen1.go new file mode 100644 index 00000000..1ca0517c --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/appengine_gen1.go @@ -0,0 +1,77 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build appengine + +// This file applies to App Engine first generation runtimes (<= Go 1.9). + +package google + +import ( + "sort" + "strings" + "sync" + + "golang.org/x/net/context" + "golang.org/x/oauth2" + "google.golang.org/appengine" +) + +func init() { + appengineTokenFunc = appengine.AccessToken + appengineAppIDFunc = appengine.AppID +} + +// See comment on AppEngineTokenSource in appengine.go. +func appEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource { + scopes := append([]string{}, scope...) + sort.Strings(scopes) + return &gaeTokenSource{ + ctx: ctx, + scopes: scopes, + key: strings.Join(scopes, " "), + } +} + +// aeTokens helps the fetched tokens to be reused until their expiration. +var ( + aeTokensMu sync.Mutex + aeTokens = make(map[string]*tokenLock) // key is space-separated scopes +) + +type tokenLock struct { + mu sync.Mutex // guards t; held while fetching or updating t + t *oauth2.Token +} + +type gaeTokenSource struct { + ctx context.Context + scopes []string + key string // to aeTokens map; space-separated scopes +} + +func (ts *gaeTokenSource) Token() (*oauth2.Token, error) { + aeTokensMu.Lock() + tok, ok := aeTokens[ts.key] + if !ok { + tok = &tokenLock{} + aeTokens[ts.key] = tok + } + aeTokensMu.Unlock() + + tok.mu.Lock() + defer tok.mu.Unlock() + if tok.t.Valid() { + return tok.t, nil + } + access, exp, err := appengineTokenFunc(ts.ctx, ts.scopes...) + if err != nil { + return nil, err + } + tok.t = &oauth2.Token{ + AccessToken: access, + Expiry: exp, + } + return tok.t, nil +} diff --git a/vendor/golang.org/x/oauth2/google/appengine_gen2_flex.go b/vendor/golang.org/x/oauth2/google/appengine_gen2_flex.go new file mode 100644 index 00000000..819aa683 --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/appengine_gen2_flex.go @@ -0,0 +1,27 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !appengine + +// This file applies to App Engine second generation runtimes (>= Go 1.11) and App Engine flexible. + +package google + +import ( + "log" + "sync" + + "golang.org/x/net/context" + "golang.org/x/oauth2" +) + +var logOnce sync.Once // only spam about deprecation once + +// See comment on AppEngineTokenSource in appengine.go. +func appEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource { + logOnce.Do(func() { + log.Print("google: AppEngineTokenSource is deprecated on App Engine standard second generation runtimes (>= Go 1.11) and App Engine flexible. Please use DefaultTokenSource or ComputeTokenSource.") + }) + return ComputeTokenSource("") +} diff --git a/vendor/golang.org/x/oauth2/google/default.go b/vendor/golang.org/x/oauth2/google/default.go new file mode 100644 index 00000000..96f9a369 --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/default.go @@ -0,0 +1,118 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package google + +import ( + "context" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "os" + "path/filepath" + "runtime" + + "cloud.google.com/go/compute/metadata" + "golang.org/x/oauth2" +) + +// DefaultClient returns an HTTP Client that uses the +// DefaultTokenSource to obtain authentication credentials. +func DefaultClient(ctx context.Context, scope ...string) (*http.Client, error) { + ts, err := DefaultTokenSource(ctx, scope...) + if err != nil { + return nil, err + } + return oauth2.NewClient(ctx, ts), nil +} + +// DefaultTokenSource returns the token source for +// "Application Default Credentials". +// It is a shortcut for FindDefaultCredentials(ctx, scope).TokenSource. +func DefaultTokenSource(ctx context.Context, scope ...string) (oauth2.TokenSource, error) { + creds, err := FindDefaultCredentials(ctx, scope...) + if err != nil { + return nil, err + } + return creds.TokenSource, nil +} + +// Common implementation for FindDefaultCredentials. +func findDefaultCredentials(ctx context.Context, scopes []string) (*DefaultCredentials, error) { + // First, try the environment variable. + const envVar = "GOOGLE_APPLICATION_CREDENTIALS" + if filename := os.Getenv(envVar); filename != "" { + creds, err := readCredentialsFile(ctx, filename, scopes) + if err != nil { + return nil, fmt.Errorf("google: error getting credentials using %v environment variable: %v", envVar, err) + } + return creds, nil + } + + // Second, try a well-known file. + filename := wellKnownFile() + if creds, err := readCredentialsFile(ctx, filename, scopes); err == nil { + return creds, nil + } else if !os.IsNotExist(err) { + return nil, fmt.Errorf("google: error getting credentials using well-known file (%v): %v", filename, err) + } + + // Third, if we're on a Google App Engine standard first generation runtime (<= Go 1.9) + // use those credentials. App Engine standard second generation runtimes (>= Go 1.11) + // and App Engine flexible use ComputeTokenSource and the metadata server. + if appengineTokenFunc != nil { + return &DefaultCredentials{ + ProjectID: appengineAppIDFunc(ctx), + TokenSource: AppEngineTokenSource(ctx, scopes...), + }, nil + } + + // Fourth, if we're on Google Compute Engine, an App Engine standard second generation runtime, + // or App Engine flexible, use the metadata server. + if metadata.OnGCE() { + id, _ := metadata.ProjectID() + return &DefaultCredentials{ + ProjectID: id, + TokenSource: ComputeTokenSource(""), + }, nil + } + + // None are found; return helpful error. + const url = "https://developers.google.com/accounts/docs/application-default-credentials" + return nil, fmt.Errorf("google: could not find default credentials. See %v for more information.", url) +} + +// Common implementation for CredentialsFromJSON. +func credentialsFromJSON(ctx context.Context, jsonData []byte, scopes []string) (*DefaultCredentials, error) { + var f credentialsFile + if err := json.Unmarshal(jsonData, &f); err != nil { + return nil, err + } + ts, err := f.tokenSource(ctx, append([]string(nil), scopes...)) + if err != nil { + return nil, err + } + return &DefaultCredentials{ + ProjectID: f.ProjectID, + TokenSource: ts, + JSON: jsonData, + }, nil +} + +func wellKnownFile() string { + const f = "application_default_credentials.json" + if runtime.GOOS == "windows" { + return filepath.Join(os.Getenv("APPDATA"), "gcloud", f) + } + return filepath.Join(guessUnixHomeDir(), ".config", "gcloud", f) +} + +func readCredentialsFile(ctx context.Context, filename string, scopes []string) (*DefaultCredentials, error) { + b, err := ioutil.ReadFile(filename) + if err != nil { + return nil, err + } + return CredentialsFromJSON(ctx, b, scopes...) +} diff --git a/vendor/golang.org/x/oauth2/google/doc_go19.go b/vendor/golang.org/x/oauth2/google/doc_go19.go new file mode 100644 index 00000000..abd2b45f --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/doc_go19.go @@ -0,0 +1,42 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.9 + +// Package google provides support for making OAuth2 authorized and authenticated +// HTTP requests to Google APIs. It supports the Web server flow, client-side +// credentials, service accounts, Google Compute Engine service accounts, and Google +// App Engine service accounts. +// +// A brief overview of the package follows. For more information, please read +// https://developers.google.com/accounts/docs/OAuth2 +// and +// https://developers.google.com/accounts/docs/application-default-credentials. +// +// OAuth2 Configs +// +// Two functions in this package return golang.org/x/oauth2.Config values from Google credential +// data. Google supports two JSON formats for OAuth2 credentials: one is handled by ConfigFromJSON, +// the other by JWTConfigFromJSON. The returned Config can be used to obtain a TokenSource or +// create an http.Client. +// +// +// Credentials +// +// The Credentials type represents Google credentials, including Application Default +// Credentials. +// +// Use FindDefaultCredentials to obtain Application Default Credentials. +// FindDefaultCredentials looks in some well-known places for a credentials file, and +// will call AppEngineTokenSource or ComputeTokenSource as needed. +// +// DefaultClient and DefaultTokenSource are convenience methods. They first call FindDefaultCredentials, +// then use the credentials to construct an http.Client or an oauth2.TokenSource. +// +// Use CredentialsFromJSON to obtain credentials from either of the two JSON formats +// described in OAuth2 Configs, above. The TokenSource in the returned value is the +// same as the one obtained from the oauth2.Config returned from ConfigFromJSON or +// JWTConfigFromJSON, but the Credentials may contain additional information +// that is useful is some circumstances. +package google diff --git a/vendor/golang.org/x/oauth2/google/doc_not_go19.go b/vendor/golang.org/x/oauth2/google/doc_not_go19.go new file mode 100644 index 00000000..a27a7494 --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/doc_not_go19.go @@ -0,0 +1,43 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !go1.9 + +// Package google provides support for making OAuth2 authorized and authenticated +// HTTP requests to Google APIs. It supports the Web server flow, client-side +// credentials, service accounts, Google Compute Engine service accounts, and Google +// App Engine service accounts. +// +// A brief overview of the package follows. For more information, please read +// https://developers.google.com/accounts/docs/OAuth2 +// and +// https://developers.google.com/accounts/docs/application-default-credentials. +// +// OAuth2 Configs +// +// Two functions in this package return golang.org/x/oauth2.Config values from Google credential +// data. Google supports two JSON formats for OAuth2 credentials: one is handled by ConfigFromJSON, +// the other by JWTConfigFromJSON. The returned Config can be used to obtain a TokenSource or +// create an http.Client. +// +// +// Credentials +// +// The DefaultCredentials type represents Google Application Default Credentials, as +// well as other forms of credential. +// +// Use FindDefaultCredentials to obtain Application Default Credentials. +// FindDefaultCredentials looks in some well-known places for a credentials file, and +// will call AppEngineTokenSource or ComputeTokenSource as needed. +// +// DefaultClient and DefaultTokenSource are convenience methods. They first call FindDefaultCredentials, +// then use the credentials to construct an http.Client or an oauth2.TokenSource. +// +// Use CredentialsFromJSON to obtain credentials from either of the two JSON +// formats described in OAuth2 Configs, above. (The DefaultCredentials returned may +// not be "Application Default Credentials".) The TokenSource in the returned value +// is the same as the one obtained from the oauth2.Config returned from +// ConfigFromJSON or JWTConfigFromJSON, but the DefaultCredentials may contain +// additional information that is useful is some circumstances. +package google diff --git a/vendor/golang.org/x/oauth2/google/go19.go b/vendor/golang.org/x/oauth2/google/go19.go new file mode 100644 index 00000000..23fe4d8a --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/go19.go @@ -0,0 +1,60 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.9 + +package google + +import ( + "context" + + "golang.org/x/oauth2" +) + +// Credentials holds Google credentials, including "Application Default Credentials". +// For more details, see: +// https://developers.google.com/accounts/docs/application-default-credentials +type Credentials struct { + ProjectID string // may be empty + TokenSource oauth2.TokenSource + + // JSON contains the raw bytes from a JSON credentials file. + // This field may be nil if authentication is provided by the + // environment and not with a credentials file, e.g. when code is + // running on Google Cloud Platform. + JSON []byte +} + +// DefaultCredentials is the old name of Credentials. +// +// Deprecated: use Credentials instead. +type DefaultCredentials = Credentials + +// FindDefaultCredentials searches for "Application Default Credentials". +// +// It looks for credentials in the following places, +// preferring the first location found: +// +// 1. A JSON file whose path is specified by the +// GOOGLE_APPLICATION_CREDENTIALS environment variable. +// 2. A JSON file in a location known to the gcloud command-line tool. +// On Windows, this is %APPDATA%/gcloud/application_default_credentials.json. +// On other systems, $HOME/.config/gcloud/application_default_credentials.json. +// 3. On Google App Engine standard first generation runtimes (<= Go 1.9) it uses +// the appengine.AccessToken function. +// 4. On Google Compute Engine, Google App Engine standard second generation runtimes +// (>= Go 1.11), and Google App Engine flexible environment, it fetches +// credentials from the metadata server. +// (In this final case any provided scopes are ignored.) +func FindDefaultCredentials(ctx context.Context, scopes ...string) (*Credentials, error) { + return findDefaultCredentials(ctx, scopes) +} + +// CredentialsFromJSON obtains Google credentials from a JSON value. The JSON can +// represent either a Google Developers Console client_credentials.json file (as in +// ConfigFromJSON) or a Google Developers service account key file (as in +// JWTConfigFromJSON). +func CredentialsFromJSON(ctx context.Context, jsonData []byte, scopes ...string) (*Credentials, error) { + return credentialsFromJSON(ctx, jsonData, scopes) +} diff --git a/vendor/golang.org/x/oauth2/google/google.go b/vendor/golang.org/x/oauth2/google/google.go new file mode 100644 index 00000000..ca7d208d --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/google.go @@ -0,0 +1,192 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package google + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "strings" + "time" + + "cloud.google.com/go/compute/metadata" + "golang.org/x/oauth2" + "golang.org/x/oauth2/jwt" +) + +// Endpoint is Google's OAuth 2.0 endpoint. +var Endpoint = oauth2.Endpoint{ + AuthURL: "https://accounts.google.com/o/oauth2/auth", + TokenURL: "https://accounts.google.com/o/oauth2/token", +} + +// JWTTokenURL is Google's OAuth 2.0 token URL to use with the JWT flow. +const JWTTokenURL = "https://accounts.google.com/o/oauth2/token" + +// ConfigFromJSON uses a Google Developers Console client_credentials.json +// file to construct a config. +// client_credentials.json can be downloaded from +// https://console.developers.google.com, under "Credentials". Download the Web +// application credentials in the JSON format and provide the contents of the +// file as jsonKey. +func ConfigFromJSON(jsonKey []byte, scope ...string) (*oauth2.Config, error) { + type cred struct { + ClientID string `json:"client_id"` + ClientSecret string `json:"client_secret"` + RedirectURIs []string `json:"redirect_uris"` + AuthURI string `json:"auth_uri"` + TokenURI string `json:"token_uri"` + } + var j struct { + Web *cred `json:"web"` + Installed *cred `json:"installed"` + } + if err := json.Unmarshal(jsonKey, &j); err != nil { + return nil, err + } + var c *cred + switch { + case j.Web != nil: + c = j.Web + case j.Installed != nil: + c = j.Installed + default: + return nil, fmt.Errorf("oauth2/google: no credentials found") + } + if len(c.RedirectURIs) < 1 { + return nil, errors.New("oauth2/google: missing redirect URL in the client_credentials.json") + } + return &oauth2.Config{ + ClientID: c.ClientID, + ClientSecret: c.ClientSecret, + RedirectURL: c.RedirectURIs[0], + Scopes: scope, + Endpoint: oauth2.Endpoint{ + AuthURL: c.AuthURI, + TokenURL: c.TokenURI, + }, + }, nil +} + +// JWTConfigFromJSON uses a Google Developers service account JSON key file to read +// the credentials that authorize and authenticate the requests. +// Create a service account on "Credentials" for your project at +// https://console.developers.google.com to download a JSON key file. +func JWTConfigFromJSON(jsonKey []byte, scope ...string) (*jwt.Config, error) { + var f credentialsFile + if err := json.Unmarshal(jsonKey, &f); err != nil { + return nil, err + } + if f.Type != serviceAccountKey { + return nil, fmt.Errorf("google: read JWT from JSON credentials: 'type' field is %q (expected %q)", f.Type, serviceAccountKey) + } + scope = append([]string(nil), scope...) // copy + return f.jwtConfig(scope), nil +} + +// JSON key file types. +const ( + serviceAccountKey = "service_account" + userCredentialsKey = "authorized_user" +) + +// credentialsFile is the unmarshalled representation of a credentials file. +type credentialsFile struct { + Type string `json:"type"` // serviceAccountKey or userCredentialsKey + + // Service Account fields + ClientEmail string `json:"client_email"` + PrivateKeyID string `json:"private_key_id"` + PrivateKey string `json:"private_key"` + TokenURL string `json:"token_uri"` + ProjectID string `json:"project_id"` + + // User Credential fields + // (These typically come from gcloud auth.) + ClientSecret string `json:"client_secret"` + ClientID string `json:"client_id"` + RefreshToken string `json:"refresh_token"` +} + +func (f *credentialsFile) jwtConfig(scopes []string) *jwt.Config { + cfg := &jwt.Config{ + Email: f.ClientEmail, + PrivateKey: []byte(f.PrivateKey), + PrivateKeyID: f.PrivateKeyID, + Scopes: scopes, + TokenURL: f.TokenURL, + } + if cfg.TokenURL == "" { + cfg.TokenURL = JWTTokenURL + } + return cfg +} + +func (f *credentialsFile) tokenSource(ctx context.Context, scopes []string) (oauth2.TokenSource, error) { + switch f.Type { + case serviceAccountKey: + cfg := f.jwtConfig(scopes) + return cfg.TokenSource(ctx), nil + case userCredentialsKey: + cfg := &oauth2.Config{ + ClientID: f.ClientID, + ClientSecret: f.ClientSecret, + Scopes: scopes, + Endpoint: Endpoint, + } + tok := &oauth2.Token{RefreshToken: f.RefreshToken} + return cfg.TokenSource(ctx, tok), nil + case "": + return nil, errors.New("missing 'type' field in credentials") + default: + return nil, fmt.Errorf("unknown credential type: %q", f.Type) + } +} + +// ComputeTokenSource returns a token source that fetches access tokens +// from Google Compute Engine (GCE)'s metadata server. It's only valid to use +// this token source if your program is running on a GCE instance. +// If no account is specified, "default" is used. +// Further information about retrieving access tokens from the GCE metadata +// server can be found at https://cloud.google.com/compute/docs/authentication. +func ComputeTokenSource(account string) oauth2.TokenSource { + return oauth2.ReuseTokenSource(nil, computeSource{account: account}) +} + +type computeSource struct { + account string +} + +func (cs computeSource) Token() (*oauth2.Token, error) { + if !metadata.OnGCE() { + return nil, errors.New("oauth2/google: can't get a token from the metadata service; not running on GCE") + } + acct := cs.account + if acct == "" { + acct = "default" + } + tokenJSON, err := metadata.Get("instance/service-accounts/" + acct + "/token") + if err != nil { + return nil, err + } + var res struct { + AccessToken string `json:"access_token"` + ExpiresInSec int `json:"expires_in"` + TokenType string `json:"token_type"` + } + err = json.NewDecoder(strings.NewReader(tokenJSON)).Decode(&res) + if err != nil { + return nil, fmt.Errorf("oauth2/google: invalid token JSON from metadata: %v", err) + } + if res.ExpiresInSec == 0 || res.AccessToken == "" { + return nil, fmt.Errorf("oauth2/google: incomplete token received from metadata") + } + return &oauth2.Token{ + AccessToken: res.AccessToken, + TokenType: res.TokenType, + Expiry: time.Now().Add(time.Duration(res.ExpiresInSec) * time.Second), + }, nil +} diff --git a/vendor/golang.org/x/oauth2/google/jwt.go b/vendor/golang.org/x/oauth2/google/jwt.go new file mode 100644 index 00000000..b0fdb3a8 --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/jwt.go @@ -0,0 +1,74 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package google + +import ( + "crypto/rsa" + "fmt" + "time" + + "golang.org/x/oauth2" + "golang.org/x/oauth2/internal" + "golang.org/x/oauth2/jws" +) + +// JWTAccessTokenSourceFromJSON uses a Google Developers service account JSON +// key file to read the credentials that authorize and authenticate the +// requests, and returns a TokenSource that does not use any OAuth2 flow but +// instead creates a JWT and sends that as the access token. +// The audience is typically a URL that specifies the scope of the credentials. +// +// Note that this is not a standard OAuth flow, but rather an +// optimization supported by a few Google services. +// Unless you know otherwise, you should use JWTConfigFromJSON instead. +func JWTAccessTokenSourceFromJSON(jsonKey []byte, audience string) (oauth2.TokenSource, error) { + cfg, err := JWTConfigFromJSON(jsonKey) + if err != nil { + return nil, fmt.Errorf("google: could not parse JSON key: %v", err) + } + pk, err := internal.ParseKey(cfg.PrivateKey) + if err != nil { + return nil, fmt.Errorf("google: could not parse key: %v", err) + } + ts := &jwtAccessTokenSource{ + email: cfg.Email, + audience: audience, + pk: pk, + pkID: cfg.PrivateKeyID, + } + tok, err := ts.Token() + if err != nil { + return nil, err + } + return oauth2.ReuseTokenSource(tok, ts), nil +} + +type jwtAccessTokenSource struct { + email, audience string + pk *rsa.PrivateKey + pkID string +} + +func (ts *jwtAccessTokenSource) Token() (*oauth2.Token, error) { + iat := time.Now() + exp := iat.Add(time.Hour) + cs := &jws.ClaimSet{ + Iss: ts.email, + Sub: ts.email, + Aud: ts.audience, + Iat: iat.Unix(), + Exp: exp.Unix(), + } + hdr := &jws.Header{ + Algorithm: "RS256", + Typ: "JWT", + KeyID: string(ts.pkID), + } + msg, err := jws.Encode(hdr, cs, ts.pk) + if err != nil { + return nil, fmt.Errorf("google: could not encode JWT: %v", err) + } + return &oauth2.Token{AccessToken: msg, TokenType: "Bearer", Expiry: exp}, nil +} diff --git a/vendor/golang.org/x/oauth2/google/not_go19.go b/vendor/golang.org/x/oauth2/google/not_go19.go new file mode 100644 index 00000000..f942b326 --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/not_go19.go @@ -0,0 +1,57 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !go1.9 + +package google + +import ( + "context" + + "golang.org/x/oauth2" +) + +// DefaultCredentials holds Google credentials, including "Application Default Credentials". +// For more details, see: +// https://developers.google.com/accounts/docs/application-default-credentials +type DefaultCredentials struct { + ProjectID string // may be empty + TokenSource oauth2.TokenSource + + // JSON contains the raw bytes from a JSON credentials file. + // This field may be nil if authentication is provided by the + // environment and not with a credentials file, e.g. when code is + // running on Google Cloud Platform. + JSON []byte +} + +// FindDefaultCredentials searches for "Application Default Credentials". +// +// It looks for credentials in the following places, +// preferring the first location found: +// +// 1. A JSON file whose path is specified by the +// GOOGLE_APPLICATION_CREDENTIALS environment variable. +// 2. A JSON file in a location known to the gcloud command-line tool. +// On Windows, this is %APPDATA%/gcloud/application_default_credentials.json. +// On other systems, $HOME/.config/gcloud/application_default_credentials.json. +// 3. On Google App Engine standard first generation runtimes (<= Go 1.9) it uses +// the appengine.AccessToken function. +// 4. On Google Compute Engine, Google App Engine standard second generation runtimes +// (>= Go 1.11), and Google App Engine flexible environment, it fetches +// credentials from the metadata server. +// (In this final case any provided scopes are ignored.) +func FindDefaultCredentials(ctx context.Context, scopes ...string) (*DefaultCredentials, error) { + return findDefaultCredentials(ctx, scopes) +} + +// CredentialsFromJSON obtains Google credentials from a JSON value. The JSON can +// represent either a Google Developers Console client_credentials.json file (as in +// ConfigFromJSON) or a Google Developers service account key file (as in +// JWTConfigFromJSON). +// +// Note: despite the name, the returned credentials may not be Application Default Credentials. +func CredentialsFromJSON(ctx context.Context, jsonData []byte, scopes ...string) (*DefaultCredentials, error) { + return credentialsFromJSON(ctx, jsonData, scopes) +} diff --git a/vendor/golang.org/x/oauth2/google/sdk.go b/vendor/golang.org/x/oauth2/google/sdk.go new file mode 100644 index 00000000..456224bc --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/sdk.go @@ -0,0 +1,201 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package google + +import ( + "bufio" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "os" + "os/user" + "path/filepath" + "runtime" + "strings" + "time" + + "golang.org/x/oauth2" +) + +type sdkCredentials struct { + Data []struct { + Credential struct { + ClientID string `json:"client_id"` + ClientSecret string `json:"client_secret"` + AccessToken string `json:"access_token"` + RefreshToken string `json:"refresh_token"` + TokenExpiry *time.Time `json:"token_expiry"` + } `json:"credential"` + Key struct { + Account string `json:"account"` + Scope string `json:"scope"` + } `json:"key"` + } +} + +// An SDKConfig provides access to tokens from an account already +// authorized via the Google Cloud SDK. +type SDKConfig struct { + conf oauth2.Config + initialToken *oauth2.Token +} + +// NewSDKConfig creates an SDKConfig for the given Google Cloud SDK +// account. If account is empty, the account currently active in +// Google Cloud SDK properties is used. +// Google Cloud SDK credentials must be created by running `gcloud auth` +// before using this function. +// The Google Cloud SDK is available at https://cloud.google.com/sdk/. +func NewSDKConfig(account string) (*SDKConfig, error) { + configPath, err := sdkConfigPath() + if err != nil { + return nil, fmt.Errorf("oauth2/google: error getting SDK config path: %v", err) + } + credentialsPath := filepath.Join(configPath, "credentials") + f, err := os.Open(credentialsPath) + if err != nil { + return nil, fmt.Errorf("oauth2/google: failed to load SDK credentials: %v", err) + } + defer f.Close() + + var c sdkCredentials + if err := json.NewDecoder(f).Decode(&c); err != nil { + return nil, fmt.Errorf("oauth2/google: failed to decode SDK credentials from %q: %v", credentialsPath, err) + } + if len(c.Data) == 0 { + return nil, fmt.Errorf("oauth2/google: no credentials found in %q, run `gcloud auth login` to create one", credentialsPath) + } + if account == "" { + propertiesPath := filepath.Join(configPath, "properties") + f, err := os.Open(propertiesPath) + if err != nil { + return nil, fmt.Errorf("oauth2/google: failed to load SDK properties: %v", err) + } + defer f.Close() + ini, err := parseINI(f) + if err != nil { + return nil, fmt.Errorf("oauth2/google: failed to parse SDK properties %q: %v", propertiesPath, err) + } + core, ok := ini["core"] + if !ok { + return nil, fmt.Errorf("oauth2/google: failed to find [core] section in %v", ini) + } + active, ok := core["account"] + if !ok { + return nil, fmt.Errorf("oauth2/google: failed to find %q attribute in %v", "account", core) + } + account = active + } + + for _, d := range c.Data { + if account == "" || d.Key.Account == account { + if d.Credential.AccessToken == "" && d.Credential.RefreshToken == "" { + return nil, fmt.Errorf("oauth2/google: no token available for account %q", account) + } + var expiry time.Time + if d.Credential.TokenExpiry != nil { + expiry = *d.Credential.TokenExpiry + } + return &SDKConfig{ + conf: oauth2.Config{ + ClientID: d.Credential.ClientID, + ClientSecret: d.Credential.ClientSecret, + Scopes: strings.Split(d.Key.Scope, " "), + Endpoint: Endpoint, + RedirectURL: "oob", + }, + initialToken: &oauth2.Token{ + AccessToken: d.Credential.AccessToken, + RefreshToken: d.Credential.RefreshToken, + Expiry: expiry, + }, + }, nil + } + } + return nil, fmt.Errorf("oauth2/google: no such credentials for account %q", account) +} + +// Client returns an HTTP client using Google Cloud SDK credentials to +// authorize requests. The token will auto-refresh as necessary. The +// underlying http.RoundTripper will be obtained using the provided +// context. The returned client and its Transport should not be +// modified. +func (c *SDKConfig) Client(ctx context.Context) *http.Client { + return &http.Client{ + Transport: &oauth2.Transport{ + Source: c.TokenSource(ctx), + }, + } +} + +// TokenSource returns an oauth2.TokenSource that retrieve tokens from +// Google Cloud SDK credentials using the provided context. +// It will returns the current access token stored in the credentials, +// and refresh it when it expires, but it won't update the credentials +// with the new access token. +func (c *SDKConfig) TokenSource(ctx context.Context) oauth2.TokenSource { + return c.conf.TokenSource(ctx, c.initialToken) +} + +// Scopes are the OAuth 2.0 scopes the current account is authorized for. +func (c *SDKConfig) Scopes() []string { + return c.conf.Scopes +} + +func parseINI(ini io.Reader) (map[string]map[string]string, error) { + result := map[string]map[string]string{ + "": {}, // root section + } + scanner := bufio.NewScanner(ini) + currentSection := "" + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + if strings.HasPrefix(line, ";") { + // comment. + continue + } + if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") { + currentSection = strings.TrimSpace(line[1 : len(line)-1]) + result[currentSection] = map[string]string{} + continue + } + parts := strings.SplitN(line, "=", 2) + if len(parts) == 2 && parts[0] != "" { + result[currentSection][strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1]) + } + } + if err := scanner.Err(); err != nil { + return nil, fmt.Errorf("error scanning ini: %v", err) + } + return result, nil +} + +// sdkConfigPath tries to guess where the gcloud config is located. +// It can be overridden during tests. +var sdkConfigPath = func() (string, error) { + if runtime.GOOS == "windows" { + return filepath.Join(os.Getenv("APPDATA"), "gcloud"), nil + } + homeDir := guessUnixHomeDir() + if homeDir == "" { + return "", errors.New("unable to get current user home directory: os/user lookup failed; $HOME is empty") + } + return filepath.Join(homeDir, ".config", "gcloud"), nil +} + +func guessUnixHomeDir() string { + // Prefer $HOME over user.Current due to glibc bug: golang.org/issue/13470 + if v := os.Getenv("HOME"); v != "" { + return v + } + // Else, fall back to user.Current: + if u, err := user.Current(); err == nil { + return u.HomeDir + } + return "" +} diff --git a/vendor/golang.org/x/oauth2/internal/client_appengine.go b/vendor/golang.org/x/oauth2/internal/client_appengine.go new file mode 100644 index 00000000..74348718 --- /dev/null +++ b/vendor/golang.org/x/oauth2/internal/client_appengine.go @@ -0,0 +1,13 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build appengine + +package internal + +import "google.golang.org/appengine/urlfetch" + +func init() { + appengineClientHook = urlfetch.Client +} diff --git a/vendor/golang.org/x/oauth2/internal/doc.go b/vendor/golang.org/x/oauth2/internal/doc.go new file mode 100644 index 00000000..03265e88 --- /dev/null +++ b/vendor/golang.org/x/oauth2/internal/doc.go @@ -0,0 +1,6 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package internal contains support packages for oauth2 package. +package internal diff --git a/vendor/golang.org/x/oauth2/internal/oauth2.go b/vendor/golang.org/x/oauth2/internal/oauth2.go index fbe1028d..c0ab196c 100644 --- a/vendor/golang.org/x/oauth2/internal/oauth2.go +++ b/vendor/golang.org/x/oauth2/internal/oauth2.go @@ -2,18 +2,14 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package internal contains support packages for oauth2 package. package internal import ( - "bufio" "crypto/rsa" "crypto/x509" "encoding/pem" "errors" "fmt" - "io" - "strings" ) // ParseKey converts the binary contents of a private key file @@ -30,7 +26,7 @@ func ParseKey(key []byte) (*rsa.PrivateKey, error) { if err != nil { parsedKey, err = x509.ParsePKCS1PrivateKey(key) if err != nil { - return nil, fmt.Errorf("private key should be a PEM or plain PKSC1 or PKCS8; parse error: %v", err) + return nil, fmt.Errorf("private key should be a PEM or plain PKCS1 or PKCS8; parse error: %v", err) } } parsed, ok := parsedKey.(*rsa.PrivateKey) @@ -39,38 +35,3 @@ func ParseKey(key []byte) (*rsa.PrivateKey, error) { } return parsed, nil } - -func ParseINI(ini io.Reader) (map[string]map[string]string, error) { - result := map[string]map[string]string{ - "": map[string]string{}, // root section - } - scanner := bufio.NewScanner(ini) - currentSection := "" - for scanner.Scan() { - line := strings.TrimSpace(scanner.Text()) - if strings.HasPrefix(line, ";") { - // comment. - continue - } - if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") { - currentSection = strings.TrimSpace(line[1 : len(line)-1]) - result[currentSection] = map[string]string{} - continue - } - parts := strings.SplitN(line, "=", 2) - if len(parts) == 2 && parts[0] != "" { - result[currentSection][strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1]) - } - } - if err := scanner.Err(); err != nil { - return nil, fmt.Errorf("error scanning ini: %v", err) - } - return result, nil -} - -func CondVal(v string) []string { - if v == "" { - return nil - } - return []string{v} -} diff --git a/vendor/golang.org/x/oauth2/internal/token.go b/vendor/golang.org/x/oauth2/internal/token.go index a6ed3cc7..5ab17b9a 100644 --- a/vendor/golang.org/x/oauth2/internal/token.go +++ b/vendor/golang.org/x/oauth2/internal/token.go @@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package internal contains support packages for oauth2 package. package internal import ( + "context" "encoding/json" + "errors" "fmt" "io" "io/ioutil" @@ -17,10 +18,10 @@ import ( "strings" "time" - "golang.org/x/net/context" + "golang.org/x/net/context/ctxhttp" ) -// Token represents the crendentials used to authorize +// Token represents the credentials used to authorize // the requests to access protected resources on the OAuth 2.0 // provider's backend. // @@ -91,6 +92,7 @@ func (e *expirationTime) UnmarshalJSON(b []byte) error { var brokenAuthHeaderProviders = []string{ "https://accounts.google.com/", + "https://api.codeswholesale.com/oauth/token", "https://api.dropbox.com/", "https://api.dropboxapi.com/", "https://api.instagram.com/", @@ -99,10 +101,16 @@ var brokenAuthHeaderProviders = []string{ "https://api.pushbullet.com/", "https://api.soundcloud.com/", "https://api.twitch.tv/", + "https://id.twitch.tv/", "https://app.box.com/", + "https://api.box.com/", "https://connect.stripe.com/", + "https://login.mailchimp.com/", "https://login.microsoftonline.com/", "https://login.salesforce.com/", + "https://login.windows.net", + "https://login.live.com/", + "https://login.live-int.com/", "https://oauth.sandbox.trainingpeaks.com/", "https://oauth.trainingpeaks.com/", "https://oauth.vk.com/", @@ -117,6 +125,24 @@ var brokenAuthHeaderProviders = []string{ "https://www.strava.com/oauth/", "https://www.wunderlist.com/oauth/", "https://api.patreon.com/", + "https://sandbox.codeswholesale.com/oauth/token", + "https://api.sipgate.com/v1/authorization/oauth", + "https://api.medium.com/v1/tokens", + "https://log.finalsurge.com/oauth/token", + "https://multisport.todaysplan.com.au/rest/oauth/access_token", + "https://whats.todaysplan.com.au/rest/oauth/access_token", + "https://stackoverflow.com/oauth/access_token", + "https://account.health.nokia.com", + "https://accounts.zoho.com", +} + +// brokenAuthHeaderDomains lists broken providers that issue dynamic endpoints. +var brokenAuthHeaderDomains = []string{ + ".auth0.com", + ".force.com", + ".myshopify.com", + ".okta.com", + ".oktapreview.com", } func RegisterBrokenAuthHeaderProvider(tokenURL string) { @@ -139,6 +165,14 @@ func providerAuthHeaderWorks(tokenURL string) bool { } } + if u, err := url.Parse(tokenURL); err == nil { + for _, s := range brokenAuthHeaderDomains { + if strings.HasSuffix(u.Host, s) { + return false + } + } + } + // Assume the provider implements the spec properly // otherwise. We can add more exceptions as they're // discovered. We will _not_ be adding configurable hooks @@ -146,25 +180,25 @@ func providerAuthHeaderWorks(tokenURL string) bool { return true } -func RetrieveToken(ctx context.Context, ClientID, ClientSecret, TokenURL string, v url.Values) (*Token, error) { - hc, err := ContextClient(ctx) - if err != nil { - return nil, err - } - v.Set("client_id", ClientID) - bustedAuth := !providerAuthHeaderWorks(TokenURL) - if bustedAuth && ClientSecret != "" { - v.Set("client_secret", ClientSecret) +func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string, v url.Values) (*Token, error) { + bustedAuth := !providerAuthHeaderWorks(tokenURL) + if bustedAuth { + if clientID != "" { + v.Set("client_id", clientID) + } + if clientSecret != "" { + v.Set("client_secret", clientSecret) + } } - req, err := http.NewRequest("POST", TokenURL, strings.NewReader(v.Encode())) + req, err := http.NewRequest("POST", tokenURL, strings.NewReader(v.Encode())) if err != nil { return nil, err } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") if !bustedAuth { - req.SetBasicAuth(ClientID, ClientSecret) + req.SetBasicAuth(url.QueryEscape(clientID), url.QueryEscape(clientSecret)) } - r, err := hc.Do(req) + r, err := ctxhttp.Do(ctx, ContextClient(ctx), req) if err != nil { return nil, err } @@ -174,7 +208,10 @@ func RetrieveToken(ctx context.Context, ClientID, ClientSecret, TokenURL string, return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err) } if code := r.StatusCode; code < 200 || code > 299 { - return nil, fmt.Errorf("oauth2: cannot fetch token: %v\nResponse: %s", r.Status, body) + return nil, &RetrieveError{ + Response: r, + Body: body, + } } var token *Token @@ -221,5 +258,17 @@ func RetrieveToken(ctx context.Context, ClientID, ClientSecret, TokenURL string, if token.RefreshToken == "" { token.RefreshToken = v.Get("refresh_token") } + if token.AccessToken == "" { + return token, errors.New("oauth2: server response missing access_token") + } return token, nil } + +type RetrieveError struct { + Response *http.Response + Body []byte +} + +func (r *RetrieveError) Error() string { + return fmt.Sprintf("oauth2: cannot fetch token: %v\nResponse: %s", r.Response.Status, r.Body) +} diff --git a/vendor/golang.org/x/oauth2/internal/transport.go b/vendor/golang.org/x/oauth2/internal/transport.go index f1f173e3..572074a6 100644 --- a/vendor/golang.org/x/oauth2/internal/transport.go +++ b/vendor/golang.org/x/oauth2/internal/transport.go @@ -2,13 +2,11 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package internal contains support packages for oauth2 package. package internal import ( + "context" "net/http" - - "golang.org/x/net/context" ) // HTTPClient is the context key to use with golang.org/x/net/context's @@ -20,50 +18,16 @@ var HTTPClient ContextKey // because nobody else can create a ContextKey, being unexported. type ContextKey struct{} -// ContextClientFunc is a func which tries to return an *http.Client -// given a Context value. If it returns an error, the search stops -// with that error. If it returns (nil, nil), the search continues -// down the list of registered funcs. -type ContextClientFunc func(context.Context) (*http.Client, error) - -var contextClientFuncs []ContextClientFunc - -func RegisterContextClientFunc(fn ContextClientFunc) { - contextClientFuncs = append(contextClientFuncs, fn) -} +var appengineClientHook func(context.Context) *http.Client -func ContextClient(ctx context.Context) (*http.Client, error) { +func ContextClient(ctx context.Context) *http.Client { if ctx != nil { if hc, ok := ctx.Value(HTTPClient).(*http.Client); ok { - return hc, nil - } - } - for _, fn := range contextClientFuncs { - c, err := fn(ctx) - if err != nil { - return nil, err - } - if c != nil { - return c, nil + return hc } } - return http.DefaultClient, nil -} - -func ContextTransport(ctx context.Context) http.RoundTripper { - hc, err := ContextClient(ctx) - // This is a rare error case (somebody using nil on App Engine). - if err != nil { - return ErrorTransport{err} + if appengineClientHook != nil { + return appengineClientHook(ctx) } - return hc.Transport -} - -// ErrorTransport returns the specified error on RoundTrip. -// This RoundTripper should be used in rare error cases where -// error handling can be postponed to response handling time. -type ErrorTransport struct{ Err error } - -func (t ErrorTransport) RoundTrip(*http.Request) (*http.Response, error) { - return nil, t.Err + return http.DefaultClient } diff --git a/vendor/golang.org/x/oauth2/jws/jws.go b/vendor/golang.org/x/oauth2/jws/jws.go new file mode 100644 index 00000000..8bcecb46 --- /dev/null +++ b/vendor/golang.org/x/oauth2/jws/jws.go @@ -0,0 +1,182 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package jws provides a partial implementation +// of JSON Web Signature encoding and decoding. +// It exists to support the golang.org/x/oauth2 package. +// +// See RFC 7515. +// +// Deprecated: this package is not intended for public use and might be +// removed in the future. It exists for internal use only. +// Please switch to another JWS package or copy this package into your own +// source tree. +package jws + +import ( + "bytes" + "crypto" + "crypto/rand" + "crypto/rsa" + "crypto/sha256" + "encoding/base64" + "encoding/json" + "errors" + "fmt" + "strings" + "time" +) + +// ClaimSet contains information about the JWT signature including the +// permissions being requested (scopes), the target of the token, the issuer, +// the time the token was issued, and the lifetime of the token. +type ClaimSet struct { + Iss string `json:"iss"` // email address of the client_id of the application making the access token request + Scope string `json:"scope,omitempty"` // space-delimited list of the permissions the application requests + Aud string `json:"aud"` // descriptor of the intended target of the assertion (Optional). + Exp int64 `json:"exp"` // the expiration time of the assertion (seconds since Unix epoch) + Iat int64 `json:"iat"` // the time the assertion was issued (seconds since Unix epoch) + Typ string `json:"typ,omitempty"` // token type (Optional). + + // Email for which the application is requesting delegated access (Optional). + Sub string `json:"sub,omitempty"` + + // The old name of Sub. Client keeps setting Prn to be + // complaint with legacy OAuth 2.0 providers. (Optional) + Prn string `json:"prn,omitempty"` + + // See http://tools.ietf.org/html/draft-jones-json-web-token-10#section-4.3 + // This array is marshalled using custom code (see (c *ClaimSet) encode()). + PrivateClaims map[string]interface{} `json:"-"` +} + +func (c *ClaimSet) encode() (string, error) { + // Reverting time back for machines whose time is not perfectly in sync. + // If client machine's time is in the future according + // to Google servers, an access token will not be issued. + now := time.Now().Add(-10 * time.Second) + if c.Iat == 0 { + c.Iat = now.Unix() + } + if c.Exp == 0 { + c.Exp = now.Add(time.Hour).Unix() + } + if c.Exp < c.Iat { + return "", fmt.Errorf("jws: invalid Exp = %v; must be later than Iat = %v", c.Exp, c.Iat) + } + + b, err := json.Marshal(c) + if err != nil { + return "", err + } + + if len(c.PrivateClaims) == 0 { + return base64.RawURLEncoding.EncodeToString(b), nil + } + + // Marshal private claim set and then append it to b. + prv, err := json.Marshal(c.PrivateClaims) + if err != nil { + return "", fmt.Errorf("jws: invalid map of private claims %v", c.PrivateClaims) + } + + // Concatenate public and private claim JSON objects. + if !bytes.HasSuffix(b, []byte{'}'}) { + return "", fmt.Errorf("jws: invalid JSON %s", b) + } + if !bytes.HasPrefix(prv, []byte{'{'}) { + return "", fmt.Errorf("jws: invalid JSON %s", prv) + } + b[len(b)-1] = ',' // Replace closing curly brace with a comma. + b = append(b, prv[1:]...) // Append private claims. + return base64.RawURLEncoding.EncodeToString(b), nil +} + +// Header represents the header for the signed JWS payloads. +type Header struct { + // The algorithm used for signature. + Algorithm string `json:"alg"` + + // Represents the token type. + Typ string `json:"typ"` + + // The optional hint of which key is being used. + KeyID string `json:"kid,omitempty"` +} + +func (h *Header) encode() (string, error) { + b, err := json.Marshal(h) + if err != nil { + return "", err + } + return base64.RawURLEncoding.EncodeToString(b), nil +} + +// Decode decodes a claim set from a JWS payload. +func Decode(payload string) (*ClaimSet, error) { + // decode returned id token to get expiry + s := strings.Split(payload, ".") + if len(s) < 2 { + // TODO(jbd): Provide more context about the error. + return nil, errors.New("jws: invalid token received") + } + decoded, err := base64.RawURLEncoding.DecodeString(s[1]) + if err != nil { + return nil, err + } + c := &ClaimSet{} + err = json.NewDecoder(bytes.NewBuffer(decoded)).Decode(c) + return c, err +} + +// Signer returns a signature for the given data. +type Signer func(data []byte) (sig []byte, err error) + +// EncodeWithSigner encodes a header and claim set with the provided signer. +func EncodeWithSigner(header *Header, c *ClaimSet, sg Signer) (string, error) { + head, err := header.encode() + if err != nil { + return "", err + } + cs, err := c.encode() + if err != nil { + return "", err + } + ss := fmt.Sprintf("%s.%s", head, cs) + sig, err := sg([]byte(ss)) + if err != nil { + return "", err + } + return fmt.Sprintf("%s.%s", ss, base64.RawURLEncoding.EncodeToString(sig)), nil +} + +// Encode encodes a signed JWS with provided header and claim set. +// This invokes EncodeWithSigner using crypto/rsa.SignPKCS1v15 with the given RSA private key. +func Encode(header *Header, c *ClaimSet, key *rsa.PrivateKey) (string, error) { + sg := func(data []byte) (sig []byte, err error) { + h := sha256.New() + h.Write(data) + return rsa.SignPKCS1v15(rand.Reader, key, crypto.SHA256, h.Sum(nil)) + } + return EncodeWithSigner(header, c, sg) +} + +// Verify tests whether the provided JWT token's signature was produced by the private key +// associated with the supplied public key. +func Verify(token string, key *rsa.PublicKey) error { + parts := strings.Split(token, ".") + if len(parts) != 3 { + return errors.New("jws: invalid token received, token must have 3 parts") + } + + signedContent := parts[0] + "." + parts[1] + signatureString, err := base64.RawURLEncoding.DecodeString(parts[2]) + if err != nil { + return err + } + + h := sha256.New() + h.Write([]byte(signedContent)) + return rsa.VerifyPKCS1v15(key, crypto.SHA256, h.Sum(nil), []byte(signatureString)) +} diff --git a/vendor/golang.org/x/oauth2/jwt/jwt.go b/vendor/golang.org/x/oauth2/jwt/jwt.go new file mode 100644 index 00000000..0783a94c --- /dev/null +++ b/vendor/golang.org/x/oauth2/jwt/jwt.go @@ -0,0 +1,162 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package jwt implements the OAuth 2.0 JSON Web Token flow, commonly +// known as "two-legged OAuth 2.0". +// +// See: https://tools.ietf.org/html/draft-ietf-oauth-jwt-bearer-12 +package jwt + +import ( + "context" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "strings" + "time" + + "golang.org/x/oauth2" + "golang.org/x/oauth2/internal" + "golang.org/x/oauth2/jws" +) + +var ( + defaultGrantType = "urn:ietf:params:oauth:grant-type:jwt-bearer" + defaultHeader = &jws.Header{Algorithm: "RS256", Typ: "JWT"} +) + +// Config is the configuration for using JWT to fetch tokens, +// commonly known as "two-legged OAuth 2.0". +type Config struct { + // Email is the OAuth client identifier used when communicating with + // the configured OAuth provider. + Email string + + // PrivateKey contains the contents of an RSA private key or the + // contents of a PEM file that contains a private key. The provided + // private key is used to sign JWT payloads. + // PEM containers with a passphrase are not supported. + // Use the following command to convert a PKCS 12 file into a PEM. + // + // $ openssl pkcs12 -in key.p12 -out key.pem -nodes + // + PrivateKey []byte + + // PrivateKeyID contains an optional hint indicating which key is being + // used. + PrivateKeyID string + + // Subject is the optional user to impersonate. + Subject string + + // Scopes optionally specifies a list of requested permission scopes. + Scopes []string + + // TokenURL is the endpoint required to complete the 2-legged JWT flow. + TokenURL string + + // Expires optionally specifies how long the token is valid for. + Expires time.Duration +} + +// TokenSource returns a JWT TokenSource using the configuration +// in c and the HTTP client from the provided context. +func (c *Config) TokenSource(ctx context.Context) oauth2.TokenSource { + return oauth2.ReuseTokenSource(nil, jwtSource{ctx, c}) +} + +// Client returns an HTTP client wrapping the context's +// HTTP transport and adding Authorization headers with tokens +// obtained from c. +// +// The returned client and its Transport should not be modified. +func (c *Config) Client(ctx context.Context) *http.Client { + return oauth2.NewClient(ctx, c.TokenSource(ctx)) +} + +// jwtSource is a source that always does a signed JWT request for a token. +// It should typically be wrapped with a reuseTokenSource. +type jwtSource struct { + ctx context.Context + conf *Config +} + +func (js jwtSource) Token() (*oauth2.Token, error) { + pk, err := internal.ParseKey(js.conf.PrivateKey) + if err != nil { + return nil, err + } + hc := oauth2.NewClient(js.ctx, nil) + claimSet := &jws.ClaimSet{ + Iss: js.conf.Email, + Scope: strings.Join(js.conf.Scopes, " "), + Aud: js.conf.TokenURL, + } + if subject := js.conf.Subject; subject != "" { + claimSet.Sub = subject + // prn is the old name of sub. Keep setting it + // to be compatible with legacy OAuth 2.0 providers. + claimSet.Prn = subject + } + if t := js.conf.Expires; t > 0 { + claimSet.Exp = time.Now().Add(t).Unix() + } + h := *defaultHeader + h.KeyID = js.conf.PrivateKeyID + payload, err := jws.Encode(&h, claimSet, pk) + if err != nil { + return nil, err + } + v := url.Values{} + v.Set("grant_type", defaultGrantType) + v.Set("assertion", payload) + resp, err := hc.PostForm(js.conf.TokenURL, v) + if err != nil { + return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err) + } + defer resp.Body.Close() + body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20)) + if err != nil { + return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err) + } + if c := resp.StatusCode; c < 200 || c > 299 { + return nil, &oauth2.RetrieveError{ + Response: resp, + Body: body, + } + } + // tokenRes is the JSON response body. + var tokenRes struct { + AccessToken string `json:"access_token"` + TokenType string `json:"token_type"` + IDToken string `json:"id_token"` + ExpiresIn int64 `json:"expires_in"` // relative seconds from now + } + if err := json.Unmarshal(body, &tokenRes); err != nil { + return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err) + } + token := &oauth2.Token{ + AccessToken: tokenRes.AccessToken, + TokenType: tokenRes.TokenType, + } + raw := make(map[string]interface{}) + json.Unmarshal(body, &raw) // no error checks for optional fields + token = token.WithExtra(raw) + + if secs := tokenRes.ExpiresIn; secs > 0 { + token.Expiry = time.Now().Add(time.Duration(secs) * time.Second) + } + if v := tokenRes.IDToken; v != "" { + // decode returned id token to get expiry + claimSet, err := jws.Decode(v) + if err != nil { + return nil, fmt.Errorf("oauth2: error decoding JWT token: %v", err) + } + token.Expiry = time.Unix(claimSet.Exp, 0) + } + return token, nil +} diff --git a/vendor/golang.org/x/oauth2/oauth2.go b/vendor/golang.org/x/oauth2/oauth2.go index 9b7b977d..23b9c819 100644 --- a/vendor/golang.org/x/oauth2/oauth2.go +++ b/vendor/golang.org/x/oauth2/oauth2.go @@ -3,24 +3,27 @@ // license that can be found in the LICENSE file. // Package oauth2 provides support for making -// OAuth2 authorized and authenticated HTTP requests. +// OAuth2 authorized and authenticated HTTP requests, +// as specified in RFC 6749. // It can additionally grant authorization with Bearer JWT. package oauth2 import ( "bytes" + "context" "errors" "net/http" "net/url" "strings" "sync" - "golang.org/x/net/context" "golang.org/x/oauth2/internal" ) // NoContext is the default context you should supply if not using // your own context.Context (see https://golang.org/x/net/context). +// +// Deprecated: Use context.Background() or context.TODO() instead. var NoContext = context.TODO() // RegisterBrokenAuthHeaderProvider registers an OAuth2 server @@ -37,6 +40,8 @@ func RegisterBrokenAuthHeaderProvider(tokenURL string) { // Config describes a typical 3-legged OAuth2 flow, with both the // client application information and the server's endpoint URLs. +// For the client credentials 2-legged OAuth2 flow, see the clientcredentials +// package (https://golang.org/x/oauth2/clientcredentials). type Config struct { // ClientID is the application's ID. ClientID string @@ -113,21 +118,30 @@ func SetAuthURLParam(key, value string) AuthCodeOption { // that asks for permissions for the required scopes explicitly. // // State is a token to protect the user from CSRF attacks. You must -// always provide a non-zero string and validate that it matches the +// always provide a non-empty string and validate that it matches the // the state query parameter on your redirect callback. // See http://tools.ietf.org/html/rfc6749#section-10.12 for more info. // // Opts may include AccessTypeOnline or AccessTypeOffline, as well // as ApprovalForce. +// It can also be used to pass the PKCE challange. +// See https://www.oauth.com/oauth2-servers/pkce/ for more info. func (c *Config) AuthCodeURL(state string, opts ...AuthCodeOption) string { var buf bytes.Buffer buf.WriteString(c.Endpoint.AuthURL) v := url.Values{ "response_type": {"code"}, "client_id": {c.ClientID}, - "redirect_uri": internal.CondVal(c.RedirectURL), - "scope": internal.CondVal(strings.Join(c.Scopes, " ")), - "state": internal.CondVal(state), + } + if c.RedirectURL != "" { + v.Set("redirect_uri", c.RedirectURL) + } + if len(c.Scopes) > 0 { + v.Set("scope", strings.Join(c.Scopes, " ")) + } + if state != "" { + // TODO(light): Docs say never to omit state; don't allow empty. + v.Set("state", state) } for _, opt := range opts { opt.setValue(v) @@ -153,12 +167,15 @@ func (c *Config) AuthCodeURL(state string, opts ...AuthCodeOption) string { // The HTTP client to use is derived from the context. // If nil, http.DefaultClient is used. func (c *Config) PasswordCredentialsToken(ctx context.Context, username, password string) (*Token, error) { - return retrieveToken(ctx, c, url.Values{ + v := url.Values{ "grant_type": {"password"}, "username": {username}, "password": {password}, - "scope": internal.CondVal(strings.Join(c.Scopes, " ")), - }) + } + if len(c.Scopes) > 0 { + v.Set("scope", strings.Join(c.Scopes, " ")) + } + return retrieveToken(ctx, c, v) } // Exchange converts an authorization code into a token. @@ -171,13 +188,21 @@ func (c *Config) PasswordCredentialsToken(ctx context.Context, username, passwor // // The code will be in the *http.Request.FormValue("code"). Before // calling Exchange, be sure to validate FormValue("state"). -func (c *Config) Exchange(ctx context.Context, code string) (*Token, error) { - return retrieveToken(ctx, c, url.Values{ - "grant_type": {"authorization_code"}, - "code": {code}, - "redirect_uri": internal.CondVal(c.RedirectURL), - "scope": internal.CondVal(strings.Join(c.Scopes, " ")), - }) +// +// Opts may include the PKCE verifier code if previously used in AuthCodeURL. +// See https://www.oauth.com/oauth2-servers/pkce/ for more info. +func (c *Config) Exchange(ctx context.Context, code string, opts ...AuthCodeOption) (*Token, error) { + v := url.Values{ + "grant_type": {"authorization_code"}, + "code": {code}, + } + if c.RedirectURL != "" { + v.Set("redirect_uri", c.RedirectURL) + } + for _, opt := range opts { + opt.setValue(v) + } + return retrieveToken(ctx, c, v) } // Client returns an HTTP client using the provided token. @@ -288,20 +313,20 @@ var HTTPClient internal.ContextKey // NewClient creates an *http.Client from a Context and TokenSource. // The returned client is not valid beyond the lifetime of the context. // +// Note that if a custom *http.Client is provided via the Context it +// is used only for token acquisition and is not used to configure the +// *http.Client returned from NewClient. +// // As a special case, if src is nil, a non-OAuth2 client is returned // using the provided context. This exists to support related OAuth2 // packages. func NewClient(ctx context.Context, src TokenSource) *http.Client { if src == nil { - c, err := internal.ContextClient(ctx) - if err != nil { - return &http.Client{Transport: internal.ErrorTransport{err}} - } - return c + return internal.ContextClient(ctx) } return &http.Client{ Transport: &Transport{ - Base: internal.ContextTransport(ctx), + Base: internal.ContextClient(ctx).Transport, Source: ReuseTokenSource(nil, src), }, } diff --git a/vendor/golang.org/x/oauth2/token.go b/vendor/golang.org/x/oauth2/token.go index 7a3167f1..9be1ae53 100644 --- a/vendor/golang.org/x/oauth2/token.go +++ b/vendor/golang.org/x/oauth2/token.go @@ -5,13 +5,14 @@ package oauth2 import ( + "context" + "fmt" "net/http" "net/url" "strconv" "strings" "time" - "golang.org/x/net/context" "golang.org/x/oauth2/internal" ) @@ -20,7 +21,7 @@ import ( // expirations due to client-server time mismatches. const expiryDelta = 10 * time.Second -// Token represents the crendentials used to authorize +// Token represents the credentials used to authorize // the requests to access protected resources on the OAuth 2.0 // provider's backend. // @@ -123,7 +124,7 @@ func (t *Token) expired() bool { if t.Expiry.IsZero() { return false } - return t.Expiry.Add(-expiryDelta).Before(time.Now()) + return t.Expiry.Round(0).Add(-expiryDelta).Before(time.Now()) } // Valid reports whether t is non-nil, has an AccessToken, and is not expired. @@ -152,7 +153,23 @@ func tokenFromInternal(t *internal.Token) *Token { func retrieveToken(ctx context.Context, c *Config, v url.Values) (*Token, error) { tk, err := internal.RetrieveToken(ctx, c.ClientID, c.ClientSecret, c.Endpoint.TokenURL, v) if err != nil { + if rErr, ok := err.(*internal.RetrieveError); ok { + return nil, (*RetrieveError)(rErr) + } return nil, err } return tokenFromInternal(tk), nil } + +// RetrieveError is the error returned when the token endpoint returns a +// non-2XX HTTP status code. +type RetrieveError struct { + Response *http.Response + // Body is the body that was consumed by reading Response.Body. + // It may be truncated. + Body []byte +} + +func (r *RetrieveError) Error() string { + return fmt.Sprintf("oauth2: cannot fetch token: %v\nResponse: %s", r.Response.Status, r.Body) +} diff --git a/vendor/golang.org/x/oauth2/transport.go b/vendor/golang.org/x/oauth2/transport.go index 92ac7e25..aa0d34f1 100644 --- a/vendor/golang.org/x/oauth2/transport.go +++ b/vendor/golang.org/x/oauth2/transport.go @@ -31,9 +31,17 @@ type Transport struct { } // RoundTrip authorizes and authenticates the request with an -// access token. If no token exists or token is expired, -// tries to refresh/fetch a new token. +// access token from Transport's Source. func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { + reqBodyClosed := false + if req.Body != nil { + defer func() { + if !reqBodyClosed { + req.Body.Close() + } + }() + } + if t.Source == nil { return nil, errors.New("oauth2: Transport's Source is nil") } @@ -46,6 +54,10 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { token.SetAuthHeader(req2) t.setModReq(req, req2) res, err := t.base().RoundTrip(req2) + + // req.Body is assumed to have been closed by the base RoundTripper. + reqBodyClosed = true + if err != nil { t.setModReq(req, nil) return nil, err diff --git a/vendor/google.golang.org/api/AUTHORS b/vendor/google.golang.org/api/AUTHORS new file mode 100644 index 00000000..f73b7257 --- /dev/null +++ b/vendor/google.golang.org/api/AUTHORS @@ -0,0 +1,10 @@ +# This is the official list of authors for copyright purposes. +# This file is distinct from the CONTRIBUTORS files. +# See the latter for an explanation. + +# Names should be added to this file as +# Name or Organization +# The email address is not required for organizations. + +# Please keep the list sorted. +Google Inc. diff --git a/vendor/google.golang.org/api/CONTRIBUTORS b/vendor/google.golang.org/api/CONTRIBUTORS new file mode 100644 index 00000000..fe55ebff --- /dev/null +++ b/vendor/google.golang.org/api/CONTRIBUTORS @@ -0,0 +1,55 @@ +# This is the official list of people who can contribute +# (and typically have contributed) code to the repository. +# The AUTHORS file lists the copyright holders; this file +# lists people. For example, Google employees are listed here +# but not in AUTHORS, because Google holds the copyright. +# +# The submission process automatically checks to make sure +# that people submitting code are listed in this file (by email address). +# +# Names should be added to this file only after verifying that +# the individual or the individual's organization has agreed to +# the appropriate Contributor License Agreement, found here: +# +# https://cla.developers.google.com/about/google-individual +# https://cla.developers.google.com/about/google-corporate +# +# The CLA can be filled out on the web: +# +# https://cla.developers.google.com/ +# +# When adding J Random Contributor's name to this file, +# either J's name or J's organization's name should be +# added to the AUTHORS file, depending on whether the +# individual or corporate CLA was used. + +# Names should be added to this file like so: +# Name +# +# An entry with two email addresses specifies that the +# first address should be used in the submit logs and +# that the second address should be recognized as the +# same person when interacting with Rietveld. + +# Please keep the list sorted. + +Alain Vongsouvanhalainv +Andrew Gerrand +Brad Fitzpatrick +Eric Koleda +Francesc Campoy +Garrick Evans +Glenn Lewis +Ivan Krasin +Jason Hall +Johan Euphrosine +Kostik Shtoyk +Kunpei Sakai +Matthew Whisenhunt +Michael McGreevy +Nick Craig-Wood +Robbie Trencheny +Ross Light +Sarah Adams +Scott Van Woudenberg +Takashi Matsuo diff --git a/vendor/google.golang.org/api/drive/v3/drive-api.json b/vendor/google.golang.org/api/drive/v3/drive-api.json index 896d44e3..f9a73c44 100644 --- a/vendor/google.golang.org/api/drive/v3/drive-api.json +++ b/vendor/google.golang.org/api/drive/v3/drive-api.json @@ -1,2410 +1,3164 @@ { - "kind": "discovery#restDescription", - "etag": "\"bRFOOrZKfO9LweMbPqu0kcu6De8/O9_NbpoVnW5GMGl7qWBIajcyrt8\"", - "discoveryVersion": "v1", - "id": "drive:v3", - "name": "drive", - "version": "v3", - "revision": "20160303", - "title": "Drive API", - "description": "The API to interact with Drive.", - "ownerDomain": "google.com", - "ownerName": "Google", - "icons": { - "x16": "https://ssl.gstatic.com/docs/doclist/images/drive_icon_16.png", - "x32": "https://ssl.gstatic.com/docs/doclist/images/drive_icon_32.png" - }, - "documentationLink": "https://developers.google.com/drive/", - "protocol": "rest", - "baseUrl": "https://www.googleapis.com/drive/v3/", - "basePath": "/drive/v3/", - "rootUrl": "https://www.googleapis.com/", - "servicePath": "drive/v3/", - "batchPath": "batch", - "parameters": { - "alt": { - "type": "string", - "description": "Data format for the response.", - "default": "json", - "enum": [ - "json" - ], - "enumDescriptions": [ - "Responses with Content-Type of application/json" - ], - "location": "query" - }, - "fields": { - "type": "string", - "description": "Selector specifying which fields to include in a partial response.", - "location": "query" - }, - "key": { - "type": "string", - "description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.", - "location": "query" - }, - "oauth_token": { - "type": "string", - "description": "OAuth 2.0 token for the current user.", - "location": "query" - }, - "prettyPrint": { - "type": "boolean", - "description": "Returns response with indentations and line breaks.", - "default": "true", - "location": "query" - }, - "quotaUser": { - "type": "string", - "description": "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.", - "location": "query" - }, - "userIp": { - "type": "string", - "description": "IP address of the site where the request originates. Use this if you want to enforce per-user limits.", - "location": "query" - } - }, - "auth": { - "oauth2": { - "scopes": { - "https://www.googleapis.com/auth/drive": { - "description": "View and manage the files in your Google Drive" - }, - "https://www.googleapis.com/auth/drive.appdata": { - "description": "View and manage its own configuration data in your Google Drive" - }, - "https://www.googleapis.com/auth/drive.file": { - "description": "View and manage Google Drive files and folders that you have opened or created with this app" - }, - "https://www.googleapis.com/auth/drive.metadata": { - "description": "View and manage metadata of files in your Google Drive" - }, - "https://www.googleapis.com/auth/drive.metadata.readonly": { - "description": "View metadata for files in your Google Drive" - }, - "https://www.googleapis.com/auth/drive.photos.readonly": { - "description": "View the photos, videos and albums in your Google Photos" - }, - "https://www.googleapis.com/auth/drive.readonly": { - "description": "View the files in your Google Drive" - }, - "https://www.googleapis.com/auth/drive.scripts": { - "description": "Modify your Google Apps Script scripts' behavior" - } - } - } - }, - "schemas": { - "About": { - "id": "About", - "type": "object", - "description": "Information about the user, the user's Drive, and system capabilities.", - "properties": { - "appInstalled": { - "type": "boolean", - "description": "Whether the user has installed the requesting app." - }, - "exportFormats": { - "type": "object", - "description": "A map of source MIME type to possible targets for all supported exports.", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "folderColorPalette": { - "type": "array", - "description": "The currently supported folder colors as RGB hex strings.", - "items": { - "type": "string" - } - }, - "importFormats": { - "type": "object", - "description": "A map of source MIME type to possible targets for all supported imports.", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "kind": { - "type": "string", - "description": "This is always drive#about.", - "default": "drive#about" - }, - "maxImportSizes": { - "type": "object", - "description": "A map of maximum import sizes by MIME type, in bytes.", - "additionalProperties": { - "type": "string", - "format": "int64" - } - }, - "maxUploadSize": { - "type": "string", - "description": "The maximum upload size in bytes.", - "format": "int64" - }, - "storageQuota": { - "type": "object", - "description": "The user's storage quota limits and usage. All fields are measured in bytes.", - "properties": { - "limit": { - "type": "string", - "description": "The usage limit, if applicable. This will not be present if the user has unlimited storage.", - "format": "int64" - }, - "usage": { - "type": "string", - "description": "The total usage across all services.", - "format": "int64" - }, - "usageInDrive": { - "type": "string", - "description": "The usage by all files in Google Drive.", - "format": "int64" - }, - "usageInDriveTrash": { - "type": "string", - "description": "The usage by trashed files in Google Drive.", - "format": "int64" - } - } - }, - "user": { - "$ref": "User", - "description": "The authenticated user." - } - } - }, - "Change": { - "id": "Change", - "type": "object", - "description": "A change to a file.", - "properties": { - "file": { - "$ref": "File", - "description": "The updated state of the file. Present if the file has not been removed." - }, - "fileId": { - "type": "string", - "description": "The ID of the file which has changed." - }, - "kind": { - "type": "string", - "description": "This is always drive#change.", - "default": "drive#change" - }, - "removed": { - "type": "boolean", - "description": "Whether the file has been removed from the view of the changes list, for example by deletion or lost access." - }, - "time": { - "type": "string", - "description": "The time of this change (RFC 3339 date-time).", - "format": "date-time" - } - } - }, - "ChangeList": { - "id": "ChangeList", - "type": "object", - "description": "A list of changes for a user.", - "properties": { - "changes": { - "type": "array", - "description": "The page of changes.", - "items": { - "$ref": "Change" - } - }, - "kind": { - "type": "string", - "description": "This is always drive#changeList.", - "default": "drive#changeList" - }, - "newStartPageToken": { - "type": "string", - "description": "The starting page token for future changes. This will be present only if the end of the current changes list has been reached." - }, - "nextPageToken": { - "type": "string", - "description": "The page token for the next page of changes. This will be absent if the end of the current changes list has been reached." - } - } - }, - "Channel": { - "id": "Channel", - "type": "object", - "description": "An notification channel used to watch for resource changes.", - "properties": { - "address": { - "type": "string", - "description": "The address where notifications are delivered for this channel." - }, - "expiration": { - "type": "string", - "description": "Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.", - "format": "int64" - }, - "id": { - "type": "string", - "description": "A UUID or similar unique string that identifies this channel." - }, - "kind": { - "type": "string", - "description": "Identifies this as a notification channel used to watch for changes to a resource. Value: the fixed string \"api#channel\".", - "default": "api#channel" - }, - "params": { - "type": "object", - "description": "Additional parameters controlling delivery channel behavior. Optional.", - "additionalProperties": { - "type": "string", - "description": "Declares a new parameter by name." - } - }, - "payload": { - "type": "boolean", - "description": "A Boolean value to indicate whether payload is wanted. Optional." - }, - "resourceId": { - "type": "string", - "description": "An opaque ID that identifies the resource being watched on this channel. Stable across different API versions." - }, - "resourceUri": { - "type": "string", - "description": "A version-specific identifier for the watched resource." - }, - "token": { - "type": "string", - "description": "An arbitrary string delivered to the target address with each notification delivered over this channel. Optional." - }, - "type": { - "type": "string", - "description": "The type of delivery mechanism used for this channel." - } - } - }, - "Comment": { - "id": "Comment", - "type": "object", - "description": "A comment on a file.", - "properties": { - "anchor": { - "type": "string", - "description": "A region of the document represented as a JSON string. See anchor documentation for details on how to define and interpret anchor properties." - }, - "author": { - "$ref": "User", - "description": "The user who created the comment." - }, - "content": { - "type": "string", - "description": "The plain text content of the comment. This field is used for setting the content, while htmlContent should be displayed.", - "annotations": { - "required": [ - "drive.comments.create", - "drive.comments.update" - ] - } - }, - "createdTime": { - "type": "string", - "description": "The time at which the comment was created (RFC 3339 date-time).", - "format": "date-time" - }, - "deleted": { - "type": "boolean", - "description": "Whether the comment has been deleted. A deleted comment has no content." - }, - "htmlContent": { - "type": "string", - "description": "The content of the comment with HTML formatting." - }, - "id": { - "type": "string", - "description": "The ID of the comment." - }, - "kind": { - "type": "string", - "description": "This is always drive#comment.", - "default": "drive#comment" - }, - "modifiedTime": { - "type": "string", - "description": "The last time the comment or any of its replies was modified (RFC 3339 date-time).", - "format": "date-time" - }, - "quotedFileContent": { - "type": "object", - "description": "The file content to which the comment refers, typically within the anchor region. For a text file, for example, this would be the text at the location of the comment.", - "properties": { - "mimeType": { - "type": "string", - "description": "The MIME type of the quoted content." - }, - "value": { - "type": "string", - "description": "The quoted content itself. This is interpreted as plain text if set through the API." + "auth": { + "oauth2": { + "scopes": { + "https://www.googleapis.com/auth/drive": { + "description": "View and manage the files in your Google Drive" + }, + "https://www.googleapis.com/auth/drive.appdata": { + "description": "View and manage its own configuration data in your Google Drive" + }, + "https://www.googleapis.com/auth/drive.file": { + "description": "View and manage Google Drive files and folders that you have opened or created with this app" + }, + "https://www.googleapis.com/auth/drive.metadata": { + "description": "View and manage metadata of files in your Google Drive" + }, + "https://www.googleapis.com/auth/drive.metadata.readonly": { + "description": "View metadata for files in your Google Drive" + }, + "https://www.googleapis.com/auth/drive.photos.readonly": { + "description": "View the photos, videos and albums in your Google Photos" + }, + "https://www.googleapis.com/auth/drive.readonly": { + "description": "View the files in your Google Drive" + }, + "https://www.googleapis.com/auth/drive.scripts": { + "description": "Modify your Google Apps Script scripts' behavior" + } } - } - }, - "replies": { - "type": "array", - "description": "The full list of replies to the comment in chronological order.", - "items": { - "$ref": "Reply" - } - }, - "resolved": { - "type": "boolean", - "description": "Whether the comment has been resolved by one of its replies." } - } }, - "CommentList": { - "id": "CommentList", - "type": "object", - "description": "A list of comments on a file.", - "properties": { - "comments": { - "type": "array", - "description": "The page of comments.", - "items": { - "$ref": "Comment" - } - }, - "kind": { - "type": "string", - "description": "This is always drive#commentList.", - "default": "drive#commentList" - }, - "nextPageToken": { - "type": "string", - "description": "The page token for the next page of comments. This will be absent if the end of the comments list has been reached." - } - } + "basePath": "/drive/v3/", + "baseUrl": "https://www.googleapis.com/drive/v3/", + "batchPath": "batch/drive/v3", + "description": "Manages files in Drive including uploading, downloading, searching, detecting changes, and updating sharing permissions.", + "discoveryVersion": "v1", + "documentationLink": "https://developers.google.com/drive/", + "etag": "\"J3WqvAcMk4eQjJXvfSI4Yr8VouA/79RB5EuEpU35909wc6O7vR4Degc\"", + "icons": { + "x16": "https://ssl.gstatic.com/docs/doclist/images/drive_icon_16.png", + "x32": "https://ssl.gstatic.com/docs/doclist/images/drive_icon_32.png" }, - "File": { - "id": "File", - "type": "object", - "description": "The metadata for a file.", - "properties": { - "appProperties": { - "type": "object", - "description": "A collection of arbitrary key-value pairs which are private to the requesting app.\nEntries with null values are cleared in update and copy requests.", - "additionalProperties": { + "id": "drive:v3", + "kind": "discovery#restDescription", + "name": "drive", + "ownerDomain": "google.com", + "ownerName": "Google", + "parameters": { + "alt": { + "default": "json", + "description": "Data format for the response.", + "enum": [ + "json" + ], + "enumDescriptions": [ + "Responses with Content-Type of application/json" + ], + "location": "query", "type": "string" - } - }, - "capabilities": { - "type": "object", - "description": "Capabilities the current user has on the file.", - "properties": { - "canComment": { - "type": "boolean", - "description": "Whether the user can comment on the file." - }, - "canCopy": { - "type": "boolean", - "description": "Whether the user can copy the file." - }, - "canEdit": { - "type": "boolean", - "description": "Whether the user can edit the file's content." - }, - "canReadRevisions": { - "type": "boolean", - "description": "Whether the current user has read access to the Revisions resource of the file." - }, - "canShare": { - "type": "boolean", - "description": "Whether the user can modify the file's permissions and sharing settings." - } - } - }, - "contentHints": { - "type": "object", - "description": "Additional information about the content of the file. These fields are never populated in responses.", - "properties": { - "indexableText": { - "type": "string", - "description": "Text to be indexed for the file to improve fullText queries. This is limited to 128KB in length and may contain HTML elements." - }, - "thumbnail": { - "type": "object", - "description": "A thumbnail for the file. This will only be used if Drive cannot generate a standard thumbnail.", - "properties": { - "image": { - "type": "string", - "description": "The thumbnail data encoded with URL-safe Base64 (RFC 4648 section 5).", - "format": "byte" - }, - "mimeType": { - "type": "string", - "description": "The MIME type of the thumbnail." - } - } - } - } - }, - "createdTime": { - "type": "string", - "description": "The time at which the file was created (RFC 3339 date-time).", - "format": "date-time" - }, - "description": { - "type": "string", - "description": "A short description of the file." - }, - "explicitlyTrashed": { - "type": "boolean", - "description": "Whether the file has been explicitly trashed, as opposed to recursively trashed from a parent folder." - }, - "fileExtension": { - "type": "string", - "description": "The final component of fullFileExtension. This is only available for files with binary content in Drive." - }, - "folderColorRgb": { - "type": "string", - "description": "The color for a folder as an RGB hex string. The supported colors are published in the folderColorPalette field of the About resource.\nIf an unsupported color is specified, the closest color in the palette will be used instead." - }, - "fullFileExtension": { - "type": "string", - "description": "The full file extension extracted from the name field. May contain multiple concatenated extensions, such as \"tar.gz\". This is only available for files with binary content in Drive.\nThis is automatically updated when the name field changes, however it is not cleared if the new name does not contain a valid extension." - }, - "headRevisionId": { - "type": "string", - "description": "The ID of the file's head revision. This is currently only available for files with binary content in Drive." - }, - "iconLink": { - "type": "string", - "description": "A static, unauthenticated link to the file's icon." - }, - "id": { - "type": "string", - "description": "The ID of the file." - }, - "imageMediaMetadata": { - "type": "object", - "description": "Additional metadata about image media, if available.", - "properties": { - "aperture": { - "type": "number", - "description": "The aperture used to create the photo (f-number).", - "format": "float" - }, - "cameraMake": { - "type": "string", - "description": "The make of the camera used to create the photo." - }, - "cameraModel": { - "type": "string", - "description": "The model of the camera used to create the photo." - }, - "colorSpace": { - "type": "string", - "description": "The color space of the photo." - }, - "exposureBias": { - "type": "number", - "description": "The exposure bias of the photo (APEX value).", - "format": "float" - }, - "exposureMode": { - "type": "string", - "description": "The exposure mode used to create the photo." - }, - "exposureTime": { - "type": "number", - "description": "The length of the exposure, in seconds.", - "format": "float" - }, - "flashUsed": { - "type": "boolean", - "description": "Whether a flash was used to create the photo." - }, - "focalLength": { - "type": "number", - "description": "The focal length used to create the photo, in millimeters.", - "format": "float" - }, - "height": { - "type": "integer", - "description": "The height of the image in pixels.", - "format": "int32" - }, - "isoSpeed": { - "type": "integer", - "description": "The ISO speed used to create the photo.", - "format": "int32" - }, - "lens": { - "type": "string", - "description": "The lens used to create the photo." - }, - "location": { - "type": "object", - "description": "Geographic location information stored in the image.", - "properties": { - "altitude": { - "type": "number", - "description": "The altitude stored in the image.", - "format": "double" - }, - "latitude": { - "type": "number", - "description": "The latitude stored in the image.", - "format": "double" - }, - "longitude": { - "type": "number", - "description": "The longitude stored in the image.", - "format": "double" - } - } - }, - "maxApertureValue": { - "type": "number", - "description": "The smallest f-number of the lens at the focal length used to create the photo (APEX value).", - "format": "float" - }, - "meteringMode": { - "type": "string", - "description": "The metering mode used to create the photo." - }, - "rotation": { - "type": "integer", - "description": "The rotation in clockwise degrees from the image's original orientation.", - "format": "int32" - }, - "sensor": { - "type": "string", - "description": "The type of sensor used to create the photo." - }, - "subjectDistance": { - "type": "integer", - "description": "The distance to the subject of the photo, in meters.", - "format": "int32" - }, - "time": { - "type": "string", - "description": "The date and time the photo was taken (EXIF DateTime)." - }, - "whiteBalance": { - "type": "string", - "description": "The white balance mode used to create the photo." - }, - "width": { - "type": "integer", - "description": "The width of the image in pixels.", - "format": "int32" - } - } - }, - "kind": { - "type": "string", - "description": "This is always drive#file.", - "default": "drive#file" - }, - "lastModifyingUser": { - "$ref": "User", - "description": "The last user to modify the file." - }, - "md5Checksum": { - "type": "string", - "description": "The MD5 checksum for the content of the file. This is only applicable to files with binary content in Drive." - }, - "mimeType": { - "type": "string", - "description": "The MIME type of the file.\nDrive will attempt to automatically detect an appropriate value from uploaded content if no value is provided. The value cannot be changed unless a new revision is uploaded.\nIf a file is created with a Google Doc MIME type, the uploaded content will be imported if possible. The supported import formats are published in the About resource." }, - "modifiedByMeTime": { - "type": "string", - "description": "The last time the file was modified by the user (RFC 3339 date-time).", - "format": "date-time" - }, - "modifiedTime": { - "type": "string", - "description": "The last time the file was modified by anyone (RFC 3339 date-time).\nNote that setting modifiedTime will also update modifiedByMeTime for the user.", - "format": "date-time" - }, - "name": { - "type": "string", - "description": "The name of the file. This is not necessarily unique within a folder." - }, - "originalFilename": { - "type": "string", - "description": "The original filename of the uploaded content if available, or else the original value of the name field. This is only available for files with binary content in Drive." - }, - "ownedByMe": { - "type": "boolean", - "description": "Whether the user owns the file." - }, - "owners": { - "type": "array", - "description": "The owners of the file. Currently, only certain legacy files may have more than one owner.", - "items": { - "$ref": "User" - } - }, - "parents": { - "type": "array", - "description": "The IDs of the parent folders which contain the file.\nIf 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.", - "items": { + "fields": { + "description": "Selector specifying which fields to include in a partial response.", + "location": "query", "type": "string" - } - }, - "permissions": { - "type": "array", - "description": "The full list of permissions for the file. This is only available if the requesting user can share the file.", - "items": { - "$ref": "Permission" - } }, - "properties": { - "type": "object", - "description": "A collection of arbitrary key-value pairs which are visible to all apps.\nEntries with null values are cleared in update and copy requests.", - "additionalProperties": { + "key": { + "description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.", + "location": "query", "type": "string" - } }, - "quotaBytesUsed": { - "type": "string", - "description": "The number of storage quota bytes used by the file. This includes the head revision as well as previous revisions with keepForever enabled.", - "format": "int64" - }, - "shared": { - "type": "boolean", - "description": "Whether the file has been shared." - }, - "sharedWithMeTime": { - "type": "string", - "description": "The time at which the file was shared with the user, if applicable (RFC 3339 date-time).", - "format": "date-time" - }, - "sharingUser": { - "$ref": "User", - "description": "The user who shared the file with the requesting user, if applicable." - }, - "size": { - "type": "string", - "description": "The size of the file's content in bytes. This is only applicable to files with binary content in Drive.", - "format": "int64" - }, - "spaces": { - "type": "array", - "description": "The list of spaces which contain the file. The currently supported values are 'drive', 'appDataFolder' and 'photos'.", - "items": { + "oauth_token": { + "description": "OAuth 2.0 token for the current user.", + "location": "query", "type": "string" - } - }, - "starred": { - "type": "boolean", - "description": "Whether the user has starred the file." - }, - "thumbnailLink": { - "type": "string", - "description": "A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours." - }, - "trashed": { - "type": "boolean", - "description": "Whether the file has been trashed, either explicitly or from a trashed parent folder. Only the owner may trash a file, and other users cannot see files in the owner's trash." - }, - "version": { - "type": "string", - "description": "A monotonically increasing version number for the file. This reflects every change made to the file on the server, even those not visible to the user.", - "format": "int64" }, - "videoMediaMetadata": { - "type": "object", - "description": "Additional metadata about video media. This may not be available immediately upon upload.", - "properties": { - "durationMillis": { - "type": "string", - "description": "The duration of the video in milliseconds.", - "format": "int64" - }, - "height": { - "type": "integer", - "description": "The height of the video in pixels.", - "format": "int32" - }, - "width": { - "type": "integer", - "description": "The width of the video in pixels.", - "format": "int32" - } - } - }, - "viewedByMe": { - "type": "boolean", - "description": "Whether the file has been viewed by this user." - }, - "viewedByMeTime": { - "type": "string", - "description": "The last time the file was viewed by the user (RFC 3339 date-time).", - "format": "date-time" + "prettyPrint": { + "default": "true", + "description": "Returns response with indentations and line breaks.", + "location": "query", + "type": "boolean" }, - "viewersCanCopyContent": { - "type": "boolean", - "description": "Whether users with only reader or commenter permission can copy the file's content. This affects copy, download, and print operations." - }, - "webContentLink": { - "type": "string", - "description": "A link for downloading the content of the file in a browser. This is only available for files with binary content in Drive." - }, - "webViewLink": { - "type": "string", - "description": "A link for opening the file in a relevant Google editor or viewer in a browser." - }, - "writersCanShare": { - "type": "boolean", - "description": "Whether users with only writer permission can modify the file's permissions." - } - } - }, - "FileList": { - "id": "FileList", - "type": "object", - "description": "A list of files.", - "properties": { - "files": { - "type": "array", - "description": "The page of files.", - "items": { - "$ref": "File" - } - }, - "kind": { - "type": "string", - "description": "This is always drive#fileList.", - "default": "drive#fileList" - }, - "nextPageToken": { - "type": "string", - "description": "The page token for the next page of files. This will be absent if the end of the files list has been reached." - } - } - }, - "GeneratedIds": { - "id": "GeneratedIds", - "type": "object", - "description": "A list of generated file IDs which can be provided in create requests.", - "properties": { - "ids": { - "type": "array", - "description": "The IDs generated for the requesting user in the specified space.", - "items": { + "quotaUser": { + "description": "An opaque string that represents a user for quota purposes. Must not exceed 40 characters.", + "location": "query", "type": "string" - } - }, - "kind": { - "type": "string", - "description": "This is always drive#generatedIds", - "default": "drive#generatedIds" - }, - "space": { - "type": "string", - "description": "The type of file that can be created with these IDs." - } - } - }, - "Permission": { - "id": "Permission", - "type": "object", - "description": "A permission for a file. A permission grants a user, group, domain or the world access to a file or a folder hierarchy.", - "properties": { - "allowFileDiscovery": { - "type": "boolean", - "description": "Whether the permission allows the file to be discovered through search. This is only applicable for permissions of type domain or anyone." - }, - "displayName": { - "type": "string", - "description": "A displayable name for users, groups or domains." - }, - "domain": { - "type": "string", - "description": "The domain to which this permission refers." - }, - "emailAddress": { - "type": "string", - "description": "The email address of the user or group to which this permission refers." - }, - "id": { - "type": "string", - "description": "The ID of this permission. This is a unique identifier for the grantee, and is published in User resources as permissionId." - }, - "kind": { - "type": "string", - "description": "This is always drive#permission.", - "default": "drive#permission" - }, - "photoLink": { - "type": "string", - "description": "A link to the user's profile photo, if available." - }, - "role": { - "type": "string", - "description": "The role granted by this permission. Valid values are: \n- owner \n- writer \n- commenter \n- reader", - "annotations": { - "required": [ - "drive.permissions.create" - ] - } }, - "type": { - "type": "string", - "description": "The type of the grantee. Valid values are: \n- user \n- group \n- domain \n- anyone", - "annotations": { - "required": [ - "drive.permissions.create" - ] - } - } - } - }, - "PermissionList": { - "id": "PermissionList", - "type": "object", - "description": "A list of permissions for a file.", - "properties": { - "kind": { - "type": "string", - "description": "This is always drive#permissionList.", - "default": "drive#permissionList" - }, - "permissions": { - "type": "array", - "description": "The full list of permissions.", - "items": { - "$ref": "Permission" - } - } - } - }, - "Reply": { - "id": "Reply", - "type": "object", - "description": "A reply to a comment on a file.", - "properties": { - "action": { - "type": "string", - "description": "The action the reply performed to the parent comment. Valid values are: \n- resolve \n- reopen" - }, - "author": { - "$ref": "User", - "description": "The user who created the reply." - }, - "content": { - "type": "string", - "description": "The plain text content of the reply. This field is used for setting the content, while htmlContent should be displayed. This is required on creates if no action is specified.", - "annotations": { - "required": [ - "drive.replies.update" - ] - } - }, - "createdTime": { - "type": "string", - "description": "The time at which the reply was created (RFC 3339 date-time).", - "format": "date-time" - }, - "deleted": { - "type": "boolean", - "description": "Whether the reply has been deleted. A deleted reply has no content." - }, - "htmlContent": { - "type": "string", - "description": "The content of the reply with HTML formatting." - }, - "id": { - "type": "string", - "description": "The ID of the reply." - }, - "kind": { - "type": "string", - "description": "This is always drive#reply.", - "default": "drive#reply" - }, - "modifiedTime": { - "type": "string", - "description": "The last time the reply was modified (RFC 3339 date-time).", - "format": "date-time" - } - } - }, - "ReplyList": { - "id": "ReplyList", - "type": "object", - "description": "A list of replies to a comment on a file.", - "properties": { - "kind": { - "type": "string", - "description": "This is always drive#replyList.", - "default": "drive#replyList" - }, - "nextPageToken": { - "type": "string", - "description": "The page token for the next page of replies. This will be absent if the end of the replies list has been reached." - }, - "replies": { - "type": "array", - "description": "The page of replies.", - "items": { - "$ref": "Reply" - } - } - } - }, - "Revision": { - "id": "Revision", - "type": "object", - "description": "The metadata for a revision to a file.", - "properties": { - "id": { - "type": "string", - "description": "The ID of the revision." - }, - "keepForever": { - "type": "boolean", - "description": "Whether to keep this revision forever, even if it is no longer the head revision. If not set, the revision will be automatically purged 30 days after newer content is uploaded. This can be set on a maximum of 200 revisions for a file.\nThis field is only applicable to files with binary content in Drive." - }, - "kind": { - "type": "string", - "description": "This is always drive#revision.", - "default": "drive#revision" - }, - "lastModifyingUser": { - "$ref": "User", - "description": "The last user to modify this revision." - }, - "md5Checksum": { - "type": "string", - "description": "The MD5 checksum of the revision's content. This is only applicable to files with binary content in Drive." - }, - "mimeType": { - "type": "string", - "description": "The MIME type of the revision." - }, - "modifiedTime": { - "type": "string", - "description": "The last time the revision was modified (RFC 3339 date-time).", - "format": "date-time" - }, - "originalFilename": { - "type": "string", - "description": "The original filename used to create this revision. This is only applicable to files with binary content in Drive." - }, - "publishAuto": { - "type": "boolean", - "description": "Whether subsequent revisions will be automatically republished. This is only applicable to Google Docs." - }, - "published": { - "type": "boolean", - "description": "Whether this revision is published. This is only applicable to Google Docs." - }, - "publishedOutsideDomain": { - "type": "boolean", - "description": "Whether this revision is published outside the domain. This is only applicable to Google Docs." - }, - "size": { - "type": "string", - "description": "The size of the revision's content in bytes. This is only applicable to files with binary content in Drive.", - "format": "int64" - } - } - }, - "RevisionList": { - "id": "RevisionList", - "type": "object", - "description": "A list of revisions of a file.", - "properties": { - "kind": { - "type": "string", - "description": "This is always drive#revisionList.", - "default": "drive#revisionList" - }, - "revisions": { - "type": "array", - "description": "The full list of revisions.", - "items": { - "$ref": "Revision" - } - } - } - }, - "StartPageToken": { - "id": "StartPageToken", - "type": "object", - "properties": { - "kind": { - "type": "string", - "description": "This is always drive#startPageToken.", - "default": "drive#startPageToken" - }, - "startPageToken": { - "type": "string", - "description": "The starting page token for listing changes." - } - } - }, - "User": { - "id": "User", - "type": "object", - "description": "Information about a Drive user.", - "properties": { - "displayName": { - "type": "string", - "description": "A plain text displayable name for this user." - }, - "emailAddress": { - "type": "string", - "description": "The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester." - }, - "kind": { - "type": "string", - "description": "This is always drive#user.", - "default": "drive#user" - }, - "me": { - "type": "boolean", - "description": "Whether this user is the requesting user." - }, - "permissionId": { - "type": "string", - "description": "The user's ID as visible in Permission resources." - }, - "photoLink": { - "type": "string", - "description": "A link to the user's profile photo, if available." - } - } - } - }, - "resources": { - "about": { - "methods": { - "get": { - "id": "drive.about.get", - "path": "about", - "httpMethod": "GET", - "description": "Gets information about the user, the user's Drive, and system capabilities.", - "response": { - "$ref": "About" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "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" - ] - } - } - }, - "changes": { - "methods": { - "getStartPageToken": { - "id": "drive.changes.getStartPageToken", - "path": "changes/startPageToken", - "httpMethod": "GET", - "description": "Gets the starting pageToken for listing future changes.", - "response": { - "$ref": "StartPageToken" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "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" - ] - }, - "list": { - "id": "drive.changes.list", - "path": "changes", - "httpMethod": "GET", - "description": "Lists changes for a user.", - "parameters": { - "includeRemoved": { - "type": "boolean", - "description": "Whether to include changes indicating that items have left the view of the changes list, for example by deletion or lost access.", - "default": "true", - "location": "query" - }, - "pageSize": { - "type": "integer", - "description": "The maximum number of changes to return per page.", - "default": "100", - "format": "int32", - "minimum": "1", - "maximum": "1000", - "location": "query" - }, - "pageToken": { - "type": "string", - "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.", - "required": true, - "location": "query" - }, - "restrictToMyDrive": { - "type": "boolean", - "description": "Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.", - "default": "false", - "location": "query" - }, - "spaces": { - "type": "string", - "description": "A comma-separated list of spaces to query within the user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.", - "default": "drive", - "location": "query" - } - }, - "parameterOrder": [ - "pageToken" - ], - "response": { - "$ref": "ChangeList" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "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" - ], - "supportsSubscription": true - }, - "watch": { - "id": "drive.changes.watch", - "path": "changes/watch", - "httpMethod": "POST", - "description": "Subscribes to changes for a user.", - "parameters": { - "includeRemoved": { - "type": "boolean", - "description": "Whether to include changes indicating that items have left the view of the changes list, for example by deletion or lost access.", - "default": "true", - "location": "query" - }, - "pageSize": { - "type": "integer", - "description": "The maximum number of changes to return per page.", - "default": "100", - "format": "int32", - "minimum": "1", - "maximum": "1000", - "location": "query" - }, - "pageToken": { - "type": "string", - "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.", - "required": true, - "location": "query" - }, - "restrictToMyDrive": { - "type": "boolean", - "description": "Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.", - "default": "false", - "location": "query" - }, - "spaces": { - "type": "string", - "description": "A comma-separated list of spaces to query within the user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.", - "default": "drive", - "location": "query" - } - }, - "parameterOrder": [ - "pageToken" - ], - "request": { - "$ref": "Channel", - "parameterName": "resource" - }, - "response": { - "$ref": "Channel" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "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" - ], - "supportsSubscription": true - } - } - }, - "channels": { - "methods": { - "stop": { - "id": "drive.channels.stop", - "path": "channels/stop", - "httpMethod": "POST", - "description": "Stop watching resources through this channel", - "request": { - "$ref": "Channel", - "parameterName": "resource" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "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" - ] - } - } - }, - "comments": { - "methods": { - "create": { - "id": "drive.comments.create", - "path": "files/{fileId}/comments", - "httpMethod": "POST", - "description": "Creates a new comment on a file.", - "parameters": { - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId" - ], - "request": { - "$ref": "Comment" - }, - "response": { - "$ref": "Comment" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file" - ] - }, - "delete": { - "id": "drive.comments.delete", - "path": "files/{fileId}/comments/{commentId}", - "httpMethod": "DELETE", - "description": "Deletes a comment.", - "parameters": { - "commentId": { - "type": "string", - "description": "The ID of the comment.", - "required": true, - "location": "path" - }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId", - "commentId" - ], - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file" - ] - }, - "get": { - "id": "drive.comments.get", - "path": "files/{fileId}/comments/{commentId}", - "httpMethod": "GET", - "description": "Gets a comment by ID.", - "parameters": { - "commentId": { - "type": "string", - "description": "The ID of the comment.", - "required": true, - "location": "path" - }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - }, - "includeDeleted": { - "type": "boolean", - "description": "Whether to return deleted comments. Deleted comments will not include their original content.", - "default": "false", - "location": "query" - } - }, - "parameterOrder": [ - "fileId", - "commentId" - ], - "response": { - "$ref": "Comment" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file", - "https://www.googleapis.com/auth/drive.readonly" - ] - }, - "list": { - "id": "drive.comments.list", - "path": "files/{fileId}/comments", - "httpMethod": "GET", - "description": "Lists a file's comments.", - "parameters": { - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - }, - "includeDeleted": { - "type": "boolean", - "description": "Whether to include deleted comments. Deleted comments will not include their original content.", - "default": "false", - "location": "query" - }, - "pageSize": { - "type": "integer", - "description": "The maximum number of comments to return per page.", - "default": "20", - "format": "int32", - "minimum": "1", - "maximum": "100", - "location": "query" - }, - "pageToken": { - "type": "string", - "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.", - "location": "query" - }, - "startModifiedTime": { - "type": "string", - "description": "The minimum value of 'modifiedTime' for the result comments (RFC 3339 date-time).", - "location": "query" - } - }, - "parameterOrder": [ - "fileId" - ], - "response": { - "$ref": "CommentList" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file", - "https://www.googleapis.com/auth/drive.readonly" - ] - }, - "update": { - "id": "drive.comments.update", - "path": "files/{fileId}/comments/{commentId}", - "httpMethod": "PATCH", - "description": "Updates a comment with patch semantics.", - "parameters": { - "commentId": { - "type": "string", - "description": "The ID of the comment.", - "required": true, - "location": "path" - }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId", - "commentId" - ], - "request": { - "$ref": "Comment" - }, - "response": { - "$ref": "Comment" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file" - ] + "userIp": { + "description": "Deprecated. Please use quotaUser instead.", + "location": "query", + "type": "string" } - } }, - "files": { - "methods": { - "copy": { - "id": "drive.files.copy", - "path": "files/{fileId}/copy", - "httpMethod": "POST", - "description": "Creates a copy of a file and applies any requested updates with patch semantics.", - "parameters": { - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - }, - "ignoreDefaultVisibility": { - "type": "boolean", - "description": "Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.", - "default": "false", - "location": "query" - }, - "keepRevisionForever": { - "type": "boolean", - "description": "Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive.", - "default": "false", - "location": "query" - }, - "ocrLanguage": { - "type": "string", - "description": "A language hint for OCR processing during image import (ISO 639-1 code).", - "location": "query" + "protocol": "rest", + "resources": { + "about": { + "methods": { + "get": { + "description": "Gets information about the user, the user's Drive, and system capabilities.", + "httpMethod": "GET", + "id": "drive.about.get", + "path": "about", + "response": { + "$ref": "About" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "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" + ] + } } - }, - "parameterOrder": [ - "fileId" - ], - "request": { - "$ref": "File" - }, - "response": { - "$ref": "File" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "https://www.googleapis.com/auth/drive.file", - "https://www.googleapis.com/auth/drive.photos.readonly" - ] }, - "create": { - "id": "drive.files.create", - "path": "files", - "httpMethod": "POST", - "description": "Creates a new file.", - "parameters": { - "ignoreDefaultVisibility": { - "type": "boolean", - "description": "Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.", - "default": "false", - "location": "query" - }, - "keepRevisionForever": { - "type": "boolean", - "description": "Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive.", - "default": "false", - "location": "query" - }, - "ocrLanguage": { - "type": "string", - "description": "A language hint for OCR processing during image import (ISO 639-1 code).", - "location": "query" - }, - "useContentAsIndexableText": { - "type": "boolean", - "description": "Whether to use the uploaded content as indexable text.", - "default": "false", - "location": "query" - } - }, - "request": { - "$ref": "File" - }, - "response": { - "$ref": "File" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "https://www.googleapis.com/auth/drive.file" - ], - "supportsMediaUpload": true, - "mediaUpload": { - "accept": [ - "*/*" - ], - "maxSize": "5120GB", - "protocols": { - "simple": { - "multipart": true, - "path": "/upload/drive/v3/files" - }, - "resumable": { - "multipart": true, - "path": "/resumable/upload/drive/v3/files" - } + "changes": { + "methods": { + "getStartPageToken": { + "description": "Gets the starting pageToken for listing future changes.", + "httpMethod": "GET", + "id": "drive.changes.getStartPageToken", + "parameters": { + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + }, + "teamDriveId": { + "description": "The ID of the Team Drive for which the starting pageToken for listing future changes from that Team Drive will be returned.", + "location": "query", + "type": "string" + } + }, + "path": "changes/startPageToken", + "response": { + "$ref": "StartPageToken" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "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" + ] + }, + "list": { + "description": "Lists the changes for a user or Team Drive.", + "httpMethod": "GET", + "id": "drive.changes.list", + "parameterOrder": [ + "pageToken" + ], + "parameters": { + "includeCorpusRemovals": { + "default": "false", + "description": "Whether changes should include the file resource if the file is still accessible by the user at the time of the request, even when a file was removed from the list of changes and there will be no further change entries for this file.", + "location": "query", + "type": "boolean" + }, + "includeRemoved": { + "default": "true", + "description": "Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access.", + "location": "query", + "type": "boolean" + }, + "includeTeamDriveItems": { + "default": "false", + "description": "Whether Team Drive files or changes should be included in results.", + "location": "query", + "type": "boolean" + }, + "pageSize": { + "default": "100", + "description": "The maximum number of changes to return per page.", + "format": "int32", + "location": "query", + "maximum": "1000", + "minimum": "1", + "type": "integer" + }, + "pageToken": { + "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.", + "location": "query", + "required": true, + "type": "string" + }, + "restrictToMyDrive": { + "default": "false", + "description": "Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.", + "location": "query", + "type": "boolean" + }, + "spaces": { + "default": "drive", + "description": "A comma-separated list of spaces to query within the user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.", + "location": "query", + "type": "string" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + }, + "teamDriveId": { + "description": "The Team Drive from which changes will be returned. If specified the change IDs will be reflective of the Team Drive; use the combined Team Drive ID and change ID as an identifier.", + "location": "query", + "type": "string" + } + }, + "path": "changes", + "response": { + "$ref": "ChangeList" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "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" + ], + "supportsSubscription": true + }, + "watch": { + "description": "Subscribes to changes for a user.", + "httpMethod": "POST", + "id": "drive.changes.watch", + "parameterOrder": [ + "pageToken" + ], + "parameters": { + "includeCorpusRemovals": { + "default": "false", + "description": "Whether changes should include the file resource if the file is still accessible by the user at the time of the request, even when a file was removed from the list of changes and there will be no further change entries for this file.", + "location": "query", + "type": "boolean" + }, + "includeRemoved": { + "default": "true", + "description": "Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access.", + "location": "query", + "type": "boolean" + }, + "includeTeamDriveItems": { + "default": "false", + "description": "Whether Team Drive files or changes should be included in results.", + "location": "query", + "type": "boolean" + }, + "pageSize": { + "default": "100", + "description": "The maximum number of changes to return per page.", + "format": "int32", + "location": "query", + "maximum": "1000", + "minimum": "1", + "type": "integer" + }, + "pageToken": { + "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.", + "location": "query", + "required": true, + "type": "string" + }, + "restrictToMyDrive": { + "default": "false", + "description": "Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.", + "location": "query", + "type": "boolean" + }, + "spaces": { + "default": "drive", + "description": "A comma-separated list of spaces to query within the user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.", + "location": "query", + "type": "string" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + }, + "teamDriveId": { + "description": "The Team Drive from which changes will be returned. If specified the change IDs will be reflective of the Team Drive; use the combined Team Drive ID and change ID as an identifier.", + "location": "query", + "type": "string" + } + }, + "path": "changes/watch", + "request": { + "$ref": "Channel", + "parameterName": "resource" + }, + "response": { + "$ref": "Channel" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "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" + ], + "supportsSubscription": true + } } - }, - "supportsSubscription": true }, - "delete": { - "id": "drive.files.delete", - "path": "files/{fileId}", - "httpMethod": "DELETE", - "description": "Permanently deletes a file owned by the user without moving it to the trash. If the target is a folder, all descendants owned by the user are also deleted.", - "parameters": { - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" + "channels": { + "methods": { + "stop": { + "description": "Stop watching resources through this channel", + "httpMethod": "POST", + "id": "drive.channels.stop", + "path": "channels/stop", + "request": { + "$ref": "Channel", + "parameterName": "resource" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "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" + ] + } } - }, - "parameterOrder": [ - "fileId" - ], - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "https://www.googleapis.com/auth/drive.file" - ] - }, - "emptyTrash": { - "id": "drive.files.emptyTrash", - "path": "files/trash", - "httpMethod": "DELETE", - "description": "Permanently deletes all of the user's trashed files.", - "scopes": [ - "https://www.googleapis.com/auth/drive" - ] }, - "export": { - "id": "drive.files.export", - "path": "files/{fileId}/export", - "httpMethod": "GET", - "description": "Exports a Google Doc to the requested MIME type and returns the exported content.", - "parameters": { - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - }, - "mimeType": { - "type": "string", - "description": "The MIME type of the format requested for this export.", - "required": true, - "location": "query" + "comments": { + "methods": { + "create": { + "description": "Creates a new comment on a file.", + "httpMethod": "POST", + "id": "drive.comments.create", + "parameterOrder": [ + "fileId" + ], + "parameters": { + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + } + }, + "path": "files/{fileId}/comments", + "request": { + "$ref": "Comment" + }, + "response": { + "$ref": "Comment" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file" + ] + }, + "delete": { + "description": "Deletes a comment.", + "httpMethod": "DELETE", + "id": "drive.comments.delete", + "parameterOrder": [ + "fileId", + "commentId" + ], + "parameters": { + "commentId": { + "description": "The ID of the comment.", + "location": "path", + "required": true, + "type": "string" + }, + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + } + }, + "path": "files/{fileId}/comments/{commentId}", + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file" + ] + }, + "get": { + "description": "Gets a comment by ID.", + "httpMethod": "GET", + "id": "drive.comments.get", + "parameterOrder": [ + "fileId", + "commentId" + ], + "parameters": { + "commentId": { + "description": "The ID of the comment.", + "location": "path", + "required": true, + "type": "string" + }, + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "includeDeleted": { + "default": "false", + "description": "Whether to return deleted comments. Deleted comments will not include their original content.", + "location": "query", + "type": "boolean" + } + }, + "path": "files/{fileId}/comments/{commentId}", + "response": { + "$ref": "Comment" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.readonly" + ] + }, + "list": { + "description": "Lists a file's comments.", + "httpMethod": "GET", + "id": "drive.comments.list", + "parameterOrder": [ + "fileId" + ], + "parameters": { + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "includeDeleted": { + "default": "false", + "description": "Whether to include deleted comments. Deleted comments will not include their original content.", + "location": "query", + "type": "boolean" + }, + "pageSize": { + "default": "20", + "description": "The maximum number of comments to return per page.", + "format": "int32", + "location": "query", + "maximum": "100", + "minimum": "1", + "type": "integer" + }, + "pageToken": { + "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.", + "location": "query", + "type": "string" + }, + "startModifiedTime": { + "description": "The minimum value of 'modifiedTime' for the result comments (RFC 3339 date-time).", + "location": "query", + "type": "string" + } + }, + "path": "files/{fileId}/comments", + "response": { + "$ref": "CommentList" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.readonly" + ] + }, + "update": { + "description": "Updates a comment with patch semantics.", + "httpMethod": "PATCH", + "id": "drive.comments.update", + "parameterOrder": [ + "fileId", + "commentId" + ], + "parameters": { + "commentId": { + "description": "The ID of the comment.", + "location": "path", + "required": true, + "type": "string" + }, + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + } + }, + "path": "files/{fileId}/comments/{commentId}", + "request": { + "$ref": "Comment" + }, + "response": { + "$ref": "Comment" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file" + ] + } } - }, - "parameterOrder": [ - "fileId", - "mimeType" - ], - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file", - "https://www.googleapis.com/auth/drive.readonly" - ], - "supportsMediaDownload": true }, - "generateIds": { - "id": "drive.files.generateIds", - "path": "files/generateIds", - "httpMethod": "GET", - "description": "Generates a set of file IDs which can be provided in create requests.", - "parameters": { - "count": { - "type": "integer", - "description": "The number of IDs to return.", - "default": "10", - "format": "int32", - "minimum": "1", - "maximum": "1000", - "location": "query" - }, - "space": { - "type": "string", - "description": "The space in which the IDs can be used to create new files. Supported values are 'drive' and 'appDataFolder'.", - "default": "drive", - "location": "query" + "files": { + "methods": { + "copy": { + "description": "Creates a copy of a file and applies any requested updates with patch semantics.", + "httpMethod": "POST", + "id": "drive.files.copy", + "parameterOrder": [ + "fileId" + ], + "parameters": { + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "ignoreDefaultVisibility": { + "default": "false", + "description": "Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.", + "location": "query", + "type": "boolean" + }, + "keepRevisionForever": { + "default": "false", + "description": "Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive.", + "location": "query", + "type": "boolean" + }, + "ocrLanguage": { + "description": "A language hint for OCR processing during image import (ISO 639-1 code).", + "location": "query", + "type": "string" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + } + }, + "path": "files/{fileId}/copy", + "request": { + "$ref": "File" + }, + "response": { + "$ref": "File" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.photos.readonly" + ] + }, + "create": { + "description": "Creates a new file.", + "httpMethod": "POST", + "id": "drive.files.create", + "mediaUpload": { + "accept": [ + "*/*" + ], + "maxSize": "5120GB", + "protocols": { + "resumable": { + "multipart": true, + "path": "/resumable/upload/drive/v3/files" + }, + "simple": { + "multipart": true, + "path": "/upload/drive/v3/files" + } + } + }, + "parameters": { + "ignoreDefaultVisibility": { + "default": "false", + "description": "Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.", + "location": "query", + "type": "boolean" + }, + "keepRevisionForever": { + "default": "false", + "description": "Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive.", + "location": "query", + "type": "boolean" + }, + "ocrLanguage": { + "description": "A language hint for OCR processing during image import (ISO 639-1 code).", + "location": "query", + "type": "string" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + }, + "useContentAsIndexableText": { + "default": "false", + "description": "Whether to use the uploaded content as indexable text.", + "location": "query", + "type": "boolean" + } + }, + "path": "files", + "request": { + "$ref": "File" + }, + "response": { + "$ref": "File" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "https://www.googleapis.com/auth/drive.file" + ], + "supportsMediaUpload": true, + "supportsSubscription": true + }, + "delete": { + "description": "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.", + "httpMethod": "DELETE", + "id": "drive.files.delete", + "parameterOrder": [ + "fileId" + ], + "parameters": { + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + } + }, + "path": "files/{fileId}", + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "https://www.googleapis.com/auth/drive.file" + ] + }, + "emptyTrash": { + "description": "Permanently deletes all of the user's trashed files.", + "httpMethod": "DELETE", + "id": "drive.files.emptyTrash", + "path": "files/trash", + "scopes": [ + "https://www.googleapis.com/auth/drive" + ] + }, + "export": { + "description": "Exports a Google Doc to the requested MIME type and returns the exported content. Please note that the exported content is limited to 10MB.", + "httpMethod": "GET", + "id": "drive.files.export", + "parameterOrder": [ + "fileId", + "mimeType" + ], + "parameters": { + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "mimeType": { + "description": "The MIME type of the format requested for this export.", + "location": "query", + "required": true, + "type": "string" + } + }, + "path": "files/{fileId}/export", + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.readonly" + ], + "supportsMediaDownload": true + }, + "generateIds": { + "description": "Generates a set of file IDs which can be provided in create requests.", + "httpMethod": "GET", + "id": "drive.files.generateIds", + "parameters": { + "count": { + "default": "10", + "description": "The number of IDs to return.", + "format": "int32", + "location": "query", + "maximum": "1000", + "minimum": "1", + "type": "integer" + }, + "space": { + "default": "drive", + "description": "The space in which the IDs can be used to create new files. Supported values are 'drive' and 'appDataFolder'.", + "location": "query", + "type": "string" + } + }, + "path": "files/generateIds", + "response": { + "$ref": "GeneratedIds" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "https://www.googleapis.com/auth/drive.file" + ] + }, + "get": { + "description": "Gets a file's metadata or content by ID.", + "httpMethod": "GET", + "id": "drive.files.get", + "parameterOrder": [ + "fileId" + ], + "parameters": { + "acknowledgeAbuse": { + "default": "false", + "description": "Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.", + "location": "query", + "type": "boolean" + }, + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + } + }, + "path": "files/{fileId}", + "response": { + "$ref": "File" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "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" + ], + "supportsMediaDownload": true, + "supportsSubscription": true, + "useMediaDownloadService": true + }, + "list": { + "description": "Lists or searches files.", + "httpMethod": "GET", + "id": "drive.files.list", + "parameters": { + "corpora": { + "description": "Comma-separated list of bodies of items (files/documents) to which the query applies. Supported bodies are 'user', 'domain', 'teamDrive' and 'allTeamDrives'. 'allTeamDrives' must be combined with 'user'; all other values must be used in isolation. Prefer 'user' or 'teamDrive' to 'allTeamDrives' for efficiency.", + "location": "query", + "type": "string" + }, + "corpus": { + "description": "The source of files to list. Deprecated: use 'corpora' instead.", + "enum": [ + "domain", + "user" + ], + "enumDescriptions": [ + "Files shared to the user's domain.", + "Files owned by or shared to the user." + ], + "location": "query", + "type": "string" + }, + "includeTeamDriveItems": { + "default": "false", + "description": "Whether Team Drive items should be included in results.", + "location": "query", + "type": "boolean" + }, + "orderBy": { + "description": "A comma-separated list of sort keys. Valid keys are 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. Each key sorts ascending by default, but may be reversed with the 'desc' modifier. Example usage: ?orderBy=folder,modifiedTime desc,name. Please note that there is a current limitation for users with approximately one million files in which the requested sort order is ignored.", + "location": "query", + "type": "string" + }, + "pageSize": { + "default": "100", + "description": "The maximum number of files to return per page. Partial or empty result pages are possible even before the end of the files list has been reached.", + "format": "int32", + "location": "query", + "maximum": "1000", + "minimum": "1", + "type": "integer" + }, + "pageToken": { + "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.", + "location": "query", + "type": "string" + }, + "q": { + "description": "A query for filtering the file results. See the \"Search for Files\" guide for supported syntax.", + "location": "query", + "type": "string" + }, + "spaces": { + "default": "drive", + "description": "A comma-separated list of spaces to query within the corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.", + "location": "query", + "type": "string" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + }, + "teamDriveId": { + "description": "ID of Team Drive to search.", + "location": "query", + "type": "string" + } + }, + "path": "files", + "response": { + "$ref": "FileList" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "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" + ] + }, + "update": { + "description": "Updates a file's metadata and/or content with patch semantics.", + "httpMethod": "PATCH", + "id": "drive.files.update", + "mediaUpload": { + "accept": [ + "*/*" + ], + "maxSize": "5120GB", + "protocols": { + "resumable": { + "multipart": true, + "path": "/resumable/upload/drive/v3/files/{fileId}" + }, + "simple": { + "multipart": true, + "path": "/upload/drive/v3/files/{fileId}" + } + } + }, + "parameterOrder": [ + "fileId" + ], + "parameters": { + "addParents": { + "description": "A comma-separated list of parent IDs to add.", + "location": "query", + "type": "string" + }, + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "keepRevisionForever": { + "default": "false", + "description": "Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive.", + "location": "query", + "type": "boolean" + }, + "ocrLanguage": { + "description": "A language hint for OCR processing during image import (ISO 639-1 code).", + "location": "query", + "type": "string" + }, + "removeParents": { + "description": "A comma-separated list of parent IDs to remove.", + "location": "query", + "type": "string" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + }, + "useContentAsIndexableText": { + "default": "false", + "description": "Whether to use the uploaded content as indexable text.", + "location": "query", + "type": "boolean" + } + }, + "path": "files/{fileId}", + "request": { + "$ref": "File" + }, + "response": { + "$ref": "File" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", + "https://www.googleapis.com/auth/drive.scripts" + ], + "supportsMediaUpload": true + }, + "watch": { + "description": "Subscribes to changes to a file", + "httpMethod": "POST", + "id": "drive.files.watch", + "parameterOrder": [ + "fileId" + ], + "parameters": { + "acknowledgeAbuse": { + "default": "false", + "description": "Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.", + "location": "query", + "type": "boolean" + }, + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + } + }, + "path": "files/{fileId}/watch", + "request": { + "$ref": "Channel", + "parameterName": "resource" + }, + "response": { + "$ref": "Channel" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "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" + ], + "supportsMediaDownload": true, + "supportsSubscription": true, + "useMediaDownloadService": true + } } - }, - "response": { - "$ref": "GeneratedIds" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "https://www.googleapis.com/auth/drive.file" - ] }, - "get": { - "id": "drive.files.get", - "path": "files/{fileId}", - "httpMethod": "GET", - "description": "Gets a file's metadata or content by ID.", - "parameters": { - "acknowledgeAbuse": { - "type": "boolean", - "description": "Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.", - "default": "false", - "location": "query" - }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" + "permissions": { + "methods": { + "create": { + "description": "Creates a permission for a file or Team Drive.", + "httpMethod": "POST", + "id": "drive.permissions.create", + "parameterOrder": [ + "fileId" + ], + "parameters": { + "emailMessage": { + "description": "A plain text custom message to include in the notification email.", + "location": "query", + "type": "string" + }, + "fileId": { + "description": "The ID of the file or Team Drive.", + "location": "path", + "required": true, + "type": "string" + }, + "sendNotificationEmail": { + "description": "Whether to send a notification email when sharing to users or groups. This defaults to true for users and groups, and is not allowed for other requests. It must not be disabled for ownership transfers.", + "location": "query", + "type": "boolean" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + }, + "transferOwnership": { + "default": "false", + "description": "Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect.", + "location": "query", + "type": "boolean" + }, + "useDomainAdminAccess": { + "default": "false", + "description": "Issue the request as 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.", + "location": "query", + "type": "boolean" + } + }, + "path": "files/{fileId}/permissions", + "request": { + "$ref": "Permission" + }, + "response": { + "$ref": "Permission" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file" + ] + }, + "delete": { + "description": "Deletes a permission.", + "httpMethod": "DELETE", + "id": "drive.permissions.delete", + "parameterOrder": [ + "fileId", + "permissionId" + ], + "parameters": { + "fileId": { + "description": "The ID of the file or Team Drive.", + "location": "path", + "required": true, + "type": "string" + }, + "permissionId": { + "description": "The ID of the permission.", + "location": "path", + "required": true, + "type": "string" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + }, + "useDomainAdminAccess": { + "default": "false", + "description": "Issue the request as 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.", + "location": "query", + "type": "boolean" + } + }, + "path": "files/{fileId}/permissions/{permissionId}", + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file" + ] + }, + "get": { + "description": "Gets a permission by ID.", + "httpMethod": "GET", + "id": "drive.permissions.get", + "parameterOrder": [ + "fileId", + "permissionId" + ], + "parameters": { + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "permissionId": { + "description": "The ID of the permission.", + "location": "path", + "required": true, + "type": "string" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + }, + "useDomainAdminAccess": { + "default": "false", + "description": "Issue the request as 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.", + "location": "query", + "type": "boolean" + } + }, + "path": "files/{fileId}/permissions/{permissionId}", + "response": { + "$ref": "Permission" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "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" + ] + }, + "list": { + "description": "Lists a file's or Team Drive's permissions.", + "httpMethod": "GET", + "id": "drive.permissions.list", + "parameterOrder": [ + "fileId" + ], + "parameters": { + "fileId": { + "description": "The ID of the file or Team Drive.", + "location": "path", + "required": true, + "type": "string" + }, + "pageSize": { + "description": "The maximum number of permissions to return per page. When not set for files in a Team Drive, at most 100 results will be returned. When not set for files that are not in a Team Drive, the entire list will be returned.", + "format": "int32", + "location": "query", + "maximum": "100", + "minimum": "1", + "type": "integer" + }, + "pageToken": { + "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.", + "location": "query", + "type": "string" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + }, + "useDomainAdminAccess": { + "default": "false", + "description": "Issue the request as 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.", + "location": "query", + "type": "boolean" + } + }, + "path": "files/{fileId}/permissions", + "response": { + "$ref": "PermissionList" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "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" + ] + }, + "update": { + "description": "Updates a permission with patch semantics.", + "httpMethod": "PATCH", + "id": "drive.permissions.update", + "parameterOrder": [ + "fileId", + "permissionId" + ], + "parameters": { + "fileId": { + "description": "The ID of the file or Team Drive.", + "location": "path", + "required": true, + "type": "string" + }, + "permissionId": { + "description": "The ID of the permission.", + "location": "path", + "required": true, + "type": "string" + }, + "removeExpiration": { + "default": "false", + "description": "Whether to remove the expiration date.", + "location": "query", + "type": "boolean" + }, + "supportsTeamDrives": { + "default": "false", + "description": "Whether the requesting application supports Team Drives.", + "location": "query", + "type": "boolean" + }, + "transferOwnership": { + "default": "false", + "description": "Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect.", + "location": "query", + "type": "boolean" + }, + "useDomainAdminAccess": { + "default": "false", + "description": "Issue the request as 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.", + "location": "query", + "type": "boolean" + } + }, + "path": "files/{fileId}/permissions/{permissionId}", + "request": { + "$ref": "Permission" + }, + "response": { + "$ref": "Permission" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file" + ] + } } - }, - "parameterOrder": [ - "fileId" - ], - "response": { - "$ref": "File" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "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" - ], - "supportsMediaDownload": true, - "useMediaDownloadService": true, - "supportsSubscription": true }, - "list": { - "id": "drive.files.list", - "path": "files", - "httpMethod": "GET", - "description": "Lists or searches files.", - "parameters": { - "corpus": { - "type": "string", - "description": "The source of files to list.", - "default": "user", - "enum": [ - "domain", - "user" - ], - "enumDescriptions": [ - "Files shared to the user's domain.", - "Files owned by or shared to the user." - ], - "location": "query" - }, - "orderBy": { - "type": "string", - "description": "A comma-separated list of sort keys. Valid keys are 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. Each key sorts ascending by default, but may be reversed with the 'desc' modifier. Example usage: ?orderBy=folder,modifiedTime desc,name. Please note that there is a current limitation for users with approximately one million files in which the requested sort order is ignored.", - "location": "query" - }, - "pageSize": { - "type": "integer", - "description": "The maximum number of files to return per page.", - "default": "100", - "format": "int32", - "minimum": "1", - "maximum": "1000", - "location": "query" - }, - "pageToken": { - "type": "string", - "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.", - "location": "query" - }, - "q": { - "type": "string", - "description": "A query for filtering the file results. See the \"Search for Files\" guide for supported syntax.", - "location": "query" - }, - "spaces": { - "type": "string", - "description": "A comma-separated list of spaces to query within the corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.", - "default": "drive", - "location": "query" + "replies": { + "methods": { + "create": { + "description": "Creates a new reply to a comment.", + "httpMethod": "POST", + "id": "drive.replies.create", + "parameterOrder": [ + "fileId", + "commentId" + ], + "parameters": { + "commentId": { + "description": "The ID of the comment.", + "location": "path", + "required": true, + "type": "string" + }, + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + } + }, + "path": "files/{fileId}/comments/{commentId}/replies", + "request": { + "$ref": "Reply" + }, + "response": { + "$ref": "Reply" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file" + ] + }, + "delete": { + "description": "Deletes a reply.", + "httpMethod": "DELETE", + "id": "drive.replies.delete", + "parameterOrder": [ + "fileId", + "commentId", + "replyId" + ], + "parameters": { + "commentId": { + "description": "The ID of the comment.", + "location": "path", + "required": true, + "type": "string" + }, + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "replyId": { + "description": "The ID of the reply.", + "location": "path", + "required": true, + "type": "string" + } + }, + "path": "files/{fileId}/comments/{commentId}/replies/{replyId}", + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file" + ] + }, + "get": { + "description": "Gets a reply by ID.", + "httpMethod": "GET", + "id": "drive.replies.get", + "parameterOrder": [ + "fileId", + "commentId", + "replyId" + ], + "parameters": { + "commentId": { + "description": "The ID of the comment.", + "location": "path", + "required": true, + "type": "string" + }, + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "includeDeleted": { + "default": "false", + "description": "Whether to return deleted replies. Deleted replies will not include their original content.", + "location": "query", + "type": "boolean" + }, + "replyId": { + "description": "The ID of the reply.", + "location": "path", + "required": true, + "type": "string" + } + }, + "path": "files/{fileId}/comments/{commentId}/replies/{replyId}", + "response": { + "$ref": "Reply" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.readonly" + ] + }, + "list": { + "description": "Lists a comment's replies.", + "httpMethod": "GET", + "id": "drive.replies.list", + "parameterOrder": [ + "fileId", + "commentId" + ], + "parameters": { + "commentId": { + "description": "The ID of the comment.", + "location": "path", + "required": true, + "type": "string" + }, + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "includeDeleted": { + "default": "false", + "description": "Whether to include deleted replies. Deleted replies will not include their original content.", + "location": "query", + "type": "boolean" + }, + "pageSize": { + "default": "20", + "description": "The maximum number of replies to return per page.", + "format": "int32", + "location": "query", + "maximum": "100", + "minimum": "1", + "type": "integer" + }, + "pageToken": { + "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.", + "location": "query", + "type": "string" + } + }, + "path": "files/{fileId}/comments/{commentId}/replies", + "response": { + "$ref": "ReplyList" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.readonly" + ] + }, + "update": { + "description": "Updates a reply with patch semantics.", + "httpMethod": "PATCH", + "id": "drive.replies.update", + "parameterOrder": [ + "fileId", + "commentId", + "replyId" + ], + "parameters": { + "commentId": { + "description": "The ID of the comment.", + "location": "path", + "required": true, + "type": "string" + }, + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "replyId": { + "description": "The ID of the reply.", + "location": "path", + "required": true, + "type": "string" + } + }, + "path": "files/{fileId}/comments/{commentId}/replies/{replyId}", + "request": { + "$ref": "Reply" + }, + "response": { + "$ref": "Reply" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file" + ] + } } - }, - "response": { - "$ref": "FileList" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "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" - ] }, - "update": { - "id": "drive.files.update", - "path": "files/{fileId}", - "httpMethod": "PATCH", - "description": "Updates a file's metadata and/or content with patch semantics.", - "parameters": { - "addParents": { - "type": "string", - "description": "A comma-separated list of parent IDs to add.", - "location": "query" - }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - }, - "keepRevisionForever": { - "type": "boolean", - "description": "Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive.", - "default": "false", - "location": "query" - }, - "ocrLanguage": { - "type": "string", - "description": "A language hint for OCR processing during image import (ISO 639-1 code).", - "location": "query" - }, - "removeParents": { - "type": "string", - "description": "A comma-separated list of parent IDs to remove.", - "location": "query" - }, - "useContentAsIndexableText": { - "type": "boolean", - "description": "Whether to use the uploaded content as indexable text.", - "default": "false", - "location": "query" - } - }, - "parameterOrder": [ - "fileId" - ], - "request": { - "$ref": "File" - }, - "response": { - "$ref": "File" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "https://www.googleapis.com/auth/drive.file", - "https://www.googleapis.com/auth/drive.metadata", - "https://www.googleapis.com/auth/drive.scripts" - ], - "supportsMediaUpload": true, - "mediaUpload": { - "accept": [ - "*/*" - ], - "maxSize": "5120GB", - "protocols": { - "simple": { - "multipart": true, - "path": "/upload/drive/v3/files/{fileId}" - }, - "resumable": { - "multipart": true, - "path": "/resumable/upload/drive/v3/files/{fileId}" - } + "revisions": { + "methods": { + "delete": { + "description": "Permanently deletes a revision. This method is only applicable to files with binary content in Drive.", + "httpMethod": "DELETE", + "id": "drive.revisions.delete", + "parameterOrder": [ + "fileId", + "revisionId" + ], + "parameters": { + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "revisionId": { + "description": "The ID of the revision.", + "location": "path", + "required": true, + "type": "string" + } + }, + "path": "files/{fileId}/revisions/{revisionId}", + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "https://www.googleapis.com/auth/drive.file" + ] + }, + "get": { + "description": "Gets a revision's metadata or content by ID.", + "httpMethod": "GET", + "id": "drive.revisions.get", + "parameterOrder": [ + "fileId", + "revisionId" + ], + "parameters": { + "acknowledgeAbuse": { + "default": "false", + "description": "Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.", + "location": "query", + "type": "boolean" + }, + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "revisionId": { + "description": "The ID of the revision.", + "location": "path", + "required": true, + "type": "string" + } + }, + "path": "files/{fileId}/revisions/{revisionId}", + "response": { + "$ref": "Revision" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "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" + ], + "supportsMediaDownload": true, + "useMediaDownloadService": true + }, + "list": { + "description": "Lists a file's revisions.", + "httpMethod": "GET", + "id": "drive.revisions.list", + "parameterOrder": [ + "fileId" + ], + "parameters": { + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "pageSize": { + "default": "200", + "description": "The maximum number of revisions to return per page.", + "format": "int32", + "location": "query", + "maximum": "1000", + "minimum": "1", + "type": "integer" + }, + "pageToken": { + "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.", + "location": "query", + "type": "string" + } + }, + "path": "files/{fileId}/revisions", + "response": { + "$ref": "RevisionList" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "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" + ] + }, + "update": { + "description": "Updates a revision with patch semantics.", + "httpMethod": "PATCH", + "id": "drive.revisions.update", + "parameterOrder": [ + "fileId", + "revisionId" + ], + "parameters": { + "fileId": { + "description": "The ID of the file.", + "location": "path", + "required": true, + "type": "string" + }, + "revisionId": { + "description": "The ID of the revision.", + "location": "path", + "required": true, + "type": "string" + } + }, + "path": "files/{fileId}/revisions/{revisionId}", + "request": { + "$ref": "Revision" + }, + "response": { + "$ref": "Revision" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.appdata", + "https://www.googleapis.com/auth/drive.file" + ] + } } - } }, - "watch": { - "id": "drive.files.watch", - "path": "files/{fileId}/watch", - "httpMethod": "POST", - "description": "Subscribes to changes to a file", - "parameters": { - "acknowledgeAbuse": { - "type": "boolean", - "description": "Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.", - "default": "false", - "location": "query" - }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" + "teamdrives": { + "methods": { + "create": { + "description": "Creates a new Team Drive.", + "httpMethod": "POST", + "id": "drive.teamdrives.create", + "parameterOrder": [ + "requestId" + ], + "parameters": { + "requestId": { + "description": "An ID, such as a random UUID, which uniquely identifies this user's request for idempotent creation of a Team Drive. A repeated request by the same user and with the same request ID will avoid creating duplicates by attempting to create the same Team Drive. If the Team Drive already exists a 409 error will be returned.", + "location": "query", + "required": true, + "type": "string" + } + }, + "path": "teamdrives", + "request": { + "$ref": "TeamDrive" + }, + "response": { + "$ref": "TeamDrive" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive" + ] + }, + "delete": { + "description": "Permanently deletes a Team Drive for which the user is an organizer. The Team Drive cannot contain any untrashed items.", + "httpMethod": "DELETE", + "id": "drive.teamdrives.delete", + "parameterOrder": [ + "teamDriveId" + ], + "parameters": { + "teamDriveId": { + "description": "The ID of the Team Drive", + "location": "path", + "required": true, + "type": "string" + } + }, + "path": "teamdrives/{teamDriveId}", + "scopes": [ + "https://www.googleapis.com/auth/drive" + ] + }, + "get": { + "description": "Gets a Team Drive's metadata by ID.", + "httpMethod": "GET", + "id": "drive.teamdrives.get", + "parameterOrder": [ + "teamDriveId" + ], + "parameters": { + "teamDriveId": { + "description": "The ID of the Team Drive", + "location": "path", + "required": true, + "type": "string" + }, + "useDomainAdminAccess": { + "default": "false", + "description": "Issue the request as 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.", + "location": "query", + "type": "boolean" + } + }, + "path": "teamdrives/{teamDriveId}", + "response": { + "$ref": "TeamDrive" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.readonly" + ] + }, + "list": { + "description": "Lists the user's Team Drives.", + "httpMethod": "GET", + "id": "drive.teamdrives.list", + "parameters": { + "pageSize": { + "default": "10", + "description": "Maximum number of Team Drives to return.", + "format": "int32", + "location": "query", + "maximum": "100", + "minimum": "1", + "type": "integer" + }, + "pageToken": { + "description": "Page token for Team Drives.", + "location": "query", + "type": "string" + }, + "q": { + "description": "Query string for searching Team Drives.", + "location": "query", + "type": "string" + }, + "useDomainAdminAccess": { + "default": "false", + "description": "Issue the request as a domain administrator; if set to true, then all Team Drives of the domain in which the requester is an administrator are returned.", + "location": "query", + "type": "boolean" + } + }, + "path": "teamdrives", + "response": { + "$ref": "TeamDriveList" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.readonly" + ] + }, + "update": { + "description": "Updates a Team Drive's metadata", + "httpMethod": "PATCH", + "id": "drive.teamdrives.update", + "parameterOrder": [ + "teamDriveId" + ], + "parameters": { + "teamDriveId": { + "description": "The ID of the Team Drive", + "location": "path", + "required": true, + "type": "string" + }, + "useDomainAdminAccess": { + "default": "false", + "description": "Issue the request as 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.", + "location": "query", + "type": "boolean" + } + }, + "path": "teamdrives/{teamDriveId}", + "request": { + "$ref": "TeamDrive" + }, + "response": { + "$ref": "TeamDrive" + }, + "scopes": [ + "https://www.googleapis.com/auth/drive" + ] + } } - }, - "parameterOrder": [ - "fileId" - ], - "request": { - "$ref": "Channel", - "parameterName": "resource" - }, - "response": { - "$ref": "Channel" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "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" - ], - "supportsMediaDownload": true, - "useMediaDownloadService": true, - "supportsSubscription": true } - } }, - "permissions": { - "methods": { - "create": { - "id": "drive.permissions.create", - "path": "files/{fileId}/permissions", - "httpMethod": "POST", - "description": "Creates a permission for a file.", - "parameters": { - "emailMessage": { - "type": "string", - "description": "A custom message to include in the notification email.", - "location": "query" - }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - }, - "sendNotificationEmail": { - "type": "boolean", - "description": "Whether to send a notification email when sharing to users or groups. This defaults to true for users and groups, and is not allowed for other requests. It must not be disabled for ownership transfers.", - "location": "query" + "revision": "20180830", + "rootUrl": "https://www.googleapis.com/", + "schemas": { + "About": { + "description": "Information about the user, the user's Drive, and system capabilities.", + "id": "About", + "properties": { + "appInstalled": { + "description": "Whether the user has installed the requesting app.", + "type": "boolean" + }, + "canCreateTeamDrives": { + "description": "Whether the user can create Team Drives.", + "type": "boolean" + }, + "exportFormats": { + "additionalProperties": { + "items": { + "type": "string" + }, + "type": "array" + }, + "description": "A map of source MIME type to possible targets for all supported exports.", + "type": "object" + }, + "folderColorPalette": { + "description": "The currently supported folder colors as RGB hex strings.", + "items": { + "type": "string" + }, + "type": "array" + }, + "importFormats": { + "additionalProperties": { + "items": { + "type": "string" + }, + "type": "array" + }, + "description": "A map of source MIME type to possible targets for all supported imports.", + "type": "object" + }, + "kind": { + "default": "drive#about", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#about\".", + "type": "string" + }, + "maxImportSizes": { + "additionalProperties": { + "format": "int64", + "type": "string" + }, + "description": "A map of maximum import sizes by MIME type, in bytes.", + "type": "object" + }, + "maxUploadSize": { + "description": "The maximum upload size in bytes.", + "format": "int64", + "type": "string" + }, + "storageQuota": { + "description": "The user's storage quota limits and usage. All fields are measured in bytes.", + "properties": { + "limit": { + "description": "The usage limit, if applicable. This will not be present if the user has unlimited storage.", + "format": "int64", + "type": "string" + }, + "usage": { + "description": "The total usage across all services.", + "format": "int64", + "type": "string" + }, + "usageInDrive": { + "description": "The usage by all files in Google Drive.", + "format": "int64", + "type": "string" + }, + "usageInDriveTrash": { + "description": "The usage by trashed files in Google Drive.", + "format": "int64", + "type": "string" + } + }, + "type": "object" + }, + "teamDriveThemes": { + "description": "A list of themes that are supported for Team Drives.", + "items": { + "properties": { + "backgroundImageLink": { + "description": "A link to this Team Drive theme's background image.", + "type": "string" + }, + "colorRgb": { + "description": "The color of this Team Drive theme as an RGB hex string.", + "type": "string" + }, + "id": { + "description": "The ID of the theme.", + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + }, + "user": { + "$ref": "User", + "description": "The authenticated user." + } }, - "transferOwnership": { - "type": "boolean", - "description": "Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect.", - "default": "false", - "location": "query" - } - }, - "parameterOrder": [ - "fileId" - ], - "request": { - "$ref": "Permission" - }, - "response": { - "$ref": "Permission" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file" - ] + "type": "object" }, - "delete": { - "id": "drive.permissions.delete", - "path": "files/{fileId}/permissions/{permissionId}", - "httpMethod": "DELETE", - "description": "Deletes a permission.", - "parameters": { - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" + "Change": { + "description": "A change to a file or Team Drive.", + "id": "Change", + "properties": { + "file": { + "$ref": "File", + "description": "The updated state of the file. Present if the type is file and the file has not been removed from this list of changes." + }, + "fileId": { + "description": "The ID of the file which has changed.", + "type": "string" + }, + "kind": { + "default": "drive#change", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#change\".", + "type": "string" + }, + "removed": { + "description": "Whether the file or Team Drive has been removed from this list of changes, for example by deletion or loss of access.", + "type": "boolean" + }, + "teamDrive": { + "$ref": "TeamDrive", + "description": "The updated state of the Team Drive. Present if the type is teamDrive, the user is still a member of the Team Drive, and the Team Drive has not been removed." + }, + "teamDriveId": { + "description": "The ID of the Team Drive associated with this change.", + "type": "string" + }, + "time": { + "description": "The time of this change (RFC 3339 date-time).", + "format": "date-time", + "type": "string" + }, + "type": { + "description": "The type of the change. Possible values are file and teamDrive.", + "type": "string" + } }, - "permissionId": { - "type": "string", - "description": "The ID of the permission.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId", - "permissionId" - ], - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file" - ] - }, - "get": { - "id": "drive.permissions.get", - "path": "files/{fileId}/permissions/{permissionId}", - "httpMethod": "GET", - "description": "Gets a permission by ID.", - "parameters": { - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" + "type": "object" + }, + "ChangeList": { + "description": "A list of changes for a user.", + "id": "ChangeList", + "properties": { + "changes": { + "description": "The list of changes. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.", + "items": { + "$ref": "Change" + }, + "type": "array" + }, + "kind": { + "default": "drive#changeList", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#changeList\".", + "type": "string" + }, + "newStartPageToken": { + "description": "The starting page token for future changes. This will be present only if the end of the current changes list has been reached.", + "type": "string" + }, + "nextPageToken": { + "description": "The page token for the next page of changes. This will be absent if the end of the changes list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.", + "type": "string" + } }, - "permissionId": { - "type": "string", - "description": "The ID of the permission.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId", - "permissionId" - ], - "response": { - "$ref": "Permission" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "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" - ] + "type": "object" }, - "list": { - "id": "drive.permissions.list", - "path": "files/{fileId}/permissions", - "httpMethod": "GET", - "description": "Lists a file's permissions.", - "parameters": { - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId" - ], - "response": { - "$ref": "PermissionList" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "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" - ] - }, - "update": { - "id": "drive.permissions.update", - "path": "files/{fileId}/permissions/{permissionId}", - "httpMethod": "PATCH", - "description": "Updates a permission with patch semantics.", - "parameters": { - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - }, - "permissionId": { - "type": "string", - "description": "The ID of the permission.", - "required": true, - "location": "path" - }, - "transferOwnership": { - "type": "boolean", - "description": "Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect.", - "default": "false", - "location": "query" - } - }, - "parameterOrder": [ - "fileId", - "permissionId" - ], - "request": { - "$ref": "Permission" - }, - "response": { - "$ref": "Permission" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file" - ] - } - } - }, - "replies": { - "methods": { - "create": { - "id": "drive.replies.create", - "path": "files/{fileId}/comments/{commentId}/replies", - "httpMethod": "POST", - "description": "Creates a new reply to a comment.", - "parameters": { - "commentId": { - "type": "string", - "description": "The ID of the comment.", - "required": true, - "location": "path" + "Channel": { + "description": "An notification channel used to watch for resource changes.", + "id": "Channel", + "properties": { + "address": { + "description": "The address where notifications are delivered for this channel.", + "type": "string" + }, + "expiration": { + "description": "Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.", + "format": "int64", + "type": "string" + }, + "id": { + "description": "A UUID or similar unique string that identifies this channel.", + "type": "string" + }, + "kind": { + "default": "api#channel", + "description": "Identifies this as a notification channel used to watch for changes to a resource. Value: the fixed string \"api#channel\".", + "type": "string" + }, + "params": { + "additionalProperties": { + "description": "Declares a new parameter by name.", + "type": "string" + }, + "description": "Additional parameters controlling delivery channel behavior. Optional.", + "type": "object" + }, + "payload": { + "description": "A Boolean value to indicate whether payload is wanted. Optional.", + "type": "boolean" + }, + "resourceId": { + "description": "An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.", + "type": "string" + }, + "resourceUri": { + "description": "A version-specific identifier for the watched resource.", + "type": "string" + }, + "token": { + "description": "An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.", + "type": "string" + }, + "type": { + "description": "The type of delivery mechanism used for this channel.", + "type": "string" + } }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId", - "commentId" - ], - "request": { - "$ref": "Reply" - }, - "response": { - "$ref": "Reply" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file" - ] + "type": "object" }, - "delete": { - "id": "drive.replies.delete", - "path": "files/{fileId}/comments/{commentId}/replies/{replyId}", - "httpMethod": "DELETE", - "description": "Deletes a reply.", - "parameters": { - "commentId": { - "type": "string", - "description": "The ID of the comment.", - "required": true, - "location": "path" + "Comment": { + "description": "A comment on a file.", + "id": "Comment", + "properties": { + "anchor": { + "description": "A region of the document represented as a JSON string. See anchor documentation for details on how to define and interpret anchor properties.", + "type": "string" + }, + "author": { + "$ref": "User", + "description": "The user who created the comment." + }, + "content": { + "annotations": { + "required": [ + "drive.comments.create", + "drive.comments.update" + ] + }, + "description": "The plain text content of the comment. This field is used for setting the content, while htmlContent should be displayed.", + "type": "string" + }, + "createdTime": { + "description": "The time at which the comment was created (RFC 3339 date-time).", + "format": "date-time", + "type": "string" + }, + "deleted": { + "description": "Whether the comment has been deleted. A deleted comment has no content.", + "type": "boolean" + }, + "htmlContent": { + "description": "The content of the comment with HTML formatting.", + "type": "string" + }, + "id": { + "description": "The ID of the comment.", + "type": "string" + }, + "kind": { + "default": "drive#comment", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#comment\".", + "type": "string" + }, + "modifiedTime": { + "description": "The last time the comment or any of its replies was modified (RFC 3339 date-time).", + "format": "date-time", + "type": "string" + }, + "quotedFileContent": { + "description": "The file content to which the comment refers, typically within the anchor region. For a text file, for example, this would be the text at the location of the comment.", + "properties": { + "mimeType": { + "description": "The MIME type of the quoted content.", + "type": "string" + }, + "value": { + "description": "The quoted content itself. This is interpreted as plain text if set through the API.", + "type": "string" + } + }, + "type": "object" + }, + "replies": { + "description": "The full list of replies to the comment in chronological order.", + "items": { + "$ref": "Reply" + }, + "type": "array" + }, + "resolved": { + "description": "Whether the comment has been resolved by one of its replies.", + "type": "boolean" + } }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" + "type": "object" + }, + "CommentList": { + "description": "A list of comments on a file.", + "id": "CommentList", + "properties": { + "comments": { + "description": "The list of comments. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.", + "items": { + "$ref": "Comment" + }, + "type": "array" + }, + "kind": { + "default": "drive#commentList", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#commentList\".", + "type": "string" + }, + "nextPageToken": { + "description": "The page token for the next page of comments. This will be absent if the end of the comments list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.", + "type": "string" + } }, - "replyId": { - "type": "string", - "description": "The ID of the reply.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId", - "commentId", - "replyId" - ], - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file" - ] - }, - "get": { - "id": "drive.replies.get", - "path": "files/{fileId}/comments/{commentId}/replies/{replyId}", - "httpMethod": "GET", - "description": "Gets a reply by ID.", - "parameters": { - "commentId": { - "type": "string", - "description": "The ID of the comment.", - "required": true, - "location": "path" + "type": "object" + }, + "File": { + "description": "The metadata for a file.", + "id": "File", + "properties": { + "appProperties": { + "additionalProperties": { + "type": "string" + }, + "description": "A collection of arbitrary key-value pairs which are private to the requesting app.\nEntries with null values are cleared in update and copy requests.", + "type": "object" + }, + "capabilities": { + "description": "Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take.", + "properties": { + "canAddChildren": { + "description": "Whether the current user can add children to this folder. This is always false when the item is not a folder.", + "type": "boolean" + }, + "canChangeCopyRequiresWriterPermission": { + "description": "Whether the current user can change the copyRequiresWriterPermission restriction of this file.", + "type": "boolean" + }, + "canChangeViewersCanCopyContent": { + "description": "Deprecated", + "type": "boolean" + }, + "canComment": { + "description": "Whether the current user can comment on this file.", + "type": "boolean" + }, + "canCopy": { + "description": "Whether the current user can copy this file. For a Team Drive item, whether the current user can copy non-folder descendants of this item, or this item itself if it is not a folder.", + "type": "boolean" + }, + "canDelete": { + "description": "Whether the current user can delete this file.", + "type": "boolean" + }, + "canDeleteChildren": { + "description": "Whether the current user can delete children of this folder. This is false when the item is not a folder. Only populated for Team Drive items.", + "type": "boolean" + }, + "canDownload": { + "description": "Whether the current user can download this file.", + "type": "boolean" + }, + "canEdit": { + "description": "Whether the current user can edit this file.", + "type": "boolean" + }, + "canListChildren": { + "description": "Whether the current user can list the children of this folder. This is always false when the item is not a folder.", + "type": "boolean" + }, + "canMoveChildrenOutOfTeamDrive": { + "description": "Whether the current user can move children of this folder outside of the Team Drive. This is false when the item is not a folder. Only populated for Team Drive items.", + "type": "boolean" + }, + "canMoveChildrenWithinTeamDrive": { + "description": "Whether the current user can move children of this folder within the Team Drive. This is false when the item is not a folder. Only populated for Team Drive items.", + "type": "boolean" + }, + "canMoveItemIntoTeamDrive": { + "description": "Whether the current user can move this item into a Team Drive. If the item is in a Team Drive, this field is equivalent to canMoveTeamDriveItem.", + "type": "boolean" + }, + "canMoveItemOutOfTeamDrive": { + "description": "Whether the current user can move this Team Drive item outside of this Team Drive by changing its parent. Note that a request to change the parent of the item may still fail depending on the new parent that is being added. Only populated for Team Drive items.", + "type": "boolean" + }, + "canMoveItemWithinTeamDrive": { + "description": "Whether the current user can move this Team Drive item within this Team Drive. Note that a request to change the parent of the item may still fail depending on the new parent that is being added. Only populated for Team Drive items.", + "type": "boolean" + }, + "canMoveTeamDriveItem": { + "description": "Deprecated - use canMoveItemWithinTeamDrive or canMoveItemOutOfTeamDrive instead.", + "type": "boolean" + }, + "canReadRevisions": { + "description": "Whether the current user can read the revisions resource of this file. For a Team Drive item, whether revisions of non-folder descendants of this item, or this item itself if it is not a folder, can be read.", + "type": "boolean" + }, + "canReadTeamDrive": { + "description": "Whether the current user can read the Team Drive to which this file belongs. Only populated for Team Drive files.", + "type": "boolean" + }, + "canRemoveChildren": { + "description": "Whether the current user can remove children from this folder. This is always false when the item is not a folder. For Team Drive items, use canDeleteChildren or canTrashChildren instead.", + "type": "boolean" + }, + "canRename": { + "description": "Whether the current user can rename this file.", + "type": "boolean" + }, + "canShare": { + "description": "Whether the current user can modify the sharing settings for this file.", + "type": "boolean" + }, + "canTrash": { + "description": "Whether the current user can move this file to trash.", + "type": "boolean" + }, + "canTrashChildren": { + "description": "Whether the current user can trash children of this folder. This is false when the item is not a folder. Only populated for Team Drive items.", + "type": "boolean" + }, + "canUntrash": { + "description": "Whether the current user can restore this file from trash.", + "type": "boolean" + } + }, + "type": "object" + }, + "contentHints": { + "description": "Additional information about the content of the file. These fields are never populated in responses.", + "properties": { + "indexableText": { + "description": "Text to be indexed for the file to improve fullText queries. This is limited to 128KB in length and may contain HTML elements.", + "type": "string" + }, + "thumbnail": { + "description": "A thumbnail for the file. This will only be used if Drive cannot generate a standard thumbnail.", + "properties": { + "image": { + "description": "The thumbnail data encoded with URL-safe Base64 (RFC 4648 section 5).", + "format": "byte", + "type": "string" + }, + "mimeType": { + "description": "The MIME type of the thumbnail.", + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "copyRequiresWriterPermission": { + "description": "Whether the options to copy, print, or download this file, should be disabled for readers and commenters.", + "type": "boolean" + }, + "createdTime": { + "description": "The time at which the file was created (RFC 3339 date-time).", + "format": "date-time", + "type": "string" + }, + "description": { + "description": "A short description of the file.", + "type": "string" + }, + "explicitlyTrashed": { + "description": "Whether the file has been explicitly trashed, as opposed to recursively trashed from a parent folder.", + "type": "boolean" + }, + "fileExtension": { + "description": "The final component of fullFileExtension. This is only available for files with binary content in Drive.", + "type": "string" + }, + "folderColorRgb": { + "description": "The color for a folder as an RGB hex string. The supported colors are published in the folderColorPalette field of the About resource.\nIf an unsupported color is specified, the closest color in the palette will be used instead.", + "type": "string" + }, + "fullFileExtension": { + "description": "The full file extension extracted from the name field. May contain multiple concatenated extensions, such as \"tar.gz\". This is only available for files with binary content in Drive.\nThis is automatically updated when the name field changes, however it is not cleared if the new name does not contain a valid extension.", + "type": "string" + }, + "hasAugmentedPermissions": { + "description": "Whether any users are granted file access directly on this file. This field is only populated for Team Drive files.", + "type": "boolean" + }, + "hasThumbnail": { + "description": "Whether this file has a thumbnail. This does not indicate whether the requesting app has access to the thumbnail. To check access, look for the presence of the thumbnailLink field.", + "type": "boolean" + }, + "headRevisionId": { + "description": "The ID of the file's head revision. This is currently only available for files with binary content in Drive.", + "type": "string" + }, + "iconLink": { + "description": "A static, unauthenticated link to the file's icon.", + "type": "string" + }, + "id": { + "description": "The ID of the file.", + "type": "string" + }, + "imageMediaMetadata": { + "description": "Additional metadata about image media, if available.", + "properties": { + "aperture": { + "description": "The aperture used to create the photo (f-number).", + "format": "float", + "type": "number" + }, + "cameraMake": { + "description": "The make of the camera used to create the photo.", + "type": "string" + }, + "cameraModel": { + "description": "The model of the camera used to create the photo.", + "type": "string" + }, + "colorSpace": { + "description": "The color space of the photo.", + "type": "string" + }, + "exposureBias": { + "description": "The exposure bias of the photo (APEX value).", + "format": "float", + "type": "number" + }, + "exposureMode": { + "description": "The exposure mode used to create the photo.", + "type": "string" + }, + "exposureTime": { + "description": "The length of the exposure, in seconds.", + "format": "float", + "type": "number" + }, + "flashUsed": { + "description": "Whether a flash was used to create the photo.", + "type": "boolean" + }, + "focalLength": { + "description": "The focal length used to create the photo, in millimeters.", + "format": "float", + "type": "number" + }, + "height": { + "description": "The height of the image in pixels.", + "format": "int32", + "type": "integer" + }, + "isoSpeed": { + "description": "The ISO speed used to create the photo.", + "format": "int32", + "type": "integer" + }, + "lens": { + "description": "The lens used to create the photo.", + "type": "string" + }, + "location": { + "description": "Geographic location information stored in the image.", + "properties": { + "altitude": { + "description": "The altitude stored in the image.", + "format": "double", + "type": "number" + }, + "latitude": { + "description": "The latitude stored in the image.", + "format": "double", + "type": "number" + }, + "longitude": { + "description": "The longitude stored in the image.", + "format": "double", + "type": "number" + } + }, + "type": "object" + }, + "maxApertureValue": { + "description": "The smallest f-number of the lens at the focal length used to create the photo (APEX value).", + "format": "float", + "type": "number" + }, + "meteringMode": { + "description": "The metering mode used to create the photo.", + "type": "string" + }, + "rotation": { + "description": "The rotation in clockwise degrees from the image's original orientation.", + "format": "int32", + "type": "integer" + }, + "sensor": { + "description": "The type of sensor used to create the photo.", + "type": "string" + }, + "subjectDistance": { + "description": "The distance to the subject of the photo, in meters.", + "format": "int32", + "type": "integer" + }, + "time": { + "description": "The date and time the photo was taken (EXIF DateTime).", + "type": "string" + }, + "whiteBalance": { + "description": "The white balance mode used to create the photo.", + "type": "string" + }, + "width": { + "description": "The width of the image in pixels.", + "format": "int32", + "type": "integer" + } + }, + "type": "object" + }, + "isAppAuthorized": { + "description": "Whether the file was created or opened by the requesting app.", + "type": "boolean" + }, + "kind": { + "default": "drive#file", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#file\".", + "type": "string" + }, + "lastModifyingUser": { + "$ref": "User", + "description": "The last user to modify the file." + }, + "md5Checksum": { + "description": "The MD5 checksum for the content of the file. This is only applicable to files with binary content in Drive.", + "type": "string" + }, + "mimeType": { + "description": "The MIME type of the file.\nDrive will attempt to automatically detect an appropriate value from uploaded content if no value is provided. The value cannot be changed unless a new revision is uploaded.\nIf a file is created with a Google Doc MIME type, the uploaded content will be imported if possible. The supported import formats are published in the About resource.", + "type": "string" + }, + "modifiedByMe": { + "description": "Whether the file has been modified by this user.", + "type": "boolean" + }, + "modifiedByMeTime": { + "description": "The last time the file was modified by the user (RFC 3339 date-time).", + "format": "date-time", + "type": "string" + }, + "modifiedTime": { + "description": "The last time the file was modified by anyone (RFC 3339 date-time).\nNote that setting modifiedTime will also update modifiedByMeTime for the user.", + "format": "date-time", + "type": "string" + }, + "name": { + "description": "The name of the file. This is not necessarily unique within a folder. Note that for immutable items such as the top level folders of Team Drives, My Drive root folder, and Application Data folder the name is constant.", + "type": "string" + }, + "originalFilename": { + "description": "The original filename of the uploaded content if available, or else the original value of the name field. This is only available for files with binary content in Drive.", + "type": "string" + }, + "ownedByMe": { + "description": "Whether the user owns the file. Not populated for Team Drive files.", + "type": "boolean" + }, + "owners": { + "description": "The owners of the file. Currently, only certain legacy files may have more than one owner. Not populated for Team Drive files.", + "items": { + "$ref": "User" + }, + "type": "array" + }, + "parents": { + "description": "The IDs of the parent folders which contain the file.\nIf 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.", + "items": { + "type": "string" + }, + "type": "array" + }, + "permissionIds": { + "description": "List of permission IDs for users with access to this file.", + "items": { + "type": "string" + }, + "type": "array" + }, + "permissions": { + "description": "The full list of permissions for the file. This is only available if the requesting user can share the file. Not populated for Team Drive files.", + "items": { + "$ref": "Permission" + }, + "type": "array" + }, + "properties": { + "additionalProperties": { + "type": "string" + }, + "description": "A collection of arbitrary key-value pairs which are visible to all apps.\nEntries with null values are cleared in update and copy requests.", + "type": "object" + }, + "quotaBytesUsed": { + "description": "The number of storage quota bytes used by the file. This includes the head revision as well as previous revisions with keepForever enabled.", + "format": "int64", + "type": "string" + }, + "shared": { + "description": "Whether the file has been shared. Not populated for Team Drive files.", + "type": "boolean" + }, + "sharedWithMeTime": { + "description": "The time at which the file was shared with the user, if applicable (RFC 3339 date-time).", + "format": "date-time", + "type": "string" + }, + "sharingUser": { + "$ref": "User", + "description": "The user who shared the file with the requesting user, if applicable." + }, + "size": { + "description": "The size of the file's content in bytes. This is only applicable to files with binary content in Drive.", + "format": "int64", + "type": "string" + }, + "spaces": { + "description": "The list of spaces which contain the file. The currently supported values are 'drive', 'appDataFolder' and 'photos'.", + "items": { + "type": "string" + }, + "type": "array" + }, + "starred": { + "description": "Whether the user has starred the file.", + "type": "boolean" + }, + "teamDriveId": { + "description": "ID of the Team Drive the file resides in.", + "type": "string" + }, + "thumbnailLink": { + "description": "A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours. Only populated when the requesting app can access the file's content.", + "type": "string" + }, + "thumbnailVersion": { + "description": "The thumbnail version for use in thumbnail cache invalidation.", + "format": "int64", + "type": "string" + }, + "trashed": { + "description": "Whether the file has been trashed, either explicitly or from a trashed parent folder. Only the owner may trash a file, and other users cannot see files in the owner's trash.", + "type": "boolean" + }, + "trashedTime": { + "description": "The time that the item was trashed (RFC 3339 date-time). Only populated for Team Drive files.", + "format": "date-time", + "type": "string" + }, + "trashingUser": { + "$ref": "User", + "description": "If the file has been explicitly trashed, the user who trashed it. Only populated for Team Drive files." + }, + "version": { + "description": "A monotonically increasing version number for the file. This reflects every change made to the file on the server, even those not visible to the user.", + "format": "int64", + "type": "string" + }, + "videoMediaMetadata": { + "description": "Additional metadata about video media. This may not be available immediately upon upload.", + "properties": { + "durationMillis": { + "description": "The duration of the video in milliseconds.", + "format": "int64", + "type": "string" + }, + "height": { + "description": "The height of the video in pixels.", + "format": "int32", + "type": "integer" + }, + "width": { + "description": "The width of the video in pixels.", + "format": "int32", + "type": "integer" + } + }, + "type": "object" + }, + "viewedByMe": { + "description": "Whether the file has been viewed by this user.", + "type": "boolean" + }, + "viewedByMeTime": { + "description": "The last time the file was viewed by the user (RFC 3339 date-time).", + "format": "date-time", + "type": "string" + }, + "viewersCanCopyContent": { + "description": "Deprecated - use copyRequiresWriterPermission instead.", + "type": "boolean" + }, + "webContentLink": { + "description": "A link for downloading the content of the file in a browser. This is only available for files with binary content in Drive.", + "type": "string" + }, + "webViewLink": { + "description": "A link for opening the file in a relevant Google editor or viewer in a browser.", + "type": "string" + }, + "writersCanShare": { + "description": "Whether users with only writer permission can modify the file's permissions. Not populated for Team Drive files.", + "type": "boolean" + } }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" + "type": "object" + }, + "FileList": { + "description": "A list of files.", + "id": "FileList", + "properties": { + "files": { + "description": "The list of files. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.", + "items": { + "$ref": "File" + }, + "type": "array" + }, + "incompleteSearch": { + "description": "Whether the search process was incomplete. If true, then some search results may be missing, since all documents were not searched. This may occur when searching multiple Team Drives with the \"user,allTeamDrives\" corpora, but all corpora could not be searched. When this happens, it is suggested that clients narrow their query by choosing a different corpus such as \"user\" or \"teamDrive\".", + "type": "boolean" + }, + "kind": { + "default": "drive#fileList", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#fileList\".", + "type": "string" + }, + "nextPageToken": { + "description": "The page token for the next page of files. This will be absent if the end of the files list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.", + "type": "string" + } }, - "includeDeleted": { - "type": "boolean", - "description": "Whether to return deleted replies. Deleted replies will not include their original content.", - "default": "false", - "location": "query" + "type": "object" + }, + "GeneratedIds": { + "description": "A list of generated file IDs which can be provided in create requests.", + "id": "GeneratedIds", + "properties": { + "ids": { + "description": "The IDs generated for the requesting user in the specified space.", + "items": { + "type": "string" + }, + "type": "array" + }, + "kind": { + "default": "drive#generatedIds", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#generatedIds\".", + "type": "string" + }, + "space": { + "description": "The type of file that can be created with these IDs.", + "type": "string" + } }, - "replyId": { - "type": "string", - "description": "The ID of the reply.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId", - "commentId", - "replyId" - ], - "response": { - "$ref": "Reply" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file", - "https://www.googleapis.com/auth/drive.readonly" - ] + "type": "object" }, - "list": { - "id": "drive.replies.list", - "path": "files/{fileId}/comments/{commentId}/replies", - "httpMethod": "GET", - "description": "Lists a comment's replies.", - "parameters": { - "commentId": { - "type": "string", - "description": "The ID of the comment.", - "required": true, - "location": "path" - }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" + "Permission": { + "description": "A permission for a file. A permission grants a user, group, domain or the world access to a file or a folder hierarchy.", + "id": "Permission", + "properties": { + "allowFileDiscovery": { + "description": "Whether the permission allows the file to be discovered through search. This is only applicable for permissions of type domain or anyone.", + "type": "boolean" + }, + "deleted": { + "description": "Whether the account associated with this permission has been deleted. This field only pertains to user and group permissions.", + "type": "boolean" + }, + "displayName": { + "description": "A displayable name for users, groups or domains.", + "type": "string" + }, + "domain": { + "description": "The domain to which this permission refers.", + "type": "string" + }, + "emailAddress": { + "description": "The email address of the user or group to which this permission refers.", + "type": "string" + }, + "expirationTime": { + "description": "The time at which this permission will expire (RFC 3339 date-time). Expiration times have the following restrictions: \n- They can only be set on user and group permissions \n- The time must be in the future \n- The time cannot be more than a year in the future", + "format": "date-time", + "type": "string" + }, + "id": { + "description": "The ID of this permission. This is a unique identifier for the grantee, and is published in User resources as permissionId.", + "type": "string" + }, + "kind": { + "default": "drive#permission", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#permission\".", + "type": "string" + }, + "photoLink": { + "description": "A link to the user's profile photo, if available.", + "type": "string" + }, + "role": { + "annotations": { + "required": [ + "drive.permissions.create" + ] + }, + "description": "The role granted by this permission. While new values may be supported in the future, the following are currently allowed: \n- owner \n- organizer \n- fileOrganizer \n- writer \n- commenter \n- reader", + "type": "string" + }, + "teamDrivePermissionDetails": { + "description": "Details of whether the permissions on this Team Drive item are inherited or directly on this item. This is an output-only field which is present only for Team Drive items.", + "items": { + "properties": { + "inherited": { + "description": "Whether this permission is inherited. This field is always populated. This is an output-only field.", + "type": "boolean" + }, + "inheritedFrom": { + "description": "The ID of the item from which this permission is inherited. This is an output-only field and is only populated for members of the Team Drive.", + "type": "string" + }, + "role": { + "description": "The primary role for this user. While new values may be added in the future, the following are currently possible: \n- organizer \n- fileOrganizer \n- writer \n- commenter \n- reader", + "type": "string" + }, + "teamDrivePermissionType": { + "description": "The Team Drive permission type for this user. While new values may be added in future, the following are currently possible: \n- file \n- member", + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + }, + "type": { + "annotations": { + "required": [ + "drive.permissions.create" + ] + }, + "description": "The type of the grantee. Valid values are: \n- user \n- group \n- domain \n- anyone", + "type": "string" + } }, - "includeDeleted": { - "type": "boolean", - "description": "Whether to include deleted replies. Deleted replies will not include their original content.", - "default": "false", - "location": "query" + "type": "object" + }, + "PermissionList": { + "description": "A list of permissions for a file.", + "id": "PermissionList", + "properties": { + "kind": { + "default": "drive#permissionList", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#permissionList\".", + "type": "string" + }, + "nextPageToken": { + "description": "The page token for the next page of permissions. This field will be absent if the end of the permissions list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.", + "type": "string" + }, + "permissions": { + "description": "The list of permissions. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.", + "items": { + "$ref": "Permission" + }, + "type": "array" + } }, - "pageSize": { - "type": "integer", - "description": "The maximum number of replies to return per page.", - "default": "20", - "format": "int32", - "minimum": "1", - "maximum": "100", - "location": "query" + "type": "object" + }, + "Reply": { + "description": "A reply to a comment on a file.", + "id": "Reply", + "properties": { + "action": { + "description": "The action the reply performed to the parent comment. Valid values are: \n- resolve \n- reopen", + "type": "string" + }, + "author": { + "$ref": "User", + "description": "The user who created the reply." + }, + "content": { + "annotations": { + "required": [ + "drive.replies.update" + ] + }, + "description": "The plain text content of the reply. This field is used for setting the content, while htmlContent should be displayed. This is required on creates if no action is specified.", + "type": "string" + }, + "createdTime": { + "description": "The time at which the reply was created (RFC 3339 date-time).", + "format": "date-time", + "type": "string" + }, + "deleted": { + "description": "Whether the reply has been deleted. A deleted reply has no content.", + "type": "boolean" + }, + "htmlContent": { + "description": "The content of the reply with HTML formatting.", + "type": "string" + }, + "id": { + "description": "The ID of the reply.", + "type": "string" + }, + "kind": { + "default": "drive#reply", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#reply\".", + "type": "string" + }, + "modifiedTime": { + "description": "The last time the reply was modified (RFC 3339 date-time).", + "format": "date-time", + "type": "string" + } }, - "pageToken": { - "type": "string", - "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.", - "location": "query" - } - }, - "parameterOrder": [ - "fileId", - "commentId" - ], - "response": { - "$ref": "ReplyList" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file", - "https://www.googleapis.com/auth/drive.readonly" - ] + "type": "object" }, - "update": { - "id": "drive.replies.update", - "path": "files/{fileId}/comments/{commentId}/replies/{replyId}", - "httpMethod": "PATCH", - "description": "Updates a reply with patch semantics.", - "parameters": { - "commentId": { - "type": "string", - "description": "The ID of the comment.", - "required": true, - "location": "path" + "ReplyList": { + "description": "A list of replies to a comment on a file.", + "id": "ReplyList", + "properties": { + "kind": { + "default": "drive#replyList", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#replyList\".", + "type": "string" + }, + "nextPageToken": { + "description": "The page token for the next page of replies. This will be absent if the end of the replies list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.", + "type": "string" + }, + "replies": { + "description": "The list of replies. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.", + "items": { + "$ref": "Reply" + }, + "type": "array" + } }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" + "type": "object" + }, + "Revision": { + "description": "The metadata for a revision to a file.", + "id": "Revision", + "properties": { + "id": { + "description": "The ID of the revision.", + "type": "string" + }, + "keepForever": { + "description": "Whether to keep this revision forever, even if it is no longer the head revision. If not set, the revision will be automatically purged 30 days after newer content is uploaded. This can be set on a maximum of 200 revisions for a file.\nThis field is only applicable to files with binary content in Drive.", + "type": "boolean" + }, + "kind": { + "default": "drive#revision", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#revision\".", + "type": "string" + }, + "lastModifyingUser": { + "$ref": "User", + "description": "The last user to modify this revision." + }, + "md5Checksum": { + "description": "The MD5 checksum of the revision's content. This is only applicable to files with binary content in Drive.", + "type": "string" + }, + "mimeType": { + "description": "The MIME type of the revision.", + "type": "string" + }, + "modifiedTime": { + "description": "The last time the revision was modified (RFC 3339 date-time).", + "format": "date-time", + "type": "string" + }, + "originalFilename": { + "description": "The original filename used to create this revision. This is only applicable to files with binary content in Drive.", + "type": "string" + }, + "publishAuto": { + "description": "Whether subsequent revisions will be automatically republished. This is only applicable to Google Docs.", + "type": "boolean" + }, + "published": { + "description": "Whether this revision is published. This is only applicable to Google Docs.", + "type": "boolean" + }, + "publishedOutsideDomain": { + "description": "Whether this revision is published outside the domain. This is only applicable to Google Docs.", + "type": "boolean" + }, + "size": { + "description": "The size of the revision's content in bytes. This is only applicable to files with binary content in Drive.", + "format": "int64", + "type": "string" + } }, - "replyId": { - "type": "string", - "description": "The ID of the reply.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId", - "commentId", - "replyId" - ], - "request": { - "$ref": "Reply" - }, - "response": { - "$ref": "Reply" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file" - ] - } - } - }, - "revisions": { - "methods": { - "delete": { - "id": "drive.revisions.delete", - "path": "files/{fileId}/revisions/{revisionId}", - "httpMethod": "DELETE", - "description": "Permanently deletes a revision. This method is only applicable to files with binary content in Drive.", - "parameters": { - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" + "type": "object" + }, + "RevisionList": { + "description": "A list of revisions of a file.", + "id": "RevisionList", + "properties": { + "kind": { + "default": "drive#revisionList", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#revisionList\".", + "type": "string" + }, + "nextPageToken": { + "description": "The page token for the next page of revisions. This will be absent if the end of the revisions list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.", + "type": "string" + }, + "revisions": { + "description": "The list of revisions. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.", + "items": { + "$ref": "Revision" + }, + "type": "array" + } }, - "revisionId": { - "type": "string", - "description": "The ID of the revision.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId", - "revisionId" - ], - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "https://www.googleapis.com/auth/drive.file" - ] + "type": "object" }, - "get": { - "id": "drive.revisions.get", - "path": "files/{fileId}/revisions/{revisionId}", - "httpMethod": "GET", - "description": "Gets a revision's metadata or content by ID.", - "parameters": { - "acknowledgeAbuse": { - "type": "boolean", - "description": "Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.", - "default": "false", - "location": "query" + "StartPageToken": { + "id": "StartPageToken", + "properties": { + "kind": { + "default": "drive#startPageToken", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#startPageToken\".", + "type": "string" + }, + "startPageToken": { + "description": "The starting page token for listing changes.", + "type": "string" + } }, - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" + "type": "object" + }, + "TeamDrive": { + "description": "Representation of a Team Drive.", + "id": "TeamDrive", + "properties": { + "backgroundImageFile": { + "description": "An image file and cropping parameters from which a background image for this Team Drive is set. This is a write only field; it can only be set on drive.teamdrives.update requests that don't set themeId. When specified, all fields of the backgroundImageFile must be set.", + "properties": { + "id": { + "description": "The ID of an image file in Drive to use for the background image.", + "type": "string" + }, + "width": { + "description": "The width of the cropped image in the closed range of 0 to 1. This value represents the width of the cropped image divided by the width of the entire image. The height is computed by applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280 pixels wide and 144 pixels high.", + "format": "float", + "type": "number" + }, + "xCoordinate": { + "description": "The X coordinate of the upper left corner of the cropping area in the background image. This is a value in the closed range of 0 to 1. This value represents the horizontal distance from the left side of the entire image to the left side of the cropping area divided by the width of the entire image.", + "format": "float", + "type": "number" + }, + "yCoordinate": { + "description": "The Y coordinate of the upper left corner of the cropping area in the background image. This is a value in the closed range of 0 to 1. This value represents the vertical distance from the top side of the entire image to the top side of the cropping area divided by the height of the entire image.", + "format": "float", + "type": "number" + } + }, + "type": "object" + }, + "backgroundImageLink": { + "description": "A short-lived link to this Team Drive's background image.", + "type": "string" + }, + "capabilities": { + "description": "Capabilities the current user has on this Team Drive.", + "properties": { + "canAddChildren": { + "description": "Whether the current user can add children to folders in this Team Drive.", + "type": "boolean" + }, + "canChangeCopyRequiresWriterPermissionRestriction": { + "description": "Whether the current user can change the copyRequiresWriterPermission restriction of this Team Drive.", + "type": "boolean" + }, + "canChangeDomainUsersOnlyRestriction": { + "description": "Whether the current user can change the domainUsersOnly restriction of this Team Drive.", + "type": "boolean" + }, + "canChangeTeamDriveBackground": { + "description": "Whether the current user can change the background of this Team Drive.", + "type": "boolean" + }, + "canChangeTeamMembersOnlyRestriction": { + "description": "Whether the current user can change the teamMembersOnly restriction of this Team Drive.", + "type": "boolean" + }, + "canComment": { + "description": "Whether the current user can comment on files in this Team Drive.", + "type": "boolean" + }, + "canCopy": { + "description": "Whether the current user can copy files in this Team Drive.", + "type": "boolean" + }, + "canDeleteChildren": { + "description": "Whether the current user can delete children from folders in this Team Drive.", + "type": "boolean" + }, + "canDeleteTeamDrive": { + "description": "Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may still fail if there are untrashed items inside the Team Drive.", + "type": "boolean" + }, + "canDownload": { + "description": "Whether the current user can download files in this Team Drive.", + "type": "boolean" + }, + "canEdit": { + "description": "Whether the current user can edit files in this Team Drive", + "type": "boolean" + }, + "canListChildren": { + "description": "Whether the current user can list the children of folders in this Team Drive.", + "type": "boolean" + }, + "canManageMembers": { + "description": "Whether the current user can add members to this Team Drive or remove them or change their role.", + "type": "boolean" + }, + "canReadRevisions": { + "description": "Whether the current user can read the revisions resource of files in this Team Drive.", + "type": "boolean" + }, + "canRemoveChildren": { + "description": "Deprecated - use canDeleteChildren or canTrashChildren instead.", + "type": "boolean" + }, + "canRename": { + "description": "Whether the current user can rename files or folders in this Team Drive.", + "type": "boolean" + }, + "canRenameTeamDrive": { + "description": "Whether the current user can rename this Team Drive.", + "type": "boolean" + }, + "canShare": { + "description": "Whether the current user can share files or folders in this Team Drive.", + "type": "boolean" + }, + "canTrashChildren": { + "description": "Whether the current user can trash children from folders in this Team Drive.", + "type": "boolean" + } + }, + "type": "object" + }, + "colorRgb": { + "description": "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.", + "type": "string" + }, + "createdTime": { + "description": "The time at which the Team Drive was created (RFC 3339 date-time).", + "format": "date-time", + "type": "string" + }, + "id": { + "description": "The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.", + "type": "string" + }, + "kind": { + "default": "drive#teamDrive", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#teamDrive\".", + "type": "string" + }, + "name": { + "description": "The name of this Team Drive.", + "type": "string" + }, + "restrictions": { + "description": "A set of restrictions that apply to this Team Drive or items inside this Team Drive.", + "properties": { + "adminManagedRestrictions": { + "description": "Whether administrative privileges on this Team Drive are required to modify restrictions.", + "type": "boolean" + }, + "copyRequiresWriterPermission": { + "description": "Whether the options to copy, print, or download files inside this Team Drive, should be disabled for readers and commenters. When this restriction is set to true, it will override the similarly named field to true for any file inside this Team Drive.", + "type": "boolean" + }, + "domainUsersOnly": { + "description": "Whether access to this Team Drive and items inside this Team Drive is restricted to users of the domain to which this Team Drive belongs. This restriction may be overridden by other sharing policies controlled outside of this Team Drive.", + "type": "boolean" + }, + "teamMembersOnly": { + "description": "Whether access to items inside this Team Drive is restricted to members of this Team Drive.", + "type": "boolean" + } + }, + "type": "object" + }, + "themeId": { + "description": "The ID of the theme from which the background image and color will be set. The set of possible teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a drive.teamdrives.create request, a random theme is chosen from which the background image and color are set. This is a write-only field; it can only be set on requests that don't set colorRgb or backgroundImageFile.", + "type": "string" + } }, - "revisionId": { - "type": "string", - "description": "The ID of the revision.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId", - "revisionId" - ], - "response": { - "$ref": "Revision" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "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" - ], - "supportsMediaDownload": true, - "useMediaDownloadService": true + "type": "object" }, - "list": { - "id": "drive.revisions.list", - "path": "files/{fileId}/revisions", - "httpMethod": "GET", - "description": "Lists a file's revisions.", - "parameters": { - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId" - ], - "response": { - "$ref": "RevisionList" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "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" - ] + "TeamDriveList": { + "description": "A list of Team Drives.", + "id": "TeamDriveList", + "properties": { + "kind": { + "default": "drive#teamDriveList", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#teamDriveList\".", + "type": "string" + }, + "nextPageToken": { + "description": "The page token for the next page of Team Drives. This will be absent if the end of the Team Drives list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.", + "type": "string" + }, + "teamDrives": { + "description": "The list of Team Drives. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.", + "items": { + "$ref": "TeamDrive" + }, + "type": "array" + } + }, + "type": "object" }, - "update": { - "id": "drive.revisions.update", - "path": "files/{fileId}/revisions/{revisionId}", - "httpMethod": "PATCH", - "description": "Updates a revision with patch semantics.", - "parameters": { - "fileId": { - "type": "string", - "description": "The ID of the file.", - "required": true, - "location": "path" + "User": { + "description": "Information about a Drive user.", + "id": "User", + "properties": { + "displayName": { + "description": "A plain text displayable name for this user.", + "type": "string" + }, + "emailAddress": { + "description": "The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester.", + "type": "string" + }, + "kind": { + "default": "drive#user", + "description": "Identifies what kind of resource this is. Value: the fixed string \"drive#user\".", + "type": "string" + }, + "me": { + "description": "Whether this user is the requesting user.", + "type": "boolean" + }, + "permissionId": { + "description": "The user's ID as visible in Permission resources.", + "type": "string" + }, + "photoLink": { + "description": "A link to the user's profile photo, if available.", + "type": "string" + } }, - "revisionId": { - "type": "string", - "description": "The ID of the revision.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "fileId", - "revisionId" - ], - "request": { - "$ref": "Revision" - }, - "response": { - "$ref": "Revision" - }, - "scopes": [ - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.appdata", - "https://www.googleapis.com/auth/drive.file" - ] + "type": "object" } - } - } - } -} + }, + "servicePath": "drive/v3/", + "title": "Drive API", + "version": "v3" +} \ No newline at end of file diff --git a/vendor/google.golang.org/api/drive/v3/drive-gen.go b/vendor/google.golang.org/api/drive/v3/drive-gen.go index 9e6e0874..2403ce8e 100644 --- a/vendor/google.golang.org/api/drive/v3/drive-gen.go +++ b/vendor/google.golang.org/api/drive/v3/drive-gen.go @@ -14,15 +14,16 @@ import ( "encoding/json" "errors" "fmt" - context "golang.org/x/net/context" - ctxhttp "golang.org/x/net/context/ctxhttp" - gensupport "google.golang.org/api/gensupport" - googleapi "google.golang.org/api/googleapi" "io" "net/http" "net/url" "strconv" "strings" + + context "golang.org/x/net/context" + ctxhttp "golang.org/x/net/context/ctxhttp" + gensupport "google.golang.org/api/gensupport" + googleapi "google.golang.org/api/googleapi" ) // Always reference these packages, just in case the auto-generated code @@ -86,6 +87,7 @@ func New(client *http.Client) (*Service, error) { s.Permissions = NewPermissionsService(s) s.Replies = NewRepliesService(s) s.Revisions = NewRevisionsService(s) + s.Teamdrives = NewTeamdrivesService(s) return s, nil } @@ -109,6 +111,8 @@ type Service struct { Replies *RepliesService Revisions *RevisionsService + + Teamdrives *TeamdrivesService } func (s *Service) userAgent() string { @@ -190,12 +194,24 @@ type RevisionsService struct { s *Service } +func NewTeamdrivesService(s *Service) *TeamdrivesService { + rs := &TeamdrivesService{s: s} + return rs +} + +type TeamdrivesService struct { + s *Service +} + // About: Information about the user, the user's Drive, and system // capabilities. type About struct { // AppInstalled: Whether the user has installed the requesting app. AppInstalled bool `json:"appInstalled,omitempty"` + // CanCreateTeamDrives: Whether the user can create Team Drives. + CanCreateTeamDrives bool `json:"canCreateTeamDrives,omitempty"` + // ExportFormats: A map of source MIME type to possible targets for all // supported exports. ExportFormats map[string][]string `json:"exportFormats,omitempty"` @@ -208,7 +224,8 @@ type About struct { // supported imports. ImportFormats map[string][]string `json:"importFormats,omitempty"` - // Kind: This is always drive#about. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#about". Kind string `json:"kind,omitempty"` // MaxImportSizes: A map of maximum import sizes by MIME type, in bytes. @@ -221,6 +238,9 @@ type About struct { // are measured in bytes. StorageQuota *AboutStorageQuota `json:"storageQuota,omitempty"` + // TeamDriveThemes: A list of themes that are supported for Team Drives. + TeamDriveThemes []*AboutTeamDriveThemes `json:"teamDriveThemes,omitempty"` + // User: The authenticated user. User *User `json:"user,omitempty"` @@ -235,12 +255,20 @@ type About struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "AppInstalled") to include + // in API requests with the JSON null value. By default, fields with + // empty values are omitted from API requests. However, any field with + // an empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *About) MarshalJSON() ([]byte, error) { - type noMethod About - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod About + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // AboutStorageQuota: The user's storage quota limits and usage. All @@ -266,33 +294,88 @@ type AboutStorageQuota struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Limit") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *AboutStorageQuota) MarshalJSON() ([]byte, error) { - type noMethod AboutStorageQuota - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod AboutStorageQuota + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) +} + +type AboutTeamDriveThemes struct { + // BackgroundImageLink: A link to this Team Drive theme's background + // image. + BackgroundImageLink string `json:"backgroundImageLink,omitempty"` + + // ColorRgb: The color of this Team Drive theme as an RGB hex string. + ColorRgb string `json:"colorRgb,omitempty"` + + // Id: The ID of the theme. + Id string `json:"id,omitempty"` + + // ForceSendFields is a list of field names (e.g. "BackgroundImageLink") + // to unconditionally include in API requests. By default, fields with + // empty values are omitted from API requests. However, any non-pointer, + // non-interface field appearing in ForceSendFields will be sent to the + // server regardless of whether the field is empty or not. This may be + // used to include empty fields in Patch requests. + ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "BackgroundImageLink") to + // include in API requests with the JSON null value. By default, fields + // with empty values are omitted from API requests. However, any field + // with an empty value appearing in NullFields will be sent to the + // server as null. It is an error if a field in this list has a + // non-empty value. This may be used to include null fields in Patch + // requests. + NullFields []string `json:"-"` +} + +func (s *AboutTeamDriveThemes) MarshalJSON() ([]byte, error) { + type NoMethod AboutTeamDriveThemes + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } -// Change: A change to a file. +// Change: A change to a file or Team Drive. type Change struct { - // File: The updated state of the file. Present if the file has not been - // removed. + // File: The updated state of the file. Present if the type is file and + // the file has not been removed from this list of changes. File *File `json:"file,omitempty"` // FileId: The ID of the file which has changed. FileId string `json:"fileId,omitempty"` - // Kind: This is always drive#change. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#change". Kind string `json:"kind,omitempty"` - // Removed: Whether the file has been removed from the view of the - // changes list, for example by deletion or lost access. + // Removed: Whether the file or Team Drive has been removed from this + // list of changes, for example by deletion or loss of access. Removed bool `json:"removed,omitempty"` + // TeamDrive: The updated state of the Team Drive. Present if the type + // is teamDrive, the user is still a member of the Team Drive, and the + // Team Drive has not been removed. + TeamDrive *TeamDrive `json:"teamDrive,omitempty"` + + // TeamDriveId: The ID of the Team Drive associated with this change. + TeamDriveId string `json:"teamDriveId,omitempty"` + // Time: The time of this change (RFC 3339 date-time). Time string `json:"time,omitempty"` + // Type: The type of the change. Possible values are file and teamDrive. + Type string `json:"type,omitempty"` + // ForceSendFields is a list of field names (e.g. "File") to // unconditionally include in API requests. By default, fields with // empty values are omitted from API requests. However, any non-pointer, @@ -300,20 +383,31 @@ type Change struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "File") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *Change) MarshalJSON() ([]byte, error) { - type noMethod Change - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod Change + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // ChangeList: A list of changes for a user. type ChangeList struct { - // Changes: The page of changes. + // Changes: The list of changes. If nextPageToken is populated, then + // this list may be incomplete and an additional page of results should + // be fetched. Changes []*Change `json:"changes,omitempty"` - // Kind: This is always drive#changeList. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#changeList". Kind string `json:"kind,omitempty"` // NewStartPageToken: The starting page token for future changes. This @@ -322,7 +416,9 @@ type ChangeList struct { NewStartPageToken string `json:"newStartPageToken,omitempty"` // NextPageToken: The page token for the next page of changes. This will - // be absent if the end of the current changes list has been reached. + // be absent if the end of the changes list has been reached. If the + // token is rejected for any reason, it should be discarded, and + // pagination should be restarted from the first page of results. NextPageToken string `json:"nextPageToken,omitempty"` // ServerResponse contains the HTTP response code and headers from the @@ -336,12 +432,20 @@ type ChangeList struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Changes") to include in + // API requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *ChangeList) MarshalJSON() ([]byte, error) { - type noMethod ChangeList - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod ChangeList + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // Channel: An notification channel used to watch for resource changes. @@ -394,12 +498,20 @@ type Channel struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Address") to include in + // API requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *Channel) MarshalJSON() ([]byte, error) { - type noMethod Channel - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod Channel + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // Comment: A comment on a file. @@ -430,7 +542,8 @@ type Comment struct { // Id: The ID of the comment. Id string `json:"id,omitempty"` - // Kind: This is always drive#comment. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#comment". Kind string `json:"kind,omitempty"` // ModifiedTime: The last time the comment or any of its replies was @@ -461,12 +574,20 @@ type Comment struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Anchor") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *Comment) MarshalJSON() ([]byte, error) { - type noMethod Comment - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod Comment + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // CommentQuotedFileContent: The file content to which the comment @@ -487,24 +608,37 @@ type CommentQuotedFileContent struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "MimeType") to include in + // API requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *CommentQuotedFileContent) MarshalJSON() ([]byte, error) { - type noMethod CommentQuotedFileContent - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod CommentQuotedFileContent + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // CommentList: A list of comments on a file. type CommentList struct { - // Comments: The page of comments. + // Comments: The list of comments. If nextPageToken is populated, then + // this list may be incomplete and an additional page of results should + // be fetched. Comments []*Comment `json:"comments,omitempty"` - // Kind: This is always drive#commentList. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#commentList". Kind string `json:"kind,omitempty"` // NextPageToken: The page token for the next page of comments. This - // will be absent if the end of the comments list has been reached. + // will be absent if the end of the comments list has been reached. If + // the token is rejected for any reason, it should be discarded, and + // pagination should be restarted from the first page of results. NextPageToken string `json:"nextPageToken,omitempty"` // ServerResponse contains the HTTP response code and headers from the @@ -518,12 +652,20 @@ type CommentList struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Comments") to include in + // API requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *CommentList) MarshalJSON() ([]byte, error) { - type noMethod CommentList - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod CommentList + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // File: The metadata for a file. @@ -533,13 +675,18 @@ type File struct { // Entries with null values are cleared in update and copy requests. AppProperties map[string]string `json:"appProperties,omitempty"` - // Capabilities: Capabilities the current user has on the file. + // Capabilities: Capabilities the current user has on this file. Each + // capability corresponds to a fine-grained action that a user may take. Capabilities *FileCapabilities `json:"capabilities,omitempty"` // ContentHints: Additional information about the content of the file. // These fields are never populated in responses. ContentHints *FileContentHints `json:"contentHints,omitempty"` + // CopyRequiresWriterPermission: Whether the options to copy, print, or + // download this file, should be disabled for readers and commenters. + CopyRequiresWriterPermission bool `json:"copyRequiresWriterPermission,omitempty"` + // CreatedTime: The time at which the file was created (RFC 3339 // date-time). CreatedTime string `json:"createdTime,omitempty"` @@ -570,6 +717,16 @@ type File struct { // is not cleared if the new name does not contain a valid extension. FullFileExtension string `json:"fullFileExtension,omitempty"` + // HasAugmentedPermissions: Whether any users are granted file access + // directly on this file. This field is only populated for Team Drive + // files. + HasAugmentedPermissions bool `json:"hasAugmentedPermissions,omitempty"` + + // HasThumbnail: Whether this file has a thumbnail. This does not + // indicate whether the requesting app has access to the thumbnail. To + // check access, look for the presence of the thumbnailLink field. + HasThumbnail bool `json:"hasThumbnail,omitempty"` + // HeadRevisionId: The ID of the file's head revision. This is currently // only available for files with binary content in Drive. HeadRevisionId string `json:"headRevisionId,omitempty"` @@ -584,7 +741,12 @@ type File struct { // available. ImageMediaMetadata *FileImageMediaMetadata `json:"imageMediaMetadata,omitempty"` - // Kind: This is always drive#file. + // IsAppAuthorized: Whether the file was created or opened by the + // requesting app. + IsAppAuthorized bool `json:"isAppAuthorized,omitempty"` + + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#file". Kind string `json:"kind,omitempty"` // LastModifyingUser: The last user to modify the file. @@ -603,6 +765,9 @@ type File struct { // are published in the About resource. MimeType string `json:"mimeType,omitempty"` + // ModifiedByMe: Whether the file has been modified by this user. + ModifiedByMe bool `json:"modifiedByMe,omitempty"` + // ModifiedByMeTime: The last time the file was modified by the user // (RFC 3339 date-time). ModifiedByMeTime string `json:"modifiedByMeTime,omitempty"` @@ -614,7 +779,9 @@ type File struct { ModifiedTime string `json:"modifiedTime,omitempty"` // Name: The name of the file. This is not necessarily unique within a - // folder. + // folder. Note that for immutable items such as the top level folders + // of Team Drives, My Drive root folder, and Application Data folder the + // name is constant. Name string `json:"name,omitempty"` // OriginalFilename: The original filename of the uploaded content if @@ -622,21 +789,29 @@ type File struct { // available for files with binary content in Drive. OriginalFilename string `json:"originalFilename,omitempty"` - // OwnedByMe: Whether the user owns the file. + // OwnedByMe: Whether the user owns the file. Not populated for Team + // Drive files. OwnedByMe bool `json:"ownedByMe,omitempty"` // Owners: The owners of the file. Currently, only certain legacy files - // may have more than one owner. + // may have more than one owner. Not populated for Team Drive files. Owners []*User `json:"owners,omitempty"` // Parents: 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. + // 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 `json:"parents,omitempty"` + // PermissionIds: List of permission IDs for users with access to this + // file. + PermissionIds []string `json:"permissionIds,omitempty"` + // Permissions: The full list of permissions for the file. This is only - // available if the requesting user can share the file. + // available if the requesting user can share the file. Not populated + // for Team Drive files. Permissions []*Permission `json:"permissions,omitempty"` // Properties: A collection of arbitrary key-value pairs which are @@ -649,7 +824,8 @@ type File struct { // keepForever enabled. QuotaBytesUsed int64 `json:"quotaBytesUsed,omitempty,string"` - // Shared: Whether the file has been shared. + // Shared: Whether the file has been shared. Not populated for Team + // Drive files. Shared bool `json:"shared,omitempty"` // SharedWithMeTime: The time at which the file was shared with the @@ -671,15 +847,31 @@ type File struct { // Starred: Whether the user has starred the file. Starred bool `json:"starred,omitempty"` + // TeamDriveId: ID of the Team Drive the file resides in. + TeamDriveId string `json:"teamDriveId,omitempty"` + // ThumbnailLink: A short-lived link to the file's thumbnail, if - // available. Typically lasts on the order of hours. + // available. Typically lasts on the order of hours. Only populated when + // the requesting app can access the file's content. ThumbnailLink string `json:"thumbnailLink,omitempty"` + // ThumbnailVersion: The thumbnail version for use in thumbnail cache + // invalidation. + ThumbnailVersion int64 `json:"thumbnailVersion,omitempty,string"` + // Trashed: Whether the file has been trashed, either explicitly or from // a trashed parent folder. Only the owner may trash a file, and other // users cannot see files in the owner's trash. Trashed bool `json:"trashed,omitempty"` + // TrashedTime: The time that the item was trashed (RFC 3339 date-time). + // Only populated for Team Drive files. + TrashedTime string `json:"trashedTime,omitempty"` + + // TrashingUser: If the file has been explicitly trashed, the user who + // trashed it. Only populated for Team Drive files. + TrashingUser *User `json:"trashingUser,omitempty"` + // Version: A monotonically increasing version number for the file. This // reflects every change made to the file on the server, even those not // visible to the user. @@ -696,9 +888,8 @@ type File struct { // 3339 date-time). ViewedByMeTime string `json:"viewedByMeTime,omitempty"` - // ViewersCanCopyContent: Whether users with only reader or commenter - // permission can copy the file's content. This affects copy, download, - // and print operations. + // ViewersCanCopyContent: Deprecated - use copyRequiresWriterPermission + // instead. ViewersCanCopyContent bool `json:"viewersCanCopyContent,omitempty"` // WebContentLink: A link for downloading the content of the file in a @@ -711,7 +902,7 @@ type File struct { WebViewLink string `json:"webViewLink,omitempty"` // WritersCanShare: Whether users with only writer permission can modify - // the file's permissions. + // the file's permissions. Not populated for Team Drive files. WritersCanShare bool `json:"writersCanShare,omitempty"` // ServerResponse contains the HTTP response code and headers from the @@ -725,46 +916,151 @@ type File struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "AppProperties") to include + // in API requests with the JSON null value. By default, fields with + // empty values are omitted from API requests. However, any field with + // an empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *File) MarshalJSON() ([]byte, error) { - type noMethod File - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod File + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } -// FileCapabilities: Capabilities the current user has on the file. +// FileCapabilities: Capabilities the current user has on this file. +// Each capability corresponds to a fine-grained action that a user may +// take. type FileCapabilities struct { - // CanComment: Whether the user can comment on the file. + // CanAddChildren: Whether the current user can add children to this + // folder. This is always false when the item is not a folder. + CanAddChildren bool `json:"canAddChildren,omitempty"` + + // CanChangeCopyRequiresWriterPermission: Whether the current user can + // change the copyRequiresWriterPermission restriction of this file. + CanChangeCopyRequiresWriterPermission bool `json:"canChangeCopyRequiresWriterPermission,omitempty"` + + // CanChangeViewersCanCopyContent: Deprecated + CanChangeViewersCanCopyContent bool `json:"canChangeViewersCanCopyContent,omitempty"` + + // CanComment: Whether the current user can comment on this file. CanComment bool `json:"canComment,omitempty"` - // CanCopy: Whether the user can copy the file. + // CanCopy: Whether the current user can copy this file. For a Team + // Drive item, whether the current user can copy non-folder descendants + // of this item, or this item itself if it is not a folder. CanCopy bool `json:"canCopy,omitempty"` - // CanEdit: Whether the user can edit the file's content. + // CanDelete: Whether the current user can delete this file. + CanDelete bool `json:"canDelete,omitempty"` + + // CanDeleteChildren: Whether the current user can delete children of + // this folder. This is false when the item is not a folder. Only + // populated for Team Drive items. + CanDeleteChildren bool `json:"canDeleteChildren,omitempty"` + + // CanDownload: Whether the current user can download this file. + CanDownload bool `json:"canDownload,omitempty"` + + // CanEdit: Whether the current user can edit this file. CanEdit bool `json:"canEdit,omitempty"` - // CanReadRevisions: Whether the current user has read access to the - // Revisions resource of the file. + // CanListChildren: Whether the current user can list the children of + // this folder. This is always false when the item is not a folder. + CanListChildren bool `json:"canListChildren,omitempty"` + + // CanMoveChildrenOutOfTeamDrive: Whether the current user can move + // children of this folder outside of the Team Drive. This is false when + // the item is not a folder. Only populated for Team Drive items. + CanMoveChildrenOutOfTeamDrive bool `json:"canMoveChildrenOutOfTeamDrive,omitempty"` + + // CanMoveChildrenWithinTeamDrive: Whether the current user can move + // children of this folder within the Team Drive. This is false when the + // item is not a folder. Only populated for Team Drive items. + CanMoveChildrenWithinTeamDrive bool `json:"canMoveChildrenWithinTeamDrive,omitempty"` + + // CanMoveItemIntoTeamDrive: Whether the current user can move this item + // into a Team Drive. If the item is in a Team Drive, this field is + // equivalent to canMoveTeamDriveItem. + CanMoveItemIntoTeamDrive bool `json:"canMoveItemIntoTeamDrive,omitempty"` + + // CanMoveItemOutOfTeamDrive: Whether the current user can move this + // Team Drive item outside of this Team Drive by changing its parent. + // Note that a request to change the parent of the item may still fail + // depending on the new parent that is being added. Only populated for + // Team Drive items. + CanMoveItemOutOfTeamDrive bool `json:"canMoveItemOutOfTeamDrive,omitempty"` + + // CanMoveItemWithinTeamDrive: Whether the current user can move this + // Team Drive item within this Team Drive. Note that a request to change + // the parent of the item may still fail depending on the new parent + // that is being added. Only populated for Team Drive items. + CanMoveItemWithinTeamDrive bool `json:"canMoveItemWithinTeamDrive,omitempty"` + + // CanMoveTeamDriveItem: Deprecated - use canMoveItemWithinTeamDrive or + // canMoveItemOutOfTeamDrive instead. + CanMoveTeamDriveItem bool `json:"canMoveTeamDriveItem,omitempty"` + + // CanReadRevisions: Whether the current user can read the revisions + // resource of this file. For a Team Drive item, whether revisions of + // non-folder descendants of this item, or this item itself if it is not + // a folder, can be read. CanReadRevisions bool `json:"canReadRevisions,omitempty"` - // CanShare: Whether the user can modify the file's permissions and - // sharing settings. + // CanReadTeamDrive: Whether the current user can read the Team Drive to + // which this file belongs. Only populated for Team Drive files. + CanReadTeamDrive bool `json:"canReadTeamDrive,omitempty"` + + // CanRemoveChildren: Whether the current user can remove children from + // this folder. This is always false when the item is not a folder. For + // Team Drive items, use canDeleteChildren or canTrashChildren instead. + CanRemoveChildren bool `json:"canRemoveChildren,omitempty"` + + // CanRename: Whether the current user can rename this file. + CanRename bool `json:"canRename,omitempty"` + + // CanShare: Whether the current user can modify the sharing settings + // for this file. CanShare bool `json:"canShare,omitempty"` - // ForceSendFields is a list of field names (e.g. "CanComment") to + // CanTrash: Whether the current user can move this file to trash. + CanTrash bool `json:"canTrash,omitempty"` + + // CanTrashChildren: Whether the current user can trash children of this + // folder. This is false when the item is not a folder. Only populated + // for Team Drive items. + CanTrashChildren bool `json:"canTrashChildren,omitempty"` + + // CanUntrash: Whether the current user can restore this file from + // trash. + CanUntrash bool `json:"canUntrash,omitempty"` + + // ForceSendFields is a list of field names (e.g. "CanAddChildren") to // unconditionally include in API requests. By default, fields with // empty values are omitted from API requests. However, any non-pointer, // non-interface field appearing in ForceSendFields will be sent to the // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "CanAddChildren") to + // include in API requests with the JSON null value. By default, fields + // with empty values are omitted from API requests. However, any field + // with an empty value appearing in NullFields will be sent to the + // server as null. It is an error if a field in this list has a + // non-empty value. This may be used to include null fields in Patch + // requests. + NullFields []string `json:"-"` } func (s *FileCapabilities) MarshalJSON() ([]byte, error) { - type noMethod FileCapabilities - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod FileCapabilities + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // FileContentHints: Additional information about the content of the @@ -786,12 +1082,20 @@ type FileContentHints struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "IndexableText") to include + // in API requests with the JSON null value. By default, fields with + // empty values are omitted from API requests. However, any field with + // an empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *FileContentHints) MarshalJSON() ([]byte, error) { - type noMethod FileContentHints - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod FileContentHints + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // FileContentHintsThumbnail: A thumbnail for the file. This will only @@ -811,12 +1115,20 @@ type FileContentHintsThumbnail struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Image") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *FileContentHintsThumbnail) MarshalJSON() ([]byte, error) { - type noMethod FileContentHintsThumbnail - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod FileContentHintsThumbnail + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // FileImageMediaMetadata: Additional metadata about image media, if @@ -895,12 +1207,42 @@ type FileImageMediaMetadata struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Aperture") to include in + // API requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *FileImageMediaMetadata) MarshalJSON() ([]byte, error) { - type noMethod FileImageMediaMetadata - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod FileImageMediaMetadata + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) +} + +func (s *FileImageMediaMetadata) UnmarshalJSON(data []byte) error { + type NoMethod FileImageMediaMetadata + var s1 struct { + Aperture gensupport.JSONFloat64 `json:"aperture"` + ExposureBias gensupport.JSONFloat64 `json:"exposureBias"` + ExposureTime gensupport.JSONFloat64 `json:"exposureTime"` + FocalLength gensupport.JSONFloat64 `json:"focalLength"` + MaxApertureValue gensupport.JSONFloat64 `json:"maxApertureValue"` + *NoMethod + } + s1.NoMethod = (*NoMethod)(s) + if err := json.Unmarshal(data, &s1); err != nil { + return err + } + s.Aperture = float64(s1.Aperture) + s.ExposureBias = float64(s1.ExposureBias) + s.ExposureTime = float64(s1.ExposureTime) + s.FocalLength = float64(s1.FocalLength) + s.MaxApertureValue = float64(s1.MaxApertureValue) + return nil } // FileImageMediaMetadataLocation: Geographic location information @@ -922,12 +1264,38 @@ type FileImageMediaMetadataLocation struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Altitude") to include in + // API requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *FileImageMediaMetadataLocation) MarshalJSON() ([]byte, error) { - type noMethod FileImageMediaMetadataLocation - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod FileImageMediaMetadataLocation + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) +} + +func (s *FileImageMediaMetadataLocation) UnmarshalJSON(data []byte) error { + type NoMethod FileImageMediaMetadataLocation + var s1 struct { + Altitude gensupport.JSONFloat64 `json:"altitude"` + Latitude gensupport.JSONFloat64 `json:"latitude"` + Longitude gensupport.JSONFloat64 `json:"longitude"` + *NoMethod + } + s1.NoMethod = (*NoMethod)(s) + if err := json.Unmarshal(data, &s1); err != nil { + return err + } + s.Altitude = float64(s1.Altitude) + s.Latitude = float64(s1.Latitude) + s.Longitude = float64(s1.Longitude) + return nil } // FileVideoMediaMetadata: Additional metadata about video media. This @@ -949,24 +1317,46 @@ type FileVideoMediaMetadata struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "DurationMillis") to + // include in API requests with the JSON null value. By default, fields + // with empty values are omitted from API requests. However, any field + // with an empty value appearing in NullFields will be sent to the + // server as null. It is an error if a field in this list has a + // non-empty value. This may be used to include null fields in Patch + // requests. + NullFields []string `json:"-"` } func (s *FileVideoMediaMetadata) MarshalJSON() ([]byte, error) { - type noMethod FileVideoMediaMetadata - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod FileVideoMediaMetadata + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // FileList: A list of files. type FileList struct { - // Files: The page of files. + // Files: The list of files. If nextPageToken is populated, then this + // list may be incomplete and an additional page of results should be + // fetched. Files []*File `json:"files,omitempty"` - // Kind: This is always drive#fileList. + // IncompleteSearch: Whether the search process was incomplete. If true, + // then some search results may be missing, since all documents were not + // searched. This may occur when searching multiple Team Drives with the + // "user,allTeamDrives" corpora, but all corpora could not be searched. + // When this happens, it is suggested that clients narrow their query by + // choosing a different corpus such as "user" or "teamDrive". + IncompleteSearch bool `json:"incompleteSearch,omitempty"` + + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#fileList". Kind string `json:"kind,omitempty"` // NextPageToken: The page token for the next page of files. This will - // be absent if the end of the files list has been reached. + // be absent if the end of the files list has been reached. If the token + // is rejected for any reason, it should be discarded, and pagination + // should be restarted from the first page of results. NextPageToken string `json:"nextPageToken,omitempty"` // ServerResponse contains the HTTP response code and headers from the @@ -980,12 +1370,20 @@ type FileList struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Files") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *FileList) MarshalJSON() ([]byte, error) { - type noMethod FileList - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod FileList + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // GeneratedIds: A list of generated file IDs which can be provided in @@ -995,7 +1393,8 @@ type GeneratedIds struct { // space. Ids []string `json:"ids,omitempty"` - // Kind: This is always drive#generatedIds + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#generatedIds". Kind string `json:"kind,omitempty"` // Space: The type of file that can be created with these IDs. @@ -1012,12 +1411,20 @@ type GeneratedIds struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Ids") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *GeneratedIds) MarshalJSON() ([]byte, error) { - type noMethod GeneratedIds - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod GeneratedIds + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // Permission: A permission for a file. A permission grants a user, @@ -1028,6 +1435,10 @@ type Permission struct { // type domain or anyone. AllowFileDiscovery bool `json:"allowFileDiscovery,omitempty"` + // Deleted: Whether the account associated with this permission has been + // deleted. This field only pertains to user and group permissions. + Deleted bool `json:"deleted,omitempty"` + // DisplayName: A displayable name for users, groups or domains. DisplayName string `json:"displayName,omitempty"` @@ -1038,23 +1449,40 @@ type Permission struct { // permission refers. EmailAddress string `json:"emailAddress,omitempty"` + // ExpirationTime: The time at which this permission will expire (RFC + // 3339 date-time). Expiration times have the following restrictions: + // + // - They can only be set on user and group permissions + // - The time must be in the future + // - The time cannot be more than a year in the future + ExpirationTime string `json:"expirationTime,omitempty"` + // Id: The ID of this permission. This is a unique identifier for the // grantee, and is published in User resources as permissionId. Id string `json:"id,omitempty"` - // Kind: This is always drive#permission. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#permission". Kind string `json:"kind,omitempty"` // PhotoLink: A link to the user's profile photo, if available. PhotoLink string `json:"photoLink,omitempty"` - // Role: The role granted by this permission. Valid values are: + // Role: The role granted by this permission. While new values may be + // supported in the future, the following are currently allowed: // - owner + // - organizer + // - fileOrganizer // - writer // - commenter // - reader Role string `json:"role,omitempty"` + // TeamDrivePermissionDetails: Details of whether the permissions on + // this Team Drive item are inherited or directly on this item. This is + // an output-only field which is present only for Team Drive items. + TeamDrivePermissionDetails []*PermissionTeamDrivePermissionDetails `json:"teamDrivePermissionDetails,omitempty"` + // Type: The type of the grantee. Valid values are: // - user // - group @@ -1073,20 +1501,88 @@ type Permission struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "AllowFileDiscovery") to + // include in API requests with the JSON null value. By default, fields + // with empty values are omitted from API requests. However, any field + // with an empty value appearing in NullFields will be sent to the + // server as null. It is an error if a field in this list has a + // non-empty value. This may be used to include null fields in Patch + // requests. + NullFields []string `json:"-"` } func (s *Permission) MarshalJSON() ([]byte, error) { - type noMethod Permission - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod Permission + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) +} + +type PermissionTeamDrivePermissionDetails struct { + // Inherited: Whether this permission is inherited. This field is always + // populated. This is an output-only field. + Inherited bool `json:"inherited,omitempty"` + + // InheritedFrom: The ID of the item from which this permission is + // inherited. This is an output-only field and is only populated for + // members of the Team Drive. + InheritedFrom string `json:"inheritedFrom,omitempty"` + + // Role: The primary role for this user. While new values may be added + // in the future, the following are currently possible: + // - organizer + // - fileOrganizer + // - writer + // - commenter + // - reader + Role string `json:"role,omitempty"` + + // TeamDrivePermissionType: The Team Drive permission type for this + // user. While new values may be added in future, the following are + // currently possible: + // - file + // - member + TeamDrivePermissionType string `json:"teamDrivePermissionType,omitempty"` + + // ForceSendFields is a list of field names (e.g. "Inherited") to + // unconditionally include in API requests. By default, fields with + // empty values are omitted from API requests. However, any non-pointer, + // non-interface field appearing in ForceSendFields will be sent to the + // server regardless of whether the field is empty or not. This may be + // used to include empty fields in Patch requests. + ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Inherited") to include in + // API requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` +} + +func (s *PermissionTeamDrivePermissionDetails) MarshalJSON() ([]byte, error) { + type NoMethod PermissionTeamDrivePermissionDetails + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // PermissionList: A list of permissions for a file. type PermissionList struct { - // Kind: This is always drive#permissionList. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#permissionList". Kind string `json:"kind,omitempty"` - // Permissions: The full list of permissions. + // NextPageToken: The page token for the next page of permissions. This + // field will be absent if the end of the permissions list has been + // reached. If the token is rejected for any reason, it should be + // discarded, and pagination should be restarted from the first page of + // results. + NextPageToken string `json:"nextPageToken,omitempty"` + + // Permissions: The list of permissions. If nextPageToken is populated, + // then this list may be incomplete and an additional page of results + // should be fetched. Permissions []*Permission `json:"permissions,omitempty"` // ServerResponse contains the HTTP response code and headers from the @@ -1100,12 +1596,20 @@ type PermissionList struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Kind") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *PermissionList) MarshalJSON() ([]byte, error) { - type noMethod PermissionList - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod PermissionList + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // Reply: A reply to a comment on a file. @@ -1138,7 +1642,8 @@ type Reply struct { // Id: The ID of the reply. Id string `json:"id,omitempty"` - // Kind: This is always drive#reply. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#reply". Kind string `json:"kind,omitempty"` // ModifiedTime: The last time the reply was modified (RFC 3339 @@ -1156,24 +1661,37 @@ type Reply struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Action") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *Reply) MarshalJSON() ([]byte, error) { - type noMethod Reply - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod Reply + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // ReplyList: A list of replies to a comment on a file. type ReplyList struct { - // Kind: This is always drive#replyList. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#replyList". Kind string `json:"kind,omitempty"` // NextPageToken: The page token for the next page of replies. This will - // be absent if the end of the replies list has been reached. + // be absent if the end of the replies list has been reached. If the + // token is rejected for any reason, it should be discarded, and + // pagination should be restarted from the first page of results. NextPageToken string `json:"nextPageToken,omitempty"` - // Replies: The page of replies. + // Replies: The list of replies. If nextPageToken is populated, then + // this list may be incomplete and an additional page of results should + // be fetched. Replies []*Reply `json:"replies,omitempty"` // ServerResponse contains the HTTP response code and headers from the @@ -1187,12 +1705,20 @@ type ReplyList struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Kind") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *ReplyList) MarshalJSON() ([]byte, error) { - type noMethod ReplyList - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod ReplyList + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // Revision: The metadata for a revision to a file. @@ -1207,7 +1733,8 @@ type Revision struct { // This field is only applicable to files with binary content in Drive. KeepForever bool `json:"keepForever,omitempty"` - // Kind: This is always drive#revision. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#revision". Kind string `json:"kind,omitempty"` // LastModifyingUser: The last user to modify this revision. @@ -1255,20 +1782,37 @@ type Revision struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Id") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *Revision) MarshalJSON() ([]byte, error) { - type noMethod Revision - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod Revision + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // RevisionList: A list of revisions of a file. type RevisionList struct { - // Kind: This is always drive#revisionList. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#revisionList". Kind string `json:"kind,omitempty"` - // Revisions: The full list of revisions. + // NextPageToken: The page token for the next page of revisions. This + // will be absent if the end of the revisions list has been reached. If + // the token is rejected for any reason, it should be discarded, and + // pagination should be restarted from the first page of results. + NextPageToken string `json:"nextPageToken,omitempty"` + + // Revisions: The list of revisions. If nextPageToken is populated, then + // this list may be incomplete and an additional page of results should + // be fetched. Revisions []*Revision `json:"revisions,omitempty"` // ServerResponse contains the HTTP response code and headers from the @@ -1282,16 +1826,25 @@ type RevisionList struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Kind") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *RevisionList) MarshalJSON() ([]byte, error) { - type noMethod RevisionList - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod RevisionList + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } type StartPageToken struct { - // Kind: This is always drive#startPageToken. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#startPageToken". Kind string `json:"kind,omitempty"` // StartPageToken: The starting page token for listing changes. @@ -1308,12 +1861,364 @@ type StartPageToken struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Kind") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *StartPageToken) MarshalJSON() ([]byte, error) { - type noMethod StartPageToken - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod StartPageToken + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) +} + +// TeamDrive: Representation of a Team Drive. +type TeamDrive struct { + // BackgroundImageFile: An image file and cropping parameters from which + // a background image for this Team Drive is set. This is a write only + // field; it can only be set on drive.teamdrives.update requests that + // don't set themeId. When specified, all fields of the + // backgroundImageFile must be set. + BackgroundImageFile *TeamDriveBackgroundImageFile `json:"backgroundImageFile,omitempty"` + + // BackgroundImageLink: A short-lived link to this Team Drive's + // background image. + BackgroundImageLink string `json:"backgroundImageLink,omitempty"` + + // Capabilities: Capabilities the current user has on this Team Drive. + Capabilities *TeamDriveCapabilities `json:"capabilities,omitempty"` + + // ColorRgb: 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 `json:"colorRgb,omitempty"` + + // CreatedTime: The time at which the Team Drive was created (RFC 3339 + // date-time). + CreatedTime string `json:"createdTime,omitempty"` + + // Id: The ID of this Team Drive which is also the ID of the top level + // folder of this Team Drive. + Id string `json:"id,omitempty"` + + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#teamDrive". + Kind string `json:"kind,omitempty"` + + // Name: The name of this Team Drive. + Name string `json:"name,omitempty"` + + // Restrictions: A set of restrictions that apply to this Team Drive or + // items inside this Team Drive. + Restrictions *TeamDriveRestrictions `json:"restrictions,omitempty"` + + // ThemeId: The ID of the theme from which the background image and + // color will be set. The set of possible teamDriveThemes can be + // retrieved from a drive.about.get response. When not specified on a + // drive.teamdrives.create request, a random theme is chosen from which + // the background image and color are set. This is a write-only field; + // it can only be set on requests that don't set colorRgb or + // backgroundImageFile. + ThemeId string `json:"themeId,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // ForceSendFields is a list of field names (e.g. "BackgroundImageFile") + // to unconditionally include in API requests. By default, fields with + // empty values are omitted from API requests. However, any non-pointer, + // non-interface field appearing in ForceSendFields will be sent to the + // server regardless of whether the field is empty or not. This may be + // used to include empty fields in Patch requests. + ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "BackgroundImageFile") to + // include in API requests with the JSON null value. By default, fields + // with empty values are omitted from API requests. However, any field + // with an empty value appearing in NullFields will be sent to the + // server as null. It is an error if a field in this list has a + // non-empty value. This may be used to include null fields in Patch + // requests. + NullFields []string `json:"-"` +} + +func (s *TeamDrive) MarshalJSON() ([]byte, error) { + type NoMethod TeamDrive + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) +} + +// TeamDriveBackgroundImageFile: An image file and cropping parameters +// from which a background image for this Team Drive is set. This is a +// write only field; it can only be set on drive.teamdrives.update +// requests that don't set themeId. When specified, all fields of the +// backgroundImageFile must be set. +type TeamDriveBackgroundImageFile struct { + // Id: The ID of an image file in Drive to use for the background image. + Id string `json:"id,omitempty"` + + // Width: The width of the cropped image in the closed range of 0 to 1. + // This value represents the width of the cropped image divided by the + // width of the entire image. The height is computed by applying a width + // to height aspect ratio of 80 to 9. The resulting image must be at + // least 1280 pixels wide and 144 pixels high. + Width float64 `json:"width,omitempty"` + + // XCoordinate: The X coordinate of the upper left corner of the + // cropping area in the background image. This is a value in the closed + // range of 0 to 1. This value represents the horizontal distance from + // the left side of the entire image to the left side of the cropping + // area divided by the width of the entire image. + XCoordinate float64 `json:"xCoordinate,omitempty"` + + // YCoordinate: The Y coordinate of the upper left corner of the + // cropping area in the background image. This is a value in the closed + // range of 0 to 1. This value represents the vertical distance from the + // top side of the entire image to the top side of the cropping area + // divided by the height of the entire image. + YCoordinate float64 `json:"yCoordinate,omitempty"` + + // ForceSendFields is a list of field names (e.g. "Id") to + // unconditionally include in API requests. By default, fields with + // empty values are omitted from API requests. However, any non-pointer, + // non-interface field appearing in ForceSendFields will be sent to the + // server regardless of whether the field is empty or not. This may be + // used to include empty fields in Patch requests. + ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Id") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` +} + +func (s *TeamDriveBackgroundImageFile) MarshalJSON() ([]byte, error) { + type NoMethod TeamDriveBackgroundImageFile + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) +} + +func (s *TeamDriveBackgroundImageFile) UnmarshalJSON(data []byte) error { + type NoMethod TeamDriveBackgroundImageFile + var s1 struct { + Width gensupport.JSONFloat64 `json:"width"` + XCoordinate gensupport.JSONFloat64 `json:"xCoordinate"` + YCoordinate gensupport.JSONFloat64 `json:"yCoordinate"` + *NoMethod + } + s1.NoMethod = (*NoMethod)(s) + if err := json.Unmarshal(data, &s1); err != nil { + return err + } + s.Width = float64(s1.Width) + s.XCoordinate = float64(s1.XCoordinate) + s.YCoordinate = float64(s1.YCoordinate) + return nil +} + +// TeamDriveCapabilities: Capabilities the current user has on this Team +// Drive. +type TeamDriveCapabilities struct { + // CanAddChildren: Whether the current user can add children to folders + // in this Team Drive. + CanAddChildren bool `json:"canAddChildren,omitempty"` + + // CanChangeCopyRequiresWriterPermissionRestriction: Whether the current + // user can change the copyRequiresWriterPermission restriction of this + // Team Drive. + CanChangeCopyRequiresWriterPermissionRestriction bool `json:"canChangeCopyRequiresWriterPermissionRestriction,omitempty"` + + // CanChangeDomainUsersOnlyRestriction: Whether the current user can + // change the domainUsersOnly restriction of this Team Drive. + CanChangeDomainUsersOnlyRestriction bool `json:"canChangeDomainUsersOnlyRestriction,omitempty"` + + // CanChangeTeamDriveBackground: Whether the current user can change the + // background of this Team Drive. + CanChangeTeamDriveBackground bool `json:"canChangeTeamDriveBackground,omitempty"` + + // CanChangeTeamMembersOnlyRestriction: Whether the current user can + // change the teamMembersOnly restriction of this Team Drive. + CanChangeTeamMembersOnlyRestriction bool `json:"canChangeTeamMembersOnlyRestriction,omitempty"` + + // CanComment: Whether the current user can comment on files in this + // Team Drive. + CanComment bool `json:"canComment,omitempty"` + + // CanCopy: Whether the current user can copy files in this Team Drive. + CanCopy bool `json:"canCopy,omitempty"` + + // CanDeleteChildren: Whether the current user can delete children from + // folders in this Team Drive. + CanDeleteChildren bool `json:"canDeleteChildren,omitempty"` + + // CanDeleteTeamDrive: Whether the current user can delete this Team + // Drive. Attempting to delete the Team Drive may still fail if there + // are untrashed items inside the Team Drive. + CanDeleteTeamDrive bool `json:"canDeleteTeamDrive,omitempty"` + + // CanDownload: Whether the current user can download files in this Team + // Drive. + CanDownload bool `json:"canDownload,omitempty"` + + // CanEdit: Whether the current user can edit files in this Team Drive + CanEdit bool `json:"canEdit,omitempty"` + + // CanListChildren: Whether the current user can list the children of + // folders in this Team Drive. + CanListChildren bool `json:"canListChildren,omitempty"` + + // CanManageMembers: Whether the current user can add members to this + // Team Drive or remove them or change their role. + CanManageMembers bool `json:"canManageMembers,omitempty"` + + // CanReadRevisions: Whether the current user can read the revisions + // resource of files in this Team Drive. + CanReadRevisions bool `json:"canReadRevisions,omitempty"` + + // CanRemoveChildren: Deprecated - use canDeleteChildren or + // canTrashChildren instead. + CanRemoveChildren bool `json:"canRemoveChildren,omitempty"` + + // CanRename: Whether the current user can rename files or folders in + // this Team Drive. + CanRename bool `json:"canRename,omitempty"` + + // CanRenameTeamDrive: Whether the current user can rename this Team + // Drive. + CanRenameTeamDrive bool `json:"canRenameTeamDrive,omitempty"` + + // CanShare: Whether the current user can share files or folders in this + // Team Drive. + CanShare bool `json:"canShare,omitempty"` + + // CanTrashChildren: Whether the current user can trash children from + // folders in this Team Drive. + CanTrashChildren bool `json:"canTrashChildren,omitempty"` + + // ForceSendFields is a list of field names (e.g. "CanAddChildren") to + // unconditionally include in API requests. By default, fields with + // empty values are omitted from API requests. However, any non-pointer, + // non-interface field appearing in ForceSendFields will be sent to the + // server regardless of whether the field is empty or not. This may be + // used to include empty fields in Patch requests. + ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "CanAddChildren") to + // include in API requests with the JSON null value. By default, fields + // with empty values are omitted from API requests. However, any field + // with an empty value appearing in NullFields will be sent to the + // server as null. It is an error if a field in this list has a + // non-empty value. This may be used to include null fields in Patch + // requests. + NullFields []string `json:"-"` +} + +func (s *TeamDriveCapabilities) MarshalJSON() ([]byte, error) { + type NoMethod TeamDriveCapabilities + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) +} + +// TeamDriveRestrictions: A set of restrictions that apply to this Team +// Drive or items inside this Team Drive. +type TeamDriveRestrictions struct { + // AdminManagedRestrictions: Whether administrative privileges on this + // Team Drive are required to modify restrictions. + AdminManagedRestrictions bool `json:"adminManagedRestrictions,omitempty"` + + // CopyRequiresWriterPermission: Whether the options to copy, print, or + // download files inside this Team Drive, should be disabled for readers + // and commenters. When this restriction is set to true, it will + // override the similarly named field to true for any file inside this + // Team Drive. + CopyRequiresWriterPermission bool `json:"copyRequiresWriterPermission,omitempty"` + + // DomainUsersOnly: Whether access to this Team Drive and items inside + // this Team Drive is restricted to users of the domain to which this + // Team Drive belongs. This restriction may be overridden by other + // sharing policies controlled outside of this Team Drive. + DomainUsersOnly bool `json:"domainUsersOnly,omitempty"` + + // TeamMembersOnly: Whether access to items inside this Team Drive is + // restricted to members of this Team Drive. + TeamMembersOnly bool `json:"teamMembersOnly,omitempty"` + + // ForceSendFields is a list of field names (e.g. + // "AdminManagedRestrictions") to unconditionally include in API + // requests. By default, fields with empty values are omitted from API + // requests. However, any non-pointer, non-interface field appearing in + // ForceSendFields will be sent to the server regardless of whether the + // field is empty or not. This may be used to include empty fields in + // Patch requests. + ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "AdminManagedRestrictions") + // to include in API requests with the JSON null value. By default, + // fields with empty values are omitted from API requests. However, any + // field with an empty value appearing in NullFields will be sent to the + // server as null. It is an error if a field in this list has a + // non-empty value. This may be used to include null fields in Patch + // requests. + NullFields []string `json:"-"` +} + +func (s *TeamDriveRestrictions) MarshalJSON() ([]byte, error) { + type NoMethod TeamDriveRestrictions + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) +} + +// TeamDriveList: A list of Team Drives. +type TeamDriveList struct { + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#teamDriveList". + Kind string `json:"kind,omitempty"` + + // NextPageToken: The page token for the next page of Team Drives. This + // will be absent if the end of the Team Drives list has been reached. + // If the token is rejected for any reason, it should be discarded, and + // pagination should be restarted from the first page of results. + NextPageToken string `json:"nextPageToken,omitempty"` + + // TeamDrives: The list of Team Drives. If nextPageToken is populated, + // then this list may be incomplete and an additional page of results + // should be fetched. + TeamDrives []*TeamDrive `json:"teamDrives,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // ForceSendFields is a list of field names (e.g. "Kind") to + // unconditionally include in API requests. By default, fields with + // empty values are omitted from API requests. However, any non-pointer, + // non-interface field appearing in ForceSendFields will be sent to the + // server regardless of whether the field is empty or not. This may be + // used to include empty fields in Patch requests. + ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Kind") to include in API + // requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` +} + +func (s *TeamDriveList) MarshalJSON() ([]byte, error) { + type NoMethod TeamDriveList + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // User: Information about a Drive user. @@ -1326,7 +2231,8 @@ type User struct { // visible to the requester. EmailAddress string `json:"emailAddress,omitempty"` - // Kind: This is always drive#user. + // Kind: Identifies what kind of resource this is. Value: the fixed + // string "drive#user". Kind string `json:"kind,omitempty"` // Me: Whether this user is the requesting user. @@ -1345,12 +2251,20 @@ type User struct { // server regardless of whether the field is empty or not. This may be // used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "DisplayName") to include + // in API requests with the JSON null value. By default, fields with + // empty values are omitted from API requests. However, any field with + // an empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` } func (s *User) MarshalJSON() ([]byte, error) { - type noMethod User - raw := noMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields) + type NoMethod User + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // method id "drive.about.get": @@ -1360,6 +2274,7 @@ type AboutGetCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // Get: Gets information about the user, the user's Drive, and system @@ -1395,21 +2310,35 @@ func (c *AboutGetCall) Context(ctx context.Context) *AboutGetCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *AboutGetCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *AboutGetCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "about") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) - googleapi.SetOpaque(req.URL) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err } - return c.s.client.Do(req) + req.Header = reqHeaders + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.about.get" call. @@ -1444,7 +2373,8 @@ func (c *AboutGetCall) Do(opts ...googleapi.CallOption) (*About, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -1476,6 +2406,7 @@ type ChangesGetStartPageTokenCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // GetStartPageToken: Gets the starting pageToken for listing future @@ -1485,6 +2416,21 @@ func (r *ChangesService) GetStartPageToken() *ChangesGetStartPageTokenCall { return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *ChangesGetStartPageTokenCall) SupportsTeamDrives(supportsTeamDrives bool) *ChangesGetStartPageTokenCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + +// TeamDriveId sets the optional parameter "teamDriveId": The ID of the +// Team Drive for which the starting pageToken for listing future +// changes from that Team Drive will be returned. +func (c *ChangesGetStartPageTokenCall) TeamDriveId(teamDriveId string) *ChangesGetStartPageTokenCall { + c.urlParams_.Set("teamDriveId", teamDriveId) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -1511,21 +2457,35 @@ func (c *ChangesGetStartPageTokenCall) Context(ctx context.Context) *ChangesGetS return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *ChangesGetStartPageTokenCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *ChangesGetStartPageTokenCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "changes/startPageToken") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) - googleapi.SetOpaque(req.URL) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err } - return c.s.client.Do(req) + req.Header = reqHeaders + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.changes.getStartPageToken" call. @@ -1560,7 +2520,8 @@ func (c *ChangesGetStartPageTokenCall) Do(opts ...googleapi.CallOption) (*StartP HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -1568,8 +2529,21 @@ func (c *ChangesGetStartPageTokenCall) Do(opts ...googleapi.CallOption) (*StartP // "description": "Gets the starting pageToken for listing future changes.", // "httpMethod": "GET", // "id": "drive.changes.getStartPageToken", - // "path": "changes/startPageToken", - // "response": { + // "parameters": { + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" + // }, + // "teamDriveId": { + // "description": "The ID of the Team Drive for which the starting pageToken for listing future changes from that Team Drive will be returned.", + // "location": "query", + // "type": "string" + // } + // }, + // "path": "changes/startPageToken", + // "response": { // "$ref": "StartPageToken" // }, // "scopes": [ @@ -1592,23 +2566,42 @@ type ChangesListCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } -// List: Lists changes for a user. +// List: Lists the changes for a user or Team Drive. func (r *ChangesService) List(pageToken string) *ChangesListCall { c := &ChangesListCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.urlParams_.Set("pageToken", pageToken) return c } +// IncludeCorpusRemovals sets the optional parameter +// "includeCorpusRemovals": Whether changes should include the file +// resource if the file is still accessible by the user at the time of +// the request, even when a file was removed from the list of changes +// and there will be no further change entries for this file. +func (c *ChangesListCall) IncludeCorpusRemovals(includeCorpusRemovals bool) *ChangesListCall { + c.urlParams_.Set("includeCorpusRemovals", fmt.Sprint(includeCorpusRemovals)) + return c +} + // IncludeRemoved sets the optional parameter "includeRemoved": Whether -// to include changes indicating that items have left the view of the -// changes list, for example by deletion or lost access. +// to include changes indicating that items have been removed from the +// list of changes, for example by deletion or loss of access. func (c *ChangesListCall) IncludeRemoved(includeRemoved bool) *ChangesListCall { c.urlParams_.Set("includeRemoved", fmt.Sprint(includeRemoved)) return c } +// IncludeTeamDriveItems sets the optional parameter +// "includeTeamDriveItems": Whether Team Drive files or changes should +// be included in results. +func (c *ChangesListCall) IncludeTeamDriveItems(includeTeamDriveItems bool) *ChangesListCall { + c.urlParams_.Set("includeTeamDriveItems", fmt.Sprint(includeTeamDriveItems)) + return c +} + // PageSize sets the optional parameter "pageSize": The maximum number // of changes to return per page. func (c *ChangesListCall) PageSize(pageSize int64) *ChangesListCall { @@ -1634,6 +2627,22 @@ func (c *ChangesListCall) Spaces(spaces string) *ChangesListCall { return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *ChangesListCall) SupportsTeamDrives(supportsTeamDrives bool) *ChangesListCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + +// TeamDriveId sets the optional parameter "teamDriveId": The Team Drive +// from which changes will be returned. If specified the change IDs will +// be reflective of the Team Drive; use the combined Team Drive ID and +// change ID as an identifier. +func (c *ChangesListCall) TeamDriveId(teamDriveId string) *ChangesListCall { + c.urlParams_.Set("teamDriveId", teamDriveId) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -1660,21 +2669,35 @@ func (c *ChangesListCall) Context(ctx context.Context) *ChangesListCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *ChangesListCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *ChangesListCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "changes") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) - googleapi.SetOpaque(req.URL) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err } - return c.s.client.Do(req) + req.Header = reqHeaders + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.changes.list" call. @@ -1709,21 +2732,34 @@ func (c *ChangesListCall) Do(opts ...googleapi.CallOption) (*ChangeList, error) HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil // { - // "description": "Lists changes for a user.", + // "description": "Lists the changes for a user or Team Drive.", // "httpMethod": "GET", // "id": "drive.changes.list", // "parameterOrder": [ // "pageToken" // ], // "parameters": { + // "includeCorpusRemovals": { + // "default": "false", + // "description": "Whether changes should include the file resource if the file is still accessible by the user at the time of the request, even when a file was removed from the list of changes and there will be no further change entries for this file.", + // "location": "query", + // "type": "boolean" + // }, // "includeRemoved": { // "default": "true", - // "description": "Whether to include changes indicating that items have left the view of the changes list, for example by deletion or lost access.", + // "description": "Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access.", + // "location": "query", + // "type": "boolean" + // }, + // "includeTeamDriveItems": { + // "default": "false", + // "description": "Whether Team Drive files or changes should be included in results.", // "location": "query", // "type": "boolean" // }, @@ -1753,6 +2789,17 @@ func (c *ChangesListCall) Do(opts ...googleapi.CallOption) (*ChangeList, error) // "description": "A comma-separated list of spaces to query within the user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.", // "location": "query", // "type": "string" + // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" + // }, + // "teamDriveId": { + // "description": "The Team Drive from which changes will be returned. If specified the change IDs will be reflective of the Team Drive; use the combined Team Drive ID and change ID as an identifier.", + // "location": "query", + // "type": "string" // } // }, // "path": "changes", @@ -1780,6 +2827,7 @@ type ChangesWatchCall struct { channel *Channel urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Watch: Subscribes to changes for a user. @@ -1790,14 +2838,32 @@ func (r *ChangesService) Watch(pageToken string, channel *Channel) *ChangesWatch return c } +// IncludeCorpusRemovals sets the optional parameter +// "includeCorpusRemovals": Whether changes should include the file +// resource if the file is still accessible by the user at the time of +// the request, even when a file was removed from the list of changes +// and there will be no further change entries for this file. +func (c *ChangesWatchCall) IncludeCorpusRemovals(includeCorpusRemovals bool) *ChangesWatchCall { + c.urlParams_.Set("includeCorpusRemovals", fmt.Sprint(includeCorpusRemovals)) + return c +} + // IncludeRemoved sets the optional parameter "includeRemoved": Whether -// to include changes indicating that items have left the view of the -// changes list, for example by deletion or lost access. +// to include changes indicating that items have been removed from the +// list of changes, for example by deletion or loss of access. func (c *ChangesWatchCall) IncludeRemoved(includeRemoved bool) *ChangesWatchCall { c.urlParams_.Set("includeRemoved", fmt.Sprint(includeRemoved)) return c } +// IncludeTeamDriveItems sets the optional parameter +// "includeTeamDriveItems": Whether Team Drive files or changes should +// be included in results. +func (c *ChangesWatchCall) IncludeTeamDriveItems(includeTeamDriveItems bool) *ChangesWatchCall { + c.urlParams_.Set("includeTeamDriveItems", fmt.Sprint(includeTeamDriveItems)) + return c +} + // PageSize sets the optional parameter "pageSize": The maximum number // of changes to return per page. func (c *ChangesWatchCall) PageSize(pageSize int64) *ChangesWatchCall { @@ -1823,6 +2889,22 @@ func (c *ChangesWatchCall) Spaces(spaces string) *ChangesWatchCall { return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *ChangesWatchCall) SupportsTeamDrives(supportsTeamDrives bool) *ChangesWatchCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + +// TeamDriveId sets the optional parameter "teamDriveId": The Team Drive +// from which changes will be returned. If specified the change IDs will +// be reflective of the Team Drive; use the combined Team Drive ID and +// change ID as an identifier. +func (c *ChangesWatchCall) TeamDriveId(teamDriveId string) *ChangesWatchCall { + c.urlParams_.Set("teamDriveId", teamDriveId) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -1839,24 +2921,37 @@ func (c *ChangesWatchCall) Context(ctx context.Context) *ChangesWatchCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *ChangesWatchCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *ChangesWatchCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "changes/watch") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("POST", urls, body) - googleapi.SetOpaque(req.URL) - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) + req, err := http.NewRequest("POST", urls, body) + if err != nil { + return nil, err } - return c.s.client.Do(req) + req.Header = reqHeaders + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.changes.watch" call. @@ -1891,7 +2986,8 @@ func (c *ChangesWatchCall) Do(opts ...googleapi.CallOption) (*Channel, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -1903,9 +2999,21 @@ func (c *ChangesWatchCall) Do(opts ...googleapi.CallOption) (*Channel, error) { // "pageToken" // ], // "parameters": { + // "includeCorpusRemovals": { + // "default": "false", + // "description": "Whether changes should include the file resource if the file is still accessible by the user at the time of the request, even when a file was removed from the list of changes and there will be no further change entries for this file.", + // "location": "query", + // "type": "boolean" + // }, // "includeRemoved": { // "default": "true", - // "description": "Whether to include changes indicating that items have left the view of the changes list, for example by deletion or lost access.", + // "description": "Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access.", + // "location": "query", + // "type": "boolean" + // }, + // "includeTeamDriveItems": { + // "default": "false", + // "description": "Whether Team Drive files or changes should be included in results.", // "location": "query", // "type": "boolean" // }, @@ -1935,6 +3043,17 @@ func (c *ChangesWatchCall) Do(opts ...googleapi.CallOption) (*Channel, error) { // "description": "A comma-separated list of spaces to query within the user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.", // "location": "query", // "type": "string" + // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" + // }, + // "teamDriveId": { + // "description": "The Team Drive from which changes will be returned. If specified the change IDs will be reflective of the Team Drive; use the combined Team Drive ID and change ID as an identifier.", + // "location": "query", + // "type": "string" // } // }, // "path": "changes/watch", @@ -1966,6 +3085,7 @@ type ChannelsStopCall struct { channel *Channel urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Stop: Stop watching resources through this channel @@ -1991,24 +3111,37 @@ func (c *ChannelsStopCall) Context(ctx context.Context) *ChannelsStopCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *ChannelsStopCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *ChannelsStopCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "channels/stop") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("POST", urls, body) - googleapi.SetOpaque(req.URL) - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) + req, err := http.NewRequest("POST", urls, body) + if err != nil { + return nil, err } - return c.s.client.Do(req) + req.Header = reqHeaders + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.channels.stop" call. @@ -2053,6 +3186,7 @@ type CommentsCreateCall struct { comment *Comment urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Create: Creates a new comment on a file. @@ -2079,26 +3213,40 @@ func (c *CommentsCreateCall) Context(ctx context.Context) *CommentsCreateCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *CommentsCreateCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *CommentsCreateCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.comment) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("POST", urls, body) + req, err := http.NewRequest("POST", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, }) - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.comments.create" call. @@ -2133,7 +3281,8 @@ func (c *CommentsCreateCall) Do(opts ...googleapi.CallOption) (*Comment, error) HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -2175,6 +3324,7 @@ type CommentsDeleteCall struct { commentId string urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Delete: Deletes a comment. @@ -2201,21 +3351,36 @@ func (c *CommentsDeleteCall) Context(ctx context.Context) *CommentsDeleteCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *CommentsDeleteCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *CommentsDeleteCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("DELETE", urls, body) + req, err := http.NewRequest("DELETE", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "commentId": c.commentId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.comments.delete" call. @@ -2270,6 +3435,7 @@ type CommentsGetCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // Get: Gets a comment by ID. @@ -2314,24 +3480,39 @@ func (c *CommentsGetCall) Context(ctx context.Context) *CommentsGetCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *CommentsGetCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *CommentsGetCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "commentId": c.commentId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.comments.get" call. @@ -2366,7 +3547,8 @@ func (c *CommentsGetCall) Do(opts ...googleapi.CallOption) (*Comment, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -2419,6 +3601,7 @@ type CommentsListCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // List: Lists a file's comments. @@ -2485,23 +3668,38 @@ func (c *CommentsListCall) Context(ctx context.Context) *CommentsListCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *CommentsListCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *CommentsListCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.comments.list" call. @@ -2536,7 +3734,8 @@ func (c *CommentsListCall) Do(opts ...googleapi.CallOption) (*CommentList, error HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -2623,6 +3822,7 @@ type CommentsUpdateCall struct { comment *Comment urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Update: Updates a comment with patch semantics. @@ -2650,27 +3850,41 @@ func (c *CommentsUpdateCall) Context(ctx context.Context) *CommentsUpdateCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *CommentsUpdateCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *CommentsUpdateCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.comment) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("PATCH", urls, body) + req, err := http.NewRequest("PATCH", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "commentId": c.commentId, }) - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.comments.update" call. @@ -2705,7 +3919,8 @@ func (c *CommentsUpdateCall) Do(opts ...googleapi.CallOption) (*Comment, error) HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -2754,6 +3969,7 @@ type FilesCopyCall struct { file *File urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Copy: Creates a copy of a file and applies any requested updates with @@ -2792,6 +4008,13 @@ func (c *FilesCopyCall) OcrLanguage(ocrLanguage string) *FilesCopyCall { return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *FilesCopyCall) SupportsTeamDrives(supportsTeamDrives bool) *FilesCopyCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -2808,26 +4031,40 @@ func (c *FilesCopyCall) Context(ctx context.Context) *FilesCopyCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *FilesCopyCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *FilesCopyCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.file) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/copy") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("POST", urls, body) + req, err := http.NewRequest("POST", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, }) - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.files.copy" call. @@ -2862,7 +4099,8 @@ func (c *FilesCopyCall) Do(opts ...googleapi.CallOption) (*File, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -2896,6 +4134,12 @@ func (c *FilesCopyCall) Do(opts ...googleapi.CallOption) (*File, error) { // "description": "A language hint for OCR processing during image import (ISO 639-1 code).", // "location": "query", // "type": "string" + // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" // } // }, // "path": "files/{fileId}/copy", @@ -2918,15 +4162,12 @@ func (c *FilesCopyCall) Do(opts ...googleapi.CallOption) (*File, error) { // method id "drive.files.create": type FilesCreateCall struct { - s *Service - file *File - urlParams_ gensupport.URLParams - media_ io.Reader - resumableBuffer_ *gensupport.ResumableBuffer - mediaType_ string - mediaSize_ int64 // mediaSize, if known. Used only for calls to progressUpdater_. - progressUpdater_ googleapi.ProgressUpdater - ctx_ context.Context + s *Service + file *File + urlParams_ gensupport.URLParams + mediaInfo_ *gensupport.MediaInfo + ctx_ context.Context + header_ http.Header } // Create: Creates a new file. @@ -2963,6 +4204,13 @@ func (c *FilesCreateCall) OcrLanguage(ocrLanguage string) *FilesCreateCall { return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *FilesCreateCall) SupportsTeamDrives(supportsTeamDrives bool) *FilesCreateCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + // UseContentAsIndexableText sets the optional parameter // "useContentAsIndexableText": Whether to use the uploaded content as // indexable text. @@ -2980,12 +4228,7 @@ func (c *FilesCreateCall) UseContentAsIndexableText(useContentAsIndexableText bo // supplied. // At most one of Media and ResumableMedia may be set. func (c *FilesCreateCall) Media(r io.Reader, options ...googleapi.MediaOption) *FilesCreateCall { - opts := googleapi.ProcessMediaOptions(options) - chunkSize := opts.ChunkSize - if !opts.ForceEmptyContentType { - r, c.mediaType_ = gensupport.DetermineContentType(r, opts.ContentType) - } - c.media_, c.resumableBuffer_ = gensupport.PrepareUpload(r, chunkSize) + c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options) return c } @@ -3000,11 +4243,7 @@ func (c *FilesCreateCall) Media(r io.Reader, options ...googleapi.MediaOption) * // supersede any context previously provided to the Context method. func (c *FilesCreateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *FilesCreateCall { c.ctx_ = ctx - rdr := gensupport.ReaderAtToReader(r, size) - rdr, c.mediaType_ = gensupport.DetermineContentType(rdr, mediaType) - c.resumableBuffer_ = gensupport.NewResumableBuffer(rdr, googleapi.DefaultUploadChunkSize) - c.media_ = nil - c.mediaSize_ = size + c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType) return c } @@ -3013,7 +4252,7 @@ func (c *FilesCreateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, siz // not slow down the upload operation. This should only be called when // using ResumableMedia (as opposed to Media). func (c *FilesCreateCall) ProgressUpdater(pu googleapi.ProgressUpdater) *FilesCreateCall { - c.progressUpdater_ = pu + c.mediaInfo_.SetProgressUpdater(pu) return c } @@ -3035,41 +4274,48 @@ func (c *FilesCreateCall) Context(ctx context.Context) *FilesCreateCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *FilesCreateCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *FilesCreateCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.file) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files") - if c.media_ != nil || c.resumableBuffer_ != nil { + if c.mediaInfo_ != nil { urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1) - protocol := "multipart" - if c.resumableBuffer_ != nil { - protocol = "resumable" - } - c.urlParams_.Set("uploadType", protocol) - } - urls += "?" + c.urlParams_.Encode() - if c.media_ != nil { - var combined io.ReadCloser - combined, ctype = gensupport.CombineBodyMedia(body, ctype, c.media_, c.mediaType_) - defer combined.Close() - body = combined + c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType()) } - req, _ := http.NewRequest("POST", urls, body) - googleapi.SetOpaque(req.URL) - if c.resumableBuffer_ != nil && c.mediaType_ != "" { - req.Header.Set("X-Upload-Content-Type", c.mediaType_) + if body == nil { + body = new(bytes.Buffer) + reqHeaders.Set("Content-Type", "application/json") } - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) + body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body) + defer cleanup() + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("POST", urls, body) + if err != nil { + return nil, err } - return c.s.client.Do(req) + req.Header = reqHeaders + gensupport.SetGetBody(req, getBody) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.files.create" call. @@ -3098,20 +4344,10 @@ func (c *FilesCreateCall) Do(opts ...googleapi.CallOption) (*File, error) { if err := googleapi.CheckResponse(res); err != nil { return nil, err } - if c.resumableBuffer_ != nil { - loc := res.Header.Get("Location") - rx := &gensupport.ResumableUpload{ - Client: c.s.client, - UserAgent: c.s.userAgent(), - URI: loc, - Media: c.resumableBuffer_, - MediaType: c.mediaType_, - Callback: func(curr int64) { - if c.progressUpdater_ != nil { - c.progressUpdater_(curr, c.mediaSize_) - } - }, - } + rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location")) + if rx != nil { + rx.Client = c.s.client + rx.UserAgent = c.s.userAgent() ctx := c.ctx_ if ctx == nil { ctx = context.TODO() @@ -3131,7 +4367,8 @@ func (c *FilesCreateCall) Do(opts ...googleapi.CallOption) (*File, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -3173,6 +4410,12 @@ func (c *FilesCreateCall) Do(opts ...googleapi.CallOption) (*File, error) { // "location": "query", // "type": "string" // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" + // }, // "useContentAsIndexableText": { // "default": "false", // "description": "Whether to use the uploaded content as indexable text.", @@ -3205,17 +4448,26 @@ type FilesDeleteCall struct { fileId string urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Delete: Permanently deletes a file owned by the user without moving -// it to the trash. If the target is a folder, all descendants owned by -// the user are also deleted. +// 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. func (r *FilesService) Delete(fileId string) *FilesDeleteCall { c := &FilesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.fileId = fileId return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *FilesDeleteCall) SupportsTeamDrives(supportsTeamDrives bool) *FilesDeleteCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -3232,20 +4484,35 @@ func (c *FilesDeleteCall) Context(ctx context.Context) *FilesDeleteCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *FilesDeleteCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *FilesDeleteCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("DELETE", urls, body) + req, err := http.NewRequest("DELETE", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.files.delete" call. @@ -3261,7 +4528,7 @@ func (c *FilesDeleteCall) Do(opts ...googleapi.CallOption) error { } return nil // { - // "description": "Permanently deletes a file owned by the user without moving it to the trash. If the target is a folder, all descendants owned by the user are also deleted.", + // "description": "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.", // "httpMethod": "DELETE", // "id": "drive.files.delete", // "parameterOrder": [ @@ -3273,6 +4540,12 @@ func (c *FilesDeleteCall) Do(opts ...googleapi.CallOption) error { // "location": "path", // "required": true, // "type": "string" + // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" // } // }, // "path": "files/{fileId}", @@ -3291,6 +4564,7 @@ type FilesEmptyTrashCall struct { s *Service urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // EmptyTrash: Permanently deletes all of the user's trashed files. @@ -3315,18 +4589,32 @@ func (c *FilesEmptyTrashCall) Context(ctx context.Context) *FilesEmptyTrashCall return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *FilesEmptyTrashCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *FilesEmptyTrashCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/trash") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("DELETE", urls, body) - googleapi.SetOpaque(req.URL) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) + req, err := http.NewRequest("DELETE", urls, body) + if err != nil { + return nil, err } - return c.s.client.Do(req) + req.Header = reqHeaders + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.files.emptyTrash" call. @@ -3361,10 +4649,12 @@ type FilesExportCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // Export: Exports a Google Doc to the requested MIME type and returns -// the exported content. +// the exported content. Please note that the exported content is +// limited to 10MB. func (r *FilesService) Export(fileId string, mimeType string) *FilesExportCall { c := &FilesExportCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.fileId = fileId @@ -3398,23 +4688,38 @@ func (c *FilesExportCall) Context(ctx context.Context) *FilesExportCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *FilesExportCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *FilesExportCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/export") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Download fetches the API endpoint's "media" value, instead of the normal @@ -3446,7 +4751,7 @@ func (c *FilesExportCall) Do(opts ...googleapi.CallOption) error { } return nil // { - // "description": "Exports a Google Doc to the requested MIME type and returns the exported content.", + // "description": "Exports a Google Doc to the requested MIME type and returns the exported content. Please note that the exported content is limited to 10MB.", // "httpMethod": "GET", // "id": "drive.files.export", // "parameterOrder": [ @@ -3485,6 +4790,7 @@ type FilesGenerateIdsCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // GenerateIds: Generates a set of file IDs which can be provided in @@ -3535,21 +4841,35 @@ func (c *FilesGenerateIdsCall) Context(ctx context.Context) *FilesGenerateIdsCal return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *FilesGenerateIdsCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *FilesGenerateIdsCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/generateIds") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) - googleapi.SetOpaque(req.URL) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err } - return c.s.client.Do(req) + req.Header = reqHeaders + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.files.generateIds" call. @@ -3584,7 +4904,8 @@ func (c *FilesGenerateIdsCall) Do(opts ...googleapi.CallOption) (*GeneratedIds, HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -3630,6 +4951,7 @@ type FilesGetCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // Get: Gets a file's metadata or content by ID. @@ -3648,6 +4970,13 @@ func (c *FilesGetCall) AcknowledgeAbuse(acknowledgeAbuse bool) *FilesGetCall { return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *FilesGetCall) SupportsTeamDrives(supportsTeamDrives bool) *FilesGetCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -3674,23 +5003,38 @@ func (c *FilesGetCall) Context(ctx context.Context) *FilesGetCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *FilesGetCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *FilesGetCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Download fetches the API endpoint's "media" value, instead of the normal @@ -3741,7 +5085,8 @@ func (c *FilesGetCall) Do(opts ...googleapi.CallOption) (*File, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -3764,6 +5109,12 @@ func (c *FilesGetCall) Do(opts ...googleapi.CallOption) (*File, error) { // "location": "path", // "required": true, // "type": "string" + // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" // } // }, // "path": "files/{fileId}", @@ -3793,6 +5144,7 @@ type FilesListCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // List: Lists or searches files. @@ -3801,33 +5153,53 @@ func (r *FilesService) List() *FilesListCall { return c } +// Corpora sets the optional parameter "corpora": Comma-separated list +// of bodies of items (files/documents) to which the query applies. +// Supported bodies are 'user', 'domain', 'teamDrive' and +// 'allTeamDrives'. 'allTeamDrives' must be combined with 'user'; all +// other values must be used in isolation. Prefer 'user' or 'teamDrive' +// to 'allTeamDrives' for efficiency. +func (c *FilesListCall) Corpora(corpora string) *FilesListCall { + c.urlParams_.Set("corpora", corpora) + return c +} + // Corpus sets the optional parameter "corpus": The source of files to -// list. +// list. Deprecated: use 'corpora' instead. // // Possible values: // "domain" - Files shared to the user's domain. -// "user" (default) - Files owned by or shared to the user. +// "user" - Files owned by or shared to the user. func (c *FilesListCall) Corpus(corpus string) *FilesListCall { c.urlParams_.Set("corpus", corpus) return c } +// IncludeTeamDriveItems sets the optional parameter +// "includeTeamDriveItems": Whether Team Drive items should be included +// in results. +func (c *FilesListCall) IncludeTeamDriveItems(includeTeamDriveItems bool) *FilesListCall { + c.urlParams_.Set("includeTeamDriveItems", fmt.Sprint(includeTeamDriveItems)) + return c +} + // OrderBy sets the optional parameter "orderBy": A comma-separated list // of sort keys. Valid keys are 'createdTime', 'folder', -// 'modifiedByMeTime', 'modifiedTime', 'name', 'quotaBytesUsed', -// 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. Each -// key sorts ascending by default, but may be reversed with the 'desc' -// modifier. Example usage: ?orderBy=folder,modifiedTime desc,name. -// Please note that there is a current limitation for users with -// approximately one million files in which the requested sort order is -// ignored. +// 'modifiedByMeTime', 'modifiedTime', 'name', 'name_natural', +// 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and +// 'viewedByMeTime'. Each key sorts ascending by default, but may be +// reversed with the 'desc' modifier. Example usage: +// ?orderBy=folder,modifiedTime desc,name. Please note that there is a +// current limitation for users with approximately one million files in +// which the requested sort order is ignored. func (c *FilesListCall) OrderBy(orderBy string) *FilesListCall { c.urlParams_.Set("orderBy", orderBy) return c } // PageSize sets the optional parameter "pageSize": The maximum number -// of files to return per page. +// of files to return per page. Partial or empty result pages are +// possible even before the end of the files list has been reached. func (c *FilesListCall) PageSize(pageSize int64) *FilesListCall { c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) return c @@ -3856,6 +5228,20 @@ func (c *FilesListCall) Spaces(spaces string) *FilesListCall { return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *FilesListCall) SupportsTeamDrives(supportsTeamDrives bool) *FilesListCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + +// TeamDriveId sets the optional parameter "teamDriveId": ID of Team +// Drive to search. +func (c *FilesListCall) TeamDriveId(teamDriveId string) *FilesListCall { + c.urlParams_.Set("teamDriveId", teamDriveId) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -3882,21 +5268,35 @@ func (c *FilesListCall) Context(ctx context.Context) *FilesListCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *FilesListCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *FilesListCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) - googleapi.SetOpaque(req.URL) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + req.Header = reqHeaders + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.files.list" call. @@ -3931,7 +5331,8 @@ func (c *FilesListCall) Do(opts ...googleapi.CallOption) (*FileList, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -3940,9 +5341,13 @@ func (c *FilesListCall) Do(opts ...googleapi.CallOption) (*FileList, error) { // "httpMethod": "GET", // "id": "drive.files.list", // "parameters": { + // "corpora": { + // "description": "Comma-separated list of bodies of items (files/documents) to which the query applies. Supported bodies are 'user', 'domain', 'teamDrive' and 'allTeamDrives'. 'allTeamDrives' must be combined with 'user'; all other values must be used in isolation. Prefer 'user' or 'teamDrive' to 'allTeamDrives' for efficiency.", + // "location": "query", + // "type": "string" + // }, // "corpus": { - // "default": "user", - // "description": "The source of files to list.", + // "description": "The source of files to list. Deprecated: use 'corpora' instead.", // "enum": [ // "domain", // "user" @@ -3954,14 +5359,20 @@ func (c *FilesListCall) Do(opts ...googleapi.CallOption) (*FileList, error) { // "location": "query", // "type": "string" // }, + // "includeTeamDriveItems": { + // "default": "false", + // "description": "Whether Team Drive items should be included in results.", + // "location": "query", + // "type": "boolean" + // }, // "orderBy": { - // "description": "A comma-separated list of sort keys. Valid keys are 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. Each key sorts ascending by default, but may be reversed with the 'desc' modifier. Example usage: ?orderBy=folder,modifiedTime desc,name. Please note that there is a current limitation for users with approximately one million files in which the requested sort order is ignored.", + // "description": "A comma-separated list of sort keys. Valid keys are 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. Each key sorts ascending by default, but may be reversed with the 'desc' modifier. Example usage: ?orderBy=folder,modifiedTime desc,name. Please note that there is a current limitation for users with approximately one million files in which the requested sort order is ignored.", // "location": "query", // "type": "string" // }, // "pageSize": { // "default": "100", - // "description": "The maximum number of files to return per page.", + // "description": "The maximum number of files to return per page. Partial or empty result pages are possible even before the end of the files list has been reached.", // "format": "int32", // "location": "query", // "maximum": "1000", @@ -3983,6 +5394,17 @@ func (c *FilesListCall) Do(opts ...googleapi.CallOption) (*FileList, error) { // "description": "A comma-separated list of spaces to query within the corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.", // "location": "query", // "type": "string" + // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" + // }, + // "teamDriveId": { + // "description": "ID of Team Drive to search.", + // "location": "query", + // "type": "string" // } // }, // "path": "files", @@ -4026,16 +5448,13 @@ func (c *FilesListCall) Pages(ctx context.Context, f func(*FileList) error) erro // method id "drive.files.update": type FilesUpdateCall struct { - s *Service - fileId string - file *File - urlParams_ gensupport.URLParams - media_ io.Reader - resumableBuffer_ *gensupport.ResumableBuffer - mediaType_ string - mediaSize_ int64 // mediaSize, if known. Used only for calls to progressUpdater_. - progressUpdater_ googleapi.ProgressUpdater - ctx_ context.Context + s *Service + fileId string + file *File + urlParams_ gensupport.URLParams + mediaInfo_ *gensupport.MediaInfo + ctx_ context.Context + header_ http.Header } // Update: Updates a file's metadata and/or content with patch @@ -4077,6 +5496,13 @@ func (c *FilesUpdateCall) RemoveParents(removeParents string) *FilesUpdateCall { return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *FilesUpdateCall) SupportsTeamDrives(supportsTeamDrives bool) *FilesUpdateCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + // UseContentAsIndexableText sets the optional parameter // "useContentAsIndexableText": Whether to use the uploaded content as // indexable text. @@ -4094,12 +5520,7 @@ func (c *FilesUpdateCall) UseContentAsIndexableText(useContentAsIndexableText bo // supplied. // At most one of Media and ResumableMedia may be set. func (c *FilesUpdateCall) Media(r io.Reader, options ...googleapi.MediaOption) *FilesUpdateCall { - opts := googleapi.ProcessMediaOptions(options) - chunkSize := opts.ChunkSize - if !opts.ForceEmptyContentType { - r, c.mediaType_ = gensupport.DetermineContentType(r, opts.ContentType) - } - c.media_, c.resumableBuffer_ = gensupport.PrepareUpload(r, chunkSize) + c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options) return c } @@ -4114,11 +5535,7 @@ func (c *FilesUpdateCall) Media(r io.Reader, options ...googleapi.MediaOption) * // supersede any context previously provided to the Context method. func (c *FilesUpdateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *FilesUpdateCall { c.ctx_ = ctx - rdr := gensupport.ReaderAtToReader(r, size) - rdr, c.mediaType_ = gensupport.DetermineContentType(rdr, mediaType) - c.resumableBuffer_ = gensupport.NewResumableBuffer(rdr, googleapi.DefaultUploadChunkSize) - c.media_ = nil - c.mediaSize_ = size + c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType) return c } @@ -4127,7 +5544,7 @@ func (c *FilesUpdateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, siz // not slow down the upload operation. This should only be called when // using ResumableMedia (as opposed to Media). func (c *FilesUpdateCall) ProgressUpdater(pu googleapi.ProgressUpdater) *FilesUpdateCall { - c.progressUpdater_ = pu + c.mediaInfo_.SetProgressUpdater(pu) return c } @@ -4149,43 +5566,51 @@ func (c *FilesUpdateCall) Context(ctx context.Context) *FilesUpdateCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *FilesUpdateCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *FilesUpdateCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.file) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}") - if c.media_ != nil || c.resumableBuffer_ != nil { + if c.mediaInfo_ != nil { urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1) - protocol := "multipart" - if c.resumableBuffer_ != nil { - protocol = "resumable" - } - c.urlParams_.Set("uploadType", protocol) + c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType()) + } + if body == nil { + body = new(bytes.Buffer) + reqHeaders.Set("Content-Type", "application/json") } + body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body) + defer cleanup() urls += "?" + c.urlParams_.Encode() - if c.media_ != nil { - var combined io.ReadCloser - combined, ctype = gensupport.CombineBodyMedia(body, ctype, c.media_, c.mediaType_) - defer combined.Close() - body = combined + req, err := http.NewRequest("PATCH", urls, body) + if err != nil { + return nil, err } - req, _ := http.NewRequest("PATCH", urls, body) + req.Header = reqHeaders + gensupport.SetGetBody(req, getBody) googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, }) - if c.resumableBuffer_ != nil && c.mediaType_ != "" { - req.Header.Set("X-Upload-Content-Type", c.mediaType_) - } - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.files.update" call. @@ -4214,20 +5639,10 @@ func (c *FilesUpdateCall) Do(opts ...googleapi.CallOption) (*File, error) { if err := googleapi.CheckResponse(res); err != nil { return nil, err } - if c.resumableBuffer_ != nil { - loc := res.Header.Get("Location") - rx := &gensupport.ResumableUpload{ - Client: c.s.client, - UserAgent: c.s.userAgent(), - URI: loc, - Media: c.resumableBuffer_, - MediaType: c.mediaType_, - Callback: func(curr int64) { - if c.progressUpdater_ != nil { - c.progressUpdater_(curr, c.mediaSize_) - } - }, - } + rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location")) + if rx != nil { + rx.Client = c.s.client + rx.UserAgent = c.s.userAgent() ctx := c.ctx_ if ctx == nil { ctx = context.TODO() @@ -4247,7 +5662,8 @@ func (c *FilesUpdateCall) Do(opts ...googleapi.CallOption) (*File, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -4302,6 +5718,12 @@ func (c *FilesUpdateCall) Do(opts ...googleapi.CallOption) (*File, error) { // "location": "query", // "type": "string" // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" + // }, // "useContentAsIndexableText": { // "default": "false", // "description": "Whether to use the uploaded content as indexable text.", @@ -4336,6 +5758,7 @@ type FilesWatchCall struct { channel *Channel urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Watch: Subscribes to changes to a file @@ -4355,6 +5778,13 @@ func (c *FilesWatchCall) AcknowledgeAbuse(acknowledgeAbuse bool) *FilesWatchCall return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *FilesWatchCall) SupportsTeamDrives(supportsTeamDrives bool) *FilesWatchCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -4371,26 +5801,40 @@ func (c *FilesWatchCall) Context(ctx context.Context) *FilesWatchCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *FilesWatchCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *FilesWatchCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/watch") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("POST", urls, body) + req, err := http.NewRequest("POST", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, }) - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Download fetches the API endpoint's "media" value, instead of the normal @@ -4441,7 +5885,8 @@ func (c *FilesWatchCall) Do(opts ...googleapi.CallOption) (*Channel, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -4464,6 +5909,12 @@ func (c *FilesWatchCall) Do(opts ...googleapi.CallOption) (*Channel, error) { // "location": "path", // "required": true, // "type": "string" + // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" // } // }, // "path": "files/{fileId}/watch", @@ -4498,9 +5949,10 @@ type PermissionsCreateCall struct { permission *Permission urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } -// Create: Creates a permission for a file. +// Create: Creates a permission for a file or Team Drive. func (r *PermissionsService) Create(fileId string, permission *Permission) *PermissionsCreateCall { c := &PermissionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.fileId = fileId @@ -4508,8 +5960,8 @@ func (r *PermissionsService) Create(fileId string, permission *Permission) *Perm return c } -// EmailMessage sets the optional parameter "emailMessage": A custom -// message to include in the notification email. +// EmailMessage sets the optional parameter "emailMessage": A plain text +// custom message to include in the notification email. func (c *PermissionsCreateCall) EmailMessage(emailMessage string) *PermissionsCreateCall { c.urlParams_.Set("emailMessage", emailMessage) return c @@ -4525,6 +5977,13 @@ func (c *PermissionsCreateCall) SendNotificationEmail(sendNotificationEmail bool return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *PermissionsCreateCall) SupportsTeamDrives(supportsTeamDrives bool) *PermissionsCreateCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + // TransferOwnership sets the optional parameter "transferOwnership": // Whether to transfer ownership to the specified user and downgrade the // current owner to a writer. This parameter is required as an @@ -4534,6 +5993,15 @@ func (c *PermissionsCreateCall) TransferOwnership(transferOwnership bool) *Permi return c } +// UseDomainAdminAccess sets the optional parameter +// "useDomainAdminAccess": Issue the request as 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. +func (c *PermissionsCreateCall) UseDomainAdminAccess(useDomainAdminAccess bool) *PermissionsCreateCall { + c.urlParams_.Set("useDomainAdminAccess", fmt.Sprint(useDomainAdminAccess)) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -4550,26 +6018,40 @@ func (c *PermissionsCreateCall) Context(ctx context.Context) *PermissionsCreateC return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *PermissionsCreateCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *PermissionsCreateCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.permission) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/permissions") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("POST", urls, body) + req, err := http.NewRequest("POST", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, }) - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.permissions.create" call. @@ -4604,12 +6086,13 @@ func (c *PermissionsCreateCall) Do(opts ...googleapi.CallOption) (*Permission, e HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil // { - // "description": "Creates a permission for a file.", + // "description": "Creates a permission for a file or Team Drive.", // "httpMethod": "POST", // "id": "drive.permissions.create", // "parameterOrder": [ @@ -4617,12 +6100,12 @@ func (c *PermissionsCreateCall) Do(opts ...googleapi.CallOption) (*Permission, e // ], // "parameters": { // "emailMessage": { - // "description": "A custom message to include in the notification email.", + // "description": "A plain text custom message to include in the notification email.", // "location": "query", // "type": "string" // }, // "fileId": { - // "description": "The ID of the file.", + // "description": "The ID of the file or Team Drive.", // "location": "path", // "required": true, // "type": "string" @@ -4632,11 +6115,23 @@ func (c *PermissionsCreateCall) Do(opts ...googleapi.CallOption) (*Permission, e // "location": "query", // "type": "boolean" // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" + // }, // "transferOwnership": { // "default": "false", // "description": "Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect.", // "location": "query", // "type": "boolean" + // }, + // "useDomainAdminAccess": { + // "default": "false", + // "description": "Issue the request as 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.", + // "location": "query", + // "type": "boolean" // } // }, // "path": "files/{fileId}/permissions", @@ -4662,6 +6157,7 @@ type PermissionsDeleteCall struct { permissionId string urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Delete: Deletes a permission. @@ -4672,6 +6168,22 @@ func (r *PermissionsService) Delete(fileId string, permissionId string) *Permiss return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *PermissionsDeleteCall) SupportsTeamDrives(supportsTeamDrives bool) *PermissionsDeleteCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + +// UseDomainAdminAccess sets the optional parameter +// "useDomainAdminAccess": Issue the request as 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. +func (c *PermissionsDeleteCall) UseDomainAdminAccess(useDomainAdminAccess bool) *PermissionsDeleteCall { + c.urlParams_.Set("useDomainAdminAccess", fmt.Sprint(useDomainAdminAccess)) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -4688,21 +6200,36 @@ func (c *PermissionsDeleteCall) Context(ctx context.Context) *PermissionsDeleteC return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *PermissionsDeleteCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *PermissionsDeleteCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/permissions/{permissionId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("DELETE", urls, body) + req, err := http.NewRequest("DELETE", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "permissionId": c.permissionId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.permissions.delete" call. @@ -4727,7 +6254,7 @@ func (c *PermissionsDeleteCall) Do(opts ...googleapi.CallOption) error { // ], // "parameters": { // "fileId": { - // "description": "The ID of the file.", + // "description": "The ID of the file or Team Drive.", // "location": "path", // "required": true, // "type": "string" @@ -4737,6 +6264,18 @@ func (c *PermissionsDeleteCall) Do(opts ...googleapi.CallOption) error { // "location": "path", // "required": true, // "type": "string" + // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" + // }, + // "useDomainAdminAccess": { + // "default": "false", + // "description": "Issue the request as 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.", + // "location": "query", + // "type": "boolean" // } // }, // "path": "files/{fileId}/permissions/{permissionId}", @@ -4757,6 +6296,7 @@ type PermissionsGetCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // Get: Gets a permission by ID. @@ -4767,6 +6307,22 @@ func (r *PermissionsService) Get(fileId string, permissionId string) *Permission return c } +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *PermissionsGetCall) SupportsTeamDrives(supportsTeamDrives bool) *PermissionsGetCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + +// UseDomainAdminAccess sets the optional parameter +// "useDomainAdminAccess": Issue the request as 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. +func (c *PermissionsGetCall) UseDomainAdminAccess(useDomainAdminAccess bool) *PermissionsGetCall { + c.urlParams_.Set("useDomainAdminAccess", fmt.Sprint(useDomainAdminAccess)) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -4793,24 +6349,39 @@ func (c *PermissionsGetCall) Context(ctx context.Context) *PermissionsGetCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *PermissionsGetCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *PermissionsGetCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/permissions/{permissionId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "permissionId": c.permissionId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.permissions.get" call. @@ -4845,7 +6416,8 @@ func (c *PermissionsGetCall) Do(opts ...googleapi.CallOption) (*Permission, erro HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -4869,6 +6441,18 @@ func (c *PermissionsGetCall) Do(opts ...googleapi.CallOption) (*Permission, erro // "location": "path", // "required": true, // "type": "string" + // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" + // }, + // "useDomainAdminAccess": { + // "default": "false", + // "description": "Issue the request as 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.", + // "location": "query", + // "type": "boolean" // } // }, // "path": "files/{fileId}/permissions/{permissionId}", @@ -4895,15 +6479,49 @@ type PermissionsListCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } -// List: Lists a file's permissions. +// List: Lists a file's or Team Drive's permissions. func (r *PermissionsService) List(fileId string) *PermissionsListCall { c := &PermissionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.fileId = fileId return c } +// PageSize sets the optional parameter "pageSize": The maximum number +// of permissions to return per page. When not set for files in a Team +// Drive, at most 100 results will be returned. When not set for files +// that are not in a Team Drive, the entire list will be returned. +func (c *PermissionsListCall) PageSize(pageSize int64) *PermissionsListCall { + c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) + return c +} + +// PageToken sets the optional parameter "pageToken": The token for +// continuing a previous list request on the next page. This should be +// set to the value of 'nextPageToken' from the previous response. +func (c *PermissionsListCall) PageToken(pageToken string) *PermissionsListCall { + c.urlParams_.Set("pageToken", pageToken) + return c +} + +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *PermissionsListCall) SupportsTeamDrives(supportsTeamDrives bool) *PermissionsListCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + +// UseDomainAdminAccess sets the optional parameter +// "useDomainAdminAccess": Issue the request as 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. +func (c *PermissionsListCall) UseDomainAdminAccess(useDomainAdminAccess bool) *PermissionsListCall { + c.urlParams_.Set("useDomainAdminAccess", fmt.Sprint(useDomainAdminAccess)) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -4930,23 +6548,38 @@ func (c *PermissionsListCall) Context(ctx context.Context) *PermissionsListCall return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *PermissionsListCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *PermissionsListCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/permissions") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.permissions.list" call. @@ -4981,12 +6614,13 @@ func (c *PermissionsListCall) Do(opts ...googleapi.CallOption) (*PermissionList, HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil // { - // "description": "Lists a file's permissions.", + // "description": "Lists a file's or Team Drive's permissions.", // "httpMethod": "GET", // "id": "drive.permissions.list", // "parameterOrder": [ @@ -4994,10 +6628,35 @@ func (c *PermissionsListCall) Do(opts ...googleapi.CallOption) (*PermissionList, // ], // "parameters": { // "fileId": { - // "description": "The ID of the file.", + // "description": "The ID of the file or Team Drive.", // "location": "path", // "required": true, // "type": "string" + // }, + // "pageSize": { + // "description": "The maximum number of permissions to return per page. When not set for files in a Team Drive, at most 100 results will be returned. When not set for files that are not in a Team Drive, the entire list will be returned.", + // "format": "int32", + // "location": "query", + // "maximum": "100", + // "minimum": "1", + // "type": "integer" + // }, + // "pageToken": { + // "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.", + // "location": "query", + // "type": "string" + // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" + // }, + // "useDomainAdminAccess": { + // "default": "false", + // "description": "Issue the request as 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.", + // "location": "query", + // "type": "boolean" // } // }, // "path": "files/{fileId}/permissions", @@ -5016,6 +6675,27 @@ func (c *PermissionsListCall) Do(opts ...googleapi.CallOption) (*PermissionList, } +// Pages invokes f for each page of results. +// A non-nil error returned from f will halt the iteration. +// The provided context supersedes any context provided to the Context method. +func (c *PermissionsListCall) Pages(ctx context.Context, f func(*PermissionList) error) error { + c.ctx_ = ctx + defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point + for { + x, err := c.Do() + if err != nil { + return err + } + if err := f(x); err != nil { + return err + } + if x.NextPageToken == "" { + return nil + } + c.PageToken(x.NextPageToken) + } +} + // method id "drive.permissions.update": type PermissionsUpdateCall struct { @@ -5025,6 +6705,7 @@ type PermissionsUpdateCall struct { permission *Permission urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Update: Updates a permission with patch semantics. @@ -5036,6 +6717,20 @@ func (r *PermissionsService) Update(fileId string, permissionId string, permissi return c } +// RemoveExpiration sets the optional parameter "removeExpiration": +// Whether to remove the expiration date. +func (c *PermissionsUpdateCall) RemoveExpiration(removeExpiration bool) *PermissionsUpdateCall { + c.urlParams_.Set("removeExpiration", fmt.Sprint(removeExpiration)) + return c +} + +// SupportsTeamDrives sets the optional parameter "supportsTeamDrives": +// Whether the requesting application supports Team Drives. +func (c *PermissionsUpdateCall) SupportsTeamDrives(supportsTeamDrives bool) *PermissionsUpdateCall { + c.urlParams_.Set("supportsTeamDrives", fmt.Sprint(supportsTeamDrives)) + return c +} + // TransferOwnership sets the optional parameter "transferOwnership": // Whether to transfer ownership to the specified user and downgrade the // current owner to a writer. This parameter is required as an @@ -5045,6 +6740,15 @@ func (c *PermissionsUpdateCall) TransferOwnership(transferOwnership bool) *Permi return c } +// UseDomainAdminAccess sets the optional parameter +// "useDomainAdminAccess": Issue the request as 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. +func (c *PermissionsUpdateCall) UseDomainAdminAccess(useDomainAdminAccess bool) *PermissionsUpdateCall { + c.urlParams_.Set("useDomainAdminAccess", fmt.Sprint(useDomainAdminAccess)) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -5061,27 +6765,41 @@ func (c *PermissionsUpdateCall) Context(ctx context.Context) *PermissionsUpdateC return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *PermissionsUpdateCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *PermissionsUpdateCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.permission) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/permissions/{permissionId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("PATCH", urls, body) + req, err := http.NewRequest("PATCH", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "permissionId": c.permissionId, }) - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.permissions.update" call. @@ -5116,7 +6834,8 @@ func (c *PermissionsUpdateCall) Do(opts ...googleapi.CallOption) (*Permission, e HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -5130,7 +6849,7 @@ func (c *PermissionsUpdateCall) Do(opts ...googleapi.CallOption) (*Permission, e // ], // "parameters": { // "fileId": { - // "description": "The ID of the file.", + // "description": "The ID of the file or Team Drive.", // "location": "path", // "required": true, // "type": "string" @@ -5141,11 +6860,29 @@ func (c *PermissionsUpdateCall) Do(opts ...googleapi.CallOption) (*Permission, e // "required": true, // "type": "string" // }, + // "removeExpiration": { + // "default": "false", + // "description": "Whether to remove the expiration date.", + // "location": "query", + // "type": "boolean" + // }, + // "supportsTeamDrives": { + // "default": "false", + // "description": "Whether the requesting application supports Team Drives.", + // "location": "query", + // "type": "boolean" + // }, // "transferOwnership": { // "default": "false", // "description": "Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect.", // "location": "query", // "type": "boolean" + // }, + // "useDomainAdminAccess": { + // "default": "false", + // "description": "Issue the request as 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.", + // "location": "query", + // "type": "boolean" // } // }, // "path": "files/{fileId}/permissions/{permissionId}", @@ -5172,6 +6909,7 @@ type RepliesCreateCall struct { reply *Reply urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Create: Creates a new reply to a comment. @@ -5199,27 +6937,41 @@ func (c *RepliesCreateCall) Context(ctx context.Context) *RepliesCreateCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *RepliesCreateCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *RepliesCreateCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.reply) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}/replies") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("POST", urls, body) + req, err := http.NewRequest("POST", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "commentId": c.commentId, }) - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.replies.create" call. @@ -5254,7 +7006,8 @@ func (c *RepliesCreateCall) Do(opts ...googleapi.CallOption) (*Reply, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -5304,6 +7057,7 @@ type RepliesDeleteCall struct { replyId string urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Delete: Deletes a reply. @@ -5331,22 +7085,37 @@ func (c *RepliesDeleteCall) Context(ctx context.Context) *RepliesDeleteCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *RepliesDeleteCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *RepliesDeleteCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}/replies/{replyId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("DELETE", urls, body) + req, err := http.NewRequest("DELETE", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "commentId": c.commentId, "replyId": c.replyId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.replies.delete" call. @@ -5409,6 +7178,7 @@ type RepliesGetCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // Get: Gets a reply by ID. @@ -5454,25 +7224,40 @@ func (c *RepliesGetCall) Context(ctx context.Context) *RepliesGetCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *RepliesGetCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *RepliesGetCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}/replies/{replyId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "commentId": c.commentId, "replyId": c.replyId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.replies.get" call. @@ -5507,7 +7292,8 @@ func (c *RepliesGetCall) Do(opts ...googleapi.CallOption) (*Reply, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -5568,6 +7354,7 @@ type RepliesListCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // List: Lists a comment's replies. @@ -5627,24 +7414,39 @@ func (c *RepliesListCall) Context(ctx context.Context) *RepliesListCall { return c } -func (c *RepliesListCall) doRequest(alt string) (*http.Response, error) { +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *RepliesListCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *RepliesListCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}/replies") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "commentId": c.commentId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.replies.list" call. @@ -5679,7 +7481,8 @@ func (c *RepliesListCall) Do(opts ...googleapi.CallOption) (*ReplyList, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -5769,6 +7572,7 @@ type RepliesUpdateCall struct { reply *Reply urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Update: Updates a reply with patch semantics. @@ -5797,28 +7601,42 @@ func (c *RepliesUpdateCall) Context(ctx context.Context) *RepliesUpdateCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *RepliesUpdateCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *RepliesUpdateCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.reply) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}/replies/{replyId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("PATCH", urls, body) + req, err := http.NewRequest("PATCH", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "commentId": c.commentId, "replyId": c.replyId, }) - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.replies.update" call. @@ -5853,7 +7671,8 @@ func (c *RepliesUpdateCall) Do(opts ...googleapi.CallOption) (*Reply, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -5909,6 +7728,7 @@ type RevisionsDeleteCall struct { revisionId string urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Delete: Permanently deletes a revision. This method is only @@ -5936,21 +7756,36 @@ func (c *RevisionsDeleteCall) Context(ctx context.Context) *RevisionsDeleteCall return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *RevisionsDeleteCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *RevisionsDeleteCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/revisions/{revisionId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("DELETE", urls, body) + req, err := http.NewRequest("DELETE", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "revisionId": c.revisionId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.revisions.delete" call. @@ -6006,6 +7841,7 @@ type RevisionsGetCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // Get: Gets a revision's metadata or content by ID. @@ -6051,24 +7887,39 @@ func (c *RevisionsGetCall) Context(ctx context.Context) *RevisionsGetCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *RevisionsGetCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *RevisionsGetCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/revisions/{revisionId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "revisionId": c.revisionId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Download fetches the API endpoint's "media" value, instead of the normal @@ -6119,7 +7970,8 @@ func (c *RevisionsGetCall) Do(opts ...googleapi.CallOption) (*Revision, error) { HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -6178,6 +8030,7 @@ type RevisionsListCall struct { urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context + header_ http.Header } // List: Lists a file's revisions. @@ -6187,6 +8040,21 @@ func (r *RevisionsService) List(fileId string) *RevisionsListCall { return c } +// PageSize sets the optional parameter "pageSize": The maximum number +// of revisions to return per page. +func (c *RevisionsListCall) PageSize(pageSize int64) *RevisionsListCall { + c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) + return c +} + +// PageToken sets the optional parameter "pageToken": The token for +// continuing a previous list request on the next page. This should be +// set to the value of 'nextPageToken' from the previous response. +func (c *RevisionsListCall) PageToken(pageToken string) *RevisionsListCall { + c.urlParams_.Set("pageToken", pageToken) + return c +} + // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. @@ -6213,23 +8081,38 @@ func (c *RevisionsListCall) Context(ctx context.Context) *RevisionsListCall { return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *RevisionsListCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *RevisionsListCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } var body io.Reader = nil c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/revisions") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("GET", urls, body) + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, }) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ifNoneMatch_ != "" { - req.Header.Set("If-None-Match", c.ifNoneMatch_) - } - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.revisions.list" call. @@ -6264,7 +8147,8 @@ func (c *RevisionsListCall) Do(opts ...googleapi.CallOption) (*RevisionList, err HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -6281,6 +8165,20 @@ func (c *RevisionsListCall) Do(opts ...googleapi.CallOption) (*RevisionList, err // "location": "path", // "required": true, // "type": "string" + // }, + // "pageSize": { + // "default": "200", + // "description": "The maximum number of revisions to return per page.", + // "format": "int32", + // "location": "query", + // "maximum": "1000", + // "minimum": "1", + // "type": "integer" + // }, + // "pageToken": { + // "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.", + // "location": "query", + // "type": "string" // } // }, // "path": "files/{fileId}/revisions", @@ -6300,6 +8198,27 @@ func (c *RevisionsListCall) Do(opts ...googleapi.CallOption) (*RevisionList, err } +// Pages invokes f for each page of results. +// A non-nil error returned from f will halt the iteration. +// The provided context supersedes any context provided to the Context method. +func (c *RevisionsListCall) Pages(ctx context.Context, f func(*RevisionList) error) error { + c.ctx_ = ctx + defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point + for { + x, err := c.Do() + if err != nil { + return err + } + if err := f(x); err != nil { + return err + } + if x.NextPageToken == "" { + return nil + } + c.PageToken(x.NextPageToken) + } +} + // method id "drive.revisions.update": type RevisionsUpdateCall struct { @@ -6309,6 +8228,7 @@ type RevisionsUpdateCall struct { revision *Revision urlParams_ gensupport.URLParams ctx_ context.Context + header_ http.Header } // Update: Updates a revision with patch semantics. @@ -6336,27 +8256,41 @@ func (c *RevisionsUpdateCall) Context(ctx context.Context) *RevisionsUpdateCall return c } +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *RevisionsUpdateCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + func (c *RevisionsUpdateCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.revision) if err != nil { return nil, err } - ctype := "application/json" + reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/revisions/{revisionId}") urls += "?" + c.urlParams_.Encode() - req, _ := http.NewRequest("PATCH", urls, body) + req, err := http.NewRequest("PATCH", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "fileId": c.fileId, "revisionId": c.revisionId, }) - req.Header.Set("Content-Type", ctype) - req.Header.Set("User-Agent", c.s.userAgent()) - if c.ctx_ != nil { - return ctxhttp.Do(c.ctx_, c.s.client, req) - } - return c.s.client.Do(req) + return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "drive.revisions.update" call. @@ -6391,7 +8325,8 @@ func (c *RevisionsUpdateCall) Do(opts ...googleapi.CallOption) (*Revision, error HTTPStatusCode: res.StatusCode, }, } - if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil @@ -6432,3 +8367,749 @@ func (c *RevisionsUpdateCall) Do(opts ...googleapi.CallOption) (*Revision, error // } } + +// method id "drive.teamdrives.create": + +type TeamdrivesCreateCall struct { + s *Service + teamdrive *TeamDrive + urlParams_ gensupport.URLParams + ctx_ context.Context + header_ http.Header +} + +// Create: Creates a new Team Drive. +func (r *TeamdrivesService) Create(requestId string, teamdrive *TeamDrive) *TeamdrivesCreateCall { + c := &TeamdrivesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.urlParams_.Set("requestId", requestId) + c.teamdrive = teamdrive + return c +} + +// Fields allows partial responses to be retrieved. See +// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse +// for more information. +func (c *TeamdrivesCreateCall) Fields(s ...googleapi.Field) *TeamdrivesCreateCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// Context sets the context to be used in this call's Do method. Any +// pending HTTP request will be aborted if the provided context is +// canceled. +func (c *TeamdrivesCreateCall) Context(ctx context.Context) *TeamdrivesCreateCall { + c.ctx_ = ctx + return c +} + +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *TeamdrivesCreateCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *TeamdrivesCreateCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.teamdrive) + if err != nil { + return nil, err + } + reqHeaders.Set("Content-Type", "application/json") + c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") + urls := googleapi.ResolveRelative(c.s.BasePath, "teamdrives") + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("POST", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders + return gensupport.SendRequest(c.ctx_, c.s.client, req) +} + +// Do executes the "drive.teamdrives.create" call. +// Exactly one of *TeamDrive or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *TeamDrive.ServerResponse.Header or (if a response was returned at +// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified +// to check whether the returned error was because +// http.StatusNotModified was returned. +func (c *TeamdrivesCreateCall) Do(opts ...googleapi.CallOption) (*TeamDrive, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("json") + if res != nil && res.StatusCode == http.StatusNotModified { + if res.Body != nil { + res.Body.Close() + } + return nil, &googleapi.Error{ + Code: res.StatusCode, + Header: res.Header, + } + } + if err != nil { + return nil, err + } + defer googleapi.CloseBody(res) + if err := googleapi.CheckResponse(res); err != nil { + return nil, err + } + ret := &TeamDrive{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Creates a new Team Drive.", + // "httpMethod": "POST", + // "id": "drive.teamdrives.create", + // "parameterOrder": [ + // "requestId" + // ], + // "parameters": { + // "requestId": { + // "description": "An ID, such as a random UUID, which uniquely identifies this user's request for idempotent creation of a Team Drive. A repeated request by the same user and with the same request ID will avoid creating duplicates by attempting to create the same Team Drive. If the Team Drive already exists a 409 error will be returned.", + // "location": "query", + // "required": true, + // "type": "string" + // } + // }, + // "path": "teamdrives", + // "request": { + // "$ref": "TeamDrive" + // }, + // "response": { + // "$ref": "TeamDrive" + // }, + // "scopes": [ + // "https://www.googleapis.com/auth/drive" + // ] + // } + +} + +// method id "drive.teamdrives.delete": + +type TeamdrivesDeleteCall struct { + s *Service + teamDriveId string + urlParams_ gensupport.URLParams + ctx_ context.Context + header_ http.Header +} + +// Delete: Permanently deletes a Team Drive for which the user is an +// organizer. The Team Drive cannot contain any untrashed items. +func (r *TeamdrivesService) Delete(teamDriveId string) *TeamdrivesDeleteCall { + c := &TeamdrivesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.teamDriveId = teamDriveId + return c +} + +// Fields allows partial responses to be retrieved. See +// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse +// for more information. +func (c *TeamdrivesDeleteCall) Fields(s ...googleapi.Field) *TeamdrivesDeleteCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// Context sets the context to be used in this call's Do method. Any +// pending HTTP request will be aborted if the provided context is +// canceled. +func (c *TeamdrivesDeleteCall) Context(ctx context.Context) *TeamdrivesDeleteCall { + c.ctx_ = ctx + return c +} + +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *TeamdrivesDeleteCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *TeamdrivesDeleteCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") + urls := googleapi.ResolveRelative(c.s.BasePath, "teamdrives/{teamDriveId}") + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("DELETE", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders + googleapi.Expand(req.URL, map[string]string{ + "teamDriveId": c.teamDriveId, + }) + return gensupport.SendRequest(c.ctx_, c.s.client, req) +} + +// Do executes the "drive.teamdrives.delete" call. +func (c *TeamdrivesDeleteCall) Do(opts ...googleapi.CallOption) error { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("json") + if err != nil { + return err + } + defer googleapi.CloseBody(res) + if err := googleapi.CheckResponse(res); err != nil { + return err + } + return nil + // { + // "description": "Permanently deletes a Team Drive for which the user is an organizer. The Team Drive cannot contain any untrashed items.", + // "httpMethod": "DELETE", + // "id": "drive.teamdrives.delete", + // "parameterOrder": [ + // "teamDriveId" + // ], + // "parameters": { + // "teamDriveId": { + // "description": "The ID of the Team Drive", + // "location": "path", + // "required": true, + // "type": "string" + // } + // }, + // "path": "teamdrives/{teamDriveId}", + // "scopes": [ + // "https://www.googleapis.com/auth/drive" + // ] + // } + +} + +// method id "drive.teamdrives.get": + +type TeamdrivesGetCall struct { + s *Service + teamDriveId string + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context + header_ http.Header +} + +// Get: Gets a Team Drive's metadata by ID. +func (r *TeamdrivesService) Get(teamDriveId string) *TeamdrivesGetCall { + c := &TeamdrivesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.teamDriveId = teamDriveId + return c +} + +// UseDomainAdminAccess sets the optional parameter +// "useDomainAdminAccess": Issue the request as 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. +func (c *TeamdrivesGetCall) UseDomainAdminAccess(useDomainAdminAccess bool) *TeamdrivesGetCall { + c.urlParams_.Set("useDomainAdminAccess", fmt.Sprint(useDomainAdminAccess)) + return c +} + +// Fields allows partial responses to be retrieved. See +// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse +// for more information. +func (c *TeamdrivesGetCall) Fields(s ...googleapi.Field) *TeamdrivesGetCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// IfNoneMatch sets the optional parameter which makes the operation +// fail if the object's ETag matches the given value. This is useful for +// getting updates only after the object has changed since the last +// request. Use googleapi.IsNotModified to check whether the response +// error from Do is the result of In-None-Match. +func (c *TeamdrivesGetCall) IfNoneMatch(entityTag string) *TeamdrivesGetCall { + c.ifNoneMatch_ = entityTag + return c +} + +// Context sets the context to be used in this call's Do method. Any +// pending HTTP request will be aborted if the provided context is +// canceled. +func (c *TeamdrivesGetCall) Context(ctx context.Context) *TeamdrivesGetCall { + c.ctx_ = ctx + return c +} + +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *TeamdrivesGetCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *TeamdrivesGetCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") + urls := googleapi.ResolveRelative(c.s.BasePath, "teamdrives/{teamDriveId}") + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders + googleapi.Expand(req.URL, map[string]string{ + "teamDriveId": c.teamDriveId, + }) + return gensupport.SendRequest(c.ctx_, c.s.client, req) +} + +// Do executes the "drive.teamdrives.get" call. +// Exactly one of *TeamDrive or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *TeamDrive.ServerResponse.Header or (if a response was returned at +// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified +// to check whether the returned error was because +// http.StatusNotModified was returned. +func (c *TeamdrivesGetCall) Do(opts ...googleapi.CallOption) (*TeamDrive, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("json") + if res != nil && res.StatusCode == http.StatusNotModified { + if res.Body != nil { + res.Body.Close() + } + return nil, &googleapi.Error{ + Code: res.StatusCode, + Header: res.Header, + } + } + if err != nil { + return nil, err + } + defer googleapi.CloseBody(res) + if err := googleapi.CheckResponse(res); err != nil { + return nil, err + } + ret := &TeamDrive{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Gets a Team Drive's metadata by ID.", + // "httpMethod": "GET", + // "id": "drive.teamdrives.get", + // "parameterOrder": [ + // "teamDriveId" + // ], + // "parameters": { + // "teamDriveId": { + // "description": "The ID of the Team Drive", + // "location": "path", + // "required": true, + // "type": "string" + // }, + // "useDomainAdminAccess": { + // "default": "false", + // "description": "Issue the request as 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.", + // "location": "query", + // "type": "boolean" + // } + // }, + // "path": "teamdrives/{teamDriveId}", + // "response": { + // "$ref": "TeamDrive" + // }, + // "scopes": [ + // "https://www.googleapis.com/auth/drive", + // "https://www.googleapis.com/auth/drive.readonly" + // ] + // } + +} + +// method id "drive.teamdrives.list": + +type TeamdrivesListCall struct { + s *Service + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context + header_ http.Header +} + +// List: Lists the user's Team Drives. +func (r *TeamdrivesService) List() *TeamdrivesListCall { + c := &TeamdrivesListCall{s: r.s, urlParams_: make(gensupport.URLParams)} + return c +} + +// PageSize sets the optional parameter "pageSize": Maximum number of +// Team Drives to return. +func (c *TeamdrivesListCall) PageSize(pageSize int64) *TeamdrivesListCall { + c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) + return c +} + +// PageToken sets the optional parameter "pageToken": Page token for +// Team Drives. +func (c *TeamdrivesListCall) PageToken(pageToken string) *TeamdrivesListCall { + c.urlParams_.Set("pageToken", pageToken) + return c +} + +// Q sets the optional parameter "q": Query string for searching Team +// Drives. +func (c *TeamdrivesListCall) Q(q string) *TeamdrivesListCall { + c.urlParams_.Set("q", q) + return c +} + +// UseDomainAdminAccess sets the optional parameter +// "useDomainAdminAccess": Issue the request as a domain administrator; +// if set to true, then all Team Drives of the domain in which the +// requester is an administrator are returned. +func (c *TeamdrivesListCall) UseDomainAdminAccess(useDomainAdminAccess bool) *TeamdrivesListCall { + c.urlParams_.Set("useDomainAdminAccess", fmt.Sprint(useDomainAdminAccess)) + return c +} + +// Fields allows partial responses to be retrieved. See +// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse +// for more information. +func (c *TeamdrivesListCall) Fields(s ...googleapi.Field) *TeamdrivesListCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// IfNoneMatch sets the optional parameter which makes the operation +// fail if the object's ETag matches the given value. This is useful for +// getting updates only after the object has changed since the last +// request. Use googleapi.IsNotModified to check whether the response +// error from Do is the result of In-None-Match. +func (c *TeamdrivesListCall) IfNoneMatch(entityTag string) *TeamdrivesListCall { + c.ifNoneMatch_ = entityTag + return c +} + +// Context sets the context to be used in this call's Do method. Any +// pending HTTP request will be aborted if the provided context is +// canceled. +func (c *TeamdrivesListCall) Context(ctx context.Context) *TeamdrivesListCall { + c.ctx_ = ctx + return c +} + +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *TeamdrivesListCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *TeamdrivesListCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") + urls := googleapi.ResolveRelative(c.s.BasePath, "teamdrives") + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders + return gensupport.SendRequest(c.ctx_, c.s.client, req) +} + +// Do executes the "drive.teamdrives.list" call. +// Exactly one of *TeamDriveList or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *TeamDriveList.ServerResponse.Header or (if a response was returned +// at all) in error.(*googleapi.Error).Header. Use +// googleapi.IsNotModified to check whether the returned error was +// because http.StatusNotModified was returned. +func (c *TeamdrivesListCall) Do(opts ...googleapi.CallOption) (*TeamDriveList, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("json") + if res != nil && res.StatusCode == http.StatusNotModified { + if res.Body != nil { + res.Body.Close() + } + return nil, &googleapi.Error{ + Code: res.StatusCode, + Header: res.Header, + } + } + if err != nil { + return nil, err + } + defer googleapi.CloseBody(res) + if err := googleapi.CheckResponse(res); err != nil { + return nil, err + } + ret := &TeamDriveList{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Lists the user's Team Drives.", + // "httpMethod": "GET", + // "id": "drive.teamdrives.list", + // "parameters": { + // "pageSize": { + // "default": "10", + // "description": "Maximum number of Team Drives to return.", + // "format": "int32", + // "location": "query", + // "maximum": "100", + // "minimum": "1", + // "type": "integer" + // }, + // "pageToken": { + // "description": "Page token for Team Drives.", + // "location": "query", + // "type": "string" + // }, + // "q": { + // "description": "Query string for searching Team Drives.", + // "location": "query", + // "type": "string" + // }, + // "useDomainAdminAccess": { + // "default": "false", + // "description": "Issue the request as a domain administrator; if set to true, then all Team Drives of the domain in which the requester is an administrator are returned.", + // "location": "query", + // "type": "boolean" + // } + // }, + // "path": "teamdrives", + // "response": { + // "$ref": "TeamDriveList" + // }, + // "scopes": [ + // "https://www.googleapis.com/auth/drive", + // "https://www.googleapis.com/auth/drive.readonly" + // ] + // } + +} + +// Pages invokes f for each page of results. +// A non-nil error returned from f will halt the iteration. +// The provided context supersedes any context provided to the Context method. +func (c *TeamdrivesListCall) Pages(ctx context.Context, f func(*TeamDriveList) error) error { + c.ctx_ = ctx + defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point + for { + x, err := c.Do() + if err != nil { + return err + } + if err := f(x); err != nil { + return err + } + if x.NextPageToken == "" { + return nil + } + c.PageToken(x.NextPageToken) + } +} + +// method id "drive.teamdrives.update": + +type TeamdrivesUpdateCall struct { + s *Service + teamDriveId string + teamdrive *TeamDrive + urlParams_ gensupport.URLParams + ctx_ context.Context + header_ http.Header +} + +// Update: Updates a Team Drive's metadata +func (r *TeamdrivesService) Update(teamDriveId string, teamdrive *TeamDrive) *TeamdrivesUpdateCall { + c := &TeamdrivesUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.teamDriveId = teamDriveId + c.teamdrive = teamdrive + return c +} + +// UseDomainAdminAccess sets the optional parameter +// "useDomainAdminAccess": Issue the request as 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. +func (c *TeamdrivesUpdateCall) UseDomainAdminAccess(useDomainAdminAccess bool) *TeamdrivesUpdateCall { + c.urlParams_.Set("useDomainAdminAccess", fmt.Sprint(useDomainAdminAccess)) + return c +} + +// Fields allows partial responses to be retrieved. See +// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse +// for more information. +func (c *TeamdrivesUpdateCall) Fields(s ...googleapi.Field) *TeamdrivesUpdateCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// Context sets the context to be used in this call's Do method. Any +// pending HTTP request will be aborted if the provided context is +// canceled. +func (c *TeamdrivesUpdateCall) Context(ctx context.Context) *TeamdrivesUpdateCall { + c.ctx_ = ctx + return c +} + +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *TeamdrivesUpdateCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *TeamdrivesUpdateCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.teamdrive) + if err != nil { + return nil, err + } + reqHeaders.Set("Content-Type", "application/json") + c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") + urls := googleapi.ResolveRelative(c.s.BasePath, "teamdrives/{teamDriveId}") + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("PATCH", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders + googleapi.Expand(req.URL, map[string]string{ + "teamDriveId": c.teamDriveId, + }) + return gensupport.SendRequest(c.ctx_, c.s.client, req) +} + +// Do executes the "drive.teamdrives.update" call. +// Exactly one of *TeamDrive or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *TeamDrive.ServerResponse.Header or (if a response was returned at +// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified +// to check whether the returned error was because +// http.StatusNotModified was returned. +func (c *TeamdrivesUpdateCall) Do(opts ...googleapi.CallOption) (*TeamDrive, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("json") + if res != nil && res.StatusCode == http.StatusNotModified { + if res.Body != nil { + res.Body.Close() + } + return nil, &googleapi.Error{ + Code: res.StatusCode, + Header: res.Header, + } + } + if err != nil { + return nil, err + } + defer googleapi.CloseBody(res) + if err := googleapi.CheckResponse(res); err != nil { + return nil, err + } + ret := &TeamDrive{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Updates a Team Drive's metadata", + // "httpMethod": "PATCH", + // "id": "drive.teamdrives.update", + // "parameterOrder": [ + // "teamDriveId" + // ], + // "parameters": { + // "teamDriveId": { + // "description": "The ID of the Team Drive", + // "location": "path", + // "required": true, + // "type": "string" + // }, + // "useDomainAdminAccess": { + // "default": "false", + // "description": "Issue the request as 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.", + // "location": "query", + // "type": "boolean" + // } + // }, + // "path": "teamdrives/{teamDriveId}", + // "request": { + // "$ref": "TeamDrive" + // }, + // "response": { + // "$ref": "TeamDrive" + // }, + // "scopes": [ + // "https://www.googleapis.com/auth/drive" + // ] + // } + +} diff --git a/vendor/google.golang.org/api/gensupport/buffer.go b/vendor/google.golang.org/api/gensupport/buffer.go index 4b8ec142..99210491 100644 --- a/vendor/google.golang.org/api/gensupport/buffer.go +++ b/vendor/google.golang.org/api/gensupport/buffer.go @@ -11,8 +11,8 @@ import ( "google.golang.org/api/googleapi" ) -// ResumableBuffer buffers data from an io.Reader to support uploading media in retryable chunks. -type ResumableBuffer struct { +// MediaBuffer buffers data from an io.Reader to support uploading media in retryable chunks. +type MediaBuffer struct { media io.Reader chunk []byte // The current chunk which is pending upload. The capacity is the chunk size. @@ -22,42 +22,42 @@ type ResumableBuffer struct { off int64 } -func NewResumableBuffer(media io.Reader, chunkSize int) *ResumableBuffer { - return &ResumableBuffer{media: media, chunk: make([]byte, 0, chunkSize)} +func NewMediaBuffer(media io.Reader, chunkSize int) *MediaBuffer { + return &MediaBuffer{media: media, chunk: make([]byte, 0, chunkSize)} } // Chunk returns the current buffered chunk, the offset in the underlying media // from which the chunk is drawn, and the size of the chunk. // Successive calls to Chunk return the same chunk between calls to Next. -func (rb *ResumableBuffer) Chunk() (chunk io.Reader, off int64, size int, err error) { +func (mb *MediaBuffer) Chunk() (chunk io.Reader, off int64, size int, err error) { // There may already be data in chunk if Next has not been called since the previous call to Chunk. - if rb.err == nil && len(rb.chunk) == 0 { - rb.err = rb.loadChunk() + if mb.err == nil && len(mb.chunk) == 0 { + mb.err = mb.loadChunk() } - return bytes.NewReader(rb.chunk), rb.off, len(rb.chunk), rb.err + return bytes.NewReader(mb.chunk), mb.off, len(mb.chunk), mb.err } // loadChunk will read from media into chunk, up to the capacity of chunk. -func (rb *ResumableBuffer) loadChunk() error { - bufSize := cap(rb.chunk) - rb.chunk = rb.chunk[:bufSize] +func (mb *MediaBuffer) loadChunk() error { + bufSize := cap(mb.chunk) + mb.chunk = mb.chunk[:bufSize] read := 0 var err error for err == nil && read < bufSize { var n int - n, err = rb.media.Read(rb.chunk[read:]) + n, err = mb.media.Read(mb.chunk[read:]) read += n } - rb.chunk = rb.chunk[:read] + mb.chunk = mb.chunk[:read] return err } // Next advances to the next chunk, which will be returned by the next call to Chunk. // Calls to Next without a corresponding prior call to Chunk will have no effect. -func (rb *ResumableBuffer) Next() { - rb.off += int64(len(rb.chunk)) - rb.chunk = rb.chunk[0:0] +func (mb *MediaBuffer) Next() { + mb.off += int64(len(mb.chunk)) + mb.chunk = mb.chunk[0:0] } type readerTyper struct { diff --git a/vendor/google.golang.org/api/gensupport/go18.go b/vendor/google.golang.org/api/gensupport/go18.go new file mode 100644 index 00000000..c76cb8f2 --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/go18.go @@ -0,0 +1,17 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.8 + +package gensupport + +import ( + "io" + "net/http" +) + +// SetGetBody sets the GetBody field of req to f. +func SetGetBody(req *http.Request, f func() (io.ReadCloser, error)) { + req.GetBody = f +} diff --git a/vendor/google.golang.org/api/gensupport/header.go b/vendor/google.golang.org/api/gensupport/header.go new file mode 100644 index 00000000..cb5e67c7 --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/header.go @@ -0,0 +1,22 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gensupport + +import ( + "fmt" + "runtime" + "strings" +) + +// GoogleClientHeader returns the value to use for the x-goog-api-client +// header, which is used internally by Google. +func GoogleClientHeader(generatorVersion, clientElement string) string { + elts := []string{"gl-go/" + strings.Replace(runtime.Version(), " ", "_", -1)} + if clientElement != "" { + elts = append(elts, clientElement) + } + elts = append(elts, fmt.Sprintf("gdcl/%s", generatorVersion)) + return strings.Join(elts, " ") +} diff --git a/vendor/google.golang.org/api/gensupport/json.go b/vendor/google.golang.org/api/gensupport/json.go index dd7bcd2e..c01e3218 100644 --- a/vendor/google.golang.org/api/gensupport/json.go +++ b/vendor/google.golang.org/api/gensupport/json.go @@ -12,29 +12,43 @@ import ( ) // MarshalJSON returns a JSON encoding of schema containing only selected fields. -// A field is selected if: -// * it has a non-empty value, or -// * its field name is present in forceSendFields, and -// * it is not a nil pointer or nil interface. +// A field is selected if any of the following is true: +// * it has a non-empty value +// * its field name is present in forceSendFields and it is not a nil pointer or nil interface +// * its field name is present in nullFields. // The JSON key for each selected field is taken from the field's json: struct tag. -func MarshalJSON(schema interface{}, forceSendFields []string) ([]byte, error) { - if len(forceSendFields) == 0 { +func MarshalJSON(schema interface{}, forceSendFields, nullFields []string) ([]byte, error) { + if len(forceSendFields) == 0 && len(nullFields) == 0 { return json.Marshal(schema) } - mustInclude := make(map[string]struct{}) + mustInclude := make(map[string]bool) for _, f := range forceSendFields { - mustInclude[f] = struct{}{} + mustInclude[f] = true + } + useNull := make(map[string]bool) + useNullMaps := make(map[string]map[string]bool) + for _, nf := range nullFields { + parts := strings.SplitN(nf, ".", 2) + field := parts[0] + if len(parts) == 1 { + useNull[field] = true + } else { + if useNullMaps[field] == nil { + useNullMaps[field] = map[string]bool{} + } + useNullMaps[field][parts[1]] = true + } } - dataMap, err := schemaToMap(schema, mustInclude) + dataMap, err := schemaToMap(schema, mustInclude, useNull, useNullMaps) if err != nil { return nil, err } return json.Marshal(dataMap) } -func schemaToMap(schema interface{}, mustInclude map[string]struct{}) (map[string]interface{}, error) { +func schemaToMap(schema interface{}, mustInclude, useNull map[string]bool, useNullMaps map[string]map[string]bool) (map[string]interface{}, error) { m := make(map[string]interface{}) s := reflect.ValueOf(schema) st := s.Type() @@ -54,10 +68,36 @@ func schemaToMap(schema interface{}, mustInclude map[string]struct{}) (map[strin v := s.Field(i) f := st.Field(i) + + if useNull[f.Name] { + if !isEmptyValue(v) { + return nil, fmt.Errorf("field %q in NullFields has non-empty value", f.Name) + } + m[tag.apiName] = nil + continue + } + if !includeField(v, f, mustInclude) { continue } + // If map fields are explicitly set to null, use a map[string]interface{}. + if f.Type.Kind() == reflect.Map && useNullMaps[f.Name] != nil { + ms, ok := v.Interface().(map[string]string) + if !ok { + return nil, fmt.Errorf("field %q has keys in NullFields but is not a map[string]string", f.Name) + } + mi := map[string]interface{}{} + for k, v := range ms { + mi[k] = v + } + for k := range useNullMaps[f.Name] { + mi[k] = nil + } + m[tag.apiName] = mi + continue + } + // nil maps are treated as empty maps. if f.Type.Kind() == reflect.Map && v.IsNil() { m[tag.apiName] = map[string]string{} @@ -127,7 +167,7 @@ func parseJSONTag(val string) (jsonTag, error) { } // Reports whether the struct field "f" with value "v" should be included in JSON output. -func includeField(v reflect.Value, f reflect.StructField, mustInclude map[string]struct{}) bool { +func includeField(v reflect.Value, f reflect.StructField, mustInclude map[string]bool) bool { // The regular JSON encoding of a nil pointer is "null", which means "delete this field". // Therefore, we could enable field deletion by honoring pointer fields' presence in the mustInclude set. // However, many fields are not pointers, so there would be no way to delete these fields. @@ -144,8 +184,7 @@ func includeField(v reflect.Value, f reflect.StructField, mustInclude map[string return false } - _, ok := mustInclude[f.Name] - return ok || !isEmptyValue(v) + return mustInclude[f.Name] || !isEmptyValue(v) } // isEmptyValue reports whether v is the empty value for its type. This diff --git a/vendor/google.golang.org/api/gensupport/jsonfloat.go b/vendor/google.golang.org/api/gensupport/jsonfloat.go new file mode 100644 index 00000000..83778508 --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/jsonfloat.go @@ -0,0 +1,57 @@ +// Copyright 2016 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gensupport + +import ( + "encoding/json" + "errors" + "fmt" + "math" +) + +// JSONFloat64 is a float64 that supports proper unmarshaling of special float +// values in JSON, according to +// https://developers.google.com/protocol-buffers/docs/proto3#json. Although +// that is a proto-to-JSON spec, it applies to all Google APIs. +// +// The jsonpb package +// (https://github.com/golang/protobuf/blob/master/jsonpb/jsonpb.go) has +// similar functionality, but only for direct translation from proto messages +// to JSON. +type JSONFloat64 float64 + +func (f *JSONFloat64) UnmarshalJSON(data []byte) error { + var ff float64 + if err := json.Unmarshal(data, &ff); err == nil { + *f = JSONFloat64(ff) + return nil + } + var s string + if err := json.Unmarshal(data, &s); err == nil { + switch s { + case "NaN": + ff = math.NaN() + case "Infinity": + ff = math.Inf(1) + case "-Infinity": + ff = math.Inf(-1) + default: + return fmt.Errorf("google.golang.org/api/internal: bad float string %q", s) + } + *f = JSONFloat64(ff) + return nil + } + return errors.New("google.golang.org/api/internal: data not float or string") +} diff --git a/vendor/google.golang.org/api/gensupport/media.go b/vendor/google.golang.org/api/gensupport/media.go index 817f46f5..5895fef8 100644 --- a/vendor/google.golang.org/api/gensupport/media.go +++ b/vendor/google.golang.org/api/gensupport/media.go @@ -5,12 +5,15 @@ package gensupport import ( + "bytes" "fmt" "io" "io/ioutil" "mime/multipart" "net/http" "net/textproto" + "strings" + "sync" "google.golang.org/api/googleapi" ) @@ -103,12 +106,13 @@ type typeReader struct { typ string } -// multipartReader combines the contents of multiple readers to creat a multipart/related HTTP body. +// multipartReader combines the contents of multiple readers to create a multipart/related HTTP body. // Close must be called if reads from the multipartReader are abandoned before reaching EOF. type multipartReader struct { pr *io.PipeReader - pipeOpen bool ctype string + mu sync.Mutex + pipeOpen bool } func newMultipartReader(parts []typeReader) *multipartReader { @@ -144,10 +148,13 @@ func (mp *multipartReader) Read(data []byte) (n int, err error) { } func (mp *multipartReader) Close() error { + mp.mu.Lock() if !mp.pipeOpen { + mp.mu.Unlock() return nil } mp.pipeOpen = false + mp.mu.Unlock() return mp.pr.Close() } @@ -174,27 +181,156 @@ func typeHeader(contentType string) textproto.MIMEHeader { // PrepareUpload determines whether the data in the supplied reader should be // uploaded in a single request, or in sequential chunks. // chunkSize is the size of the chunk that media should be split into. -// If chunkSize is non-zero and the contents of media do not fit in a single -// chunk (or there is an error reading media), then media will be returned as a -// ResumableBuffer. Otherwise, media will be returned as a Reader. +// +// If chunkSize is zero, media is returned as the first value, and the other +// two return values are nil, true. +// +// Otherwise, a MediaBuffer is returned, along with a bool indicating whether the +// contents of media fit in a single chunk. // // After PrepareUpload has been called, media should no longer be used: the // media content should be accessed via one of the return values. -func PrepareUpload(media io.Reader, chunkSize int) (io.Reader, - *ResumableBuffer) { +func PrepareUpload(media io.Reader, chunkSize int) (r io.Reader, mb *MediaBuffer, singleChunk bool) { if chunkSize == 0 { // do not chunk - return media, nil + return media, nil, true + } + mb = NewMediaBuffer(media, chunkSize) + _, _, _, err := mb.Chunk() + // If err is io.EOF, we can upload this in a single request. Otherwise, err is + // either nil or a non-EOF error. If it is the latter, then the next call to + // mb.Chunk will return the same error. Returning a MediaBuffer ensures that this + // error will be handled at some point. + return nil, mb, err == io.EOF +} + +// MediaInfo holds information for media uploads. It is intended for use by generated +// code only. +type MediaInfo struct { + // At most one of Media and MediaBuffer will be set. + media io.Reader + buffer *MediaBuffer + singleChunk bool + mType string + size int64 // mediaSize, if known. Used only for calls to progressUpdater_. + progressUpdater googleapi.ProgressUpdater +} + +// NewInfoFromMedia should be invoked from the Media method of a call. It returns a +// MediaInfo populated with chunk size and content type, and a reader or MediaBuffer +// if needed. +func NewInfoFromMedia(r io.Reader, options []googleapi.MediaOption) *MediaInfo { + mi := &MediaInfo{} + opts := googleapi.ProcessMediaOptions(options) + if !opts.ForceEmptyContentType { + r, mi.mType = DetermineContentType(r, opts.ContentType) + } + mi.media, mi.buffer, mi.singleChunk = PrepareUpload(r, opts.ChunkSize) + return mi +} + +// NewInfoFromResumableMedia should be invoked from the ResumableMedia method of a +// call. It returns a MediaInfo using the given reader, size and media type. +func NewInfoFromResumableMedia(r io.ReaderAt, size int64, mediaType string) *MediaInfo { + rdr := ReaderAtToReader(r, size) + rdr, mType := DetermineContentType(rdr, mediaType) + return &MediaInfo{ + size: size, + mType: mType, + buffer: NewMediaBuffer(rdr, googleapi.DefaultUploadChunkSize), + media: nil, + singleChunk: false, + } +} + +func (mi *MediaInfo) SetProgressUpdater(pu googleapi.ProgressUpdater) { + if mi != nil { + mi.progressUpdater = pu + } +} + +// UploadType determines the type of upload: a single request, or a resumable +// series of requests. +func (mi *MediaInfo) UploadType() string { + if mi.singleChunk { + return "multipart" } + return "resumable" +} - rb := NewResumableBuffer(media, chunkSize) - rdr, _, _, err := rb.Chunk() +// UploadRequest sets up an HTTP request for media upload. It adds headers +// as necessary, and returns a replacement for the body and a function for http.Request.GetBody. +func (mi *MediaInfo) UploadRequest(reqHeaders http.Header, body io.Reader) (newBody io.Reader, getBody func() (io.ReadCloser, error), cleanup func()) { + cleanup = func() {} + if mi == nil { + return body, nil, cleanup + } + var media io.Reader + if mi.media != nil { + // This only happens when the caller has turned off chunking. In that + // case, we write all of media in a single non-retryable request. + media = mi.media + } else if mi.singleChunk { + // The data fits in a single chunk, which has now been read into the MediaBuffer. + // We obtain that chunk so we can write it in a single request. The request can + // be retried because the data is stored in the MediaBuffer. + media, _, _, _ = mi.buffer.Chunk() + } + if media != nil { + fb := readerFunc(body) + fm := readerFunc(media) + combined, ctype := CombineBodyMedia(body, "application/json", media, mi.mType) + if fb != nil && fm != nil { + getBody = func() (io.ReadCloser, error) { + rb := ioutil.NopCloser(fb()) + rm := ioutil.NopCloser(fm()) + r, _ := CombineBodyMedia(rb, "application/json", rm, mi.mType) + return r, nil + } + } + cleanup = func() { combined.Close() } + reqHeaders.Set("Content-Type", ctype) + body = combined + } + if mi.buffer != nil && mi.mType != "" && !mi.singleChunk { + reqHeaders.Set("X-Upload-Content-Type", mi.mType) + } + return body, getBody, cleanup +} - if err == io.EOF { // we can upload this in a single request - return rdr, nil +// readerFunc returns a function that always returns an io.Reader that has the same +// contents as r, provided that can be done without consuming r. Otherwise, it +// returns nil. +// See http.NewRequest (in net/http/request.go). +func readerFunc(r io.Reader) func() io.Reader { + switch r := r.(type) { + case *bytes.Buffer: + buf := r.Bytes() + return func() io.Reader { return bytes.NewReader(buf) } + case *bytes.Reader: + snapshot := *r + return func() io.Reader { r := snapshot; return &r } + case *strings.Reader: + snapshot := *r + return func() io.Reader { r := snapshot; return &r } + default: + return nil } - // err might be a non-EOF error. If it is, the next call to rb.Chunk will - // return the same error. Returning a ResumableBuffer ensures that this error - // will be handled at some point. +} - return nil, rb +// ResumableUpload returns an appropriately configured ResumableUpload value if the +// upload is resumable, or nil otherwise. +func (mi *MediaInfo) ResumableUpload(locURI string) *ResumableUpload { + if mi == nil || mi.singleChunk { + return nil + } + return &ResumableUpload{ + URI: locURI, + Media: mi.buffer, + MediaType: mi.mType, + Callback: func(curr int64) { + if mi.progressUpdater != nil { + mi.progressUpdater(curr, mi.size) + } + }, + } } diff --git a/vendor/google.golang.org/api/gensupport/not_go18.go b/vendor/google.golang.org/api/gensupport/not_go18.go new file mode 100644 index 00000000..2536501c --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/not_go18.go @@ -0,0 +1,14 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !go1.8 + +package gensupport + +import ( + "io" + "net/http" +) + +func SetGetBody(req *http.Request, f func() (io.ReadCloser, error)) {} diff --git a/vendor/google.golang.org/api/gensupport/resumable.go b/vendor/google.golang.org/api/gensupport/resumable.go index b3e774aa..dcd591f7 100644 --- a/vendor/google.golang.org/api/gensupport/resumable.go +++ b/vendor/google.golang.org/api/gensupport/resumable.go @@ -5,6 +5,7 @@ package gensupport import ( + "errors" "fmt" "io" "net/http" @@ -12,14 +13,9 @@ import ( "time" "golang.org/x/net/context" - "golang.org/x/net/context/ctxhttp" ) const ( - // statusResumeIncomplete is the code returned by the Google uploader - // when the transfer is not yet complete. - statusResumeIncomplete = 308 - // statusTooManyRequests is returned by the storage API if the // per-project limits have been temporarily exceeded. The request // should be retried. @@ -35,7 +31,7 @@ type ResumableUpload struct { URI string UserAgent string // User-Agent for header of the request // Media is the object being uploaded. - Media *ResumableBuffer + Media *MediaBuffer // MediaType defines the media type, e.g. "image/jpeg". MediaType string @@ -80,8 +76,23 @@ func (rx *ResumableUpload) doUploadRequest(ctx context.Context, data io.Reader, req.Header.Set("Content-Range", contentRange) req.Header.Set("Content-Type", rx.MediaType) req.Header.Set("User-Agent", rx.UserAgent) - return ctxhttp.Do(ctx, rx.Client, req) + // Google's upload endpoint uses status code 308 for a + // different purpose than the "308 Permanent Redirect" + // since-standardized in RFC 7238. Because of the conflict in + // semantics, Google added this new request header which + // causes it to not use "308" and instead reply with 200 OK + // and sets the upload-specific "X-HTTP-Status-Code-Override: + // 308" response header. + req.Header.Set("X-GUploader-No-308", "yes") + + return SendRequest(ctx, rx.Client, req) +} + +func statusResumeIncomplete(resp *http.Response) bool { + // This is how the server signals "status resume incomplete" + // when X-GUploader-No-308 is set to "yes": + return resp != nil && resp.Header.Get("X-Http-Status-Code-Override") == "308" } // reportProgress calls a user-supplied callback to report upload progress. @@ -112,11 +123,17 @@ func (rx *ResumableUpload) transferChunk(ctx context.Context) (*http.Response, e return res, err } - if res.StatusCode == statusResumeIncomplete || res.StatusCode == http.StatusOK { + // We sent "X-GUploader-No-308: yes" (see comment elsewhere in + // this file), so we don't expect to get a 308. + if res.StatusCode == 308 { + return nil, errors.New("unexpected 308 response status code") + } + + if res.StatusCode == http.StatusOK { rx.reportProgress(off, off+int64(size)) } - if res.StatusCode == statusResumeIncomplete { + if statusResumeIncomplete(res) { rx.Media.Next() } return res, nil @@ -135,6 +152,8 @@ func contextDone(ctx context.Context) bool { // It retries using the provided back off strategy until cancelled or the // strategy indicates to stop retrying. // It is called from the auto-generated API code and is not visible to the user. +// Before sending an HTTP request, Upload calls any registered hook functions, +// and calls the returned functions after the request returns (see send.go). // rx is private to the auto-generated API code. // Exactly one of resp or err will be nil. If resp is non-nil, the caller must call resp.Body.Close. func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err error) { @@ -176,7 +195,7 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err // If the chunk was uploaded successfully, but there's still // more to go, upload the next chunk without any delay. - if status == statusResumeIncomplete { + if statusResumeIncomplete(resp) { pause = 0 backoff.Reset() resp.Body.Close() diff --git a/vendor/google.golang.org/api/gensupport/retry.go b/vendor/google.golang.org/api/gensupport/retry.go index 7f83d1da..e58c75e4 100644 --- a/vendor/google.golang.org/api/gensupport/retry.go +++ b/vendor/google.golang.org/api/gensupport/retry.go @@ -1,3 +1,17 @@ +// Copyright 2017 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package gensupport import ( @@ -55,23 +69,17 @@ func DefaultBackoffStrategy() BackoffStrategy { // shouldRetry returns true if the HTTP response / error indicates that the // request should be attempted again. func shouldRetry(status int, err error) bool { - // Retry for 5xx response codes. - if 500 <= status && status < 600 { + if 500 <= status && status <= 599 { return true } - - // Retry on statusTooManyRequests{ if status == statusTooManyRequests { return true } - - // Retry on unexpected EOFs and temporary network errors. if err == io.ErrUnexpectedEOF { return true } if err, ok := err.(net.Error); ok { return err.Temporary() } - return false } diff --git a/vendor/google.golang.org/api/gensupport/send.go b/vendor/google.golang.org/api/gensupport/send.go new file mode 100644 index 00000000..0f75aa86 --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/send.go @@ -0,0 +1,71 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gensupport + +import ( + "encoding/json" + "errors" + "net/http" + + "golang.org/x/net/context" + "golang.org/x/net/context/ctxhttp" +) + +// Hook is the type of a function that is called once before each HTTP request +// that is sent by a generated API. It returns a function that is called after +// the request returns. +// Hooks are not called if the context is nil. +type Hook func(ctx context.Context, req *http.Request) func(resp *http.Response) + +var hooks []Hook + +// RegisterHook registers a Hook to be called before each HTTP request by a +// generated API. Hooks are called in the order they are registered. Each +// hook can return a function; if it is non-nil, it is called after the HTTP +// request returns. These functions are called in the reverse order. +// RegisterHook should not be called concurrently with itself or SendRequest. +func RegisterHook(h Hook) { + hooks = append(hooks, h) +} + +// SendRequest sends a single HTTP request using the given client. +// If ctx is non-nil, it calls all hooks, then sends the request with +// ctxhttp.Do, then calls any functions returned by the hooks in reverse order. +func SendRequest(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) { + // Disallow Accept-Encoding because it interferes with the automatic gzip handling + // done by the default http.Transport. See https://github.com/google/google-api-go-client/issues/219. + if _, ok := req.Header["Accept-Encoding"]; ok { + return nil, errors.New("google api: custom Accept-Encoding headers not allowed") + } + if ctx == nil { + return client.Do(req) + } + // Call hooks in order of registration, store returned funcs. + post := make([]func(resp *http.Response), len(hooks)) + for i, h := range hooks { + fn := h(ctx, req) + post[i] = fn + } + + // Send request. + resp, err := ctxhttp.Do(ctx, client, req) + + // Call returned funcs in reverse order. + for i := len(post) - 1; i >= 0; i-- { + if fn := post[i]; fn != nil { + fn(resp) + } + } + return resp, err +} + +// DecodeResponse decodes the body of res into target. If there is no body, +// target is unchanged. +func DecodeResponse(target interface{}, res *http.Response) error { + if res.StatusCode == http.StatusNoContent { + return nil + } + return json.NewDecoder(res.Body).Decode(target) +} diff --git a/vendor/google.golang.org/api/googleapi/googleapi.go b/vendor/google.golang.org/api/googleapi/googleapi.go index 858537e0..3d970ee1 100644 --- a/vendor/google.golang.org/api/googleapi/googleapi.go +++ b/vendor/google.golang.org/api/googleapi/googleapi.go @@ -50,7 +50,7 @@ const ( // UserAgent is the header string used to identify this package. UserAgent = "google-api-go-client/" + Version - // The default chunk size to use for resumable uplods if not specified by the user. + // The default chunk size to use for resumable uploads if not specified by the user. DefaultUploadChunkSize = 8 * 1024 * 1024 // The minimum chunk size that can be used for resumable uploads. All @@ -149,12 +149,12 @@ func IsNotModified(err error) bool { // CheckMediaResponse returns an error (of type *Error) if the response // status code is not 2xx. Unlike CheckResponse it does not assume the // body is a JSON error document. +// It is the caller's responsibility to close res.Body. func CheckMediaResponse(res *http.Response) error { if res.StatusCode >= 200 && res.StatusCode <= 299 { return nil } slurp, _ := ioutil.ReadAll(io.LimitReader(res.Body, 1<<20)) - res.Body.Close() return &Error{ Code: res.StatusCode, Body: string(slurp), @@ -270,49 +270,32 @@ func ProcessMediaOptions(opts []MediaOption) *MediaOptions { func ResolveRelative(basestr, relstr string) string { u, _ := url.Parse(basestr) + afterColonPath := "" + if i := strings.IndexRune(relstr, ':'); i > 0 { + afterColonPath = relstr[i+1:] + relstr = relstr[:i] + } rel, _ := url.Parse(relstr) u = u.ResolveReference(rel) us := u.String() + if afterColonPath != "" { + us = fmt.Sprintf("%s:%s", us, afterColonPath) + } us = strings.Replace(us, "%7B", "{", -1) us = strings.Replace(us, "%7D", "}", -1) + us = strings.Replace(us, "%2A", "*", -1) return us } -// has4860Fix is whether this Go environment contains the fix for -// http://golang.org/issue/4860 -var has4860Fix bool - -// init initializes has4860Fix by checking the behavior of the net/http package. -func init() { - r := http.Request{ - URL: &url.URL{ - Scheme: "http", - Opaque: "//opaque", - }, - } - b := &bytes.Buffer{} - r.Write(b) - has4860Fix = bytes.HasPrefix(b.Bytes(), []byte("GET http")) -} - -// SetOpaque sets u.Opaque from u.Path such that HTTP requests to it -// don't alter any hex-escaped characters in u.Path. -func SetOpaque(u *url.URL) { - u.Opaque = "//" + u.Host + u.Path - if !has4860Fix { - u.Opaque = u.Scheme + ":" + u.Opaque - } -} - // Expand subsitutes any {encoded} strings in the URL passed in using // the map supplied. // // This calls SetOpaque to avoid encoding of the parameters in the URL path. func Expand(u *url.URL, expansions map[string]string) { - expanded, err := uritemplates.Expand(u.Path, expansions) + escaped, unescaped, err := uritemplates.Expand(u.Path, expansions) if err == nil { - u.Path = expanded - SetOpaque(u) + u.Path = unescaped + u.RawPath = escaped } } diff --git a/vendor/google.golang.org/api/googleapi/internal/uritemplates/uritemplates.go b/vendor/google.golang.org/api/googleapi/internal/uritemplates/uritemplates.go index 7c103ba1..63bf0538 100644 --- a/vendor/google.golang.org/api/googleapi/internal/uritemplates/uritemplates.go +++ b/vendor/google.golang.org/api/googleapi/internal/uritemplates/uritemplates.go @@ -34,11 +34,37 @@ func pctEncode(src []byte) []byte { return dst } -func escape(s string, allowReserved bool) string { +// pairWriter is a convenience struct which allows escaped and unescaped +// versions of the template to be written in parallel. +type pairWriter struct { + escaped, unescaped bytes.Buffer +} + +// Write writes the provided string directly without any escaping. +func (w *pairWriter) Write(s string) { + w.escaped.WriteString(s) + w.unescaped.WriteString(s) +} + +// Escape writes the provided string, escaping the string for the +// escaped output. +func (w *pairWriter) Escape(s string, allowReserved bool) { + w.unescaped.WriteString(s) if allowReserved { - return string(reserved.ReplaceAllFunc([]byte(s), pctEncode)) + w.escaped.Write(reserved.ReplaceAllFunc([]byte(s), pctEncode)) + } else { + w.escaped.Write(unreserved.ReplaceAllFunc([]byte(s), pctEncode)) } - return string(unreserved.ReplaceAllFunc([]byte(s), pctEncode)) +} + +// Escaped returns the escaped string. +func (w *pairWriter) Escaped() string { + return w.escaped.String() +} + +// Unescaped returns the unescaped string. +func (w *pairWriter) Unescaped() string { + return w.unescaped.String() } // A uriTemplate is a parsed representation of a URI template. @@ -170,18 +196,20 @@ func parseTerm(term string) (result templateTerm, err error) { return result, err } -// Expand expands a URI template with a set of values to produce a string. -func (t *uriTemplate) Expand(values map[string]string) string { - var buf bytes.Buffer +// Expand expands a URI template with a set of values to produce the +// resultant URI. Two forms of the result are returned: one with all the +// elements escaped, and one with the elements unescaped. +func (t *uriTemplate) Expand(values map[string]string) (escaped, unescaped string) { + var w pairWriter for _, p := range t.parts { - p.expand(&buf, values) + p.expand(&w, values) } - return buf.String() + return w.Escaped(), w.Unescaped() } -func (tp *templatePart) expand(buf *bytes.Buffer, values map[string]string) { +func (tp *templatePart) expand(w *pairWriter, values map[string]string) { if len(tp.raw) > 0 { - buf.WriteString(tp.raw) + w.Write(tp.raw) return } var first = true @@ -191,30 +219,30 @@ func (tp *templatePart) expand(buf *bytes.Buffer, values map[string]string) { continue } if first { - buf.WriteString(tp.first) + w.Write(tp.first) first = false } else { - buf.WriteString(tp.sep) + w.Write(tp.sep) } - tp.expandString(buf, term, value) + tp.expandString(w, term, value) } } -func (tp *templatePart) expandName(buf *bytes.Buffer, name string, empty bool) { +func (tp *templatePart) expandName(w *pairWriter, name string, empty bool) { if tp.named { - buf.WriteString(name) + w.Write(name) if empty { - buf.WriteString(tp.ifemp) + w.Write(tp.ifemp) } else { - buf.WriteString("=") + w.Write("=") } } } -func (tp *templatePart) expandString(buf *bytes.Buffer, t templateTerm, s string) { +func (tp *templatePart) expandString(w *pairWriter, t templateTerm, s string) { if len(s) > t.truncate && t.truncate > 0 { s = s[:t.truncate] } - tp.expandName(buf, t.name, len(s) == 0) - buf.WriteString(escape(s, tp.allowReserved)) + tp.expandName(w, t.name, len(s) == 0) + w.Escape(s, tp.allowReserved) } diff --git a/vendor/google.golang.org/api/googleapi/internal/uritemplates/utils.go b/vendor/google.golang.org/api/googleapi/internal/uritemplates/utils.go index eff260a6..2e70b815 100644 --- a/vendor/google.golang.org/api/googleapi/internal/uritemplates/utils.go +++ b/vendor/google.golang.org/api/googleapi/internal/uritemplates/utils.go @@ -4,10 +4,14 @@ package uritemplates -func Expand(path string, values map[string]string) (string, error) { +// Expand parses then expands a URI template with a set of values to produce +// the resultant URI. Two forms of the result are returned: one with all the +// elements escaped, and one with the elements unescaped. +func Expand(path string, values map[string]string) (escaped, unescaped string, err error) { template, err := parse(path) if err != nil { - return "", err + return "", "", err } - return template.Expand(values), nil + escaped, unescaped = template.Expand(values) + return escaped, unescaped, nil } diff --git a/vendor/google.golang.org/api/googleapi/types.go b/vendor/google.golang.org/api/googleapi/types.go index a02b4b07..c8fdd541 100644 --- a/vendor/google.golang.org/api/googleapi/types.go +++ b/vendor/google.golang.org/api/googleapi/types.go @@ -6,6 +6,7 @@ package googleapi import ( "encoding/json" + "errors" "strconv" ) @@ -149,6 +150,25 @@ func (s Float64s) MarshalJSON() ([]byte, error) { }) } +// RawMessage is a raw encoded JSON value. +// It is identical to json.RawMessage, except it does not suffer from +// https://golang.org/issue/14493. +type RawMessage []byte + +// MarshalJSON returns m. +func (m RawMessage) MarshalJSON() ([]byte, error) { + return m, nil +} + +// UnmarshalJSON sets *m to a copy of data. +func (m *RawMessage) UnmarshalJSON(data []byte) error { + if m == nil { + return errors.New("googleapi.RawMessage: UnmarshalJSON on nil pointer") + } + *m = append((*m)[:0], data...) + return nil +} + /* * Helper routines for simplifying the creation of optional fields of basic type. */