PageRenderTime 360ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/src/ServiceManagement/Storage/Commands.Storage.Test/Service/MockStorageBlobManagement.cs

https://github.com/IrisClasson/azure-sdk-tools
C# | 691 lines | 328 code | 65 blank | 298 comment | 25 complexity | b0926f4fb20cd1150712232aa1ab2076 MD5 | raw file
Possible License(s): Apache-2.0
  1. // ----------------------------------------------------------------------------------
  2. //
  3. // Copyright Microsoft Corporation
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. // -----------------------------------------------------------------------------------
  14. namespace Microsoft.WindowsAzure.Commands.Storage.Test.Service
  15. {
  16. using Microsoft.WindowsAzure.Commands.Storage.Common;
  17. using Microsoft.WindowsAzure.Commands.Storage.Model.ResourceModel;
  18. using Microsoft.WindowsAzure.Storage;
  19. using Microsoft.WindowsAzure.Storage.Auth;
  20. using Microsoft.WindowsAzure.Storage.Blob;
  21. using Microsoft.WindowsAzure.Storage.Shared.Protocol;
  22. using Model.Contract;
  23. using System;
  24. using System.Collections.Generic;
  25. using System.Threading;
  26. using System.Threading.Tasks;
  27. /// <summary>
  28. /// Mock blob management
  29. /// </summary>
  30. public class MockStorageBlobManagement : IStorageBlobManagement
  31. {
  32. public static string ContainerNotFound = "Container not found";
  33. public static string BlobNotFound = "Blob not found";
  34. /// <summary>
  35. /// Blob end point
  36. /// </summary>
  37. private string BlobEndPoint = "http://127.0.0.1/account/";
  38. /// <summary>
  39. /// Container list
  40. /// </summary>
  41. private List<CloudBlobContainer> containerList = new List<CloudBlobContainer>();
  42. public List<CloudBlobContainer> ContainerList
  43. {
  44. get
  45. {
  46. return containerList;
  47. }
  48. }
  49. public List<Tuple<CloudBlobContainer, BlobContinuationToken>> ContainerAndTokenList
  50. {
  51. get
  52. {
  53. List<Tuple<CloudBlobContainer, BlobContinuationToken>> containerAndTokenList = new List<Tuple<CloudBlobContainer, BlobContinuationToken>>(ContainerList.Count);
  54. foreach (CloudBlobContainer container in ContainerList)
  55. {
  56. containerAndTokenList.Add(new Tuple<CloudBlobContainer, BlobContinuationToken>(container, null));
  57. }
  58. return containerAndTokenList;
  59. }
  60. }
  61. /// <summary>
  62. /// Container permissions list
  63. /// </summary>
  64. private Dictionary<string, BlobContainerPermissions> containerPermissions = new Dictionary<string, BlobContainerPermissions>();
  65. public Dictionary<string, BlobContainerPermissions> ContainerPermissions
  66. {
  67. get
  68. {
  69. return containerPermissions;
  70. }
  71. }
  72. /// <summary>
  73. /// Container blobs list
  74. /// </summary>
  75. private Dictionary<string, List<ICloudBlob>> containerBlobs = new Dictionary<string, List<ICloudBlob>>();
  76. public Dictionary<string, List<ICloudBlob>> ContainerBlobs
  77. {
  78. get
  79. {
  80. return containerBlobs;
  81. }
  82. }
  83. /// <summary>
  84. /// Get a list of cloudblobcontainer in azure
  85. /// </summary>
  86. /// <param name="prefix">Container prefix</param>
  87. /// <param name="detailsIncluded">Container listing details</param>
  88. /// <param name="options">Blob request option</param>
  89. /// <param name="operationContext">Operation context</param>
  90. /// <returns>An enumerable collection of cloudblobcontainer</returns>
  91. public IEnumerable<CloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded, BlobRequestOptions options = null, OperationContext operationContext = null)
  92. {
  93. if (string.IsNullOrEmpty(prefix))
  94. {
  95. return ContainerList;
  96. }
  97. else
  98. {
  99. List<CloudBlobContainer> prefixContainerList = new List<CloudBlobContainer>();
  100. foreach (CloudBlobContainer container in ContainerList)
  101. {
  102. if (container.Name.StartsWith(prefix))
  103. {
  104. prefixContainerList.Add(container);
  105. }
  106. }
  107. return prefixContainerList;
  108. }
  109. }
  110. /// <summary>
  111. /// Get container permissions
  112. /// </summary>
  113. /// <param name="container">A cloudblobcontainer object</param>
  114. /// <param name="accessCondition">Access condition</param>
  115. /// <param name="options">Blob request option</param>
  116. /// <param name="operationContext">Operation context</param>
  117. /// <returns>The container's permission</returns>
  118. public BlobContainerPermissions GetContainerPermissions(CloudBlobContainer container, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null)
  119. {
  120. BlobContainerPermissions defaultPermission = new BlobContainerPermissions();
  121. defaultPermission.PublicAccess = BlobContainerPublicAccessType.Off;
  122. if (ContainerPermissions.ContainsKey(container.Name))
  123. {
  124. return ContainerPermissions[container.Name];
  125. }
  126. else
  127. {
  128. return defaultPermission;
  129. }
  130. }
  131. /// <summary>
  132. /// Get an CloudBlobContainer instance in local
  133. /// </summary>
  134. /// <param name="name">Container name</param>
  135. /// <returns>A CloudBlobContainer in local memory</returns>
  136. public CloudBlobContainer GetContainerReference(string name)
  137. {
  138. Uri containerUri = new Uri(String.Format("{0}{1}/", BlobEndPoint, name));
  139. string testName = "testaccount";
  140. Guid guid = Guid.NewGuid();
  141. string testKey = Convert.ToBase64String(guid.ToByteArray());
  142. StorageCredentials credentials = new StorageCredentials(testName, testKey);
  143. return new CloudBlobContainer(containerUri, credentials);
  144. }
  145. /// <summary>
  146. /// Create the container if not exists
  147. /// </summary>
  148. /// <param name="container">A cloudblobcontainer object</param>
  149. /// <param name="options">Blob request option</param>
  150. /// <param name="operationContext">Operation context</param>
  151. /// <returns>True if the container did not already exist and was created; otherwise false.</returns>
  152. public bool CreateContainerIfNotExists(CloudBlobContainer container, BlobRequestOptions requestOptions = null, OperationContext operationContext = null)
  153. {
  154. CloudBlobContainer containerRef = GetContainerReference(container.Name);
  155. if (DoesContainerExist(containerRef, requestOptions, operationContext))
  156. {
  157. return false;
  158. }
  159. else
  160. {
  161. containerRef = GetContainerReference(container.Name);
  162. ContainerList.Add(containerRef);
  163. return true;
  164. }
  165. }
  166. /// <summary>
  167. /// Delete container
  168. /// </summary>
  169. /// <param name="container">A cloudblobcontainer object</param>
  170. /// <param name="accessCondition">Access condition</param>
  171. /// <param name="options">Blob request option</param>
  172. /// <param name="operationContext">Operation context</param>
  173. public void DeleteContainer(CloudBlobContainer container, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
  174. {
  175. foreach (CloudBlobContainer containerRef in ContainerList)
  176. {
  177. if (container.Name == containerRef.Name)
  178. {
  179. ContainerList.Remove(containerRef);
  180. return;
  181. }
  182. }
  183. }
  184. /// <summary>
  185. /// Set container permissions
  186. /// </summary>
  187. /// <param name="container">A cloudblobcontainer object</param>
  188. /// <param name="permissions">The container's permission</param>
  189. /// <param name="accessCondition">Access condition</param>
  190. /// <param name="options">Blob request option</param>
  191. /// <param name="operationContext">Operation context</param>
  192. public void SetContainerPermissions(CloudBlobContainer container, BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
  193. {
  194. String name = container.Name;
  195. if (ContainerPermissions.ContainsKey(name))
  196. {
  197. ContainerPermissions[name] = permissions;
  198. }
  199. else
  200. {
  201. ContainerPermissions.Add(name, permissions);
  202. }
  203. }
  204. /// <summary>
  205. /// Get blob reference with properties and meta data from server
  206. /// </summary>
  207. /// <param name="container">A cloudblobcontainer object</param>
  208. /// <param name="blobName">Blob name</param>
  209. /// <param name="accessCondition">Access condition</param>
  210. /// <param name="options">Blob request options</param>
  211. /// <param name="operationContext">Operation context</param>
  212. /// <returns>Return an ICloudBlob if the specific blob exists on azure, otherwise return null</returns>
  213. public ICloudBlob GetBlobReferenceFromServer(CloudBlobContainer container, string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
  214. {
  215. string containerName = container.Name;
  216. if (ContainerBlobs.ContainsKey(containerName))
  217. {
  218. List<ICloudBlob> blobList = ContainerBlobs[containerName];
  219. foreach (ICloudBlob blob in blobList)
  220. {
  221. if (blob.Name == blobName)
  222. {
  223. return blob;
  224. }
  225. }
  226. return null;
  227. }
  228. else
  229. {
  230. return null;
  231. }
  232. }
  233. /// <summary>
  234. /// List all blobs in specified containers
  235. /// </summary>
  236. /// <param name="container">A cloudblobcontainer object</param>
  237. /// <param name="prefix">Blob prefix</param>
  238. /// <param name="useFlatBlobListing">Use flat blob listing(whether treat "container/" as directory)</param>
  239. /// <param name="blobListingDetails">Blob listing details</param>
  240. /// <param name="options">Blob request option</param>
  241. /// <param name="operationContext">Operation context</param>
  242. /// <returns>An enumerable collection of icloudblob</returns>
  243. public IEnumerable<IListBlobItem> ListBlobs(CloudBlobContainer container, string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, BlobRequestOptions options, OperationContext operationContext)
  244. {
  245. string containerName = container.Name;
  246. if (ContainerBlobs.ContainsKey(containerName))
  247. {
  248. List<ICloudBlob> blobList = ContainerBlobs[containerName];
  249. if (string.IsNullOrEmpty(prefix))
  250. {
  251. return blobList;
  252. }
  253. List<ICloudBlob> prefixBlobs = new List<ICloudBlob>();
  254. foreach (ICloudBlob blob in blobList)
  255. {
  256. if (blob.Name.StartsWith(prefix))
  257. {
  258. prefixBlobs.Add(blob);
  259. }
  260. }
  261. return prefixBlobs;
  262. }
  263. else
  264. {
  265. return new List<ICloudBlob>();
  266. }
  267. }
  268. /// <summary>
  269. /// Whether the container is exists or not
  270. /// </summary>
  271. /// <param name="container">A cloudblobcontainer object</param>
  272. /// <param name="options">Blob request option</param>
  273. /// <param name="operationContext">Operation context</param>
  274. /// <returns>True if the specific container exists, otherwise return false</returns>
  275. public bool DoesContainerExist(CloudBlobContainer container, BlobRequestOptions options, OperationContext operationContext)
  276. {
  277. if (null == container)
  278. {
  279. return false;
  280. }
  281. foreach (CloudBlobContainer containerRef in ContainerList)
  282. {
  283. if (containerRef.Name == container.Name)
  284. {
  285. return true;
  286. }
  287. }
  288. return false;
  289. }
  290. /// <summary>
  291. /// Whether the blob is exists or not
  292. /// </summary>
  293. /// <param name="blob">A icloudblob object</param>
  294. /// <param name="options">Blob request option</param>
  295. /// <param name="operationContext">Operation context</param>
  296. /// <returns>True if the specific blob exists, otherwise return false</returns>
  297. public bool DoesBlobExist(ICloudBlob blob, BlobRequestOptions options, OperationContext operationContext)
  298. {
  299. CloudBlobContainer container = blob.Container;
  300. if (!ContainerBlobs.ContainsKey(container.Name))
  301. {
  302. return false;
  303. }
  304. else
  305. {
  306. List<ICloudBlob> blobList = ContainerBlobs[container.Name];
  307. foreach (ICloudBlob blobRef in blobList)
  308. {
  309. if (blobRef.Name == blob.Name)
  310. {
  311. return true;
  312. }
  313. }
  314. return false;
  315. }
  316. }
  317. /// <summary>
  318. /// Delete azure blob
  319. /// </summary>
  320. /// <param name="blob">ICloudblob object</param>
  321. /// <param name="deleteSnapshotsOption">Delete snapshots option</param>
  322. /// <param name="accessCondition">Access condition</param>
  323. /// <param name="operationContext">Operation context</param>
  324. /// <returns>An enumerable collection of icloudblob</returns>
  325. public void DeleteICloudBlob(ICloudBlob blob, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
  326. {
  327. CloudBlobContainer container = blob.Container;
  328. if (!this.DoesContainerExist(container, null, null))
  329. {
  330. throw new StorageException(ContainerNotFound);
  331. }
  332. else if (ContainerBlobs.ContainsKey(container.Name))
  333. {
  334. List<ICloudBlob> blobList = ContainerBlobs[container.Name];
  335. foreach (ICloudBlob blobRef in blobList)
  336. {
  337. if (blobRef.Name == blob.Name)
  338. {
  339. blobList.Remove(blobRef);
  340. return;
  341. }
  342. }
  343. }
  344. throw new StorageException(BlobNotFound);
  345. }
  346. /// <summary>
  347. /// fetch container attributes
  348. /// </summary>
  349. /// <param name="container">CloudBlobContainer object</param>
  350. /// <param name="accessCondition">Access condition</param>
  351. /// <param name="options">blob request options</param>
  352. /// <param name="operationContext">An object that represents the context for the current operation.</param>
  353. public void FetchContainerAttributes(CloudBlobContainer container, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
  354. {
  355. return;
  356. }
  357. /// <summary>
  358. /// fetch blob attributes
  359. /// </summary>
  360. /// <param name="accessCondition">Access condition</param>
  361. /// <param name="options">blob request options</param>
  362. /// <param name="operationContext">An object that represents the context for the current operation.</param>
  363. public void FetchBlobAttributes(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
  364. {
  365. return ;
  366. }
  367. /// <summary>
  368. /// set blob properties
  369. /// </summary>
  370. /// <param name="accessCondition">Access condition</param>
  371. /// <param name="options">blob request options</param>
  372. /// <param name="operationContext">An object that represents the context for the current operation.</param>
  373. public void SetBlobProperties(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
  374. {
  375. return;
  376. }
  377. /// <summary>
  378. /// set blob meta data
  379. /// </summary>
  380. /// <param name="blob">ICloud blob object</param>
  381. /// <param name="accessCondition">Access condition</param>
  382. /// <param name="options">blob request options</param>
  383. /// <param name="operationContext">An object that represents the context for the current operation.</param>
  384. public void SetBlobMetadata(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
  385. {
  386. return;
  387. }
  388. /// <summary>
  389. /// Abort copy operation on specified blob
  390. /// </summary>
  391. /// <param name="blob">ICloudBlob object</param>
  392. /// <param name="copyId">Copy id</param>
  393. /// <param name="accessCondition">Access condition</param>
  394. /// <param name="options">Blob request options</param>
  395. /// <param name="operationContext">Operation context</param>
  396. public void AbortCopy(ICloudBlob blob, string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
  397. {
  398. return;
  399. }
  400. /// <summary>
  401. /// Get the service properties
  402. /// </summary>
  403. /// <param name="account">Cloud storage account</param>
  404. /// <param name="type">Service type</param>
  405. /// <param name="options">Request options</param>
  406. /// <param name="operationContext">Operation context</param>
  407. /// <returns>The service properties of the specified service type</returns>
  408. public ServiceProperties GetStorageServiceProperties(StorageServiceType type, IRequestOptions options, OperationContext operationContext)
  409. {
  410. throw new NotImplementedException("No need to cover this in unit test since the logic is quite simple. For more details, please read GetAzureStorageServiceLogging.cs");
  411. }
  412. /// <summary>
  413. /// Set service properties
  414. /// </summary>
  415. /// <param name="account">Cloud storage account</param>
  416. /// <param name="type">Service type</param>
  417. /// <param name="properties">Service properties</param>
  418. /// <param name="options">Request options</param>
  419. /// <param name="operationContext">Operation context</param>
  420. public void SetStorageServiceProperties(StorageServiceType type, WindowsAzure.Storage.Shared.Protocol.ServiceProperties properties, IRequestOptions options, OperationContext operationContext)
  421. {
  422. throw new NotImplementedException("No need to cover this in unit test since there are no additional logics on this api");
  423. }
  424. /// <summary>
  425. /// List part of blobs.
  426. /// </summary>
  427. /// <param name="prefix">Blob prefix</param>
  428. /// <param name="useFlatBlobListing">Use flat blob listing</param>
  429. /// <param name="blobListingDetails">Blob listing details.</param>
  430. /// <param name="maxResults">Max results.</param>
  431. /// <param name="currentToken">Current token.</param>
  432. /// <param name="options">Request options</param>
  433. /// <param name="operationContext">Operation Context.</param>
  434. /// <returns>BlobResultSegment object</returns>
  435. public BlobResultSegment ListBlobsSegmented(CloudBlobContainer container, string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext)
  436. {
  437. throw new NotImplementedException("Can not create a BlobResultSegment object");
  438. }
  439. /// <summary>
  440. /// Get a list of cloudblobcontainer in azure
  441. /// </summary>
  442. /// <param name="prefix">Container prefix</param>
  443. /// <param name="detailsIncluded">Container listing details</param>
  444. /// <param name="options">Blob request option</param>
  445. /// <param name="operationContext">Operation context</param>
  446. /// <returns>An enumerable collection of cloudblobcontainer</returns>
  447. public ContainerResultSegment ListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext)
  448. {
  449. throw new NotImplementedException("Can not create a ContainerResultSegment object");
  450. }
  451. /// <summary>
  452. /// Async Get container presssions
  453. /// </summary>
  454. /// <param name="container">A cloudblobcontainer object</param>
  455. /// <param name="accessCondition">Access condition</param>
  456. /// <param name="options">Blob request option</param>
  457. /// <param name="operationContext">Operation context</param>
  458. /// <param name="cancellationToken">User cancellation token</param>
  459. /// <returns>A task object which retrieve the permission of the specified container</returns>
  460. public Task<BlobContainerPermissions> GetContainerPermissionsAsync(CloudBlobContainer container, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
  461. {
  462. return Task.Factory.StartNew(() => this.GetContainerPermissions(container,
  463. accessCondition, options, operationContext));
  464. }
  465. /// <summary>
  466. /// Return a task that asynchronously check whether the specified container exists.
  467. /// </summary>
  468. /// <param name="container">CloudBlobContainer object</param>
  469. /// <param name="requestOptions">Blob request option</param>
  470. /// <param name="operationContext">Operation context</param>
  471. /// <param name="cmdletCancellationToken">Cancellation token</param>
  472. /// <returns>A task object that asynchronously check whether the specified container exists </returns>
  473. public Task<bool> DoesContainerExistAsync(CloudBlobContainer container, BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cmdletCancellationToken)
  474. {
  475. return Task.Factory.StartNew(() => this.DoesContainerExist(container, requestOptions, operationContext));
  476. }
  477. /// <summary>
  478. /// Return a task that asynchronously check whether the specified blob exists.
  479. /// </summary>
  480. /// <param name="blob">ICloudBlob object</param>
  481. /// <param name="options">Blob request options</param>
  482. /// <param name="operationContext">Operation context</param>
  483. /// <param name="cmdletCancellationToken">Cancellation token</param>
  484. /// <returns>A task object that asynchronously check whether the specified blob exists.</returns>
  485. public Task<bool> DoesBlobExistAsync(ICloudBlob blob, BlobRequestOptions options, OperationContext operationContext, CancellationToken cmdletCancellationToken)
  486. {
  487. return Task.Factory.StartNew(() => this.DoesBlobExist(blob, options, operationContext));
  488. }
  489. /// <summary>
  490. /// Return a task that asynchronously get the blob reference from server
  491. /// </summary>
  492. /// <param name="container">CloudBlobContainer object</param>
  493. /// <param name="blobName">Blob name</param>
  494. /// <param name="accessCondition">Access condition</param>
  495. /// <param name="options">Blob request options</param>
  496. /// <param name="operationContext">Operation context</param>
  497. /// <param name="cmdletCancellationToken">Cancellation token</param>
  498. /// <returns>A task object that asynchronously get the blob reference from server</returns>
  499. public Task<ICloudBlob> GetBlobReferenceFromServerAsync(CloudBlobContainer container, string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cmdletCancellationToken)
  500. {
  501. return Task.Factory.StartNew(() => this.GetBlobReferenceFromServer(container, blobName, accessCondition, options, operationContext));
  502. }
  503. /// <summary>
  504. /// Return a task that asynchronously fetch blob attributes
  505. /// </summary>
  506. /// <param name="blob">ICloud blob object</param>
  507. /// <param name="accessCondition">Access condition</param>
  508. /// <param name="options">Blob request options</param>
  509. /// <param name="operationContext">Operation context</param>
  510. /// <param name="cmdletCancellationToken">Cancellation token</param>
  511. /// <returns>Return a task that asynchronously fetch blob attributes</returns>
  512. public Task FetchBlobAttributesAsync(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cmdletCancellationToken)
  513. {
  514. return Task.Factory.StartNew(() => this.FetchBlobAttributes(blob, accessCondition, options, operationContext));
  515. }
  516. /// <summary>
  517. /// Return a task that asynchronously create a container if it doesn't exist.
  518. /// </summary>
  519. /// <param name="container">CloudBlobContainer object</param>
  520. /// <param name="accessType">Blob container public access type</param>
  521. /// <param name="requestOptions">Blob request options</param>
  522. /// <param name="operationContext">Operation context</param>
  523. /// <param name="cmdletCancellationToken">Cancellation token</param>
  524. /// <returns>Return a task that asynchronously create a container if it doesn't exist.</returns>
  525. public Task<bool> CreateContainerIfNotExistsAsync(CloudBlobContainer container, BlobContainerPublicAccessType accessType, BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cmdletCancellationToken)
  526. {
  527. return Task.Factory.StartNew(() => this.CreateContainerIfNotExists(container, requestOptions, operationContext));
  528. }
  529. /// <summary>
  530. /// Return a task that asynchronously delete the specified container.
  531. /// </summary>
  532. /// <param name="container">CloudBlobContainer object</param>
  533. /// <param name="accessCondition">Access condition</param>
  534. /// <param name="requestOptions">Blob request option</param>
  535. /// <param name="operationContext">Operation context</param>
  536. /// <param name="cmdletCancellationToken">Cancellation token</param>
  537. /// <returns>Return a task that asynchronously delete the specified container.</returns>
  538. public Task DeleteContainerAsync(CloudBlobContainer container, AccessCondition accessCondition, BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cmdletCancellationToken)
  539. {
  540. return Task.Factory.StartNew(() => this.DeleteContainer(container, accessCondition, requestOptions, operationContext));
  541. }
  542. /// <summary>
  543. /// Return a task that asynchronously abort the blob copy operation
  544. /// </summary>
  545. /// <param name="blob">ICloudBlob object</param>
  546. /// <param name="abortCopyId">Copy id</param>
  547. /// <param name="accessCondition">Access condition</param>
  548. /// <param name="abortRequestOption">Blob request options</param>
  549. /// <param name="operationContext">Operation context</param>
  550. /// <param name="cmdletCancellationToken">Cancellation token</param>
  551. /// <returns>Return a task that asynchronously abort the blob copy operation</returns>
  552. public Task AbortCopyAsync(ICloudBlob blob, string copyId, AccessCondition accessCondition, BlobRequestOptions requestOption, OperationContext operationContext, CancellationToken cmdletCancellationToken)
  553. {
  554. return Task.Factory.StartNew(() => this.AbortCopy(blob, copyId, accessCondition, requestOption, operationContext));
  555. }
  556. /// <summary>
  557. /// Set container permissions
  558. /// </summary>
  559. /// <param name="container">A cloudblobcontainer object</param>
  560. /// <param name="permissions">The container's permission</param>
  561. /// <param name="accessCondition">Access condition</param>
  562. /// <param name="options">Blob request option</param>
  563. /// <param name="operationContext">Operation context</param>
  564. public Task SetContainerPermissionsAsync(CloudBlobContainer container, BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cmdletCancellationToken)
  565. {
  566. return Task.Factory.StartNew(() => this.SetContainerPermissions(container, permissions, accessCondition, requestOptions, operationContext));
  567. }
  568. /// <summary>
  569. /// Return a task that asynchronously delete the specified blob
  570. /// </summary>
  571. /// <param name="blob">ICloudBlob object</param>
  572. /// <param name="deleteSnapshotsOption">Snapshot delete option</param>
  573. /// <param name="accessCondition">Access condition</param>
  574. /// <param name="requestOptions">Blob request option</param>
  575. /// <param name="operationContext">Operation context</param>
  576. /// <param name="cmdletCancellationToken">Cancellation token</param>
  577. /// <returns>Return a task that asynchronously delete the specified blob</returns>
  578. public Task DeleteICloudBlobAsync(ICloudBlob blob, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cmdletCancellationToken)
  579. {
  580. return Task.Factory.StartNew(() => this.DeleteICloudBlob(blob, deleteSnapshotsOption, accessCondition, requestOptions, operationContext));
  581. }
  582. /// <summary>
  583. /// Return a task that asynchronously set blob properties
  584. /// </summary>
  585. /// <param name="blob">ICloud blob object</param>
  586. /// <param name="accessCondition">Access condition</param>
  587. /// <param name="options">Blob request options</param>
  588. /// <param name="operationContext">An object that represents the context for the current operation.</param>
  589. public Task SetBlobPropertiesAsync(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cmdletCancellationToken)
  590. {
  591. return Task.Factory.StartNew(() => this.SetBlobProperties(blob, accessCondition, options, operationContext));
  592. }
  593. /// <summary>
  594. /// Return a task that asynchronously set blob meta data
  595. /// </summary>
  596. /// <param name="blob">ICloud blob object</param>
  597. /// <param name="accessCondition">Access condition</param>
  598. /// <param name="options">Blob request options</param>
  599. /// <param name="operationContext">An object that represents the context for the current operation.</param>
  600. public Task SetBlobMetadataAsync(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cmdletCancellationToken)
  601. {
  602. return Task.Factory.StartNew(() => this.SetBlobMetadata(blob, accessCondition, options, operationContext));
  603. }
  604. /// <summary>
  605. /// List the blobs segmented in specified containers
  606. /// </summary>
  607. /// <param name="container">A cloudblobcontainer object</param>
  608. /// <param name="prefix">Blob prefix</param>
  609. /// <param name="useFlatBlobListing">Use flat blob listing(whether treat "container/" as directory)</param>
  610. /// <param name="blobListingDetails">Blob listing details</param>
  611. /// <param name="options">Blob request option</param>
  612. /// <param name="operationContext">Operation context</param>
  613. public Task<BlobResultSegment> ListBlobsSegmentedAsync(CloudBlobContainer container, string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
  614. {
  615. //BlobResultSegment is sealed without any public constructors.
  616. throw new NotImplementedException();
  617. }
  618. /// <summary>
  619. /// The storage context
  620. /// </summary>
  621. public AzureStorageContext StorageContext
  622. {
  623. get { return null; }
  624. }
  625. }
  626. }