// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ #define GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ #include <stdint.h> #include <memory> #include <string> #include <utility> #include <vector> #include "base/functional/bind.h" #include "base/functional/callback_forward.h" #include "base/location.h" #include "base/memory/raw_ptr.h" #include "base/task/sequenced_task_runner.h" #include "base/time/time.h" #include "base/values.h" #include "google_apis/common/base_requests.h" #include "google_apis/drive/drive_api_parser.h" #include "google_apis/drive/drive_api_url_generator.h" #include "google_apis/drive/drive_base_requests.h" #include "google_apis/drive/drive_common_callbacks.h" #include "services/network/public/mojom/url_response_head.mojom-forward.h" namespace google_apis { // Callback used for requests that the server returns TeamDrive data // formatted into JSON value. TeamDriveListCallback; // Callback used for requests that the server returns FileList data // formatted into JSON value. FileListCallback; // DEPRECATED: Please use ChangeListOnceCallback instead // Callback used for requests that the server returns ChangeList data // formatted into JSON value. ChangeListCallback; ChangeListOnceCallback; // Callback used for requests that the server returns StartToken data // formatted into JSON value. StartPageTokenCallback; namespace drive { // Represents a property for a file or a directory. // https://developers.google.com/drive/v2/reference/properties class Property { … }; // List of properties for a single file or a directory. Properties; // Child response embedded in multipart parent response. struct MultipartHttpResponse { … }; // Splits multipart |response| into |parts|. Each part must be HTTP sub-response // of drive batch request. |content_type| is a value of Content-Type response // header. Returns true on success. bool ParseMultipartResponse(const std::string& content_type, const std::string& response, std::vector<MultipartHttpResponse>* parts); //============================ DriveApiPartialFieldRequest ==================== // This is base class of the Drive API related requests. All Drive API requests // support partial request (to improve the performance). The function can be // shared among the Drive API requests. // See also https://developers.google.com/drive/performance class DriveApiPartialFieldRequest : public DriveUrlFetchRequestBase { … }; //============================ DriveApiDataRequest =========================== // The base class of Drive API related requests that receive a JSON response // representing |DataType|. template <class DataType> class DriveApiDataRequest : public DriveApiPartialFieldRequest { … }; //=============================== FilesGetRequest ============================= // This class performs the request for fetching a file. // This request is mapped to // https://developers.google.com/drive/v2/reference/files/get class FilesGetRequest : public DriveApiDataRequest<FileResource> { … }; //============================ FilesInsertRequest ============================= // Enumeration type for specifying visibility of files. enum FileVisibility { … }; // This class performs the request for creating a resource. // This request is mapped to // https://developers.google.com/drive/v2/reference/files/insert // See also https://developers.google.com/drive/manage-uploads and // https://developers.google.com/drive/folder class FilesInsertRequest : public DriveApiDataRequest<FileResource> { … }; //============================== FilesPatchRequest ============================ // This class performs the request for patching file metadata. // This request is mapped to // https://developers.google.com/drive/v2/reference/files/patch class FilesPatchRequest : public DriveApiDataRequest<FileResource> { … }; //============================= FilesCopyRequest ============================== // This class performs the request for copying a resource. // This request is mapped to // https://developers.google.com/drive/v2/reference/files/copy class FilesCopyRequest : public DriveApiDataRequest<FileResource> { … }; //========================== TeamDriveListRequest ============================= // This class performs the request for fetching TeamDrive list. // The result may contain only first part of the result. The remaining result // should be able to be fetched by another request using this class, by // setting the next_page_token from previous call, to page_token. // This request is mapped to // https://developers.google.com/drive/v2/reference/teamdrives/list class TeamDriveListRequest : public DriveApiDataRequest<TeamDriveList> { … }; //========================== StartPageTokenRequest ============================= // This class performs the request for fetching the start page token. // |team_drive_id_| may be empty, in which case the start page token will be // returned for the users changes. // This request is mapped to // https://developers.google.com/drive/v2/reference/changes/getStartPageToken class StartPageTokenRequest : public DriveApiDataRequest<StartPageToken> { … }; //============================= FilesListRequest ============================= // This class performs the request for fetching FileList. // The result may contain only first part of the result. The remaining result // should be able to be fetched by ContinueGetFileListRequest defined below, // or by FilesListRequest with setting page token. // This request is mapped to // https://developers.google.com/drive/v2/reference/files/list class FilesListRequest : public DriveApiDataRequest<FileList> { … }; //========================= FilesListNextPageRequest ========================== // There are two ways to obtain next pages of "Files: list" result (if paged). // 1) Set pageToken and all params used for the initial request. // 2) Use URL in the nextLink field in the previous response. // This class implements 2)'s request. class FilesListNextPageRequest : public DriveApiDataRequest<FileList> { … }; //============================= FilesDeleteRequest ============================= // This class performs the request for deleting a resource. // This request is mapped to // https://developers.google.com/drive/v2/reference/files/delete class FilesDeleteRequest : public EntryActionRequest { … }; //============================= FilesTrashRequest ============================== // This class performs the request for trashing a resource. // This request is mapped to // https://developers.google.com/drive/v2/reference/files/trash class FilesTrashRequest : public DriveApiDataRequest<FileResource> { … }; //============================== AboutGetRequest ============================= // This class performs the request for fetching About data. // This request is mapped to // https://developers.google.com/drive/v2/reference/about/get class AboutGetRequest : public DriveApiDataRequest<AboutResource> { … }; //============================ ChangesListRequest ============================ // This class performs the request for fetching ChangeList. // The result may contain only first part of the result. The remaining result // should be able to be fetched by ContinueGetFileListRequest defined below. // or by ChangesListRequest with setting page token. // This request is mapped to // https://developers.google.com/drive/v2/reference/changes/list class ChangesListRequest : public DriveApiDataRequest<ChangeList> { … }; //======================== ChangesListNextPageRequest ========================= // There are two ways to obtain next pages of "Changes: list" result (if paged). // 1) Set pageToken and all params used for the initial request. // 2) Use URL in the nextLink field in the previous response. // This class implements 2)'s request. class ChangesListNextPageRequest : public DriveApiDataRequest<ChangeList> { … }; //========================== ChildrenInsertRequest ============================ // This class performs the request for inserting a resource to a directory. // This request is mapped to // https://developers.google.com/drive/v2/reference/children/insert class ChildrenInsertRequest : public EntryActionRequest { … }; //========================== ChildrenDeleteRequest ============================ // This class performs the request for removing a resource from a directory. // This request is mapped to // https://developers.google.com/drive/v2/reference/children/delete class ChildrenDeleteRequest : public EntryActionRequest { … }; //======================= InitiateUploadNewFileRequest ======================= // This class performs the request for initiating the upload of a new file. class InitiateUploadNewFileRequest : public InitiateUploadRequestBase { … }; //==================== InitiateUploadExistingFileRequest ===================== // This class performs the request for initiating the upload of an existing // file. class InitiateUploadExistingFileRequest : public InitiateUploadRequestBase { … }; // Callback used for ResumeUpload() and GetUploadStatus(). UploadRangeCallback; //============================ ResumeUploadRequest =========================== // Performs the request for resuming the upload of a file. class ResumeUploadRequest : public ResumeUploadRequestBase { … }; //========================== GetUploadStatusRequest ========================== // Performs the request to fetch the current upload status of a file. class GetUploadStatusRequest : public GetUploadStatusRequestBase { … }; //======================= MultipartUploadNewFileDelegate ======================= // This class performs the request for initiating the upload of a new file. class MultipartUploadNewFileDelegate : public MultipartUploadRequestBase { … }; //====================== MultipartUploadExistingFileDelegate =================== // This class performs the request for initiating the upload of a new file. class MultipartUploadExistingFileDelegate : public MultipartUploadRequestBase { … }; //========================== DownloadFileRequest ========================== // This class performs the request for downloading of a specified file. class DownloadFileRequest : public DownloadFileRequestBase { … }; //========================== PermissionsInsertRequest ========================== // Enumeration type for specifying type of permissions. enum PermissionType { … }; // Enumeration type for specifying the role of permissions. enum PermissionRole { … }; // This class performs the request for adding permission on a specified file. class PermissionsInsertRequest : public EntryActionRequest { … }; //======================= SingleBatchableDelegateRequest ======================= // Request that is operated by single BatchableDelegate. class SingleBatchableDelegateRequest : public DriveUrlFetchRequestBase { … }; //========================== BatchUploadRequest ========================== class BatchUploadChildEntry { … }; class BatchUploadRequest : public DriveUrlFetchRequestBase { … }; } // namespace drive } // namespace google_apis #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_