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;
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
) const;
60 // Returns a URL to fetch file list.
61 GURL
GetFilesListUrl(int max_results
,
62 const std::string
& page_token
,
63 const std::string
& q
) const;
65 // Returns a URL to delete a resource with the given |file_id|.
66 GURL
GetFilesDeleteUrl(const std::string
& file_id
) const;
68 // Returns a URL to trash a resource with the given |file_id|.
69 GURL
GetFilesTrashUrl(const std::string
& file_id
) const;
71 // Returns a URL to fetch a list of changes.
72 GURL
GetChangesListUrl(bool include_deleted
,
74 const std::string
& page_token
,
75 int64 start_change_id
) const;
77 // Returns a URL to add a resource to a directory with |folder_id|.
78 GURL
GetChildrenInsertUrl(const std::string
& folder_id
) const;
80 // Returns a URL to remove a resource with |child_id| from a directory
82 GURL
GetChildrenDeleteUrl(const std::string
& child_id
,
83 const std::string
& folder_id
) const;
85 // Returns a URL to initiate "resumable upload" of a new file that uploads
86 // chunked data by multiple HTTP posts.
87 GURL
GetInitiateUploadNewFileUrl(bool set_modified_date
) const;
89 // Returns a URL to initiate "resumable upload" of an existing file specified
90 // by |resource_id| that uploads chunked data by multiple HTTP posts.
91 GURL
GetInitiateUploadExistingFileUrl(const std::string
& resource_id
,
92 bool set_modified_date
) const;
94 // Returns a URL for "multipart upload" of a new file that sends both metadata
95 // and file content in a single HTTP post.
96 GURL
GetMultipartUploadNewFileUrl(bool set_modified_date
) const;
98 // Returns a URL for "multipart upload" of an existing file specified by
99 // |resource_id| that sends both metadata and file content in a single HTTP
101 GURL
GetMultipartUploadExistingFileUrl(const std::string
& resource_id
,
102 bool set_modified_date
) const;
104 // Generates a URL for downloading a file.
105 GURL
GenerateDownloadFileUrl(const std::string
& resource_id
) const;
107 // Generates a URL for adding permissions.
108 GURL
GetPermissionsInsertUrl(const std::string
& resource_id
) const;
110 // Generates a URL for a thumbnail with specified dimensions.
111 GURL
GetThumbnailUrl(const std::string
& resource_id
,
116 const GURL base_url_
;
117 const GURL base_download_url_
;
119 // This class is copyable hence no DISALLOW_COPY_AND_ASSIGN here.
122 } // namespace google_apis
124 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_URL_GENERATOR_H_