Exemple #1
0
        /// <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>
        internal 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);
        }
Exemple #2
0
        /// <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>
        internal 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);
        }
Exemple #3
0
        public static HttpWebRequest ListSharesRequest(FileContext context, ListingContext listingContext)
        {
            Uri uri = FileClientTests.ConstructUri(context.Address);
            OperationContext opContext = new OperationContext();
            HttpWebRequest   request   = ShareHttpWebRequestFactory.List(uri, context.Timeout, listingContext, ShareListingDetails.Metadata, true, opContext);

            Assert.IsNotNull(request);
            Assert.IsNotNull(request.Method);
            Assert.AreEqual("GET", request.Method);
            FileTestUtils.RangeHeader(request, null);
            return(request);
        }
Exemple #4
0
        public static HttpWebRequest DeleteShareRequest(FileContext context, string shareName, AccessCondition accessCondition)
        {
            Uri uri = FileClientTests.ConstructUri(context.Address, shareName);
            OperationContext opContext = new OperationContext();
            HttpWebRequest   request   = ShareHttpWebRequestFactory.Delete(uri, context.Timeout, accessCondition, true, opContext);

            Assert.IsNotNull(request);
            Assert.IsNotNull(request.Method);
            Assert.AreEqual("DELETE", request.Method);
            FileTestUtils.RangeHeader(request, null);
            return(request);
        }
Exemple #5
0
        public static HttpWebRequest CreateShareRequest(FileContext context, string shareName)
        {
            Uri uri = FileClientTests.ConstructUri(context.Address, shareName);
            OperationContext opContext = new OperationContext();
            HttpWebRequest   request   = ShareHttpWebRequestFactory.Create(uri, context.Timeout, true, opContext);

            Assert.IsNotNull(request);
            Assert.IsNotNull(request.Method);
            Assert.AreEqual("PUT", request.Method);
            FileTestUtils.RangeHeader(request, null);
            FileTestUtils.VersionHeader(request, false);
            return(request);
        }
Exemple #6
0
 /// <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));
 }
Exemple #7
0
 /// <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));
 }