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.
4
5#ifndef GOOGLE_APIS_DRIVE_DRIVE_API_URL_GENERATOR_H_
6#define GOOGLE_APIS_DRIVE_DRIVE_API_URL_GENERATOR_H_
7
8#include <string>
9
10#include "url/gurl.h"
11
12namespace google_apis {
13
14// This class is used to generate URLs for communicating with drive api
15// servers for production, and a local server for testing.
16class DriveApiUrlGenerator {
17 public:
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();
22
23  // The base URL for communicating with the production drive api server.
24  static const char kBaseUrlForProduction[];
25
26  // The base URL for the file download server for production.
27  static const char kBaseDownloadUrlForProduction[];
28
29  // Returns a URL to invoke "About: get" method.
30  GURL GetAboutGetUrl() const;
31
32  // Returns a URL to invoke "Apps: list" method.
33  GURL GetAppsListUrl() const;
34
35  // Returns a URL to fetch a file metadata.
36  GURL GetFilesGetUrl(const std::string& file_id) const;
37
38  // Returns a URL to create a resource.
39  GURL GetFilesInsertUrl() const;
40
41  // Returns a URL to patch file metadata.
42  GURL GetFilesPatchUrl(const std::string& file_id,
43                        bool set_modified_date,
44                        bool update_viewed_date) const;
45
46  // Returns a URL to copy a resource specified by |file_id|.
47  GURL GetFilesCopyUrl(const std::string& file_id) const;
48
49  // Returns a URL to fetch file list.
50  GURL GetFilesListUrl(int max_results,
51                       const std::string& page_token,
52                       const std::string& q) const;
53
54  // Returns a URL to delete a resource with the given |file_id|.
55  GURL GetFilesDeleteUrl(const std::string& file_id) const;
56
57  // Returns a URL to trash a resource with the given |file_id|.
58  GURL GetFilesTrashUrl(const std::string& file_id) const;
59
60  // Returns a URL to fetch a list of changes.
61  GURL GetChangesListUrl(bool include_deleted,
62                         int max_results,
63                         const std::string& page_token,
64                         int64 start_change_id) const;
65
66  // Returns a URL to add a resource to a directory with |folder_id|.
67  GURL GetChildrenInsertUrl(const std::string& folder_id) const;
68
69  // Returns a URL to remove a resource with |child_id| from a directory
70  // with |folder_id|.
71  GURL GetChildrenDeleteUrl(const std::string& child_id,
72                            const std::string& folder_id) const;
73
74  // Returns a URL to initiate uploading a new file.
75  GURL GetInitiateUploadNewFileUrl() const;
76
77  // Returns a URL to initiate uploading an existing file specified by
78  // |resource_id|.
79  GURL GetInitiateUploadExistingFileUrl(const std::string& resource_id) const;
80
81  // Generates a URL for downloading a file.
82  GURL GenerateDownloadFileUrl(const std::string& resource_id) const;
83
84 private:
85  const GURL base_url_;
86  const GURL base_download_url_;
87
88  // This class is copyable hence no DISALLOW_COPY_AND_ASSIGN here.
89};
90
91}  // namespace google_apis
92
93#endif  // GOOGLE_APIS_DRIVE_DRIVE_API_URL_GENERATOR_H_
94