/// <summary> /// Constructs a web request to delete the share and all of the files within it. /// </summary> /// <param name="uri">The absolute URI to the share.</param> /// <param name="timeout">The server timeout interval.</param> /// <param name="snapshot">A <see cref="DateTimeOffset"/> specifying the snapshot timestamp, if the share is a snapshot.</param> /// <param name="deleteSnapshotsOption">A <see cref="DeleteShareSnapshotsOption"/> object indicating whether to only delete the share or delete the share and all snapshots.</param> /// <param name="accessCondition">The access condition to apply to the request.</param> /// <param name="useVersionHeader">A flag indicating whether to set the x-ms-version HTTP header.</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 Delete(Uri uri, int?timeout, DateTimeOffset?snapshot, DeleteShareSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, bool useVersionHeader, OperationContext operationContext) { if ((snapshot != null) && (deleteSnapshotsOption != DeleteShareSnapshotsOption.None)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, SR.DeleteSnapshotsNotValidError, "deleteSnapshotsOption", "snapshot")); } UriQueryBuilder shareBuilder = GetShareUriQueryBuilder(); ShareHttpWebRequestFactory.AddShareSnapshot(shareBuilder, snapshot); HttpWebRequest request = HttpWebRequestFactory.Delete(uri, shareBuilder, timeout, useVersionHeader, operationContext); switch (deleteSnapshotsOption) { case DeleteShareSnapshotsOption.None: break; // nop case DeleteShareSnapshotsOption.IncludeSnapshots: request.Headers.Add( Constants.HeaderConstants.DeleteSnapshotHeader, Constants.HeaderConstants.IncludeSnapshotsValue); break; } request.ApplyAccessCondition(accessCondition); return(request); }
/// <summary> /// Generates a web request to return the properties and user-defined metadata for this share. /// </summary> /// <param name="uri">The absolute URI to the share.</param> /// <param name="timeout">The server timeout interval.</param> /// <param name="snapshot">A <see cref="DateTimeOffset"/> specifying the snapshot timestamp, if the share is a snapshot.</param> /// <param name="accessCondition">The access condition to apply to the request.</param> /// <param name="useVersionHeader">A flag indicating whether to set the x-ms-version HTTP header.</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 GetProperties(Uri uri, int?timeout, DateTimeOffset?snapshot, AccessCondition accessCondition, bool useVersionHeader, OperationContext operationContext) { UriQueryBuilder shareBuilder = GetShareUriQueryBuilder(); ShareHttpWebRequestFactory.AddShareSnapshot(shareBuilder, snapshot); HttpWebRequest request = HttpWebRequestFactory.GetProperties(uri, timeout, shareBuilder, useVersionHeader, operationContext); request.ApplyAccessCondition(accessCondition); return(request); }
/// <summary> /// Constructs a web request to create a new share. /// </summary> /// <param name="uri">The absolute URI to the share.</param> /// <param name="timeout">The server timeout interval.</param> /// <param name="useVersionHeader">A boolean value indicating whether to set the <i>x-ms-version</i> HTTP header.</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 Create(Uri uri, int?timeout, bool useVersionHeader, OperationContext operationContext) { return(ShareHttpWebRequestFactory.Create(uri, null /* properties */, timeout, useVersionHeader, operationContext)); }
/// <summary> /// Constructs a web request to delete the share and all of the files within it. /// </summary> /// <param name="uri">The absolute URI to the share.</param> /// <param name="timeout">The server timeout interval.</param> /// <param name="accessCondition">The access condition to apply to the request.</param> /// <param name="useVersionHeader">A boolean value indicating whether to set the <i>x-ms-version</i> HTTP header.</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 Delete(Uri uri, int?timeout, AccessCondition accessCondition, bool useVersionHeader, OperationContext operationContext) { return(ShareHttpWebRequestFactory.Delete(uri, timeout, null /* snapshot */, DeleteShareSnapshotsOption.None, accessCondition, useVersionHeader, operationContext)); }