/// <summary> /// Constructs a web request to return a listing of all containers in this storage account. /// </summary> /// <param name="uri">The absolute URI for the account.</param> /// <param name="timeout">The server timeout interval.</param> /// <param name="listingContext">A set of parameters for the listing operation.</param> /// <param name="detailsIncluded">Additional details to return with the listing.</param> /// <returns>A web request for the specified operation.</returns> public static HttpWebRequest List(Uri uri, int timeout, ListingContext listingContext, ContainerListingDetails detailsIncluded) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "list"); if (listingContext != null) { if (listingContext.Prefix != null) { builder.Add("prefix", listingContext.Prefix); } if (listingContext.Marker != null) { builder.Add("marker", listingContext.Marker); } if (listingContext.MaxResults != null) { builder.Add("maxresults", listingContext.MaxResults.ToString()); } } if ((detailsIncluded & ContainerListingDetails.Metadata) != 0) { builder.Add("include", "metadata"); } HttpWebRequest request = CreateWebRequest(uri, timeout, builder); request.Method = "GET"; return(request); }
/// <summary> /// Constructs a web request to return a listing of all containers in this storage account. /// </summary> /// <param name="uri">The absolute URI for the account.</param> /// <param name="timeout">The server timeout interval.</param> /// <param name="listingContext">A set of parameters for the listing operation.</param> /// <param name="detailsIncluded">Additional details to return with the listing.</param> /// <returns>A web request for the specified operation.</returns> public static HttpWebRequest List(Uri uri, int timeout, ListingContext listingContext, ContainerListingDetails detailsIncluded) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "list"); if (listingContext != null) { if (listingContext.Prefix != null) { builder.Add("prefix", listingContext.Prefix); } if (listingContext.Marker != null) { builder.Add("marker", listingContext.Marker); } if (listingContext.MaxResults != null) { builder.Add("maxresults", listingContext.MaxResults.ToString()); } } if ((detailsIncluded & ContainerListingDetails.Metadata) != 0) { builder.Add("include", "metadata"); } HttpWebRequest request = CreateWebRequest(uri, timeout, builder); request.Method = "GET"; return request; }
/// <summary>Core implementation for the ListContainers method.</summary> /// <param name="prefix">The container prefix. </param> /// <param name="detailsIncluded">The details included. </param> /// <param name="continuationToken">The continuation token. </param> /// <param name="pagination">The pagination. </param> /// <param name="setResult">The result report delegate. </param> /// <returns>A <see cref="TaskSequence"/> that lists the containers. </returns> private TaskSequence ListContainersImplCore( string prefix, ContainerListingDetails detailsIncluded, ResultContinuation continuationToken, ResultPagination pagination, Action<ResultSegment<CloudBlobContainer>> setResult) { CommonUtils.AssertContinuationType(continuationToken, ResultContinuation.ContinuationType.Container); var listingContext = new ListingContext(prefix, pagination.GetNextRequestPageSize()) { Marker = continuationToken != null ? continuationToken.NextMarker : null }; var containersList = new List<CloudBlobContainer>(); var request = ContainerRequest.List( this.BaseUri, this.Timeout.RoundUpToSeconds(), listingContext, detailsIncluded); this.Credentials.SignRequest(request); var listTask = request.GetResponseAsyncWithTimeout(this, this.Timeout); yield return listTask; string nextMarker; using (var response = listTask.Result as HttpWebResponse) { var listContainersResponse = ContainerResponse.List(response); containersList.AddRange( listContainersResponse.Containers.Select(item => new CloudBlobContainer(item.Attributes, this))); nextMarker = listContainersResponse.NextMarker; } var newContinuationToken = new ResultContinuation { NextMarker = nextMarker, Type = ResultContinuation.ContinuationType.Container }; ResultSegment.CreateResultSegment( setResult, containersList, newContinuationToken, pagination, this.RetryPolicy, (paginationArg, continuationArg, resultSegmentArg) => this.ListContainersImplCore(prefix, detailsIncluded, continuationArg, paginationArg, resultSegmentArg)); }
/// <summary>Lists the queues impl core.</summary> /// <param name="prefix">The prefix. </param> /// <param name="detailsIncluded">The details included. </param> /// <param name="continuationToken">The continuation token. </param> /// <param name="pagination">The pagination. </param> /// <param name="setResult">The set result. </param> /// <returns>A <see cref="TaskSequence"/> for listing the queues. </returns> private TaskSequence ListQueuesImplCore( string prefix, QueueListingDetails detailsIncluded, ResultContinuation continuationToken, ResultPagination pagination, Action<ResultSegment<CloudQueue>> setResult) { CommonUtils.AssertContinuationType(continuationToken, ResultContinuation.ContinuationType.Queue); var listingContext = new ListingContext(prefix, pagination.GetNextRequestPageSize()) { Marker = continuationToken != null ? continuationToken.NextMarker : null }; var queueList = new List<CloudQueue>(); var webRequest = QueueRequest.List( this.BaseUri, this.Timeout.RoundUpToSeconds(), listingContext, detailsIncluded); this.Credentials.SignRequest(webRequest); var listTask = webRequest.GetResponseAsyncWithTimeout(this, this.Timeout); yield return listTask; string nextMarker; using (var response = listTask.Result as HttpWebResponse) { var parsedResponse = QueueResponse.List(response); // Materialize the results so that we can close the response queueList.AddRange(parsedResponse.Queues.Select(this.SelectResponse)); nextMarker = parsedResponse.NextMarker; } var newContinuationToken = new ResultContinuation { NextMarker = nextMarker, Type = ResultContinuation.ContinuationType.Queue }; ResultSegment.CreateResultSegment( setResult, queueList, newContinuationToken, pagination, this.RetryPolicy, (paginationArg, continuationArg, resultSegment) => this.ListQueuesImplCore(prefix, detailsIncluded, continuationArg, paginationArg, resultSegment)); }