diff options
| author | Petter Rasmussen | 2016-04-17 13:11:19 +0200 |
|---|---|---|
| committer | Petter Rasmussen | 2016-04-17 13:11:19 +0200 |
| commit | 97981f7fd205353907135eacfc0e0ade24b88269 (patch) | |
| tree | 1fdb61a7138642a1612bb201434e8ebda141cc8a /vendor/google.golang.org | |
| parent | 8de8e05c483c6b5f23b14742315f1860211dcef7 (diff) | |
| parent | b5eb2866cfceb69b0d4dd4948273d679a884fbb2 (diff) | |
| download | gdrive-97981f7fd205353907135eacfc0e0ade24b88269.tar.bz2 | |
Merge pull request #140 from paulz/godep
add Go dependencies by godep
Diffstat (limited to 'vendor/google.golang.org')
16 files changed, 10566 insertions, 0 deletions
diff --git a/vendor/google.golang.org/api/LICENSE b/vendor/google.golang.org/api/LICENSE new file mode 100644 index 0000000..263aa7a --- /dev/null +++ b/vendor/google.golang.org/api/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2011 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/google.golang.org/api/drive/v3/drive-api.json b/vendor/google.golang.org/api/drive/v3/drive-api.json new file mode 100644 index 0000000..896d44e --- /dev/null +++ b/vendor/google.golang.org/api/drive/v3/drive-api.json @@ -0,0 +1,2410 @@ +{ + "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." + } + } + }, + "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." + } + } + }, + "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": { + "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": { + "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": { + "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": { + "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" + }, + "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": { + "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" + ] + } + } + }, + "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" + } + }, + "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" + } + } + }, + "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" + } + }, + "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" + } + }, + "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" + } + }, + "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" + } + }, + "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" + } + }, + "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}" + } + } + } + }, + "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" + } + }, + "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" + }, + "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" + ] + }, + "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" + }, + "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" + }, + "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" + ] + }, + "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" + }, + "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" + ] + }, + "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" + }, + "fileId": { + "type": "string", + "description": "The ID of the file.", + "required": true, + "location": "path" + }, + "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" + }, + "fileId": { + "type": "string", + "description": "The ID of the file.", + "required": true, + "location": "path" + }, + "includeDeleted": { + "type": "boolean", + "description": "Whether to return deleted replies. Deleted replies will not include their original content.", + "default": "false", + "location": "query" + }, + "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" + ] + }, + "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" + }, + "includeDeleted": { + "type": "boolean", + "description": "Whether to include deleted replies. Deleted replies will not include their original content.", + "default": "false", + "location": "query" + }, + "pageSize": { + "type": "integer", + "description": "The maximum number of replies 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" + } + }, + "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" + ] + }, + "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" + }, + "fileId": { + "type": "string", + "description": "The ID of the file.", + "required": true, + "location": "path" + }, + "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" + }, + "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" + ] + }, + "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" + }, + "fileId": { + "type": "string", + "description": "The ID of the file.", + "required": true, + "location": "path" + }, + "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 + }, + "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" + ] + }, + "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" + }, + "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" + ] + } + } + } + } +} diff --git a/vendor/google.golang.org/api/drive/v3/drive-gen.go b/vendor/google.golang.org/api/drive/v3/drive-gen.go new file mode 100644 index 0000000..9e6e087 --- /dev/null +++ b/vendor/google.golang.org/api/drive/v3/drive-gen.go @@ -0,0 +1,6434 @@ +// Package drive provides access to the Drive API. +// +// See https://developers.google.com/drive/ +// +// Usage example: +// +// import "google.golang.org/api/drive/v3" +// ... +// driveService, err := drive.New(oauthHttpClient) +package drive + +import ( + "bytes" + "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" +) + +// Always reference these packages, just in case the auto-generated code +// below doesn't. +var _ = bytes.NewBuffer +var _ = strconv.Itoa +var _ = fmt.Sprintf +var _ = json.NewDecoder +var _ = io.Copy +var _ = url.Parse +var _ = gensupport.MarshalJSON +var _ = googleapi.Version +var _ = errors.New +var _ = strings.Replace +var _ = context.Canceled +var _ = ctxhttp.Do + +const apiId = "drive:v3" +const apiName = "drive" +const apiVersion = "v3" +const basePath = "https://www.googleapis.com/drive/v3/" + +// OAuth2 scopes used by this API. +const ( + // View and manage the files in your Google Drive + DriveScope = "https://www.googleapis.com/auth/drive" + + // View and manage its own configuration data in your Google Drive + DriveAppdataScope = "https://www.googleapis.com/auth/drive.appdata" + + // View and manage Google Drive files and folders that you have opened + // or created with this app + DriveFileScope = "https://www.googleapis.com/auth/drive.file" + + // View and manage metadata of files in your Google Drive + DriveMetadataScope = "https://www.googleapis.com/auth/drive.metadata" + + // View metadata for files in your Google Drive + DriveMetadataReadonlyScope = "https://www.googleapis.com/auth/drive.metadata.readonly" + + // View the photos, videos and albums in your Google Photos + DrivePhotosReadonlyScope = "https://www.googleapis.com/auth/drive.photos.readonly" + + // View the files in your Google Drive + DriveReadonlyScope = "https://www.googleapis.com/auth/drive.readonly" + + // Modify your Google Apps Script scripts' behavior + DriveScriptsScope = "https://www.googleapis.com/auth/drive.scripts" +) + +func New(client *http.Client) (*Service, error) { + if client == nil { + return nil, errors.New("client is nil") + } + s := &Service{client: client, BasePath: basePath} + s.About = NewAboutService(s) + s.Changes = NewChangesService(s) + s.Channels = NewChannelsService(s) + s.Comments = NewCommentsService(s) + s.Files = NewFilesService(s) + s.Permissions = NewPermissionsService(s) + s.Replies = NewRepliesService(s) + s.Revisions = NewRevisionsService(s) + return s, nil +} + +type Service struct { + client *http.Client + BasePath string // API endpoint base URL + UserAgent string // optional additional User-Agent fragment + + About *AboutService + + Changes *ChangesService + + Channels *ChannelsService + + Comments *CommentsService + + Files *FilesService + + Permissions *PermissionsService + + Replies *RepliesService + + Revisions *RevisionsService +} + +func (s *Service) userAgent() string { + if s.UserAgent == "" { + return googleapi.UserAgent + } + return googleapi.UserAgent + " " + s.UserAgent +} + +func NewAboutService(s *Service) *AboutService { + rs := &AboutService{s: s} + return rs +} + +type AboutService struct { + s *Service +} + +func NewChangesService(s *Service) *ChangesService { + rs := &ChangesService{s: s} + return rs +} + +type ChangesService struct { + s *Service +} + +func NewChannelsService(s *Service) *ChannelsService { + rs := &ChannelsService{s: s} + return rs +} + +type ChannelsService struct { + s *Service +} + +func NewCommentsService(s *Service) *CommentsService { + rs := &CommentsService{s: s} + return rs +} + +type CommentsService struct { + s *Service +} + +func NewFilesService(s *Service) *FilesService { + rs := &FilesService{s: s} + return rs +} + +type FilesService struct { + s *Service +} + +func NewPermissionsService(s *Service) *PermissionsService { + rs := &PermissionsService{s: s} + return rs +} + +type PermissionsService struct { + s *Service +} + +func NewRepliesService(s *Service) *RepliesService { + rs := &RepliesService{s: s} + return rs +} + +type RepliesService struct { + s *Service +} + +func NewRevisionsService(s *Service) *RevisionsService { + rs := &RevisionsService{s: s} + return rs +} + +type RevisionsService 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"` + + // ExportFormats: A map of source MIME type to possible targets for all + // supported exports. + ExportFormats map[string][]string `json:"exportFormats,omitempty"` + + // FolderColorPalette: The currently supported folder colors as RGB hex + // strings. + FolderColorPalette []string `json:"folderColorPalette,omitempty"` + + // ImportFormats: A map of source MIME type to possible targets for all + // supported imports. + ImportFormats map[string][]string `json:"importFormats,omitempty"` + + // Kind: This is always drive#about. + Kind string `json:"kind,omitempty"` + + // MaxImportSizes: A map of maximum import sizes by MIME type, in bytes. + MaxImportSizes map[string]string `json:"maxImportSizes,omitempty"` + + // MaxUploadSize: The maximum upload size in bytes. + MaxUploadSize int64 `json:"maxUploadSize,omitempty,string"` + + // StorageQuota: The user's storage quota limits and usage. All fields + // are measured in bytes. + StorageQuota *AboutStorageQuota `json:"storageQuota,omitempty"` + + // User: The authenticated user. + User *User `json:"user,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // ForceSendFields is a list of field names (e.g. "AppInstalled") 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:"-"` +} + +func (s *About) MarshalJSON() ([]byte, error) { + type noMethod About + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// AboutStorageQuota: The user's storage quota limits and usage. All +// fields are measured in bytes. +type AboutStorageQuota struct { + // Limit: The usage limit, if applicable. This will not be present if + // the user has unlimited storage. + Limit int64 `json:"limit,omitempty,string"` + + // Usage: The total usage across all services. + Usage int64 `json:"usage,omitempty,string"` + + // UsageInDrive: The usage by all files in Google Drive. + UsageInDrive int64 `json:"usageInDrive,omitempty,string"` + + // UsageInDriveTrash: The usage by trashed files in Google Drive. + UsageInDriveTrash int64 `json:"usageInDriveTrash,omitempty,string"` + + // ForceSendFields is a list of field names (e.g. "Limit") 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:"-"` +} + +func (s *AboutStorageQuota) MarshalJSON() ([]byte, error) { + type noMethod AboutStorageQuota + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// Change: A change to a file. +type Change struct { + // File: The updated state of the file. Present if the file has not been + // removed. + 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 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 bool `json:"removed,omitempty"` + + // Time: The time of this change (RFC 3339 date-time). + Time string `json:"time,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, + // 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:"-"` +} + +func (s *Change) MarshalJSON() ([]byte, error) { + type noMethod Change + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// ChangeList: A list of changes for a user. +type ChangeList struct { + // Changes: The page of changes. + Changes []*Change `json:"changes,omitempty"` + + // Kind: This is always drive#changeList. + Kind string `json:"kind,omitempty"` + + // NewStartPageToken: The starting page token for future changes. This + // will be present only if the end of the current changes list has been + // reached. + 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. + NextPageToken string `json:"nextPageToken,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // ForceSendFields is a list of field names (e.g. "Changes") 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:"-"` +} + +func (s *ChangeList) MarshalJSON() ([]byte, error) { + type noMethod ChangeList + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// Channel: An notification channel used to watch for resource changes. +type Channel struct { + // Address: The address where notifications are delivered for this + // channel. + Address string `json:"address,omitempty"` + + // Expiration: Date and time of notification channel expiration, + // expressed as a Unix timestamp, in milliseconds. Optional. + Expiration int64 `json:"expiration,omitempty,string"` + + // Id: A UUID or similar unique string that identifies this channel. + Id string `json:"id,omitempty"` + + // Kind: Identifies this as a notification channel used to watch for + // changes to a resource. Value: the fixed string "api#channel". + Kind string `json:"kind,omitempty"` + + // Params: Additional parameters controlling delivery channel behavior. + // Optional. + Params map[string]string `json:"params,omitempty"` + + // Payload: A Boolean value to indicate whether payload is wanted. + // Optional. + Payload bool `json:"payload,omitempty"` + + // ResourceId: An opaque ID that identifies the resource being watched + // on this channel. Stable across different API versions. + ResourceId string `json:"resourceId,omitempty"` + + // ResourceUri: A version-specific identifier for the watched resource. + ResourceUri string `json:"resourceUri,omitempty"` + + // Token: An arbitrary string delivered to the target address with each + // notification delivered over this channel. Optional. + Token string `json:"token,omitempty"` + + // Type: The type of delivery mechanism used for this channel. + Type string `json:"type,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // ForceSendFields is a list of field names (e.g. "Address") 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:"-"` +} + +func (s *Channel) MarshalJSON() ([]byte, error) { + type noMethod Channel + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// Comment: A comment on a file. +type Comment struct { + // Anchor: A region of the document represented as a JSON string. See + // anchor documentation for details on how to define and interpret + // anchor properties. + Anchor string `json:"anchor,omitempty"` + + // Author: The user who created the comment. + Author *User `json:"author,omitempty"` + + // Content: The plain text content of the comment. This field is used + // for setting the content, while htmlContent should be displayed. + Content string `json:"content,omitempty"` + + // CreatedTime: The time at which the comment was created (RFC 3339 + // date-time). + CreatedTime string `json:"createdTime,omitempty"` + + // Deleted: Whether the comment has been deleted. A deleted comment has + // no content. + Deleted bool `json:"deleted,omitempty"` + + // HtmlContent: The content of the comment with HTML formatting. + HtmlContent string `json:"htmlContent,omitempty"` + + // Id: The ID of the comment. + Id string `json:"id,omitempty"` + + // Kind: This is always drive#comment. + Kind string `json:"kind,omitempty"` + + // ModifiedTime: The last time the comment or any of its replies was + // modified (RFC 3339 date-time). + ModifiedTime string `json:"modifiedTime,omitempty"` + + // QuotedFileContent: 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. + QuotedFileContent *CommentQuotedFileContent `json:"quotedFileContent,omitempty"` + + // Replies: The full list of replies to the comment in chronological + // order. + Replies []*Reply `json:"replies,omitempty"` + + // Resolved: Whether the comment has been resolved by one of its + // replies. + Resolved bool `json:"resolved,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // ForceSendFields is a list of field names (e.g. "Anchor") 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:"-"` +} + +func (s *Comment) MarshalJSON() ([]byte, error) { + type noMethod Comment + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// CommentQuotedFileContent: 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. +type CommentQuotedFileContent struct { + // MimeType: The MIME type of the quoted content. + MimeType string `json:"mimeType,omitempty"` + + // Value: The quoted content itself. This is interpreted as plain text + // if set through the API. + Value string `json:"value,omitempty"` + + // ForceSendFields is a list of field names (e.g. "MimeType") 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:"-"` +} + +func (s *CommentQuotedFileContent) MarshalJSON() ([]byte, error) { + type noMethod CommentQuotedFileContent + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// CommentList: A list of comments on a file. +type CommentList struct { + // Comments: The page of comments. + Comments []*Comment `json:"comments,omitempty"` + + // Kind: This is always 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. + NextPageToken string `json:"nextPageToken,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // ForceSendFields is a list of field names (e.g. "Comments") 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:"-"` +} + +func (s *CommentList) MarshalJSON() ([]byte, error) { + type noMethod CommentList + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// File: The metadata for a file. +type File struct { + // AppProperties: A collection of arbitrary key-value pairs which are + // private to the requesting app. + // 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 *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"` + + // CreatedTime: The time at which the file was created (RFC 3339 + // date-time). + CreatedTime string `json:"createdTime,omitempty"` + + // Description: A short description of the file. + Description string `json:"description,omitempty"` + + // ExplicitlyTrashed: Whether the file has been explicitly trashed, as + // opposed to recursively trashed from a parent folder. + ExplicitlyTrashed bool `json:"explicitlyTrashed,omitempty"` + + // FileExtension: The final component of fullFileExtension. This is only + // available for files with binary content in Drive. + FileExtension string `json:"fileExtension,omitempty"` + + // FolderColorRgb: The color for a folder as an RGB hex string. The + // supported colors are published in the folderColorPalette field of the + // About resource. + // If an unsupported color is specified, the closest color in the + // palette will be used instead. + FolderColorRgb string `json:"folderColorRgb,omitempty"` + + // FullFileExtension: 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. + // This is automatically updated when the name field changes, however it + // is not cleared if the new name does not contain a valid extension. + FullFileExtension string `json:"fullFileExtension,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"` + + // IconLink: A static, unauthenticated link to the file's icon. + IconLink string `json:"iconLink,omitempty"` + + // Id: The ID of the file. + Id string `json:"id,omitempty"` + + // ImageMediaMetadata: Additional metadata about image media, if + // available. + ImageMediaMetadata *FileImageMediaMetadata `json:"imageMediaMetadata,omitempty"` + + // Kind: This is always drive#file. + Kind string `json:"kind,omitempty"` + + // LastModifyingUser: The last user to modify the file. + LastModifyingUser *User `json:"lastModifyingUser,omitempty"` + + // Md5Checksum: The MD5 checksum for the content of the file. This is + // only applicable to files with binary content in Drive. + Md5Checksum string `json:"md5Checksum,omitempty"` + + // MimeType: The MIME type of the file. + // Drive 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. + // If 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. + MimeType string `json:"mimeType,omitempty"` + + // ModifiedByMeTime: The last time the file was modified by the user + // (RFC 3339 date-time). + ModifiedByMeTime string `json:"modifiedByMeTime,omitempty"` + + // ModifiedTime: The last time the file was modified by anyone (RFC 3339 + // date-time). + // Note that setting modifiedTime will also update modifiedByMeTime for + // the user. + ModifiedTime string `json:"modifiedTime,omitempty"` + + // Name: The name of the file. This is not necessarily unique within a + // folder. + Name string `json:"name,omitempty"` + + // OriginalFilename: 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. + OriginalFilename string `json:"originalFilename,omitempty"` + + // OwnedByMe: Whether the user owns the file. + OwnedByMe bool `json:"ownedByMe,omitempty"` + + // Owners: The owners of the file. Currently, only certain legacy files + // may have more than one owner. + 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. + Parents []string `json:"parents,omitempty"` + + // Permissions: The full list of permissions for the file. This is only + // available if the requesting user can share the file. + Permissions []*Permission `json:"permissions,omitempty"` + + // Properties: A collection of arbitrary key-value pairs which are + // visible to all apps. + // Entries with null values are cleared in update and copy requests. + Properties map[string]string `json:"properties,omitempty"` + + // QuotaBytesUsed: The number of storage quota bytes used by the file. + // This includes the head revision as well as previous revisions with + // keepForever enabled. + QuotaBytesUsed int64 `json:"quotaBytesUsed,omitempty,string"` + + // Shared: Whether the file has been shared. + Shared bool `json:"shared,omitempty"` + + // SharedWithMeTime: The time at which the file was shared with the + // user, if applicable (RFC 3339 date-time). + SharedWithMeTime string `json:"sharedWithMeTime,omitempty"` + + // SharingUser: The user who shared the file with the requesting user, + // if applicable. + SharingUser *User `json:"sharingUser,omitempty"` + + // Size: The size of the file's content in bytes. This is only + // applicable to files with binary content in Drive. + Size int64 `json:"size,omitempty,string"` + + // Spaces: The list of spaces which contain the file. The currently + // supported values are 'drive', 'appDataFolder' and 'photos'. + Spaces []string `json:"spaces,omitempty"` + + // Starred: Whether the user has starred the file. + Starred bool `json:"starred,omitempty"` + + // ThumbnailLink: A short-lived link to the file's thumbnail, if + // available. Typically lasts on the order of hours. + ThumbnailLink string `json:"thumbnailLink,omitempty"` + + // 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"` + + // 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. + Version int64 `json:"version,omitempty,string"` + + // VideoMediaMetadata: Additional metadata about video media. This may + // not be available immediately upon upload. + VideoMediaMetadata *FileVideoMediaMetadata `json:"videoMediaMetadata,omitempty"` + + // ViewedByMe: Whether the file has been viewed by this user. + ViewedByMe bool `json:"viewedByMe,omitempty"` + + // ViewedByMeTime: The last time the file was viewed by the user (RFC + // 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 bool `json:"viewersCanCopyContent,omitempty"` + + // WebContentLink: A link for downloading the content of the file in a + // browser. This is only available for files with binary content in + // Drive. + WebContentLink string `json:"webContentLink,omitempty"` + + // WebViewLink: A link for opening the file in a relevant Google editor + // or viewer in a browser. + WebViewLink string `json:"webViewLink,omitempty"` + + // WritersCanShare: Whether users with only writer permission can modify + // the file's permissions. + WritersCanShare bool `json:"writersCanShare,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // ForceSendFields is a list of field names (e.g. "AppProperties") 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:"-"` +} + +func (s *File) MarshalJSON() ([]byte, error) { + type noMethod File + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// FileCapabilities: Capabilities the current user has on the file. +type FileCapabilities struct { + // CanComment: Whether the user can comment on the file. + CanComment bool `json:"canComment,omitempty"` + + // CanCopy: Whether the user can copy the file. + CanCopy bool `json:"canCopy,omitempty"` + + // CanEdit: Whether the user can edit the file's content. + CanEdit bool `json:"canEdit,omitempty"` + + // CanReadRevisions: Whether the current user has read access to the + // Revisions resource of the file. + CanReadRevisions bool `json:"canReadRevisions,omitempty"` + + // CanShare: Whether the user can modify the file's permissions and + // sharing settings. + CanShare bool `json:"canShare,omitempty"` + + // ForceSendFields is a list of field names (e.g. "CanComment") 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:"-"` +} + +func (s *FileCapabilities) MarshalJSON() ([]byte, error) { + type noMethod FileCapabilities + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// FileContentHints: Additional information about the content of the +// file. These fields are never populated in responses. +type FileContentHints struct { + // IndexableText: Text to be indexed for the file to improve fullText + // queries. This is limited to 128KB in length and may contain HTML + // elements. + IndexableText string `json:"indexableText,omitempty"` + + // Thumbnail: A thumbnail for the file. This will only be used if Drive + // cannot generate a standard thumbnail. + Thumbnail *FileContentHintsThumbnail `json:"thumbnail,omitempty"` + + // ForceSendFields is a list of field names (e.g. "IndexableText") 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:"-"` +} + +func (s *FileContentHints) MarshalJSON() ([]byte, error) { + type noMethod FileContentHints + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// FileContentHintsThumbnail: A thumbnail for the file. This will only +// be used if Drive cannot generate a standard thumbnail. +type FileContentHintsThumbnail struct { + // Image: The thumbnail data encoded with URL-safe Base64 (RFC 4648 + // section 5). + Image string `json:"image,omitempty"` + + // MimeType: The MIME type of the thumbnail. + MimeType string `json:"mimeType,omitempty"` + + // ForceSendFields is a list of field names (e.g. "Image") 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:"-"` +} + +func (s *FileContentHintsThumbnail) MarshalJSON() ([]byte, error) { + type noMethod FileContentHintsThumbnail + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// FileImageMediaMetadata: Additional metadata about image media, if +// available. +type FileImageMediaMetadata struct { + // Aperture: The aperture used to create the photo (f-number). + Aperture float64 `json:"aperture,omitempty"` + + // CameraMake: The make of the camera used to create the photo. + CameraMake string `json:"cameraMake,omitempty"` + + // CameraModel: The model of the camera used to create the photo. + CameraModel string `json:"cameraModel,omitempty"` + + // ColorSpace: The color space of the photo. + ColorSpace string `json:"colorSpace,omitempty"` + + // ExposureBias: The exposure bias of the photo (APEX value). + ExposureBias float64 `json:"exposureBias,omitempty"` + + // ExposureMode: The exposure mode used to create the photo. + ExposureMode string `json:"exposureMode,omitempty"` + + // ExposureTime: The length of the exposure, in seconds. + ExposureTime float64 `json:"exposureTime,omitempty"` + + // FlashUsed: Whether a flash was used to create the photo. + FlashUsed bool `json:"flashUsed,omitempty"` + + // FocalLength: The focal length used to create the photo, in + // millimeters. + FocalLength float64 `json:"focalLength,omitempty"` + + // Height: The height of the image in pixels. + Height int64 `json:"height,omitempty"` + + // IsoSpeed: The ISO speed used to create the photo. + IsoSpeed int64 `json:"isoSpeed,omitempty"` + + // Lens: The lens used to create the photo. + Lens string `json:"lens,omitempty"` + + // Location: Geographic location information stored in the image. + Location *FileImageMediaMetadataLocation `json:"location,omitempty"` + + // MaxApertureValue: The smallest f-number of the lens at the focal + // length used to create the photo (APEX value). + MaxApertureValue float64 `json:"maxApertureValue,omitempty"` + + // MeteringMode: The metering mode used to create the photo. + MeteringMode string `json:"meteringMode,omitempty"` + + // Rotation: The rotation in clockwise degrees from the image's original + // orientation. + Rotation int64 `json:"rotation,omitempty"` + + // Sensor: The type of sensor used to create the photo. + Sensor string `json:"sensor,omitempty"` + + // SubjectDistance: The distance to the subject of the photo, in meters. + SubjectDistance int64 `json:"subjectDistance,omitempty"` + + // Time: The date and time the photo was taken (EXIF DateTime). + Time string `json:"time,omitempty"` + + // WhiteBalance: The white balance mode used to create the photo. + WhiteBalance string `json:"whiteBalance,omitempty"` + + // Width: The width of the image in pixels. + Width int64 `json:"width,omitempty"` + + // ForceSendFields is a list of field names (e.g. "Aperture") 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:"-"` +} + +func (s *FileImageMediaMetadata) MarshalJSON() ([]byte, error) { + type noMethod FileImageMediaMetadata + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// FileImageMediaMetadataLocation: Geographic location information +// stored in the image. +type FileImageMediaMetadataLocation struct { + // Altitude: The altitude stored in the image. + Altitude float64 `json:"altitude,omitempty"` + + // Latitude: The latitude stored in the image. + Latitude float64 `json:"latitude,omitempty"` + + // Longitude: The longitude stored in the image. + Longitude float64 `json:"longitude,omitempty"` + + // ForceSendFields is a list of field names (e.g. "Altitude") 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:"-"` +} + +func (s *FileImageMediaMetadataLocation) MarshalJSON() ([]byte, error) { + type noMethod FileImageMediaMetadataLocation + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// FileVideoMediaMetadata: Additional metadata about video media. This +// may not be available immediately upon upload. +type FileVideoMediaMetadata struct { + // DurationMillis: The duration of the video in milliseconds. + DurationMillis int64 `json:"durationMillis,omitempty,string"` + + // Height: The height of the video in pixels. + Height int64 `json:"height,omitempty"` + + // Width: The width of the video in pixels. + Width int64 `json:"width,omitempty"` + + // ForceSendFields is a list of field names (e.g. "DurationMillis") 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:"-"` +} + +func (s *FileVideoMediaMetadata) MarshalJSON() ([]byte, error) { + type noMethod FileVideoMediaMetadata + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// FileList: A list of files. +type FileList struct { + // Files: The page of files. + Files []*File `json:"files,omitempty"` + + // Kind: This is always 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. + NextPageToken string `json:"nextPageToken,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // ForceSendFields is a list of field names (e.g. "Files") 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:"-"` +} + +func (s *FileList) MarshalJSON() ([]byte, error) { + type noMethod FileList + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// GeneratedIds: A list of generated file IDs which can be provided in +// create requests. +type GeneratedIds struct { + // Ids: The IDs generated for the requesting user in the specified + // space. + Ids []string `json:"ids,omitempty"` + + // Kind: This is always drive#generatedIds + Kind string `json:"kind,omitempty"` + + // Space: The type of file that can be created with these IDs. + Space string `json:"space,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // ForceSendFields is a list of field names (e.g. "Ids") 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:"-"` +} + +func (s *GeneratedIds) MarshalJSON() ([]byte, error) { + type noMethod GeneratedIds + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// Permission: A permission for a file. A permission grants a user, +// group, domain or the world access to a file or a folder hierarchy. +type Permission struct { + // AllowFileDiscovery: Whether the permission allows the file to be + // discovered through search. This is only applicable for permissions of + // type domain or anyone. + AllowFileDiscovery bool `json:"allowFileDiscovery,omitempty"` + + // DisplayName: A displayable name for users, groups or domains. + DisplayName string `json:"displayName,omitempty"` + + // Domain: The domain to which this permission refers. + Domain string `json:"domain,omitempty"` + + // EmailAddress: The email address of the user or group to which this + // permission refers. + EmailAddress string `json:"emailAddress,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 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: + // - owner + // - writer + // - commenter + // - reader + Role string `json:"role,omitempty"` + + // Type: The type of the grantee. Valid values are: + // - user + // - group + // - domain + // - anyone + Type string `json:"type,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // ForceSendFields is a list of field names (e.g. "AllowFileDiscovery") + // 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:"-"` +} + +func (s *Permission) MarshalJSON() ([]byte, error) { + type noMethod Permission + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// PermissionList: A list of permissions for a file. +type PermissionList struct { + // Kind: This is always drive#permissionList. + Kind string `json:"kind,omitempty"` + + // Permissions: The full list of permissions. + Permissions []*Permission `json:"permissions,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:"-"` +} + +func (s *PermissionList) MarshalJSON() ([]byte, error) { + type noMethod PermissionList + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// Reply: A reply to a comment on a file. +type Reply struct { + // Action: The action the reply performed to the parent comment. Valid + // values are: + // - resolve + // - reopen + Action string `json:"action,omitempty"` + + // Author: The user who created the reply. + Author *User `json:"author,omitempty"` + + // Content: 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. + Content string `json:"content,omitempty"` + + // CreatedTime: The time at which the reply was created (RFC 3339 + // date-time). + CreatedTime string `json:"createdTime,omitempty"` + + // Deleted: Whether the reply has been deleted. A deleted reply has no + // content. + Deleted bool `json:"deleted,omitempty"` + + // HtmlContent: The content of the reply with HTML formatting. + HtmlContent string `json:"htmlContent,omitempty"` + + // Id: The ID of the reply. + Id string `json:"id,omitempty"` + + // Kind: This is always drive#reply. + Kind string `json:"kind,omitempty"` + + // ModifiedTime: The last time the reply was modified (RFC 3339 + // date-time). + ModifiedTime string `json:"modifiedTime,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // ForceSendFields is a list of field names (e.g. "Action") 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:"-"` +} + +func (s *Reply) MarshalJSON() ([]byte, error) { + type noMethod Reply + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// ReplyList: A list of replies to a comment on a file. +type ReplyList struct { + // Kind: This is always 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. + NextPageToken string `json:"nextPageToken,omitempty"` + + // Replies: The page of replies. + Replies []*Reply `json:"replies,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:"-"` +} + +func (s *ReplyList) MarshalJSON() ([]byte, error) { + type noMethod ReplyList + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// Revision: The metadata for a revision to a file. +type Revision struct { + // Id: The ID of the revision. + Id string `json:"id,omitempty"` + + // KeepForever: 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. + // This field is only applicable to files with binary content in Drive. + KeepForever bool `json:"keepForever,omitempty"` + + // Kind: This is always drive#revision. + Kind string `json:"kind,omitempty"` + + // LastModifyingUser: The last user to modify this revision. + LastModifyingUser *User `json:"lastModifyingUser,omitempty"` + + // Md5Checksum: The MD5 checksum of the revision's content. This is only + // applicable to files with binary content in Drive. + Md5Checksum string `json:"md5Checksum,omitempty"` + + // MimeType: The MIME type of the revision. + MimeType string `json:"mimeType,omitempty"` + + // ModifiedTime: The last time the revision was modified (RFC 3339 + // date-time). + ModifiedTime string `json:"modifiedTime,omitempty"` + + // OriginalFilename: The original filename used to create this revision. + // This is only applicable to files with binary content in Drive. + OriginalFilename string `json:"originalFilename,omitempty"` + + // PublishAuto: Whether subsequent revisions will be automatically + // republished. This is only applicable to Google Docs. + PublishAuto bool `json:"publishAuto,omitempty"` + + // Published: Whether this revision is published. This is only + // applicable to Google Docs. + Published bool `json:"published,omitempty"` + + // PublishedOutsideDomain: Whether this revision is published outside + // the domain. This is only applicable to Google Docs. + PublishedOutsideDomain bool `json:"publishedOutsideDomain,omitempty"` + + // Size: The size of the revision's content in bytes. This is only + // applicable to files with binary content in Drive. + Size int64 `json:"size,omitempty,string"` + + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + + // 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:"-"` +} + +func (s *Revision) MarshalJSON() ([]byte, error) { + type noMethod Revision + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// RevisionList: A list of revisions of a file. +type RevisionList struct { + // Kind: This is always drive#revisionList. + Kind string `json:"kind,omitempty"` + + // Revisions: The full list of revisions. + Revisions []*Revision `json:"revisions,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:"-"` +} + +func (s *RevisionList) MarshalJSON() ([]byte, error) { + type noMethod RevisionList + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +type StartPageToken struct { + // Kind: This is always drive#startPageToken. + Kind string `json:"kind,omitempty"` + + // StartPageToken: The starting page token for listing changes. + StartPageToken string `json:"startPageToken,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:"-"` +} + +func (s *StartPageToken) MarshalJSON() ([]byte, error) { + type noMethod StartPageToken + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// User: Information about a Drive user. +type User struct { + // DisplayName: A plain text displayable name for this user. + DisplayName string `json:"displayName,omitempty"` + + // EmailAddress: 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. + EmailAddress string `json:"emailAddress,omitempty"` + + // Kind: This is always drive#user. + Kind string `json:"kind,omitempty"` + + // Me: Whether this user is the requesting user. + Me bool `json:"me,omitempty"` + + // PermissionId: The user's ID as visible in Permission resources. + PermissionId string `json:"permissionId,omitempty"` + + // PhotoLink: A link to the user's profile photo, if available. + PhotoLink string `json:"photoLink,omitempty"` + + // ForceSendFields is a list of field names (e.g. "DisplayName") 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:"-"` +} + +func (s *User) MarshalJSON() ([]byte, error) { + type noMethod User + raw := noMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields) +} + +// method id "drive.about.get": + +type AboutGetCall struct { + s *Service + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// Get: Gets information about the user, the user's Drive, and system +// capabilities. +func (r *AboutService) Get() *AboutGetCall { + c := &AboutGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} + 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 *AboutGetCall) Fields(s ...googleapi.Field) *AboutGetCall { + 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 *AboutGetCall) IfNoneMatch(entityTag string) *AboutGetCall { + 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 *AboutGetCall) Context(ctx context.Context) *AboutGetCall { + c.ctx_ = ctx + return c +} + +func (c *AboutGetCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + 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) + } + return c.s.client.Do(req) +} + +// Do executes the "drive.about.get" call. +// Exactly one of *About or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *About.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 *AboutGetCall) Do(opts ...googleapi.CallOption) (*About, 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 := &About{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // ] + // } + +} + +// method id "drive.changes.getStartPageToken": + +type ChangesGetStartPageTokenCall struct { + s *Service + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// GetStartPageToken: Gets the starting pageToken for listing future +// changes. +func (r *ChangesService) GetStartPageToken() *ChangesGetStartPageTokenCall { + c := &ChangesGetStartPageTokenCall{s: r.s, urlParams_: make(gensupport.URLParams)} + 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 *ChangesGetStartPageTokenCall) Fields(s ...googleapi.Field) *ChangesGetStartPageTokenCall { + 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 *ChangesGetStartPageTokenCall) IfNoneMatch(entityTag string) *ChangesGetStartPageTokenCall { + 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 *ChangesGetStartPageTokenCall) Context(ctx context.Context) *ChangesGetStartPageTokenCall { + c.ctx_ = ctx + return c +} + +func (c *ChangesGetStartPageTokenCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + 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) + } + return c.s.client.Do(req) +} + +// Do executes the "drive.changes.getStartPageToken" call. +// Exactly one of *StartPageToken or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *StartPageToken.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 *ChangesGetStartPageTokenCall) Do(opts ...googleapi.CallOption) (*StartPageToken, 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 := &StartPageToken{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Gets the starting pageToken for listing future changes.", + // "httpMethod": "GET", + // "id": "drive.changes.getStartPageToken", + // "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" + // ] + // } + +} + +// method id "drive.changes.list": + +type ChangesListCall struct { + s *Service + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// List: Lists changes for a user. +func (r *ChangesService) List(pageToken string) *ChangesListCall { + c := &ChangesListCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.urlParams_.Set("pageToken", pageToken) + 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. +func (c *ChangesListCall) IncludeRemoved(includeRemoved bool) *ChangesListCall { + c.urlParams_.Set("includeRemoved", fmt.Sprint(includeRemoved)) + return c +} + +// PageSize sets the optional parameter "pageSize": The maximum number +// of changes to return per page. +func (c *ChangesListCall) PageSize(pageSize int64) *ChangesListCall { + c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) + return c +} + +// RestrictToMyDrive sets the optional parameter "restrictToMyDrive": +// 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. +func (c *ChangesListCall) RestrictToMyDrive(restrictToMyDrive bool) *ChangesListCall { + c.urlParams_.Set("restrictToMyDrive", fmt.Sprint(restrictToMyDrive)) + return c +} + +// Spaces sets the optional parameter "spaces": A comma-separated list +// of spaces to query within the user corpus. Supported values are +// 'drive', 'appDataFolder' and 'photos'. +func (c *ChangesListCall) Spaces(spaces string) *ChangesListCall { + c.urlParams_.Set("spaces", spaces) + 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 *ChangesListCall) Fields(s ...googleapi.Field) *ChangesListCall { + 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 *ChangesListCall) IfNoneMatch(entityTag string) *ChangesListCall { + 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 *ChangesListCall) Context(ctx context.Context) *ChangesListCall { + c.ctx_ = ctx + return c +} + +func (c *ChangesListCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + 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) + } + return c.s.client.Do(req) +} + +// Do executes the "drive.changes.list" call. +// Exactly one of *ChangeList or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *ChangeList.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 *ChangesListCall) Do(opts ...googleapi.CallOption) (*ChangeList, 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 := &ChangeList{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Lists changes for a user.", + // "httpMethod": "GET", + // "id": "drive.changes.list", + // "parameterOrder": [ + // "pageToken" + // ], + // "parameters": { + // "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.", + // "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" + // } + // }, + // "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 + // } + +} + +// method id "drive.changes.watch": + +type ChangesWatchCall struct { + s *Service + channel *Channel + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Watch: Subscribes to changes for a user. +func (r *ChangesService) Watch(pageToken string, channel *Channel) *ChangesWatchCall { + c := &ChangesWatchCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.urlParams_.Set("pageToken", pageToken) + c.channel = channel + 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. +func (c *ChangesWatchCall) IncludeRemoved(includeRemoved bool) *ChangesWatchCall { + c.urlParams_.Set("includeRemoved", fmt.Sprint(includeRemoved)) + return c +} + +// PageSize sets the optional parameter "pageSize": The maximum number +// of changes to return per page. +func (c *ChangesWatchCall) PageSize(pageSize int64) *ChangesWatchCall { + c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) + return c +} + +// RestrictToMyDrive sets the optional parameter "restrictToMyDrive": +// 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. +func (c *ChangesWatchCall) RestrictToMyDrive(restrictToMyDrive bool) *ChangesWatchCall { + c.urlParams_.Set("restrictToMyDrive", fmt.Sprint(restrictToMyDrive)) + return c +} + +// Spaces sets the optional parameter "spaces": A comma-separated list +// of spaces to query within the user corpus. Supported values are +// 'drive', 'appDataFolder' and 'photos'. +func (c *ChangesWatchCall) Spaces(spaces string) *ChangesWatchCall { + c.urlParams_.Set("spaces", spaces) + 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 *ChangesWatchCall) Fields(s ...googleapi.Field) *ChangesWatchCall { + 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 *ChangesWatchCall) Context(ctx context.Context) *ChangesWatchCall { + c.ctx_ = ctx + return c +} + +func (c *ChangesWatchCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + 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) + } + return c.s.client.Do(req) +} + +// Do executes the "drive.changes.watch" call. +// Exactly one of *Channel or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *Channel.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 *ChangesWatchCall) Do(opts ...googleapi.CallOption) (*Channel, 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 := &Channel{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Subscribes to changes for a user.", + // "httpMethod": "POST", + // "id": "drive.changes.watch", + // "parameterOrder": [ + // "pageToken" + // ], + // "parameters": { + // "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.", + // "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" + // } + // }, + // "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 + // } + +} + +// method id "drive.channels.stop": + +type ChannelsStopCall struct { + s *Service + channel *Channel + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Stop: Stop watching resources through this channel +func (r *ChannelsService) Stop(channel *Channel) *ChannelsStopCall { + c := &ChannelsStopCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.channel = channel + 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 *ChannelsStopCall) Fields(s ...googleapi.Field) *ChannelsStopCall { + 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 *ChannelsStopCall) Context(ctx context.Context) *ChannelsStopCall { + c.ctx_ = ctx + return c +} + +func (c *ChannelsStopCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + 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) + } + return c.s.client.Do(req) +} + +// Do executes the "drive.channels.stop" call. +func (c *ChannelsStopCall) 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": "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" + // ] + // } + +} + +// method id "drive.comments.create": + +type CommentsCreateCall struct { + s *Service + fileId string + comment *Comment + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Create: Creates a new comment on a file. +func (r *CommentsService) Create(fileId string, comment *Comment) *CommentsCreateCall { + c := &CommentsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.comment = comment + 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 *CommentsCreateCall) Fields(s ...googleapi.Field) *CommentsCreateCall { + 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 *CommentsCreateCall) Context(ctx context.Context) *CommentsCreateCall { + c.ctx_ = ctx + return c +} + +func (c *CommentsCreateCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.comment) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("POST", urls, body) + 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) +} + +// Do executes the "drive.comments.create" call. +// Exactly one of *Comment or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *Comment.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 *CommentsCreateCall) Do(opts ...googleapi.CallOption) (*Comment, 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 := &Comment{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // ] + // } + +} + +// method id "drive.comments.delete": + +type CommentsDeleteCall struct { + s *Service + fileId string + commentId string + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Delete: Deletes a comment. +func (r *CommentsService) Delete(fileId string, commentId string) *CommentsDeleteCall { + c := &CommentsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.commentId = commentId + 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 *CommentsDeleteCall) Fields(s ...googleapi.Field) *CommentsDeleteCall { + 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 *CommentsDeleteCall) Context(ctx context.Context) *CommentsDeleteCall { + c.ctx_ = ctx + return c +} + +func (c *CommentsDeleteCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("DELETE", urls, body) + 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) +} + +// Do executes the "drive.comments.delete" call. +func (c *CommentsDeleteCall) 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": "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" + // ] + // } + +} + +// method id "drive.comments.get": + +type CommentsGetCall struct { + s *Service + fileId string + commentId string + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// Get: Gets a comment by ID. +func (r *CommentsService) Get(fileId string, commentId string) *CommentsGetCall { + c := &CommentsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.commentId = commentId + return c +} + +// IncludeDeleted sets the optional parameter "includeDeleted": Whether +// to return deleted comments. Deleted comments will not include their +// original content. +func (c *CommentsGetCall) IncludeDeleted(includeDeleted bool) *CommentsGetCall { + c.urlParams_.Set("includeDeleted", fmt.Sprint(includeDeleted)) + 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 *CommentsGetCall) Fields(s ...googleapi.Field) *CommentsGetCall { + 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 *CommentsGetCall) IfNoneMatch(entityTag string) *CommentsGetCall { + 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 *CommentsGetCall) Context(ctx context.Context) *CommentsGetCall { + c.ctx_ = ctx + return c +} + +func (c *CommentsGetCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("GET", urls, body) + 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) +} + +// Do executes the "drive.comments.get" call. +// Exactly one of *Comment or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *Comment.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 *CommentsGetCall) Do(opts ...googleapi.CallOption) (*Comment, 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 := &Comment{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // ] + // } + +} + +// method id "drive.comments.list": + +type CommentsListCall struct { + s *Service + fileId string + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// List: Lists a file's comments. +func (r *CommentsService) List(fileId string) *CommentsListCall { + c := &CommentsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + return c +} + +// IncludeDeleted sets the optional parameter "includeDeleted": Whether +// to include deleted comments. Deleted comments will not include their +// original content. +func (c *CommentsListCall) IncludeDeleted(includeDeleted bool) *CommentsListCall { + c.urlParams_.Set("includeDeleted", fmt.Sprint(includeDeleted)) + return c +} + +// PageSize sets the optional parameter "pageSize": The maximum number +// of comments to return per page. +func (c *CommentsListCall) PageSize(pageSize int64) *CommentsListCall { + 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 *CommentsListCall) PageToken(pageToken string) *CommentsListCall { + c.urlParams_.Set("pageToken", pageToken) + return c +} + +// StartModifiedTime sets the optional parameter "startModifiedTime": +// The minimum value of 'modifiedTime' for the result comments (RFC 3339 +// date-time). +func (c *CommentsListCall) StartModifiedTime(startModifiedTime string) *CommentsListCall { + c.urlParams_.Set("startModifiedTime", startModifiedTime) + 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 *CommentsListCall) Fields(s ...googleapi.Field) *CommentsListCall { + 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 *CommentsListCall) IfNoneMatch(entityTag string) *CommentsListCall { + 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 *CommentsListCall) Context(ctx context.Context) *CommentsListCall { + c.ctx_ = ctx + return c +} + +func (c *CommentsListCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("GET", urls, body) + 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) +} + +// Do executes the "drive.comments.list" call. +// Exactly one of *CommentList or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *CommentList.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 *CommentsListCall) Do(opts ...googleapi.CallOption) (*CommentList, 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 := &CommentList{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // ] + // } + +} + +// 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 *CommentsListCall) Pages(ctx context.Context, f func(*CommentList) 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.comments.update": + +type CommentsUpdateCall struct { + s *Service + fileId string + commentId string + comment *Comment + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Update: Updates a comment with patch semantics. +func (r *CommentsService) Update(fileId string, commentId string, comment *Comment) *CommentsUpdateCall { + c := &CommentsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.commentId = commentId + c.comment = comment + 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 *CommentsUpdateCall) Fields(s ...googleapi.Field) *CommentsUpdateCall { + 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 *CommentsUpdateCall) Context(ctx context.Context) *CommentsUpdateCall { + c.ctx_ = ctx + return c +} + +func (c *CommentsUpdateCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.comment) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("PATCH", urls, body) + 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) +} + +// Do executes the "drive.comments.update" call. +// Exactly one of *Comment or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *Comment.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 *CommentsUpdateCall) Do(opts ...googleapi.CallOption) (*Comment, 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 := &Comment{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // ] + // } + +} + +// method id "drive.files.copy": + +type FilesCopyCall struct { + s *Service + fileId string + file *File + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Copy: Creates a copy of a file and applies any requested updates with +// patch semantics. +func (r *FilesService) Copy(fileId string, file *File) *FilesCopyCall { + c := &FilesCopyCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.file = file + return c +} + +// IgnoreDefaultVisibility sets the optional parameter +// "ignoreDefaultVisibility": 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. +func (c *FilesCopyCall) IgnoreDefaultVisibility(ignoreDefaultVisibility bool) *FilesCopyCall { + c.urlParams_.Set("ignoreDefaultVisibility", fmt.Sprint(ignoreDefaultVisibility)) + return c +} + +// KeepRevisionForever sets the optional parameter +// "keepRevisionForever": Whether to set the 'keepForever' field in the +// new head revision. This is only applicable to files with binary +// content in Drive. +func (c *FilesCopyCall) KeepRevisionForever(keepRevisionForever bool) *FilesCopyCall { + c.urlParams_.Set("keepRevisionForever", fmt.Sprint(keepRevisionForever)) + return c +} + +// OcrLanguage sets the optional parameter "ocrLanguage": A language +// hint for OCR processing during image import (ISO 639-1 code). +func (c *FilesCopyCall) OcrLanguage(ocrLanguage string) *FilesCopyCall { + c.urlParams_.Set("ocrLanguage", ocrLanguage) + 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 *FilesCopyCall) Fields(s ...googleapi.Field) *FilesCopyCall { + 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 *FilesCopyCall) Context(ctx context.Context) *FilesCopyCall { + c.ctx_ = ctx + return c +} + +func (c *FilesCopyCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.file) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/copy") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("POST", urls, body) + 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) +} + +// Do executes the "drive.files.copy" call. +// Exactly one of *File or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *File.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 *FilesCopyCall) Do(opts ...googleapi.CallOption) (*File, 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 := &File{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // } + // }, + // "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" + // ] + // } + +} + +// 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 +} + +// Create: Creates a new file. +func (r *FilesService) Create(file *File) *FilesCreateCall { + c := &FilesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.file = file + return c +} + +// IgnoreDefaultVisibility sets the optional parameter +// "ignoreDefaultVisibility": 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. +func (c *FilesCreateCall) IgnoreDefaultVisibility(ignoreDefaultVisibility bool) *FilesCreateCall { + c.urlParams_.Set("ignoreDefaultVisibility", fmt.Sprint(ignoreDefaultVisibility)) + return c +} + +// KeepRevisionForever sets the optional parameter +// "keepRevisionForever": Whether to set the 'keepForever' field in the +// new head revision. This is only applicable to files with binary +// content in Drive. +func (c *FilesCreateCall) KeepRevisionForever(keepRevisionForever bool) *FilesCreateCall { + c.urlParams_.Set("keepRevisionForever", fmt.Sprint(keepRevisionForever)) + return c +} + +// OcrLanguage sets the optional parameter "ocrLanguage": A language +// hint for OCR processing during image import (ISO 639-1 code). +func (c *FilesCreateCall) OcrLanguage(ocrLanguage string) *FilesCreateCall { + c.urlParams_.Set("ocrLanguage", ocrLanguage) + return c +} + +// UseContentAsIndexableText sets the optional parameter +// "useContentAsIndexableText": Whether to use the uploaded content as +// indexable text. +func (c *FilesCreateCall) UseContentAsIndexableText(useContentAsIndexableText bool) *FilesCreateCall { + c.urlParams_.Set("useContentAsIndexableText", fmt.Sprint(useContentAsIndexableText)) + return c +} + +// Media specifies the media to upload in one or more chunks. The chunk +// size may be controlled by supplying a MediaOption generated by +// googleapi.ChunkSize. The chunk size defaults to +// googleapi.DefaultUploadChunkSize.The Content-Type header used in the +// upload request will be determined by sniffing the contents of r, +// unless a MediaOption generated by googleapi.ContentType is +// 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) + return c +} + +// ResumableMedia specifies the media to upload in chunks and can be +// canceled with ctx. +// +// Deprecated: use Media instead. +// +// At most one of Media and ResumableMedia may be set. mediaType +// identifies the MIME media type of the upload, such as "image/png". If +// mediaType is "", it will be auto-detected. The provided ctx will +// 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 + return c +} + +// ProgressUpdater provides a callback function that will be called +// after every chunk. It should be a low-latency function in order to +// 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 + 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 *FilesCreateCall) Fields(s ...googleapi.Field) *FilesCreateCall { + 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. +// This context will supersede any context previously provided to the +// ResumableMedia method. +func (c *FilesCreateCall) Context(ctx context.Context) *FilesCreateCall { + c.ctx_ = ctx + return c +} + +func (c *FilesCreateCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.file) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files") + if c.media_ != nil || c.resumableBuffer_ != 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 + } + 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_) + } + 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) +} + +// Do executes the "drive.files.create" call. +// Exactly one of *File or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *File.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 *FilesCreateCall) Do(opts ...googleapi.CallOption) (*File, 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 + } + 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_) + } + }, + } + ctx := c.ctx_ + if ctx == nil { + ctx = context.TODO() + } + res, err = rx.Upload(ctx) + if err != nil { + return nil, err + } + defer res.Body.Close() + if err := googleapi.CheckResponse(res); err != nil { + return nil, err + } + } + ret := &File{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // }, + // "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 + // } + +} + +// method id "drive.files.delete": + +type FilesDeleteCall struct { + s *Service + fileId string + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// 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. +func (r *FilesService) Delete(fileId string) *FilesDeleteCall { + c := &FilesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + 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 *FilesDeleteCall) Fields(s ...googleapi.Field) *FilesDeleteCall { + 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 *FilesDeleteCall) Context(ctx context.Context) *FilesDeleteCall { + c.ctx_ = ctx + return c +} + +func (c *FilesDeleteCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("DELETE", urls, body) + 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) +} + +// Do executes the "drive.files.delete" call. +func (c *FilesDeleteCall) 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 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.", + // "httpMethod": "DELETE", + // "id": "drive.files.delete", + // "parameterOrder": [ + // "fileId" + // ], + // "parameters": { + // "fileId": { + // "description": "The ID of the file.", + // "location": "path", + // "required": true, + // "type": "string" + // } + // }, + // "path": "files/{fileId}", + // "scopes": [ + // "https://www.googleapis.com/auth/drive", + // "https://www.googleapis.com/auth/drive.appdata", + // "https://www.googleapis.com/auth/drive.file" + // ] + // } + +} + +// method id "drive.files.emptyTrash": + +type FilesEmptyTrashCall struct { + s *Service + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// EmptyTrash: Permanently deletes all of the user's trashed files. +func (r *FilesService) EmptyTrash() *FilesEmptyTrashCall { + c := &FilesEmptyTrashCall{s: r.s, urlParams_: make(gensupport.URLParams)} + 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 *FilesEmptyTrashCall) Fields(s ...googleapi.Field) *FilesEmptyTrashCall { + 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 *FilesEmptyTrashCall) Context(ctx context.Context) *FilesEmptyTrashCall { + c.ctx_ = ctx + return c +} + +func (c *FilesEmptyTrashCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + 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) + } + return c.s.client.Do(req) +} + +// Do executes the "drive.files.emptyTrash" call. +func (c *FilesEmptyTrashCall) 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 all of the user's trashed files.", + // "httpMethod": "DELETE", + // "id": "drive.files.emptyTrash", + // "path": "files/trash", + // "scopes": [ + // "https://www.googleapis.com/auth/drive" + // ] + // } + +} + +// method id "drive.files.export": + +type FilesExportCall struct { + s *Service + fileId string + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// Export: Exports a Google Doc to the requested MIME type and returns +// the exported content. +func (r *FilesService) Export(fileId string, mimeType string) *FilesExportCall { + c := &FilesExportCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.urlParams_.Set("mimeType", mimeType) + 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 *FilesExportCall) Fields(s ...googleapi.Field) *FilesExportCall { + 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 *FilesExportCall) IfNoneMatch(entityTag string) *FilesExportCall { + c.ifNoneMatch_ = entityTag + return c +} + +// Context sets the context to be used in this call's Do and Download +// methods. Any pending HTTP request will be aborted if the provided +// context is canceled. +func (c *FilesExportCall) Context(ctx context.Context) *FilesExportCall { + c.ctx_ = ctx + return c +} + +func (c *FilesExportCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/export") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("GET", urls, body) + 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) +} + +// Download fetches the API endpoint's "media" value, instead of the normal +// API response value. If the returned error is nil, the Response is guaranteed to +// have a 2xx status code. Callers must close the Response.Body as usual. +func (c *FilesExportCall) Download(opts ...googleapi.CallOption) (*http.Response, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("media") + if err != nil { + return nil, err + } + if err := googleapi.CheckMediaResponse(res); err != nil { + res.Body.Close() + return nil, err + } + return res, nil +} + +// Do executes the "drive.files.export" call. +func (c *FilesExportCall) 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": "Exports a Google Doc to the requested MIME type and returns the exported content.", + // "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 + // } + +} + +// method id "drive.files.generateIds": + +type FilesGenerateIdsCall struct { + s *Service + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// GenerateIds: Generates a set of file IDs which can be provided in +// create requests. +func (r *FilesService) GenerateIds() *FilesGenerateIdsCall { + c := &FilesGenerateIdsCall{s: r.s, urlParams_: make(gensupport.URLParams)} + return c +} + +// Count sets the optional parameter "count": The number of IDs to +// return. +func (c *FilesGenerateIdsCall) Count(count int64) *FilesGenerateIdsCall { + c.urlParams_.Set("count", fmt.Sprint(count)) + return c +} + +// Space sets the optional parameter "space": The space in which the IDs +// can be used to create new files. Supported values are 'drive' and +// 'appDataFolder'. +func (c *FilesGenerateIdsCall) Space(space string) *FilesGenerateIdsCall { + c.urlParams_.Set("space", space) + 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 *FilesGenerateIdsCall) Fields(s ...googleapi.Field) *FilesGenerateIdsCall { + 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 *FilesGenerateIdsCall) IfNoneMatch(entityTag string) *FilesGenerateIdsCall { + 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 *FilesGenerateIdsCall) Context(ctx context.Context) *FilesGenerateIdsCall { + c.ctx_ = ctx + return c +} + +func (c *FilesGenerateIdsCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + 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) + } + return c.s.client.Do(req) +} + +// Do executes the "drive.files.generateIds" call. +// Exactly one of *GeneratedIds or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *GeneratedIds.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 *FilesGenerateIdsCall) Do(opts ...googleapi.CallOption) (*GeneratedIds, 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 := &GeneratedIds{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // ] + // } + +} + +// method id "drive.files.get": + +type FilesGetCall struct { + s *Service + fileId string + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// Get: Gets a file's metadata or content by ID. +func (r *FilesService) Get(fileId string) *FilesGetCall { + c := &FilesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + return c +} + +// AcknowledgeAbuse sets the optional parameter "acknowledgeAbuse": +// Whether the user is acknowledging the risk of downloading known +// malware or other abusive files. This is only applicable when +// alt=media. +func (c *FilesGetCall) AcknowledgeAbuse(acknowledgeAbuse bool) *FilesGetCall { + c.urlParams_.Set("acknowledgeAbuse", fmt.Sprint(acknowledgeAbuse)) + 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 *FilesGetCall) Fields(s ...googleapi.Field) *FilesGetCall { + 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 *FilesGetCall) IfNoneMatch(entityTag string) *FilesGetCall { + c.ifNoneMatch_ = entityTag + return c +} + +// Context sets the context to be used in this call's Do and Download +// methods. Any pending HTTP request will be aborted if the provided +// context is canceled. +func (c *FilesGetCall) Context(ctx context.Context) *FilesGetCall { + c.ctx_ = ctx + return c +} + +func (c *FilesGetCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("GET", urls, body) + 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) +} + +// Download fetches the API endpoint's "media" value, instead of the normal +// API response value. If the returned error is nil, the Response is guaranteed to +// have a 2xx status code. Callers must close the Response.Body as usual. +func (c *FilesGetCall) Download(opts ...googleapi.CallOption) (*http.Response, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("media") + if err != nil { + return nil, err + } + if err := googleapi.CheckMediaResponse(res); err != nil { + res.Body.Close() + return nil, err + } + return res, nil +} + +// Do executes the "drive.files.get" call. +// Exactly one of *File or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *File.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 *FilesGetCall) Do(opts ...googleapi.CallOption) (*File, 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 := &File{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // } + // }, + // "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 + // } + +} + +// method id "drive.files.list": + +type FilesListCall struct { + s *Service + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// List: Lists or searches files. +func (r *FilesService) List() *FilesListCall { + c := &FilesListCall{s: r.s, urlParams_: make(gensupport.URLParams)} + return c +} + +// Corpus sets the optional parameter "corpus": The source of files to +// list. +// +// Possible values: +// "domain" - Files shared to the user's domain. +// "user" (default) - Files owned by or shared to the user. +func (c *FilesListCall) Corpus(corpus string) *FilesListCall { + c.urlParams_.Set("corpus", corpus) + 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. +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. +func (c *FilesListCall) PageSize(pageSize int64) *FilesListCall { + 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 *FilesListCall) PageToken(pageToken string) *FilesListCall { + c.urlParams_.Set("pageToken", pageToken) + return c +} + +// Q sets the optional parameter "q": A query for filtering the file +// results. See the "Search for Files" guide for supported syntax. +func (c *FilesListCall) Q(q string) *FilesListCall { + c.urlParams_.Set("q", q) + return c +} + +// Spaces sets the optional parameter "spaces": A comma-separated list +// of spaces to query within the corpus. Supported values are 'drive', +// 'appDataFolder' and 'photos'. +func (c *FilesListCall) Spaces(spaces string) *FilesListCall { + c.urlParams_.Set("spaces", spaces) + 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 *FilesListCall) Fields(s ...googleapi.Field) *FilesListCall { + 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 *FilesListCall) IfNoneMatch(entityTag string) *FilesListCall { + 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 *FilesListCall) Context(ctx context.Context) *FilesListCall { + c.ctx_ = ctx + return c +} + +func (c *FilesListCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + 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_) + } + if c.ctx_ != nil { + return ctxhttp.Do(c.ctx_, c.s.client, req) + } + return c.s.client.Do(req) +} + +// Do executes the "drive.files.list" call. +// Exactly one of *FileList or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *FileList.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 *FilesListCall) Do(opts ...googleapi.CallOption) (*FileList, 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 := &FileList{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Lists or searches files.", + // "httpMethod": "GET", + // "id": "drive.files.list", + // "parameters": { + // "corpus": { + // "default": "user", + // "description": "The source of files to list.", + // "enum": [ + // "domain", + // "user" + // ], + // "enumDescriptions": [ + // "Files shared to the user's domain.", + // "Files owned by or shared to the user." + // ], + // "location": "query", + // "type": "string" + // }, + // "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.", + // "location": "query", + // "type": "string" + // }, + // "pageSize": { + // "default": "100", + // "description": "The maximum number of files 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" + // }, + // "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" + // } + // }, + // "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" + // ] + // } + +} + +// 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 *FilesListCall) Pages(ctx context.Context, f func(*FileList) 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.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 +} + +// Update: Updates a file's metadata and/or content with patch +// semantics. +func (r *FilesService) Update(fileId string, file *File) *FilesUpdateCall { + c := &FilesUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.file = file + return c +} + +// AddParents sets the optional parameter "addParents": A +// comma-separated list of parent IDs to add. +func (c *FilesUpdateCall) AddParents(addParents string) *FilesUpdateCall { + c.urlParams_.Set("addParents", addParents) + return c +} + +// KeepRevisionForever sets the optional parameter +// "keepRevisionForever": Whether to set the 'keepForever' field in the +// new head revision. This is only applicable to files with binary +// content in Drive. +func (c *FilesUpdateCall) KeepRevisionForever(keepRevisionForever bool) *FilesUpdateCall { + c.urlParams_.Set("keepRevisionForever", fmt.Sprint(keepRevisionForever)) + return c +} + +// OcrLanguage sets the optional parameter "ocrLanguage": A language +// hint for OCR processing during image import (ISO 639-1 code). +func (c *FilesUpdateCall) OcrLanguage(ocrLanguage string) *FilesUpdateCall { + c.urlParams_.Set("ocrLanguage", ocrLanguage) + return c +} + +// RemoveParents sets the optional parameter "removeParents": A +// comma-separated list of parent IDs to remove. +func (c *FilesUpdateCall) RemoveParents(removeParents string) *FilesUpdateCall { + c.urlParams_.Set("removeParents", removeParents) + return c +} + +// UseContentAsIndexableText sets the optional parameter +// "useContentAsIndexableText": Whether to use the uploaded content as +// indexable text. +func (c *FilesUpdateCall) UseContentAsIndexableText(useContentAsIndexableText bool) *FilesUpdateCall { + c.urlParams_.Set("useContentAsIndexableText", fmt.Sprint(useContentAsIndexableText)) + return c +} + +// Media specifies the media to upload in one or more chunks. The chunk +// size may be controlled by supplying a MediaOption generated by +// googleapi.ChunkSize. The chunk size defaults to +// googleapi.DefaultUploadChunkSize.The Content-Type header used in the +// upload request will be determined by sniffing the contents of r, +// unless a MediaOption generated by googleapi.ContentType is +// 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) + return c +} + +// ResumableMedia specifies the media to upload in chunks and can be +// canceled with ctx. +// +// Deprecated: use Media instead. +// +// At most one of Media and ResumableMedia may be set. mediaType +// identifies the MIME media type of the upload, such as "image/png". If +// mediaType is "", it will be auto-detected. The provided ctx will +// 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 + return c +} + +// ProgressUpdater provides a callback function that will be called +// after every chunk. It should be a low-latency function in order to +// 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 + 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 *FilesUpdateCall) Fields(s ...googleapi.Field) *FilesUpdateCall { + 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. +// This context will supersede any context previously provided to the +// ResumableMedia method. +func (c *FilesUpdateCall) Context(ctx context.Context) *FilesUpdateCall { + c.ctx_ = ctx + return c +} + +func (c *FilesUpdateCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.file) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}") + if c.media_ != nil || c.resumableBuffer_ != 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 + } + req, _ := http.NewRequest("PATCH", urls, body) + 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) +} + +// Do executes the "drive.files.update" call. +// Exactly one of *File or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *File.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 *FilesUpdateCall) Do(opts ...googleapi.CallOption) (*File, 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 + } + 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_) + } + }, + } + ctx := c.ctx_ + if ctx == nil { + ctx = context.TODO() + } + res, err = rx.Upload(ctx) + if err != nil { + return nil, err + } + defer res.Body.Close() + if err := googleapi.CheckResponse(res); err != nil { + return nil, err + } + } + ret := &File{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // }, + // "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 + // } + +} + +// method id "drive.files.watch": + +type FilesWatchCall struct { + s *Service + fileId string + channel *Channel + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Watch: Subscribes to changes to a file +func (r *FilesService) Watch(fileId string, channel *Channel) *FilesWatchCall { + c := &FilesWatchCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.channel = channel + return c +} + +// AcknowledgeAbuse sets the optional parameter "acknowledgeAbuse": +// Whether the user is acknowledging the risk of downloading known +// malware or other abusive files. This is only applicable when +// alt=media. +func (c *FilesWatchCall) AcknowledgeAbuse(acknowledgeAbuse bool) *FilesWatchCall { + c.urlParams_.Set("acknowledgeAbuse", fmt.Sprint(acknowledgeAbuse)) + 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 *FilesWatchCall) Fields(s ...googleapi.Field) *FilesWatchCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// Context sets the context to be used in this call's Do and Download +// methods. Any pending HTTP request will be aborted if the provided +// context is canceled. +func (c *FilesWatchCall) Context(ctx context.Context) *FilesWatchCall { + c.ctx_ = ctx + return c +} + +func (c *FilesWatchCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/watch") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("POST", urls, body) + 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) +} + +// Download fetches the API endpoint's "media" value, instead of the normal +// API response value. If the returned error is nil, the Response is guaranteed to +// have a 2xx status code. Callers must close the Response.Body as usual. +func (c *FilesWatchCall) Download(opts ...googleapi.CallOption) (*http.Response, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("media") + if err != nil { + return nil, err + } + if err := googleapi.CheckMediaResponse(res); err != nil { + res.Body.Close() + return nil, err + } + return res, nil +} + +// Do executes the "drive.files.watch" call. +// Exactly one of *Channel or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *Channel.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 *FilesWatchCall) Do(opts ...googleapi.CallOption) (*Channel, 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 := &Channel{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // } + // }, + // "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 + // } + +} + +// method id "drive.permissions.create": + +type PermissionsCreateCall struct { + s *Service + fileId string + permission *Permission + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Create: Creates a permission for a file. +func (r *PermissionsService) Create(fileId string, permission *Permission) *PermissionsCreateCall { + c := &PermissionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.permission = permission + return c +} + +// EmailMessage sets the optional parameter "emailMessage": A custom +// message to include in the notification email. +func (c *PermissionsCreateCall) EmailMessage(emailMessage string) *PermissionsCreateCall { + c.urlParams_.Set("emailMessage", emailMessage) + return c +} + +// SendNotificationEmail sets the optional parameter +// "sendNotificationEmail": 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. +func (c *PermissionsCreateCall) SendNotificationEmail(sendNotificationEmail bool) *PermissionsCreateCall { + c.urlParams_.Set("sendNotificationEmail", fmt.Sprint(sendNotificationEmail)) + 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 +// acknowledgement of the side effect. +func (c *PermissionsCreateCall) TransferOwnership(transferOwnership bool) *PermissionsCreateCall { + c.urlParams_.Set("transferOwnership", fmt.Sprint(transferOwnership)) + 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 *PermissionsCreateCall) Fields(s ...googleapi.Field) *PermissionsCreateCall { + 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 *PermissionsCreateCall) Context(ctx context.Context) *PermissionsCreateCall { + c.ctx_ = ctx + return c +} + +func (c *PermissionsCreateCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.permission) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/permissions") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("POST", urls, body) + 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) +} + +// Do executes the "drive.permissions.create" call. +// Exactly one of *Permission or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *Permission.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 *PermissionsCreateCall) Do(opts ...googleapi.CallOption) (*Permission, 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 := &Permission{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Creates a permission for a file.", + // "httpMethod": "POST", + // "id": "drive.permissions.create", + // "parameterOrder": [ + // "fileId" + // ], + // "parameters": { + // "emailMessage": { + // "description": "A custom message to include in the notification email.", + // "location": "query", + // "type": "string" + // }, + // "fileId": { + // "description": "The ID of the file.", + // "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" + // }, + // "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" + // } + // }, + // "path": "files/{fileId}/permissions", + // "request": { + // "$ref": "Permission" + // }, + // "response": { + // "$ref": "Permission" + // }, + // "scopes": [ + // "https://www.googleapis.com/auth/drive", + // "https://www.googleapis.com/auth/drive.file" + // ] + // } + +} + +// method id "drive.permissions.delete": + +type PermissionsDeleteCall struct { + s *Service + fileId string + permissionId string + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Delete: Deletes a permission. +func (r *PermissionsService) Delete(fileId string, permissionId string) *PermissionsDeleteCall { + c := &PermissionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.permissionId = permissionId + 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 *PermissionsDeleteCall) Fields(s ...googleapi.Field) *PermissionsDeleteCall { + 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 *PermissionsDeleteCall) Context(ctx context.Context) *PermissionsDeleteCall { + c.ctx_ = ctx + return c +} + +func (c *PermissionsDeleteCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/permissions/{permissionId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("DELETE", urls, body) + 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) +} + +// Do executes the "drive.permissions.delete" call. +func (c *PermissionsDeleteCall) 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": "Deletes a permission.", + // "httpMethod": "DELETE", + // "id": "drive.permissions.delete", + // "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" + // } + // }, + // "path": "files/{fileId}/permissions/{permissionId}", + // "scopes": [ + // "https://www.googleapis.com/auth/drive", + // "https://www.googleapis.com/auth/drive.file" + // ] + // } + +} + +// method id "drive.permissions.get": + +type PermissionsGetCall struct { + s *Service + fileId string + permissionId string + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// Get: Gets a permission by ID. +func (r *PermissionsService) Get(fileId string, permissionId string) *PermissionsGetCall { + c := &PermissionsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.permissionId = permissionId + 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 *PermissionsGetCall) Fields(s ...googleapi.Field) *PermissionsGetCall { + 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 *PermissionsGetCall) IfNoneMatch(entityTag string) *PermissionsGetCall { + 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 *PermissionsGetCall) Context(ctx context.Context) *PermissionsGetCall { + c.ctx_ = ctx + return c +} + +func (c *PermissionsGetCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/permissions/{permissionId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("GET", urls, body) + 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) +} + +// Do executes the "drive.permissions.get" call. +// Exactly one of *Permission or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *Permission.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 *PermissionsGetCall) Do(opts ...googleapi.CallOption) (*Permission, 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 := &Permission{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // } + // }, + // "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" + // ] + // } + +} + +// method id "drive.permissions.list": + +type PermissionsListCall struct { + s *Service + fileId string + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// List: Lists a file's permissions. +func (r *PermissionsService) List(fileId string) *PermissionsListCall { + c := &PermissionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + 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 *PermissionsListCall) Fields(s ...googleapi.Field) *PermissionsListCall { + 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 *PermissionsListCall) IfNoneMatch(entityTag string) *PermissionsListCall { + 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 *PermissionsListCall) Context(ctx context.Context) *PermissionsListCall { + c.ctx_ = ctx + return c +} + +func (c *PermissionsListCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/permissions") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("GET", urls, body) + 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) +} + +// Do executes the "drive.permissions.list" call. +// Exactly one of *PermissionList or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *PermissionList.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 *PermissionsListCall) Do(opts ...googleapi.CallOption) (*PermissionList, 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 := &PermissionList{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Lists a file's permissions.", + // "httpMethod": "GET", + // "id": "drive.permissions.list", + // "parameterOrder": [ + // "fileId" + // ], + // "parameters": { + // "fileId": { + // "description": "The ID of the file.", + // "location": "path", + // "required": true, + // "type": "string" + // } + // }, + // "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" + // ] + // } + +} + +// method id "drive.permissions.update": + +type PermissionsUpdateCall struct { + s *Service + fileId string + permissionId string + permission *Permission + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Update: Updates a permission with patch semantics. +func (r *PermissionsService) Update(fileId string, permissionId string, permission *Permission) *PermissionsUpdateCall { + c := &PermissionsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.permissionId = permissionId + c.permission = permission + 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 +// acknowledgement of the side effect. +func (c *PermissionsUpdateCall) TransferOwnership(transferOwnership bool) *PermissionsUpdateCall { + c.urlParams_.Set("transferOwnership", fmt.Sprint(transferOwnership)) + 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 *PermissionsUpdateCall) Fields(s ...googleapi.Field) *PermissionsUpdateCall { + 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 *PermissionsUpdateCall) Context(ctx context.Context) *PermissionsUpdateCall { + c.ctx_ = ctx + return c +} + +func (c *PermissionsUpdateCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.permission) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/permissions/{permissionId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("PATCH", urls, body) + 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) +} + +// Do executes the "drive.permissions.update" call. +// Exactly one of *Permission or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *Permission.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 *PermissionsUpdateCall) Do(opts ...googleapi.CallOption) (*Permission, 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 := &Permission{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Updates a permission with patch semantics.", + // "httpMethod": "PATCH", + // "id": "drive.permissions.update", + // "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" + // }, + // "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" + // } + // }, + // "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" + // ] + // } + +} + +// method id "drive.replies.create": + +type RepliesCreateCall struct { + s *Service + fileId string + commentId string + reply *Reply + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Create: Creates a new reply to a comment. +func (r *RepliesService) Create(fileId string, commentId string, reply *Reply) *RepliesCreateCall { + c := &RepliesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.commentId = commentId + c.reply = reply + 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 *RepliesCreateCall) Fields(s ...googleapi.Field) *RepliesCreateCall { + 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 *RepliesCreateCall) Context(ctx context.Context) *RepliesCreateCall { + c.ctx_ = ctx + return c +} + +func (c *RepliesCreateCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.reply) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}/replies") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("POST", urls, body) + 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) +} + +// Do executes the "drive.replies.create" call. +// Exactly one of *Reply or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *Reply.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 *RepliesCreateCall) Do(opts ...googleapi.CallOption) (*Reply, 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 := &Reply{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // ] + // } + +} + +// method id "drive.replies.delete": + +type RepliesDeleteCall struct { + s *Service + fileId string + commentId string + replyId string + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Delete: Deletes a reply. +func (r *RepliesService) Delete(fileId string, commentId string, replyId string) *RepliesDeleteCall { + c := &RepliesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.commentId = commentId + c.replyId = replyId + 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 *RepliesDeleteCall) Fields(s ...googleapi.Field) *RepliesDeleteCall { + 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 *RepliesDeleteCall) Context(ctx context.Context) *RepliesDeleteCall { + c.ctx_ = ctx + return c +} + +func (c *RepliesDeleteCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}/replies/{replyId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("DELETE", urls, body) + 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) +} + +// Do executes the "drive.replies.delete" call. +func (c *RepliesDeleteCall) 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": "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" + // ] + // } + +} + +// method id "drive.replies.get": + +type RepliesGetCall struct { + s *Service + fileId string + commentId string + replyId string + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// Get: Gets a reply by ID. +func (r *RepliesService) Get(fileId string, commentId string, replyId string) *RepliesGetCall { + c := &RepliesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.commentId = commentId + c.replyId = replyId + return c +} + +// IncludeDeleted sets the optional parameter "includeDeleted": Whether +// to return deleted replies. Deleted replies will not include their +// original content. +func (c *RepliesGetCall) IncludeDeleted(includeDeleted bool) *RepliesGetCall { + c.urlParams_.Set("includeDeleted", fmt.Sprint(includeDeleted)) + 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 *RepliesGetCall) Fields(s ...googleapi.Field) *RepliesGetCall { + 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 *RepliesGetCall) IfNoneMatch(entityTag string) *RepliesGetCall { + 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 *RepliesGetCall) Context(ctx context.Context) *RepliesGetCall { + c.ctx_ = ctx + return c +} + +func (c *RepliesGetCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}/replies/{replyId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("GET", urls, body) + 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) +} + +// Do executes the "drive.replies.get" call. +// Exactly one of *Reply or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *Reply.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 *RepliesGetCall) Do(opts ...googleapi.CallOption) (*Reply, 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 := &Reply{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // ] + // } + +} + +// method id "drive.replies.list": + +type RepliesListCall struct { + s *Service + fileId string + commentId string + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// List: Lists a comment's replies. +func (r *RepliesService) List(fileId string, commentId string) *RepliesListCall { + c := &RepliesListCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.commentId = commentId + return c +} + +// IncludeDeleted sets the optional parameter "includeDeleted": Whether +// to include deleted replies. Deleted replies will not include their +// original content. +func (c *RepliesListCall) IncludeDeleted(includeDeleted bool) *RepliesListCall { + c.urlParams_.Set("includeDeleted", fmt.Sprint(includeDeleted)) + return c +} + +// PageSize sets the optional parameter "pageSize": The maximum number +// of replies to return per page. +func (c *RepliesListCall) PageSize(pageSize int64) *RepliesListCall { + 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 *RepliesListCall) PageToken(pageToken string) *RepliesListCall { + 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. +func (c *RepliesListCall) Fields(s ...googleapi.Field) *RepliesListCall { + 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 *RepliesListCall) IfNoneMatch(entityTag string) *RepliesListCall { + 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 *RepliesListCall) Context(ctx context.Context) *RepliesListCall { + c.ctx_ = ctx + return c +} + +func (c *RepliesListCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}/replies") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("GET", urls, body) + 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) +} + +// Do executes the "drive.replies.list" call. +// Exactly one of *ReplyList or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *ReplyList.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 *RepliesListCall) Do(opts ...googleapi.CallOption) (*ReplyList, 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 := &ReplyList{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // ] + // } + +} + +// 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 *RepliesListCall) Pages(ctx context.Context, f func(*ReplyList) 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.replies.update": + +type RepliesUpdateCall struct { + s *Service + fileId string + commentId string + replyId string + reply *Reply + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Update: Updates a reply with patch semantics. +func (r *RepliesService) Update(fileId string, commentId string, replyId string, reply *Reply) *RepliesUpdateCall { + c := &RepliesUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.commentId = commentId + c.replyId = replyId + c.reply = reply + 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 *RepliesUpdateCall) Fields(s ...googleapi.Field) *RepliesUpdateCall { + 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 *RepliesUpdateCall) Context(ctx context.Context) *RepliesUpdateCall { + c.ctx_ = ctx + return c +} + +func (c *RepliesUpdateCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.reply) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}/replies/{replyId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("PATCH", urls, body) + 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) +} + +// Do executes the "drive.replies.update" call. +// Exactly one of *Reply or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *Reply.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 *RepliesUpdateCall) Do(opts ...googleapi.CallOption) (*Reply, 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 := &Reply{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // ] + // } + +} + +// method id "drive.revisions.delete": + +type RevisionsDeleteCall struct { + s *Service + fileId string + revisionId string + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Delete: Permanently deletes a revision. This method is only +// applicable to files with binary content in Drive. +func (r *RevisionsService) Delete(fileId string, revisionId string) *RevisionsDeleteCall { + c := &RevisionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.revisionId = revisionId + 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 *RevisionsDeleteCall) Fields(s ...googleapi.Field) *RevisionsDeleteCall { + 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 *RevisionsDeleteCall) Context(ctx context.Context) *RevisionsDeleteCall { + c.ctx_ = ctx + return c +} + +func (c *RevisionsDeleteCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/revisions/{revisionId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("DELETE", urls, body) + 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) +} + +// Do executes the "drive.revisions.delete" call. +func (c *RevisionsDeleteCall) 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 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" + // ] + // } + +} + +// method id "drive.revisions.get": + +type RevisionsGetCall struct { + s *Service + fileId string + revisionId string + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// Get: Gets a revision's metadata or content by ID. +func (r *RevisionsService) Get(fileId string, revisionId string) *RevisionsGetCall { + c := &RevisionsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.revisionId = revisionId + return c +} + +// AcknowledgeAbuse sets the optional parameter "acknowledgeAbuse": +// Whether the user is acknowledging the risk of downloading known +// malware or other abusive files. This is only applicable when +// alt=media. +func (c *RevisionsGetCall) AcknowledgeAbuse(acknowledgeAbuse bool) *RevisionsGetCall { + c.urlParams_.Set("acknowledgeAbuse", fmt.Sprint(acknowledgeAbuse)) + 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 *RevisionsGetCall) Fields(s ...googleapi.Field) *RevisionsGetCall { + 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 *RevisionsGetCall) IfNoneMatch(entityTag string) *RevisionsGetCall { + c.ifNoneMatch_ = entityTag + return c +} + +// Context sets the context to be used in this call's Do and Download +// methods. Any pending HTTP request will be aborted if the provided +// context is canceled. +func (c *RevisionsGetCall) Context(ctx context.Context) *RevisionsGetCall { + c.ctx_ = ctx + return c +} + +func (c *RevisionsGetCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/revisions/{revisionId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("GET", urls, body) + 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) +} + +// Download fetches the API endpoint's "media" value, instead of the normal +// API response value. If the returned error is nil, the Response is guaranteed to +// have a 2xx status code. Callers must close the Response.Body as usual. +func (c *RevisionsGetCall) Download(opts ...googleapi.CallOption) (*http.Response, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("media") + if err != nil { + return nil, err + } + if err := googleapi.CheckMediaResponse(res); err != nil { + res.Body.Close() + return nil, err + } + return res, nil +} + +// Do executes the "drive.revisions.get" call. +// Exactly one of *Revision or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *Revision.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 *RevisionsGetCall) Do(opts ...googleapi.CallOption) (*Revision, 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 := &Revision{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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 + // } + +} + +// method id "drive.revisions.list": + +type RevisionsListCall struct { + s *Service + fileId string + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context +} + +// List: Lists a file's revisions. +func (r *RevisionsService) List(fileId string) *RevisionsListCall { + c := &RevisionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + 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 *RevisionsListCall) Fields(s ...googleapi.Field) *RevisionsListCall { + 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 *RevisionsListCall) IfNoneMatch(entityTag string) *RevisionsListCall { + 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 *RevisionsListCall) Context(ctx context.Context) *RevisionsListCall { + c.ctx_ = ctx + return c +} + +func (c *RevisionsListCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/revisions") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("GET", urls, body) + 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) +} + +// Do executes the "drive.revisions.list" call. +// Exactly one of *RevisionList or error will be non-nil. Any non-2xx +// status code is an error. Response headers are in either +// *RevisionList.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 *RevisionsListCall) Do(opts ...googleapi.CallOption) (*RevisionList, 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 := &RevisionList{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // } + // }, + // "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" + // ] + // } + +} + +// method id "drive.revisions.update": + +type RevisionsUpdateCall struct { + s *Service + fileId string + revisionId string + revision *Revision + urlParams_ gensupport.URLParams + ctx_ context.Context +} + +// Update: Updates a revision with patch semantics. +func (r *RevisionsService) Update(fileId string, revisionId string, revision *Revision) *RevisionsUpdateCall { + c := &RevisionsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.fileId = fileId + c.revisionId = revisionId + c.revision = revision + 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 *RevisionsUpdateCall) Fields(s ...googleapi.Field) *RevisionsUpdateCall { + 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 *RevisionsUpdateCall) Context(ctx context.Context) *RevisionsUpdateCall { + c.ctx_ = ctx + return c +} + +func (c *RevisionsUpdateCall) doRequest(alt string) (*http.Response, error) { + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.revision) + if err != nil { + return nil, err + } + ctype := "application/json" + c.urlParams_.Set("alt", alt) + urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/revisions/{revisionId}") + urls += "?" + c.urlParams_.Encode() + req, _ := http.NewRequest("PATCH", urls, body) + 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) +} + +// Do executes the "drive.revisions.update" call. +// Exactly one of *Revision or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *Revision.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 *RevisionsUpdateCall) Do(opts ...googleapi.CallOption) (*Revision, 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 := &Revision{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { + return nil, err + } + return ret, nil + // { + // "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" + // ] + // } + +} diff --git a/vendor/google.golang.org/api/gensupport/backoff.go b/vendor/google.golang.org/api/gensupport/backoff.go new file mode 100644 index 0000000..1356140 --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/backoff.go @@ -0,0 +1,46 @@ +// 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 ( + "math/rand" + "time" +) + +type BackoffStrategy interface { + // Pause returns the duration of the next pause and true if the operation should be + // retried, or false if no further retries should be attempted. + Pause() (time.Duration, bool) + + // Reset restores the strategy to its initial state. + Reset() +} + +// ExponentialBackoff performs exponential backoff as per https://en.wikipedia.org/wiki/Exponential_backoff. +// The initial pause time is given by Base. +// Once the total pause time exceeds Max, Pause will indicate no further retries. +type ExponentialBackoff struct { + Base time.Duration + Max time.Duration + total time.Duration + n uint +} + +func (eb *ExponentialBackoff) Pause() (time.Duration, bool) { + if eb.total > eb.Max { + return 0, false + } + + // The next pause is selected from randomly from [0, 2^n * Base). + d := time.Duration(rand.Int63n((1 << eb.n) * int64(eb.Base))) + eb.total += d + eb.n++ + return d, true +} + +func (eb *ExponentialBackoff) Reset() { + eb.n = 0 + eb.total = 0 +} diff --git a/vendor/google.golang.org/api/gensupport/buffer.go b/vendor/google.golang.org/api/gensupport/buffer.go new file mode 100644 index 0000000..4b8ec14 --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/buffer.go @@ -0,0 +1,77 @@ +// 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 ( + "bytes" + "io" + + "google.golang.org/api/googleapi" +) + +// ResumableBuffer buffers data from an io.Reader to support uploading media in retryable chunks. +type ResumableBuffer struct { + media io.Reader + + chunk []byte // The current chunk which is pending upload. The capacity is the chunk size. + err error // Any error generated when populating chunk by reading media. + + // The absolute position of chunk in the underlying media. + off int64 +} + +func NewResumableBuffer(media io.Reader, chunkSize int) *ResumableBuffer { + return &ResumableBuffer{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) { + // 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() + } + return bytes.NewReader(rb.chunk), rb.off, len(rb.chunk), rb.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] + + read := 0 + var err error + for err == nil && read < bufSize { + var n int + n, err = rb.media.Read(rb.chunk[read:]) + read += n + } + rb.chunk = rb.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] +} + +type readerTyper struct { + io.Reader + googleapi.ContentTyper +} + +// ReaderAtToReader adapts a ReaderAt to be used as a Reader. +// If ra implements googleapi.ContentTyper, then the returned reader +// will also implement googleapi.ContentTyper, delegating to ra. +func ReaderAtToReader(ra io.ReaderAt, size int64) io.Reader { + r := io.NewSectionReader(ra, 0, size) + if typer, ok := ra.(googleapi.ContentTyper); ok { + return readerTyper{r, typer} + } + return r +} diff --git a/vendor/google.golang.org/api/gensupport/doc.go b/vendor/google.golang.org/api/gensupport/doc.go new file mode 100644 index 0000000..752c4b4 --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/doc.go @@ -0,0 +1,10 @@ +// 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 is an internal implementation detail used by code +// generated by the google-api-go-generator tool. +// +// This package may be modified at any time without regard for backwards +// compatibility. It should not be used directly by API users. +package gensupport diff --git a/vendor/google.golang.org/api/gensupport/json.go b/vendor/google.golang.org/api/gensupport/json.go new file mode 100644 index 0000000..dd7bcd2 --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/json.go @@ -0,0 +1,172 @@ +// 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 gensupport + +import ( + "encoding/json" + "fmt" + "reflect" + "strings" +) + +// 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. +// 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 { + return json.Marshal(schema) + } + + mustInclude := make(map[string]struct{}) + for _, f := range forceSendFields { + mustInclude[f] = struct{}{} + } + + dataMap, err := schemaToMap(schema, mustInclude) + if err != nil { + return nil, err + } + return json.Marshal(dataMap) +} + +func schemaToMap(schema interface{}, mustInclude map[string]struct{}) (map[string]interface{}, error) { + m := make(map[string]interface{}) + s := reflect.ValueOf(schema) + st := s.Type() + + for i := 0; i < s.NumField(); i++ { + jsonTag := st.Field(i).Tag.Get("json") + if jsonTag == "" { + continue + } + tag, err := parseJSONTag(jsonTag) + if err != nil { + return nil, err + } + if tag.ignore { + continue + } + + v := s.Field(i) + f := st.Field(i) + if !includeField(v, f, mustInclude) { + continue + } + + // nil maps are treated as empty maps. + if f.Type.Kind() == reflect.Map && v.IsNil() { + m[tag.apiName] = map[string]string{} + continue + } + + // nil slices are treated as empty slices. + if f.Type.Kind() == reflect.Slice && v.IsNil() { + m[tag.apiName] = []bool{} + continue + } + + if tag.stringFormat { + m[tag.apiName] = formatAsString(v, f.Type.Kind()) + } else { + m[tag.apiName] = v.Interface() + } + } + return m, nil +} + +// formatAsString returns a string representation of v, dereferencing it first if possible. +func formatAsString(v reflect.Value, kind reflect.Kind) string { + if kind == reflect.Ptr && !v.IsNil() { + v = v.Elem() + } + + return fmt.Sprintf("%v", v.Interface()) +} + +// jsonTag represents a restricted version of the struct tag format used by encoding/json. +// It is used to describe the JSON encoding of fields in a Schema struct. +type jsonTag struct { + apiName string + stringFormat bool + ignore bool +} + +// parseJSONTag parses a restricted version of the struct tag format used by encoding/json. +// The format of the tag must match that generated by the Schema.writeSchemaStruct method +// in the api generator. +func parseJSONTag(val string) (jsonTag, error) { + if val == "-" { + return jsonTag{ignore: true}, nil + } + + var tag jsonTag + + i := strings.Index(val, ",") + if i == -1 || val[:i] == "" { + return tag, fmt.Errorf("malformed json tag: %s", val) + } + + tag = jsonTag{ + apiName: val[:i], + } + + switch val[i+1:] { + case "omitempty": + case "omitempty,string": + tag.stringFormat = true + default: + return tag, fmt.Errorf("malformed json tag: %s", val) + } + + return tag, nil +} + +// 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 { + // 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. + // Rather than partially supporting field deletion, we ignore mustInclude for nil pointer fields. + // Deletion will be handled by a separate mechanism. + if f.Type.Kind() == reflect.Ptr && v.IsNil() { + return false + } + + // The "any" type is represented as an interface{}. If this interface + // is nil, there is no reasonable representation to send. We ignore + // these fields, for the same reasons as given above for pointers. + if f.Type.Kind() == reflect.Interface && v.IsNil() { + return false + } + + _, ok := mustInclude[f.Name] + return ok || !isEmptyValue(v) +} + +// isEmptyValue reports whether v is the empty value for its type. This +// implementation is based on that of the encoding/json package, but its +// correctness does not depend on it being identical. What's important is that +// this function return false in situations where v should not be sent as part +// of a PATCH operation. +func isEmptyValue(v reflect.Value) bool { + switch v.Kind() { + case reflect.Array, reflect.Map, reflect.Slice, reflect.String: + return v.Len() == 0 + case reflect.Bool: + return !v.Bool() + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.Interface, reflect.Ptr: + return v.IsNil() + } + return false +} diff --git a/vendor/google.golang.org/api/gensupport/media.go b/vendor/google.golang.org/api/gensupport/media.go new file mode 100644 index 0000000..817f46f --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/media.go @@ -0,0 +1,200 @@ +// 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 ( + "fmt" + "io" + "io/ioutil" + "mime/multipart" + "net/http" + "net/textproto" + + "google.golang.org/api/googleapi" +) + +const sniffBuffSize = 512 + +func newContentSniffer(r io.Reader) *contentSniffer { + return &contentSniffer{r: r} +} + +// contentSniffer wraps a Reader, and reports the content type determined by sniffing up to 512 bytes from the Reader. +type contentSniffer struct { + r io.Reader + start []byte // buffer for the sniffed bytes. + err error // set to any error encountered while reading bytes to be sniffed. + + ctype string // set on first sniff. + sniffed bool // set to true on first sniff. +} + +func (cs *contentSniffer) Read(p []byte) (n int, err error) { + // Ensure that the content type is sniffed before any data is consumed from Reader. + _, _ = cs.ContentType() + + if len(cs.start) > 0 { + n := copy(p, cs.start) + cs.start = cs.start[n:] + return n, nil + } + + // We may have read some bytes into start while sniffing, even if the read ended in an error. + // We should first return those bytes, then the error. + if cs.err != nil { + return 0, cs.err + } + + // Now we have handled all bytes that were buffered while sniffing. Now just delegate to the underlying reader. + return cs.r.Read(p) +} + +// ContentType returns the sniffed content type, and whether the content type was succesfully sniffed. +func (cs *contentSniffer) ContentType() (string, bool) { + if cs.sniffed { + return cs.ctype, cs.ctype != "" + } + cs.sniffed = true + // If ReadAll hits EOF, it returns err==nil. + cs.start, cs.err = ioutil.ReadAll(io.LimitReader(cs.r, sniffBuffSize)) + + // Don't try to detect the content type based on possibly incomplete data. + if cs.err != nil { + return "", false + } + + cs.ctype = http.DetectContentType(cs.start) + return cs.ctype, true +} + +// DetermineContentType determines the content type of the supplied reader. +// If the content type is already known, it can be specified via ctype. +// Otherwise, the content of media will be sniffed to determine the content type. +// If media implements googleapi.ContentTyper (deprecated), this will be used +// instead of sniffing the content. +// After calling DetectContentType the caller must not perform further reads on +// media, but rather read from the Reader that is returned. +func DetermineContentType(media io.Reader, ctype string) (io.Reader, string) { + // Note: callers could avoid calling DetectContentType if ctype != "", + // but doing the check inside this function reduces the amount of + // generated code. + if ctype != "" { + return media, ctype + } + + // For backwards compatability, allow clients to set content + // type by providing a ContentTyper for media. + if typer, ok := media.(googleapi.ContentTyper); ok { + return media, typer.ContentType() + } + + sniffer := newContentSniffer(media) + if ctype, ok := sniffer.ContentType(); ok { + return sniffer, ctype + } + // If content type could not be sniffed, reads from sniffer will eventually fail with an error. + return sniffer, "" +} + +type typeReader struct { + io.Reader + typ string +} + +// multipartReader combines the contents of multiple readers to creat 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 +} + +func newMultipartReader(parts []typeReader) *multipartReader { + mp := &multipartReader{pipeOpen: true} + var pw *io.PipeWriter + mp.pr, pw = io.Pipe() + mpw := multipart.NewWriter(pw) + mp.ctype = "multipart/related; boundary=" + mpw.Boundary() + go func() { + for _, part := range parts { + w, err := mpw.CreatePart(typeHeader(part.typ)) + if err != nil { + mpw.Close() + pw.CloseWithError(fmt.Errorf("googleapi: CreatePart failed: %v", err)) + return + } + _, err = io.Copy(w, part.Reader) + if err != nil { + mpw.Close() + pw.CloseWithError(fmt.Errorf("googleapi: Copy failed: %v", err)) + return + } + } + + mpw.Close() + pw.Close() + }() + return mp +} + +func (mp *multipartReader) Read(data []byte) (n int, err error) { + return mp.pr.Read(data) +} + +func (mp *multipartReader) Close() error { + if !mp.pipeOpen { + return nil + } + mp.pipeOpen = false + return mp.pr.Close() +} + +// CombineBodyMedia combines a json body with media content to create a multipart/related HTTP body. +// It returns a ReadCloser containing the combined body, and the overall "multipart/related" content type, with random boundary. +// +// The caller must call Close on the returned ReadCloser if reads are abandoned before reaching EOF. +func CombineBodyMedia(body io.Reader, bodyContentType string, media io.Reader, mediaContentType string) (io.ReadCloser, string) { + mp := newMultipartReader([]typeReader{ + {body, bodyContentType}, + {media, mediaContentType}, + }) + return mp, mp.ctype +} + +func typeHeader(contentType string) textproto.MIMEHeader { + h := make(textproto.MIMEHeader) + if contentType != "" { + h.Set("Content-Type", contentType) + } + return h +} + +// 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. +// +// 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) { + if chunkSize == 0 { // do not chunk + return media, nil + } + + rb := NewResumableBuffer(media, chunkSize) + rdr, _, _, err := rb.Chunk() + + if err == io.EOF { // we can upload this in a single request + return rdr, 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 +} diff --git a/vendor/google.golang.org/api/gensupport/params.go b/vendor/google.golang.org/api/gensupport/params.go new file mode 100644 index 0000000..3b3c743 --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/params.go @@ -0,0 +1,50 @@ +// 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 gensupport + +import ( + "net/url" + + "google.golang.org/api/googleapi" +) + +// URLParams is a simplified replacement for url.Values +// that safely builds up URL parameters for encoding. +type URLParams map[string][]string + +// Get returns the first value for the given key, or "". +func (u URLParams) Get(key string) string { + vs := u[key] + if len(vs) == 0 { + return "" + } + return vs[0] +} + +// Set sets the key to value. +// It replaces any existing values. +func (u URLParams) Set(key, value string) { + u[key] = []string{value} +} + +// SetMulti sets the key to an array of values. +// It replaces any existing values. +// Note that values must not be modified after calling SetMulti +// so the caller is responsible for making a copy if necessary. +func (u URLParams) SetMulti(key string, values []string) { + u[key] = values +} + +// Encode encodes the values into ``URL encoded'' form +// ("bar=baz&foo=quux") sorted by key. +func (u URLParams) Encode() string { + return url.Values(u).Encode() +} + +func SetOptions(u URLParams, opts ...googleapi.CallOption) { + for _, o := range opts { + u.Set(o.Get()) + } +} diff --git a/vendor/google.golang.org/api/gensupport/resumable.go b/vendor/google.golang.org/api/gensupport/resumable.go new file mode 100644 index 0000000..b3e774a --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/resumable.go @@ -0,0 +1,198 @@ +// 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 ( + "fmt" + "io" + "net/http" + "sync" + "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. + // https://cloud.google.com/storage/docs/json_api/v1/status-codes#standardcodes + statusTooManyRequests = 429 +) + +// ResumableUpload is used by the generated APIs to provide resumable uploads. +// It is not used by developers directly. +type ResumableUpload struct { + Client *http.Client + // URI is the resumable resource destination provided by the server after specifying "&uploadType=resumable". + URI string + UserAgent string // User-Agent for header of the request + // Media is the object being uploaded. + Media *ResumableBuffer + // MediaType defines the media type, e.g. "image/jpeg". + MediaType string + + mu sync.Mutex // guards progress + progress int64 // number of bytes uploaded so far + + // Callback is an optional function that will be periodically called with the cumulative number of bytes uploaded. + Callback func(int64) + + // If not specified, a default exponential backoff strategy will be used. + Backoff BackoffStrategy +} + +// Progress returns the number of bytes uploaded at this point. +func (rx *ResumableUpload) Progress() int64 { + rx.mu.Lock() + defer rx.mu.Unlock() + return rx.progress +} + +// doUploadRequest performs a single HTTP request to upload data. +// off specifies the offset in rx.Media from which data is drawn. +// size is the number of bytes in data. +// final specifies whether data is the final chunk to be uploaded. +func (rx *ResumableUpload) doUploadRequest(ctx context.Context, data io.Reader, off, size int64, final bool) (*http.Response, error) { + req, err := http.NewRequest("POST", rx.URI, data) + if err != nil { + return nil, err + } + + req.ContentLength = size + var contentRange string + if final { + if size == 0 { + contentRange = fmt.Sprintf("bytes */%v", off) + } else { + contentRange = fmt.Sprintf("bytes %v-%v/%v", off, off+size-1, off+size) + } + } else { + contentRange = fmt.Sprintf("bytes %v-%v/*", off, off+size-1) + } + 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) + +} + +// reportProgress calls a user-supplied callback to report upload progress. +// If old==updated, the callback is not called. +func (rx *ResumableUpload) reportProgress(old, updated int64) { + if updated-old == 0 { + return + } + rx.mu.Lock() + rx.progress = updated + rx.mu.Unlock() + if rx.Callback != nil { + rx.Callback(updated) + } +} + +// transferChunk performs a single HTTP request to upload a single chunk from rx.Media. +func (rx *ResumableUpload) transferChunk(ctx context.Context) (*http.Response, error) { + chunk, off, size, err := rx.Media.Chunk() + + done := err == io.EOF + if !done && err != nil { + return nil, err + } + + res, err := rx.doUploadRequest(ctx, chunk, off, int64(size), done) + if err != nil { + return res, err + } + + if res.StatusCode == statusResumeIncomplete || res.StatusCode == http.StatusOK { + rx.reportProgress(off, off+int64(size)) + } + + if res.StatusCode == statusResumeIncomplete { + rx.Media.Next() + } + return res, nil +} + +func contextDone(ctx context.Context) bool { + select { + case <-ctx.Done(): + return true + default: + return false + } +} + +// Upload starts the process of a resumable upload with a cancellable context. +// 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. +// 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) { + var pause time.Duration + backoff := rx.Backoff + if backoff == nil { + backoff = DefaultBackoffStrategy() + } + + for { + // Ensure that we return in the case of cancelled context, even if pause is 0. + if contextDone(ctx) { + return nil, ctx.Err() + } + select { + case <-ctx.Done(): + return nil, ctx.Err() + case <-time.After(pause): + } + + resp, err = rx.transferChunk(ctx) + + var status int + if resp != nil { + status = resp.StatusCode + } + + // Check if we should retry the request. + if shouldRetry(status, err) { + var retry bool + pause, retry = backoff.Pause() + if retry { + if resp != nil && resp.Body != nil { + resp.Body.Close() + } + continue + } + } + + // If the chunk was uploaded successfully, but there's still + // more to go, upload the next chunk without any delay. + if status == statusResumeIncomplete { + pause = 0 + backoff.Reset() + resp.Body.Close() + continue + } + + // It's possible for err and resp to both be non-nil here, but we expose a simpler + // contract to our callers: exactly one of resp and err will be non-nil. This means + // that any response body must be closed here before returning a non-nil error. + if err != nil { + if resp != nil && resp.Body != nil { + resp.Body.Close() + } + return nil, err + } + + return resp, nil + } +} diff --git a/vendor/google.golang.org/api/gensupport/retry.go b/vendor/google.golang.org/api/gensupport/retry.go new file mode 100644 index 0000000..7f83d1d --- /dev/null +++ b/vendor/google.golang.org/api/gensupport/retry.go @@ -0,0 +1,77 @@ +package gensupport + +import ( + "io" + "net" + "net/http" + "time" + + "golang.org/x/net/context" +) + +// Retry invokes the given function, retrying it multiple times if the connection failed or +// the HTTP status response indicates the request should be attempted again. ctx may be nil. +func Retry(ctx context.Context, f func() (*http.Response, error), backoff BackoffStrategy) (*http.Response, error) { + for { + resp, err := f() + + var status int + if resp != nil { + status = resp.StatusCode + } + + // Return if we shouldn't retry. + pause, retry := backoff.Pause() + if !shouldRetry(status, err) || !retry { + return resp, err + } + + // Ensure the response body is closed, if any. + if resp != nil && resp.Body != nil { + resp.Body.Close() + } + + // Pause, but still listen to ctx.Done if context is not nil. + var done <-chan struct{} + if ctx != nil { + done = ctx.Done() + } + select { + case <-done: + return nil, ctx.Err() + case <-time.After(pause): + } + } +} + +// DefaultBackoffStrategy returns a default strategy to use for retrying failed upload requests. +func DefaultBackoffStrategy() BackoffStrategy { + return &ExponentialBackoff{ + Base: 250 * time.Millisecond, + Max: 16 * time.Second, + } +} + +// 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 { + 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/googleapi/googleapi.go b/vendor/google.golang.org/api/googleapi/googleapi.go new file mode 100644 index 0000000..858537e --- /dev/null +++ b/vendor/google.golang.org/api/googleapi/googleapi.go @@ -0,0 +1,432 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package googleapi contains the common code shared by all Google API +// libraries. +package googleapi + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "strings" + + "google.golang.org/api/googleapi/internal/uritemplates" +) + +// ContentTyper is an interface for Readers which know (or would like +// to override) their Content-Type. If a media body doesn't implement +// ContentTyper, the type is sniffed from the content using +// http.DetectContentType. +type ContentTyper interface { + ContentType() string +} + +// A SizeReaderAt is a ReaderAt with a Size method. +// An io.SectionReader implements SizeReaderAt. +type SizeReaderAt interface { + io.ReaderAt + Size() int64 +} + +// ServerResponse is embedded in each Do response and +// provides the HTTP status code and header sent by the server. +type ServerResponse struct { + // HTTPStatusCode is the server's response status code. + // When using a resource method's Do call, this will always be in the 2xx range. + HTTPStatusCode int + // Header contains the response header fields from the server. + Header http.Header +} + +const ( + Version = "0.5" + + // 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. + DefaultUploadChunkSize = 8 * 1024 * 1024 + + // The minimum chunk size that can be used for resumable uploads. All + // user-specified chunk sizes must be multiple of this value. + MinUploadChunkSize = 256 * 1024 +) + +// Error contains an error response from the server. +type Error struct { + // Code is the HTTP response status code and will always be populated. + Code int `json:"code"` + // Message is the server response message and is only populated when + // explicitly referenced by the JSON server response. + Message string `json:"message"` + // Body is the raw response returned by the server. + // It is often but not always JSON, depending on how the request fails. + Body string + // Header contains the response header fields from the server. + Header http.Header + + Errors []ErrorItem +} + +// ErrorItem is a detailed error code & message from the Google API frontend. +type ErrorItem struct { + // Reason is the typed error code. For example: "some_example". + Reason string `json:"reason"` + // Message is the human-readable description of the error. + Message string `json:"message"` +} + +func (e *Error) Error() string { + if len(e.Errors) == 0 && e.Message == "" { + return fmt.Sprintf("googleapi: got HTTP response code %d with body: %v", e.Code, e.Body) + } + var buf bytes.Buffer + fmt.Fprintf(&buf, "googleapi: Error %d: ", e.Code) + if e.Message != "" { + fmt.Fprintf(&buf, "%s", e.Message) + } + if len(e.Errors) == 0 { + return strings.TrimSpace(buf.String()) + } + if len(e.Errors) == 1 && e.Errors[0].Message == e.Message { + fmt.Fprintf(&buf, ", %s", e.Errors[0].Reason) + return buf.String() + } + fmt.Fprintln(&buf, "\nMore details:") + for _, v := range e.Errors { + fmt.Fprintf(&buf, "Reason: %s, Message: %s\n", v.Reason, v.Message) + } + return buf.String() +} + +type errorReply struct { + Error *Error `json:"error"` +} + +// CheckResponse returns an error (of type *Error) if the response +// status code is not 2xx. +func CheckResponse(res *http.Response) error { + if res.StatusCode >= 200 && res.StatusCode <= 299 { + return nil + } + slurp, err := ioutil.ReadAll(res.Body) + if err == nil { + jerr := new(errorReply) + err = json.Unmarshal(slurp, jerr) + if err == nil && jerr.Error != nil { + if jerr.Error.Code == 0 { + jerr.Error.Code = res.StatusCode + } + jerr.Error.Body = string(slurp) + return jerr.Error + } + } + return &Error{ + Code: res.StatusCode, + Body: string(slurp), + Header: res.Header, + } +} + +// IsNotModified reports whether err is the result of the +// server replying with http.StatusNotModified. +// Such error values are sometimes returned by "Do" methods +// on calls when If-None-Match is used. +func IsNotModified(err error) bool { + if err == nil { + return false + } + ae, ok := err.(*Error) + return ok && ae.Code == http.StatusNotModified +} + +// 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. +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), + } +} + +type MarshalStyle bool + +var WithDataWrapper = MarshalStyle(true) +var WithoutDataWrapper = MarshalStyle(false) + +func (wrap MarshalStyle) JSONReader(v interface{}) (io.Reader, error) { + buf := new(bytes.Buffer) + if wrap { + buf.Write([]byte(`{"data": `)) + } + err := json.NewEncoder(buf).Encode(v) + if err != nil { + return nil, err + } + if wrap { + buf.Write([]byte(`}`)) + } + return buf, nil +} + +// endingWithErrorReader from r until it returns an error. If the +// final error from r is io.EOF and e is non-nil, e is used instead. +type endingWithErrorReader struct { + r io.Reader + e error +} + +func (er endingWithErrorReader) Read(p []byte) (n int, err error) { + n, err = er.r.Read(p) + if err == io.EOF && er.e != nil { + err = er.e + } + return +} + +// countingWriter counts the number of bytes it receives to write, but +// discards them. +type countingWriter struct { + n *int64 +} + +func (w countingWriter) Write(p []byte) (int, error) { + *w.n += int64(len(p)) + return len(p), nil +} + +// ProgressUpdater is a function that is called upon every progress update of a resumable upload. +// This is the only part of a resumable upload (from googleapi) that is usable by the developer. +// The remaining usable pieces of resumable uploads is exposed in each auto-generated API. +type ProgressUpdater func(current, total int64) + +type MediaOption interface { + setOptions(o *MediaOptions) +} + +type contentTypeOption string + +func (ct contentTypeOption) setOptions(o *MediaOptions) { + o.ContentType = string(ct) + if o.ContentType == "" { + o.ForceEmptyContentType = true + } +} + +// ContentType returns a MediaOption which sets the Content-Type header for media uploads. +// If ctype is empty, the Content-Type header will be omitted. +func ContentType(ctype string) MediaOption { + return contentTypeOption(ctype) +} + +type chunkSizeOption int + +func (cs chunkSizeOption) setOptions(o *MediaOptions) { + size := int(cs) + if size%MinUploadChunkSize != 0 { + size += MinUploadChunkSize - (size % MinUploadChunkSize) + } + o.ChunkSize = size +} + +// ChunkSize returns a MediaOption which sets the chunk size for media uploads. +// size will be rounded up to the nearest multiple of 256K. +// Media which contains fewer than size bytes will be uploaded in a single request. +// Media which contains size bytes or more will be uploaded in separate chunks. +// If size is zero, media will be uploaded in a single request. +func ChunkSize(size int) MediaOption { + return chunkSizeOption(size) +} + +// MediaOptions stores options for customizing media upload. It is not used by developers directly. +type MediaOptions struct { + ContentType string + ForceEmptyContentType bool + + ChunkSize int +} + +// ProcessMediaOptions stores options from opts in a MediaOptions. +// It is not used by developers directly. +func ProcessMediaOptions(opts []MediaOption) *MediaOptions { + mo := &MediaOptions{ChunkSize: DefaultUploadChunkSize} + for _, o := range opts { + o.setOptions(mo) + } + return mo +} + +func ResolveRelative(basestr, relstr string) string { + u, _ := url.Parse(basestr) + rel, _ := url.Parse(relstr) + u = u.ResolveReference(rel) + us := u.String() + us = strings.Replace(us, "%7B", "{", -1) + us = strings.Replace(us, "%7D", "}", -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) + if err == nil { + u.Path = expanded + SetOpaque(u) + } +} + +// CloseBody is used to close res.Body. +// Prior to calling Close, it also tries to Read a small amount to see an EOF. +// Not seeing an EOF can prevent HTTP Transports from reusing connections. +func CloseBody(res *http.Response) { + if res == nil || res.Body == nil { + return + } + // Justification for 3 byte reads: two for up to "\r\n" after + // a JSON/XML document, and then 1 to see EOF if we haven't yet. + // TODO(bradfitz): detect Go 1.3+ and skip these reads. + // See https://codereview.appspot.com/58240043 + // and https://codereview.appspot.com/49570044 + buf := make([]byte, 1) + for i := 0; i < 3; i++ { + _, err := res.Body.Read(buf) + if err != nil { + break + } + } + res.Body.Close() + +} + +// VariantType returns the type name of the given variant. +// If the map doesn't contain the named key or the value is not a []interface{}, "" is returned. +// This is used to support "variant" APIs that can return one of a number of different types. +func VariantType(t map[string]interface{}) string { + s, _ := t["type"].(string) + return s +} + +// ConvertVariant uses the JSON encoder/decoder to fill in the struct 'dst' with the fields found in variant 'v'. +// This is used to support "variant" APIs that can return one of a number of different types. +// It reports whether the conversion was successful. +func ConvertVariant(v map[string]interface{}, dst interface{}) bool { + var buf bytes.Buffer + err := json.NewEncoder(&buf).Encode(v) + if err != nil { + return false + } + return json.Unmarshal(buf.Bytes(), dst) == nil +} + +// A Field names a field to be retrieved with a partial response. +// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse +// +// Partial responses can dramatically reduce the amount of data that must be sent to your application. +// In order to request partial responses, you can specify the full list of fields +// that your application needs by adding the Fields option to your request. +// +// Field strings use camelCase with leading lower-case characters to identify fields within the response. +// +// For example, if your response has a "NextPageToken" and a slice of "Items" with "Id" fields, +// you could request just those fields like this: +// +// svc.Events.List().Fields("nextPageToken", "items/id").Do() +// +// or if you were also interested in each Item's "Updated" field, you can combine them like this: +// +// svc.Events.List().Fields("nextPageToken", "items(id,updated)").Do() +// +// More information about field formatting can be found here: +// https://developers.google.com/+/api/#fields-syntax +// +// Another way to find field names is through the Google API explorer: +// https://developers.google.com/apis-explorer/#p/ +type Field string + +// CombineFields combines fields into a single string. +func CombineFields(s []Field) string { + r := make([]string, len(s)) + for i, v := range s { + r[i] = string(v) + } + return strings.Join(r, ",") +} + +// A CallOption is an optional argument to an API call. +// It should be treated as an opaque value by users of Google APIs. +// +// A CallOption is something that configures an API call in a way that is +// not specific to that API; for instance, controlling the quota user for +// an API call is common across many APIs, and is thus a CallOption. +type CallOption interface { + Get() (key, value string) +} + +// QuotaUser returns a CallOption that will set the quota user for a call. +// The quota user can be used by server-side applications to control accounting. +// It can be an arbitrary string up to 40 characters, and will override UserIP +// if both are provided. +func QuotaUser(u string) CallOption { return quotaUser(u) } + +type quotaUser string + +func (q quotaUser) Get() (string, string) { return "quotaUser", string(q) } + +// UserIP returns a CallOption that will set the "userIp" parameter of a call. +// This should be the IP address of the originating request. +func UserIP(ip string) CallOption { return userIP(ip) } + +type userIP string + +func (i userIP) Get() (string, string) { return "userIp", string(i) } + +// Trace returns a CallOption that enables diagnostic tracing for a call. +// traceToken is an ID supplied by Google support. +func Trace(traceToken string) CallOption { return traceTok(traceToken) } + +type traceTok string + +func (t traceTok) Get() (string, string) { return "trace", "token:" + string(t) } + +// TODO: Fields too diff --git a/vendor/google.golang.org/api/googleapi/internal/uritemplates/LICENSE b/vendor/google.golang.org/api/googleapi/internal/uritemplates/LICENSE new file mode 100644 index 0000000..de9c88c --- /dev/null +++ b/vendor/google.golang.org/api/googleapi/internal/uritemplates/LICENSE @@ -0,0 +1,18 @@ +Copyright (c) 2013 Joshua Tacoma + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/google.golang.org/api/googleapi/internal/uritemplates/uritemplates.go b/vendor/google.golang.org/api/googleapi/internal/uritemplates/uritemplates.go new file mode 100644 index 0000000..7c103ba --- /dev/null +++ b/vendor/google.golang.org/api/googleapi/internal/uritemplates/uritemplates.go @@ -0,0 +1,220 @@ +// Copyright 2013 Joshua Tacoma. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package uritemplates is a level 3 implementation of RFC 6570 (URI +// Template, http://tools.ietf.org/html/rfc6570). +// uritemplates does not support composite values (in Go: slices or maps) +// and so does not qualify as a level 4 implementation. +package uritemplates + +import ( + "bytes" + "errors" + "regexp" + "strconv" + "strings" +) + +var ( + unreserved = regexp.MustCompile("[^A-Za-z0-9\\-._~]") + reserved = regexp.MustCompile("[^A-Za-z0-9\\-._~:/?#[\\]@!$&'()*+,;=]") + validname = regexp.MustCompile("^([A-Za-z0-9_\\.]|%[0-9A-Fa-f][0-9A-Fa-f])+$") + hex = []byte("0123456789ABCDEF") +) + +func pctEncode(src []byte) []byte { + dst := make([]byte, len(src)*3) + for i, b := range src { + buf := dst[i*3 : i*3+3] + buf[0] = 0x25 + buf[1] = hex[b/16] + buf[2] = hex[b%16] + } + return dst +} + +func escape(s string, allowReserved bool) string { + if allowReserved { + return string(reserved.ReplaceAllFunc([]byte(s), pctEncode)) + } + return string(unreserved.ReplaceAllFunc([]byte(s), pctEncode)) +} + +// A uriTemplate is a parsed representation of a URI template. +type uriTemplate struct { + raw string + parts []templatePart +} + +// parse parses a URI template string into a uriTemplate object. +func parse(rawTemplate string) (*uriTemplate, error) { + split := strings.Split(rawTemplate, "{") + parts := make([]templatePart, len(split)*2-1) + for i, s := range split { + if i == 0 { + if strings.Contains(s, "}") { + return nil, errors.New("unexpected }") + } + parts[i].raw = s + continue + } + subsplit := strings.Split(s, "}") + if len(subsplit) != 2 { + return nil, errors.New("malformed template") + } + expression := subsplit[0] + var err error + parts[i*2-1], err = parseExpression(expression) + if err != nil { + return nil, err + } + parts[i*2].raw = subsplit[1] + } + return &uriTemplate{ + raw: rawTemplate, + parts: parts, + }, nil +} + +type templatePart struct { + raw string + terms []templateTerm + first string + sep string + named bool + ifemp string + allowReserved bool +} + +type templateTerm struct { + name string + explode bool + truncate int +} + +func parseExpression(expression string) (result templatePart, err error) { + switch expression[0] { + case '+': + result.sep = "," + result.allowReserved = true + expression = expression[1:] + case '.': + result.first = "." + result.sep = "." + expression = expression[1:] + case '/': + result.first = "/" + result.sep = "/" + expression = expression[1:] + case ';': + result.first = ";" + result.sep = ";" + result.named = true + expression = expression[1:] + case '?': + result.first = "?" + result.sep = "&" + result.named = true + result.ifemp = "=" + expression = expression[1:] + case '&': + result.first = "&" + result.sep = "&" + result.named = true + result.ifemp = "=" + expression = expression[1:] + case '#': + result.first = "#" + result.sep = "," + result.allowReserved = true + expression = expression[1:] + default: + result.sep = "," + } + rawterms := strings.Split(expression, ",") + result.terms = make([]templateTerm, len(rawterms)) + for i, raw := range rawterms { + result.terms[i], err = parseTerm(raw) + if err != nil { + break + } + } + return result, err +} + +func parseTerm(term string) (result templateTerm, err error) { + // TODO(djd): Remove "*" suffix parsing once we check that no APIs have + // mistakenly used that attribute. + if strings.HasSuffix(term, "*") { + result.explode = true + term = term[:len(term)-1] + } + split := strings.Split(term, ":") + if len(split) == 1 { + result.name = term + } else if len(split) == 2 { + result.name = split[0] + var parsed int64 + parsed, err = strconv.ParseInt(split[1], 10, 0) + result.truncate = int(parsed) + } else { + err = errors.New("multiple colons in same term") + } + if !validname.MatchString(result.name) { + err = errors.New("not a valid name: " + result.name) + } + if result.explode && result.truncate > 0 { + err = errors.New("both explode and prefix modifers on same term") + } + 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 + for _, p := range t.parts { + p.expand(&buf, values) + } + return buf.String() +} + +func (tp *templatePart) expand(buf *bytes.Buffer, values map[string]string) { + if len(tp.raw) > 0 { + buf.WriteString(tp.raw) + return + } + var first = true + for _, term := range tp.terms { + value, exists := values[term.name] + if !exists { + continue + } + if first { + buf.WriteString(tp.first) + first = false + } else { + buf.WriteString(tp.sep) + } + tp.expandString(buf, term, value) + } +} + +func (tp *templatePart) expandName(buf *bytes.Buffer, name string, empty bool) { + if tp.named { + buf.WriteString(name) + if empty { + buf.WriteString(tp.ifemp) + } else { + buf.WriteString("=") + } + } +} + +func (tp *templatePart) expandString(buf *bytes.Buffer, 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)) +} diff --git a/vendor/google.golang.org/api/googleapi/internal/uritemplates/utils.go b/vendor/google.golang.org/api/googleapi/internal/uritemplates/utils.go new file mode 100644 index 0000000..eff260a --- /dev/null +++ b/vendor/google.golang.org/api/googleapi/internal/uritemplates/utils.go @@ -0,0 +1,13 @@ +// 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 uritemplates + +func Expand(path string, values map[string]string) (string, error) { + template, err := parse(path) + if err != nil { + return "", err + } + return template.Expand(values), nil +} diff --git a/vendor/google.golang.org/api/googleapi/types.go b/vendor/google.golang.org/api/googleapi/types.go new file mode 100644 index 0000000..a02b4b0 --- /dev/null +++ b/vendor/google.golang.org/api/googleapi/types.go @@ -0,0 +1,182 @@ +// Copyright 2013 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package googleapi + +import ( + "encoding/json" + "strconv" +) + +// Int64s is a slice of int64s that marshal as quoted strings in JSON. +type Int64s []int64 + +func (q *Int64s) UnmarshalJSON(raw []byte) error { + *q = (*q)[:0] + var ss []string + if err := json.Unmarshal(raw, &ss); err != nil { + return err + } + for _, s := range ss { + v, err := strconv.ParseInt(s, 10, 64) + if err != nil { + return err + } + *q = append(*q, int64(v)) + } + return nil +} + +// Int32s is a slice of int32s that marshal as quoted strings in JSON. +type Int32s []int32 + +func (q *Int32s) UnmarshalJSON(raw []byte) error { + *q = (*q)[:0] + var ss []string + if err := json.Unmarshal(raw, &ss); err != nil { + return err + } + for _, s := range ss { + v, err := strconv.ParseInt(s, 10, 32) + if err != nil { + return err + } + *q = append(*q, int32(v)) + } + return nil +} + +// Uint64s is a slice of uint64s that marshal as quoted strings in JSON. +type Uint64s []uint64 + +func (q *Uint64s) UnmarshalJSON(raw []byte) error { + *q = (*q)[:0] + var ss []string + if err := json.Unmarshal(raw, &ss); err != nil { + return err + } + for _, s := range ss { + v, err := strconv.ParseUint(s, 10, 64) + if err != nil { + return err + } + *q = append(*q, uint64(v)) + } + return nil +} + +// Uint32s is a slice of uint32s that marshal as quoted strings in JSON. +type Uint32s []uint32 + +func (q *Uint32s) UnmarshalJSON(raw []byte) error { + *q = (*q)[:0] + var ss []string + if err := json.Unmarshal(raw, &ss); err != nil { + return err + } + for _, s := range ss { + v, err := strconv.ParseUint(s, 10, 32) + if err != nil { + return err + } + *q = append(*q, uint32(v)) + } + return nil +} + +// Float64s is a slice of float64s that marshal as quoted strings in JSON. +type Float64s []float64 + +func (q *Float64s) UnmarshalJSON(raw []byte) error { + *q = (*q)[:0] + var ss []string + if err := json.Unmarshal(raw, &ss); err != nil { + return err + } + for _, s := range ss { + v, err := strconv.ParseFloat(s, 64) + if err != nil { + return err + } + *q = append(*q, float64(v)) + } + return nil +} + +func quotedList(n int, fn func(dst []byte, i int) []byte) ([]byte, error) { + dst := make([]byte, 0, 2+n*10) // somewhat arbitrary + dst = append(dst, '[') + for i := 0; i < n; i++ { + if i > 0 { + dst = append(dst, ',') + } + dst = append(dst, '"') + dst = fn(dst, i) + dst = append(dst, '"') + } + dst = append(dst, ']') + return dst, nil +} + +func (s Int64s) MarshalJSON() ([]byte, error) { + return quotedList(len(s), func(dst []byte, i int) []byte { + return strconv.AppendInt(dst, s[i], 10) + }) +} + +func (s Int32s) MarshalJSON() ([]byte, error) { + return quotedList(len(s), func(dst []byte, i int) []byte { + return strconv.AppendInt(dst, int64(s[i]), 10) + }) +} + +func (s Uint64s) MarshalJSON() ([]byte, error) { + return quotedList(len(s), func(dst []byte, i int) []byte { + return strconv.AppendUint(dst, s[i], 10) + }) +} + +func (s Uint32s) MarshalJSON() ([]byte, error) { + return quotedList(len(s), func(dst []byte, i int) []byte { + return strconv.AppendUint(dst, uint64(s[i]), 10) + }) +} + +func (s Float64s) MarshalJSON() ([]byte, error) { + return quotedList(len(s), func(dst []byte, i int) []byte { + return strconv.AppendFloat(dst, s[i], 'g', -1, 64) + }) +} + +/* + * Helper routines for simplifying the creation of optional fields of basic type. + */ + +// Bool is a helper routine that allocates a new bool value +// to store v and returns a pointer to it. +func Bool(v bool) *bool { return &v } + +// Int32 is a helper routine that allocates a new int32 value +// to store v and returns a pointer to it. +func Int32(v int32) *int32 { return &v } + +// Int64 is a helper routine that allocates a new int64 value +// to store v and returns a pointer to it. +func Int64(v int64) *int64 { return &v } + +// Float64 is a helper routine that allocates a new float64 value +// to store v and returns a pointer to it. +func Float64(v float64) *float64 { return &v } + +// Uint32 is a helper routine that allocates a new uint32 value +// to store v and returns a pointer to it. +func Uint32(v uint32) *uint32 { return &v } + +// Uint64 is a helper routine that allocates a new uint64 value +// to store v and returns a pointer to it. +func Uint64(v uint64) *uint64 { return &v } + +// String is a helper routine that allocates a new string value +// to store v and returns a pointer to it. +func String(v string) *string { return &v } |
