Revision c53aa229 trunk/Pithos.Network/ICloudClient.cs
b/trunk/Pithos.Network/ICloudClient.cs | ||
---|---|---|
9 | 9 |
[ContractClass(typeof(ICloudClientContract))] |
10 | 10 |
public interface ICloudClient |
11 | 11 |
{ |
12 |
|
|
12 | 13 |
string ApiKey { get; set; } |
13 | 14 |
string UserName { get; set; } |
14 | 15 |
Uri StorageUrl { get; set; } |
16 |
|
|
15 | 17 |
string Token { get; set; } |
18 |
|
|
16 | 19 |
bool UsePithos { get; set; } |
17 |
void Authenticate(string userName,string apiKey);
|
|
20 |
AccountInfo Authenticate();
|
|
18 | 21 |
Uri Proxy { get; set; } |
19 | 22 |
double DownloadPercentLimit { get; set; } |
20 | 23 |
double UploadPercentLimit { get; set; } |
21 | 24 |
string AuthenticationUrl { get; set; } |
22 | 25 |
|
23 | 26 |
#region Container operations |
24 |
|
|
25 |
IList<ContainerInfo> ListContainers(string account=null);
|
|
27 |
|
|
28 |
IList<ContainerInfo> ListContainers(string account); |
|
26 | 29 |
IList<ObjectInfo> ListObjects(string account, string container, DateTime? since = null); |
27 | 30 |
IList<ObjectInfo> ListObjects(string account, string container, string folder, DateTime? since = null); |
28 | 31 |
bool ContainerExists(string account, string container); |
... | ... | |
34 | 37 |
#region Object operations |
35 | 38 |
Task GetObject(string account, string container, string objectName, string fileName); |
36 | 39 |
Task PutObject(string account, string container, string objectName, string fileName, string hash = null); |
37 |
void DeleteObject(string account, string container, string objectName, string trashContainer);
|
|
40 |
void DeleteObject(string account, string container, string objectName); |
|
38 | 41 |
//void DeleteObject(string container, string objectName, string account = null); |
39 | 42 |
void MoveObject(string account, string sourceContainer, string oldObjectName, string targetContainer, string newObjectName); |
40 | 43 |
bool ObjectExists(string account, string container, string objectName); |
... | ... | |
60 | 63 |
[ContractClassFor(typeof(ICloudClient))] |
61 | 64 |
public abstract class ICloudClientContract:ICloudClient |
62 | 65 |
{ |
66 |
|
|
63 | 67 |
public string ApiKey { get; set; } |
64 | 68 |
public string UserName { get; set; } |
65 | 69 |
public Uri StorageUrl { get; set; } |
66 | 70 |
public string Token { get; set; } |
71 |
|
|
67 | 72 |
public Uri Proxy { get; set; } |
68 | 73 |
public double DownloadPercentLimit { get; set; } |
69 | 74 |
public double UploadPercentLimit { get; set; } |
... | ... | |
72 | 77 |
|
73 | 78 |
public bool UsePithos { get; set; } |
74 | 79 |
|
75 |
public void Authenticate(string userName, string apiKey)
|
|
80 |
public AccountInfo Authenticate()
|
|
76 | 81 |
{ |
77 |
Contract.Requires<ArgumentNullException>(!String.IsNullOrWhiteSpace(apiKey), "ApiKey must be filled before calling Authenticate"); |
|
78 |
Contract.Requires<ArgumentNullException>(!String.IsNullOrWhiteSpace(userName), "UserName must be filled before calling Authenticate"); |
|
79 |
|
|
82 |
Contract.Requires<ArgumentNullException>(!String.IsNullOrWhiteSpace(ApiKey), "ApiKey must be filled before calling Authenticate"); |
|
83 |
Contract.Requires<ArgumentNullException>(!String.IsNullOrWhiteSpace(UserName), "UserName must be filled before calling Authenticate"); |
|
80 | 84 |
|
81 |
Contract.Ensures(apiKey==ApiKey); |
|
82 |
Contract.Ensures(userName==UserName); |
|
83 |
Contract.Ensures(StorageUrl!=null); |
|
84 |
Contract.Ensures(!String.IsNullOrWhiteSpace(Token)); |
|
85 |
|
|
85 |
return default(AccountInfo); |
|
86 | 86 |
} |
87 | 87 |
|
88 |
public IList<ContainerInfo> ListContainers(string account=null)
|
|
88 |
public IList<ContainerInfo> ListContainers(string account) |
|
89 | 89 |
{ |
90 | 90 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
91 | 91 |
Contract.Requires(StorageUrl!=null); |
... | ... | |
95 | 95 |
|
96 | 96 |
public IList<ObjectInfo> ListSharedObjects(DateTime? since) |
97 | 97 |
{ |
98 |
|
|
99 |
|
|
98 | 100 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
99 | 101 |
Contract.Requires(StorageUrl != null); |
100 | 102 |
|
... | ... | |
103 | 105 |
|
104 | 106 |
public void ShareObject(string account, string container, string objectName, string shareTo, bool read, bool write) |
105 | 107 |
{ |
108 |
|
|
106 | 109 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
107 | 110 |
Contract.Requires(StorageUrl != null); |
108 | 111 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
115 | 118 |
|
116 | 119 |
public IList<ObjectInfo> ListObjects(string account, string container, DateTime? since = null) |
117 | 120 |
{ |
121 |
|
|
118 | 122 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
119 | 123 |
Contract.Requires(StorageUrl != null); |
120 | 124 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
124 | 128 |
|
125 | 129 |
public IList<ObjectInfo> ListObjects(string account, string container, string folder, DateTime? since = null) |
126 | 130 |
{ |
131 |
|
|
127 | 132 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
128 | 133 |
Contract.Requires(StorageUrl != null); |
129 | 134 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
134 | 139 |
|
135 | 140 |
public bool ContainerExists(string account, string container) |
136 | 141 |
{ |
142 |
|
|
137 | 143 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
138 | 144 |
Contract.Requires(StorageUrl!=null); |
139 | 145 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
143 | 149 |
|
144 | 150 |
public ContainerInfo GetContainerInfo(string account, string container) |
145 | 151 |
{ |
152 |
|
|
146 | 153 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
147 | 154 |
Contract.Requires(StorageUrl!=null); |
148 | 155 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
152 | 159 |
|
153 | 160 |
public void CreateContainer(string account, string container) |
154 | 161 |
{ |
162 |
|
|
155 | 163 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
156 | 164 |
Contract.Requires(StorageUrl!=null); |
157 | 165 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
159 | 167 |
|
160 | 168 |
public void DeleteContainer(string account, string container) |
161 | 169 |
{ |
170 |
|
|
162 | 171 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
163 | 172 |
Contract.Requires(StorageUrl!=null); |
164 | 173 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
166 | 175 |
|
167 | 176 |
public Task GetObject(string account, string container, string objectName, string fileName) |
168 | 177 |
{ |
178 |
|
|
169 | 179 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
170 | 180 |
Contract.Requires(StorageUrl!=null); |
171 | 181 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
176 | 186 |
|
177 | 187 |
public Task PutObject(string account, string container, string objectName, string fileName, string hash = null) |
178 | 188 |
{ |
189 |
|
|
179 | 190 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
180 | 191 |
Contract.Requires(StorageUrl!=null); |
181 | 192 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
185 | 196 |
return default(Task); |
186 | 197 |
} |
187 | 198 |
|
188 |
public void DeleteObject(string account, string container, string objectName, string trashContainer) |
|
189 |
{ |
|
190 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
|
191 |
Contract.Requires(StorageUrl!=null); |
|
192 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
|
193 |
Contract.Requires(!String.IsNullOrWhiteSpace(objectName)); |
|
194 |
Contract.Requires(!String.IsNullOrWhiteSpace(trashContainer)); |
|
195 |
} |
|
196 |
|
|
197 |
public void DeleteObject(string container, string objectName, string account = null) |
|
199 |
public void DeleteObject(string account, string container, string objectName) |
|
198 | 200 |
{ |
201 |
|
|
199 | 202 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
200 | 203 |
Contract.Requires(StorageUrl!=null); |
201 | 204 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
204 | 207 |
|
205 | 208 |
public void MoveObject(string account, string sourceContainer, string oldObjectName, string targetContainer, string newObjectName) |
206 | 209 |
{ |
210 |
|
|
207 | 211 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
208 | 212 |
Contract.Requires(StorageUrl!=null); |
209 | 213 |
Contract.Requires(!String.IsNullOrWhiteSpace(sourceContainer)); |
... | ... | |
214 | 218 |
|
215 | 219 |
public bool ObjectExists(string account, string container, string objectName) |
216 | 220 |
{ |
221 |
|
|
217 | 222 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
218 | 223 |
Contract.Requires(StorageUrl!=null); |
219 | 224 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
224 | 229 |
|
225 | 230 |
public ObjectInfo GetObjectInfo(string account, string container, string objectName) |
226 | 231 |
{ |
232 |
|
|
227 | 233 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
228 | 234 |
Contract.Requires(StorageUrl!=null); |
229 | 235 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
234 | 240 |
|
235 | 241 |
public void CreateFolder(string account, string container, string folder) |
236 | 242 |
{ |
243 |
|
|
237 | 244 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
238 | 245 |
Contract.Requires(StorageUrl != null); |
239 | 246 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
242 | 249 |
|
243 | 250 |
public Task<TreeHash> GetHashMap(string account, string container, string objectName) |
244 | 251 |
{ |
252 |
|
|
245 | 253 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
246 | 254 |
Contract.Requires(StorageUrl != null); |
247 | 255 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
252 | 260 |
|
253 | 261 |
public Task<IList<string>> PutHashMap(string account, string container, string objectName, TreeHash hash) |
254 | 262 |
{ |
263 |
|
|
255 | 264 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
256 | 265 |
Contract.Requires(StorageUrl != null); |
257 | 266 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
263 | 272 |
|
264 | 273 |
public Task PostBlock(string account, string container, byte[] block, int offset, int count) |
265 | 274 |
{ |
275 |
|
|
266 | 276 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
267 | 277 |
Contract.Requires(StorageUrl != null); |
268 | 278 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
... | ... | |
277 | 287 |
|
278 | 288 |
public Task<byte[]> GetBlock(string account, string container, Uri relativeUrl, long start, long? end) |
279 | 289 |
{ |
290 |
|
|
280 | 291 |
Contract.Requires(!String.IsNullOrWhiteSpace(Token)); |
281 | 292 |
Contract.Requires(StorageUrl != null); |
282 | 293 |
Contract.Requires(!String.IsNullOrWhiteSpace(container)); |
Also available in: Unified diff