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
) const;
43 // Returns a URL to authorize an app to access a file.
44 GURL
GetFilesAuthorizeUrl(const std::string
& file_id
,
45 const std::string
& app_id
) const;
47 // Returns a URL to create a resource.
48 GURL
GetFilesInsertUrl() const;
50 // Returns a URL to patch file metadata.
51 GURL
GetFilesPatchUrl(const std::string
& file_id
,
52 bool set_modified_date
,
53 bool update_viewed_date
) const;
55 // Returns a URL to copy a resource specified by |file_id|.
56 GURL
GetFilesCopyUrl(const std::string
& file_id
) const;
58 // Returns a URL to fetch file list.
59 GURL
GetFilesListUrl(int max_results
,
60 const std::string
& page_token
,
61 const std::string
& q
) const;
63 // Returns a URL to delete a resource with the given |file_id|.
64 GURL
GetFilesDeleteUrl(const std::string
& file_id
) const;
66 // Returns a URL to trash a resource with the given |file_id|.
67 GURL
GetFilesTrashUrl(const std::string
& file_id
) const;
69 // Returns a URL to fetch a list of changes.
70 GURL
GetChangesListUrl(bool include_deleted
,
72 const std::string
& page_token
,
73 int64 start_change_id
) const;
75 // Returns a URL to add a resource to a directory with |folder_id|.
76 GURL
GetChildrenInsertUrl(const std::string
& folder_id
) const;
78 // Returns a URL to remove a resource with |child_id| from a directory
80 GURL
GetChildrenDeleteUrl(const std::string
& child_id
,
81 const std::string
& folder_id
) const;
83 // Returns a URL to initiate uploading a new file.
84 GURL
GetInitiateUploadNewFileUrl(bool set_modified_date
) const;
86 // Returns a URL to initiate uploading an existing file specified by
88 GURL
GetInitiateUploadExistingFileUrl(const std::string
& resource_id
,
89 bool set_modified_date
) const;
91 // Generates a URL for downloading a file.
92 GURL
GenerateDownloadFileUrl(const std::string
& resource_id
) const;
94 // Generates a URL for adding permissions.
95 GURL
GetPermissionsInsertUrl(const std::string
& resource_id
) const;
99 const GURL base_download_url_
;
101 // This class is copyable hence no DISALLOW_COPY_AND_ASSIGN here.
104 } // namespace google_apis
106 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_URL_GENERATOR_H_