Ejemplo n.º 1
0
        /// <summary>
        /// Generates a web request to return the 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>
        /// <returns>A web request to use to perform the operation.</returns>
        public static StorageRequestMessage GetMetadata(Uri uri, int?timeout, DateTimeOffset?snapshot, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials)
        {
            UriQueryBuilder shareBuilder = GetShareUriQueryBuilder();

            ShareHttpRequestMessageFactory.AddShareSnapshot(shareBuilder, snapshot);

            StorageRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, shareBuilder, content, operationContext, canonicalizer, credentials);

            request.ApplyAccessCondition(accessCondition);
            return(request);
        }
Ejemplo n.º 2
0
        public static HttpRequestMessage DeleteShareRequest(FileContext context, string shareName, AccessCondition accessCondition)
        {
            Uri uri = FileClientTests.ConstructUri(context.Address, shareName);
            OperationContext   opContext = new OperationContext();
            HttpRequestMessage request   = ShareHttpRequestMessageFactory.Delete(uri, context.Timeout, null, DeleteShareSnapshotsOption.None, accessCondition, null, opContext, SharedKeyCanonicalizer.Instance, context.Credentials);

            Assert.IsNotNull(request);
            Assert.IsNotNull(request.Method);
            Assert.AreEqual(HttpMethod.Delete, request.Method);
            FileTestUtils.RangeHeader(request, null);
            return(request);
        }
Ejemplo n.º 3
0
        public static HttpRequestMessage ListSharesRequest(FileContext context, ListingContext listingContext)
        {
            Uri uri = FileClientTests.ConstructUri(context.Address);
            OperationContext   opContext = new OperationContext();
            HttpRequestMessage request   = ShareHttpRequestMessageFactory.List(uri, context.Timeout, listingContext, ShareListingDetails.Metadata, null, opContext, SharedKeyCanonicalizer.Instance, context.Credentials);

            Assert.IsNotNull(request);
            Assert.IsNotNull(request.Method);
            Assert.AreEqual(HttpMethod.Get, request.Method);
            FileTestUtils.RangeHeader(request, null);
            return(request);
        }
Ejemplo n.º 4
0
        public static HttpRequestMessage CreateShareRequest(FileContext context, string shareName)
        {
            Uri uri = FileClientTests.ConstructUri(context.Address, shareName);
            OperationContext   opContext = new OperationContext();
            HttpRequestMessage request   = ShareHttpRequestMessageFactory.Create(uri, null, context.Timeout, null, opContext, SharedKeyCanonicalizer.Instance, context.Credentials);

            Assert.IsNotNull(request);
            Assert.IsNotNull(request.Method);
            Assert.AreEqual(HttpMethod.Put, request.Method);
            FileTestUtils.RangeHeader(request, null);
            FileTestUtils.VersionHeader(request, false);
            return(request);
        }
Ejemplo n.º 5
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>
        /// <returns>A web request to use to perform the operation.</returns>
        public static StorageRequestMessage Delete(Uri uri, int?timeout, DateTimeOffset?snapshot, DeleteShareSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials)
        {
            UriQueryBuilder shareBuilder = GetShareUriQueryBuilder();

            ShareHttpRequestMessageFactory.AddShareSnapshot(shareBuilder, snapshot);
            StorageRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, shareBuilder, content, operationContext, canonicalizer, credentials);

            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);
        }