public static HttpWebRequest Delete(Uri uri, int?timeout, DateTimeOffset?snapshot, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, OperationContext operationContext) { if ((snapshot != null) && (deleteSnapshotsOption != DeleteSnapshotsOption.None)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, SR.DeleteSnapshotsNotValidError, "deleteSnapshotsOption", "snapshot")); } UriQueryBuilder builder = new UriQueryBuilder(); BlobHttpWebRequestFactory.AddSnapshot(builder, snapshot); HttpWebRequest request = HttpWebRequestFactory.Delete(uri, builder, timeout, operationContext); switch (deleteSnapshotsOption) { case DeleteSnapshotsOption.None: break; // nop case DeleteSnapshotsOption.IncludeSnapshots: request.Headers.Add( Constants.HeaderConstants.DeleteSnapshotHeader, Constants.HeaderConstants.IncludeSnapshotsValue); break; case DeleteSnapshotsOption.DeleteSnapshotsOnly: request.Headers.Add( Constants.HeaderConstants.DeleteSnapshotHeader, Constants.HeaderConstants.SnapshotsOnlyValue); break; } request.ApplyAccessCondition(accessCondition); return(request); }
/// <summary> /// Constructs a web request to return the user-defined metadata for the blob. /// </summary> /// <param name="uri">The absolute URI to the blob.</param> /// <param name="timeout">The server timeout interval.</param> /// <param name="snapshot">The snapshot timestamp, if the blob is a snapshot.</param> /// <param name="accessCondition">The access condition to apply to the request.</param> /// <param name="operationContext">An <see cref="OperationContext"/> object for tracking the current operation.</param> /// <returns>A web request for performing the operation.</returns> public static HttpWebRequest GetMetadata(Uri uri, int?timeout, DateTimeOffset?snapshot, AccessCondition accessCondition, OperationContext operationContext) { UriQueryBuilder builder = new UriQueryBuilder(); BlobHttpWebRequestFactory.AddSnapshot(builder, snapshot); HttpWebRequest request = HttpWebRequestFactory.GetMetadata(uri, timeout, builder, operationContext); request.ApplyAccessCondition(accessCondition); return(request); }
/// <summary> /// Constructs a web request to return the list of blocks for a block blob. /// </summary> /// <param name="uri">The absolute URI to the blob.</param> /// <param name="timeout">The server timeout interval.</param> /// <param name="snapshot">The snapshot timestamp, if the blob is a snapshot.</param> /// <param name="typesOfBlocks">The types of blocks to include in the list: committed, uncommitted, or both.</param> /// <param name="accessCondition">The access condition to apply to the request.</param> /// <param name="operationContext">An <see cref="OperationContext"/> object for tracking the current operation.</param> /// <returns>A web request to use to perform the operation.</returns> public static HttpWebRequest GetBlockList(Uri uri, int?timeout, DateTimeOffset?snapshot, BlockListingFilter typesOfBlocks, AccessCondition accessCondition, OperationContext operationContext) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "blocklist"); builder.Add("blocklisttype", typesOfBlocks.ToString()); BlobHttpWebRequestFactory.AddSnapshot(builder, snapshot); HttpWebRequest request = HttpWebRequestFactory.CreateWebRequest(WebRequestMethods.Http.Get, uri, timeout, builder, operationContext); request.ApplyAccessCondition(accessCondition); return(request); }
/// <summary> /// Constructs a web request to return the list of valid page ranges for a page blob. /// </summary> /// <param name="uri">The absolute URI to the blob.</param> /// <param name="timeout">The server timeout interval.</param> /// <param name="snapshot">The snapshot timestamp, if the blob is a snapshot.</param> /// <param name="offset">The starting offset of the data range over which to list page ranges, in bytes. Must be a multiple of 512.</param> /// <param name="count">The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512.</param> /// <param name="accessCondition">The access condition to apply to the request.</param> /// <param name="operationContext">An <see cref="OperationContext" /> object for tracking the current operation.</param> /// <returns> /// A web request to use to perform the operation. /// </returns> public static HttpWebRequest GetPageRanges(Uri uri, int?timeout, DateTimeOffset?snapshot, long?offset, long?count, AccessCondition accessCondition, OperationContext operationContext) { if (offset.HasValue) { CommonUtility.AssertNotNull("count", count); } UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "pagelist"); BlobHttpWebRequestFactory.AddSnapshot(builder, snapshot); HttpWebRequest request = HttpWebRequestFactory.CreateWebRequest(WebRequestMethods.Http.Get, uri, timeout, builder, operationContext); AddRange(request, offset, count); request.ApplyAccessCondition(accessCondition); return(request); }