1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef GOOGLE_APIS_DRIVE_DRIVE_API_URL_GENERATOR_H_
6 #define GOOGLE_APIS_DRIVE_DRIVE_API_URL_GENERATOR_H_
12 namespace google_apis
{
14 // This class is used to generate URLs for communicating with drive api
15 // servers for production, and a local server for testing.
16 class DriveApiUrlGenerator
{
18 // |base_url| is the path to the target drive api server.
19 // Note that this is an injecting point for a testing server.
20 DriveApiUrlGenerator(const GURL
& base_url
, const GURL
& base_download_url
);
21 ~DriveApiUrlGenerator();
23 // The base URL for communicating with the production drive api server.
24 static const char kBaseUrlForProduction
[];
26 // The base URL for the file download server for production.
27 static const char kBaseDownloadUrlForProduction
[];
29 // Returns a URL to invoke "About: get" method.
30 GURL
GetAboutGetUrl() const;
32 // Returns a URL to invoke "Apps: list" method.
33 // Set |use_internal_endpoint| to true if official Chrome's API key is used
34 // and retrieving more information (related to App uninstall) is necessary.
35 GURL
GetAppsListUrl(bool use_internal_endpoint
) const;
37 // Returns a URL to uninstall an app with the give |app_id|.
38 GURL
GetAppsDeleteUrl(const std::string
& app_id
) const;
40 // Returns a URL to fetch a file metadata.
41 GURL
GetFilesGetUrl(const std::string
& file_id
,
42 bool use_internal_endpoint
,
43 const GURL
& embed_origin
) const;
45 // Returns a URL to authorize an app to access a file.
46 GURL
GetFilesAuthorizeUrl(const std::string
& file_id
,
47 const std::string
& app_id
) const;
49 // Returns a URL to create a resource.
50 GURL
GetFilesInsertUrl(const std::string
& visibility
) const;
52 // Returns a URL to patch file metadata.
53 GURL
GetFilesPatchUrl(const std::string
& file_id
,
54 bool set_modified_date
,
55 bool update_viewed_date
) const;
57 // Returns a URL to copy a resource specified by |file_id|.
58 GURL
GetFilesCopyUrl(const std::string
& file_id
,
59 const std::string
& visibility
) const;
61 // Returns a URL to fetch file list.
62 GURL
GetFilesListUrl(int max_results
,
63 const std::string
& page_token
,
64 const std::string
& q
) const;
66 // Returns a URL to delete a resource with the given |file_id|.
67 GURL
GetFilesDeleteUrl(const std::string
& file_id
) const;
69 // Returns a URL to trash a resource with the given |file_id|.
70 GURL
GetFilesTrashUrl(const std::string
& file_id
) const;
72 // Returns a URL to fetch a list of changes.
73 GURL
GetChangesListUrl(bool include_deleted
,
75 const std::string
& page_token
,
76 int64 start_change_id
) const;
78 // Returns a URL to add a resource to a directory with |folder_id|.
79 GURL
GetChildrenInsertUrl(const std::string
& folder_id
) const;
81 // Returns a URL to remove a resource with |child_id| from a directory
83 GURL
GetChildrenDeleteUrl(const std::string
& child_id
,
84 const std::string
& folder_id
) const;
86 // Returns a URL to initiate "resumable upload" of a new file that uploads
87 // chunked data by multiple HTTP posts.
88 GURL
GetInitiateUploadNewFileUrl(bool set_modified_date
) const;
90 // Returns a URL to initiate "resumable upload" of an existing file specified
91 // by |resource_id| that uploads chunked data by multiple HTTP posts.
92 GURL
GetInitiateUploadExistingFileUrl(const std::string
& resource_id
,
93 bool set_modified_date
) const;
95 // Returns a URL for "multipart upload" of a new file that sends both metadata
96 // and file content in a single HTTP post.
97 GURL
GetMultipartUploadNewFileUrl(bool set_modified_date
) const;
99 // Returns a URL for "multipart upload" of an existing file specified by
100 // |resource_id| that sends both metadata and file content in a single HTTP
102 GURL
GetMultipartUploadExistingFileUrl(const std::string
& resource_id
,
103 bool set_modified_date
) const;
105 // Generates a URL for downloading a file.
106 GURL
GenerateDownloadFileUrl(const std::string
& resource_id
) const;
108 // Generates a URL for adding permissions.
109 GURL
GetPermissionsInsertUrl(const std::string
& resource_id
) const;
111 // Generates a URL for a thumbnail with specified dimensions. Set |crop| to
112 // true to get a cropped thumbnail in the dimensions.
113 GURL
GetThumbnailUrl(const std::string
& resource_id
,
118 // Generates a URL for batch upload.
119 GURL
GetBatchUploadUrl() const;
122 const GURL base_url_
;
123 const GURL base_download_url_
;
125 // This class is copyable hence no DISALLOW_COPY_AND_ASSIGN here.
128 } // namespace google_apis
130 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_URL_GENERATOR_H_