Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / ispy / common / cloud_bucket.py
blob39134c9794193521bb01aae59f53ceeb45dec4ee
1 # Copyright 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 """Abstract injector class for GS requests."""
8 class FileNotFoundError(Exception):
9 """Thrown by a subclass of CloudBucket when a file is not found."""
10 pass
13 class BaseCloudBucket(object):
14 """An abstract base class for working with GS."""
16 def UploadFile(self, path, contents, content_type):
17 """Uploads a file to GS.
19 Args:
20 path: where in GS to upload the file.
21 contents: the contents of the file to be uploaded.
22 content_type: the MIME Content-Type of the file.
23 """
24 raise NotImplementedError
26 def DownloadFile(self, path):
27 """Downsloads a file from GS.
29 Args:
30 path: the location in GS to download the file from.
32 Returns:
33 String contents of the file downloaded.
35 Raises:
36 bucket_injector.NotFoundException: if the file is not found.
37 """
38 raise NotImplementedError
40 def UpdateFile(self, path, contents):
41 """Uploads a file to GS.
43 Args:
44 path: location of the file in GS to update.
45 contents: the contents of the file to be updated.
46 """
47 raise NotImplementedError
49 def RemoveFile(self, path):
50 """Removes a file from GS.
52 Args:
53 path: the location in GS to download the file from.
54 """
55 raise NotImplementedError
57 def FileExists(self, path):
58 """Checks if a file exists in GS.
60 Args:
61 path: the location in GS of the file.
63 Returns:
64 boolean representing whether the file exists in GS.
65 """
66 raise NotImplementedError
68 def GetImageURL(self, path):
69 """Gets a URL to an item in GS from its path.
71 Args:
72 path: the location in GS of a file.
74 Returns:
75 an url to a file in GS.
77 Raises:
78 bucket_injector.NotFoundException: if the file is not found.
79 """
80 raise NotImplementedError
82 def GetAllPaths(self, prefix):
83 """Gets paths to files in GS that start with a prefix.
85 Args:
86 prefix: the prefix to filter files in GS.
88 Returns:
89 a generator of paths to files in GS.
90 """
91 raise NotImplementedError