Exemplo n.º 1
0
 public ICancellableAsyncResult BeginListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded,
                                                             int?maxResults, BlobContinuationToken continuationToken,
                                                             BlobRequestOptions options, OperationContext operationContext,
                                                             AsyncCallback callback, object state)
 {
     throw new NotImplementedException();
 }
        public ContainerResultSegment ListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int?maxResults, BlobContinuationToken currentToken, BlobRequestOptions options = null, OperationContext operationContext = null)
        {
            BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this);
            ResultSegment <CloudBlobContainer> resultSegment = this.ListContainersSegmentedCore(prefix, detailsIncluded, maxResults, currentToken, modifiedOptions, operationContext);

            return(new ContainerResultSegment(resultSegment.Results, (BlobContinuationToken)resultSegment.ContinuationToken));
        }
 private Task<ContainerResultSegment> ListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken continuationToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken = default(CancellationToken))
 {
     return AsyncTaskUtil.RunAsyncCancellable<ContainerResultSegment>(
         _inner.BeginListContainersSegmented(prefix, detailsIncluded, maxResults, continuationToken, options, operationContext, null, null),
         _inner.EndListContainersSegmented,
         cancellationToken);
 }
Exemplo n.º 4
0
        private async Task <HttpResponseMessage> ListContainersAsync()
        {
            var client = DashConfiguration.NamespaceAccount.CreateCloudBlobClient();
            // Extract query parameters
            var queryParams  = this.Request.GetQueryParameters();
            var includeFlags = String.Join(",", queryParams.Values <string>("include"));
            ContainerListingDetails listDetails = ContainerListingDetails.None;

            Enum.TryParse(includeFlags, true, out listDetails);
            var retval = new ContainerListResults
            {
                RequestVersion  = this.Request.GetHeaders().Value("x-ms-version", StorageServiceVersions.Version_2009_09_19),
                ServiceEndpoint = this.Request.RequestUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped),
                Prefix          = queryParams.Value <string>("prefix"),
                Marker          = queryParams.Value <string>("marker"),
                MaxResults      = queryParams.ValueOrNull <int>("maxresults"),
                IncludeDetails  = listDetails,
            };

            retval.Containers = await client.ListContainersSegmentedAsync(
                retval.Prefix,
                listDetails,
                retval.MaxResults == 0?(int?)null : retval.MaxResults,
                new BlobContinuationToken
            {
                NextMarker = retval.Marker,
            },
                null,
                null);

            return(CreateResponse(retval));
        }
        public IEnumerable <CloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded, BlobRequestOptions options = null, OperationContext operationContext = null)
        {
            BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this);

            return(General.LazyEnumerable(
                       token =>
                       this.ListContainersSegmentedCore(prefix, detailsIncluded, null /* maxResults */, (BlobContinuationToken)token, modifiedOptions, operationContext),
                       long.MaxValue,
                       operationContext));
        }
 /// <summary>
 /// Get a list of cloudblobcontainer in azure
 /// </summary>
 /// <param name="prefix">Container prefix</param>
 /// <param name="detailsIncluded">Container listing details</param>
 /// <param name="options">Blob request option</param>
 /// <param name="operationContext">Operation context</param>
 /// <returns>An enumerable collection of cloudblobcontainer</returns>
 public ContainerResultSegment ListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int?maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, XSCL.OperationContext operationContext)
 {
     try
     {
         return(this.BlobClient.ListContainersSegmentedAsync(prefix, detailsIncluded, maxResults, currentToken, options, operationContext).Result);
     }
     catch (AggregateException e) when(e.InnerException is XSCL.StorageException)
     {
         throw e.InnerException;
     }
 }
        public ICancellableAsyncResult BeginListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int?maxResults, BlobContinuationToken continuationToken, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state)
        {
            BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this);

            return(Executor.BeginExecuteAsync(
                       this.ListContainersImpl(prefix, detailsIncluded, continuationToken, maxResults, modifiedOptions),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       callback,
                       state));
        }
Exemplo n.º 8
0
        /// <summary>
        /// List containers by container name prefix
        /// </summary>
        /// <param name="prefix">Container name prefix</param>
        /// <returns>An enumerable collection of cloudblobcontainer</returns>
        internal IEnumerable <CloudBlobContainer> ListContainersByPrefix(string prefix)
        {
            ContainerListingDetails details        = ContainerListingDetails.Metadata;
            BlobRequestOptions      requestOptions = null;

            if (!NameUtil.IsValidContainerPrefix(prefix))
            {
                throw new ArgumentException(String.Format(Resources.InvalidContainerName, prefix));
            }

            IEnumerable <CloudBlobContainer> containers = Channel.ListContainers(prefix, details, requestOptions, OperationContext);

            return(containers);
        }
        /// <summary>
        /// Get a list of cloudblobcontainer in azure
        /// </summary>
        /// <param name="prefix">Container prefix</param>
        /// <param name="detailsIncluded">Container listing details</param>
        /// <param name="options">Blob request option</param>
        /// <param name="operationContext">Operation context</param>
        /// <returns>An enumerable collection of cloudblobcontainer</returns>
        public IEnumerable <CloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded, BlobRequestOptions options, OperationContext operationContext)
        {
            //https://ahmet.im/blog/azure-listblobssegmentedasync-listcontainerssegmentedasync-how-to/
            BlobContinuationToken continuationToken = null;
            var results = new List <CloudBlobContainer>();

            do
            {
                var response = BlobClient.ListContainersSegmentedAsync(prefix, detailsIncluded, null, continuationToken, options, operationContext).Result;
                continuationToken = response.ContinuationToken;
                results.AddRange(response.Results);
            } while (continuationToken != null);
            return(results);
        }
Exemplo n.º 10
0
        public static async Task<List<CloudBlobContainer>> ListContainersAsync(this CloudBlobClient client, ContainerListingDetails details)
        {
            BlobContinuationToken continuationToken = null;
            BlobRequestOptions blobRequestOptions = new BlobRequestOptions();
            OperationContext operationContext = new OperationContext();

            List<CloudBlobContainer> results = new List<CloudBlobContainer>();
            do
            {
                var response = await client.ListContainersSegmentedAsync(string.Empty, details, null, continuationToken, blobRequestOptions, operationContext);
                continuationToken = response.ContinuationToken;
                results.AddRange(response.Results);
            }
            while (continuationToken != null);
            return results;
        }
Exemplo n.º 11
0
        /// <summary>
        /// List containers by container name pattern.
        /// </summary>
        /// <param name="name">Container name pattern</param>
        /// <returns>An enumerable collection of cloudblob container</returns>
        internal IEnumerable <CloudBlobContainer> ListContainersByName(string name)
        {
            ContainerListingDetails details    = ContainerListingDetails.Metadata;
            string             prefix          = string.Empty;
            BlobRequestOptions requestOptions  = null;
            AccessCondition    accessCondition = null;

            if (String.IsNullOrEmpty(name) || WildcardPattern.ContainsWildcardCharacters(name))
            {
                IEnumerable <CloudBlobContainer> containers = Channel.ListContainers(prefix, details, requestOptions, OperationContext);
                WildcardOptions options  = WildcardOptions.IgnoreCase | WildcardOptions.Compiled;
                WildcardPattern wildcard = null;

                if (!string.IsNullOrEmpty(name))
                {
                    wildcard = new WildcardPattern(name, options);
                }

                foreach (CloudBlobContainer container in containers)
                {
                    if (null == wildcard || wildcard.IsMatch(container.Name))
                    {
                        yield return(container);
                    }
                }
            }
            else
            {
                if (!NameUtil.IsValidContainerName(name))
                {
                    throw new ArgumentException(String.Format(Resources.InvalidContainerName, name));
                }

                CloudBlobContainer container = Channel.GetContainerReference(name);

                if (Channel.DoesContainerExist(container, requestOptions, OperationContext))
                {
                    //fetch container attributes
                    Channel.FetchContainerAttributes(container, accessCondition, requestOptions, OperationContext);
                    yield return(container);
                }
                else
                {
                    throw new ResourceNotFoundException(String.Format(Resources.ContainerNotFound, name));
                }
            }
        }
        public IObservable<AsyncCloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobRequestOptions options, OperationContext operationContext)
        {
            return Observable.Create<AsyncCloudBlobContainer>(
            async (observer, ct) =>
            {
                var containerToken = new BlobContinuationToken();
                while (containerToken != null)
                {
                    var results = await ListContainersSegmented(prefix, detailsIncluded, maxResults, containerToken, options, operationContext, ct);
                    foreach (var result in results.Results)
                    {
                        observer.OnNext(new AsyncCloudBlobContainer(result));
                    }

                    containerToken = results.ContinuationToken;
                }
            });
        }
        /// <summary>
        /// List containers by container name prefix
        /// </summary>
        /// <param name="prefix">Container name prefix</param>
        /// <returns>An enumerable collection of cloudblobcontainer</returns>
        internal IEnumerable <Tuple <CloudBlobContainer, BlobContinuationToken> > ListContainersByPrefix(string prefix, Func <CloudBlobContainer, bool> containerFilter = null)
        {
            ContainerListingDetails details        = ContainerListingDetails.Metadata;
            BlobRequestOptions      requestOptions = RequestOptions;

            if (!string.IsNullOrEmpty(prefix) && !NameUtil.IsValidContainerPrefix(prefix))
            {
                throw new ArgumentException(String.Format(Resources.InvalidContainerName, prefix));
            }

            int listCount     = InternalMaxCount;
            int MaxListCount  = 5000;
            int requestCount  = MaxListCount;
            int realListCount = 0;
            BlobContinuationToken continuationToken = ContinuationToken;

            do
            {
                requestCount  = Math.Min(listCount, MaxListCount);
                realListCount = 0;

                ContainerResultSegment containerResult = Channel.ListContainersSegmented(prefix, details, requestCount, continuationToken, requestOptions, OperationContext);

                foreach (CloudBlobContainer container in containerResult.Results)
                {
                    if (containerFilter == null || containerFilter(container))
                    {
                        yield return(new Tuple <CloudBlobContainer, BlobContinuationToken>(container, containerResult.ContinuationToken));

                        realListCount++;
                    }
                }

                if (InternalMaxCount != int.MaxValue)
                {
                    listCount -= realListCount;
                }

                continuationToken = containerResult.ContinuationToken;
            }while (listCount > 0 && continuationToken != null);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Get a list of cloudblobcontainer in azure
        /// </summary>
        /// <param name="prefix">Container prefix</param>
        /// <param name="detailsIncluded">Container listing details</param>
        /// <param name="options">Blob request option</param>
        /// <param name="operationContext">Operation context</param>
        /// <returns>An enumerable collection of cloudblobcontainer</returns>
        public IEnumerable <CloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded, BlobRequestOptions options = null, OperationContext operationContext = null)
        {
            if (string.IsNullOrEmpty(prefix))
            {
                return(ContainerList);
            }
            else
            {
                List <CloudBlobContainer> prefixContainerList = new List <CloudBlobContainer>();

                foreach (CloudBlobContainer container in ContainerList)
                {
                    if (container.Name.StartsWith(prefix))
                    {
                        prefixContainerList.Add(container);
                    }
                }

                return(prefixContainerList);
            }
        }
        /// <summary>
        /// Get a list of cloudblobcontainer in azure
        /// </summary>
        /// <param name="prefix">Container prefix</param>
        /// <param name="detailsIncluded">Container listing details</param>
        /// <param name="options">Blob request option</param>
        /// <param name="operationContext">Operation context</param>
        /// <returns>An enumerable collection of cloudblobcontainer</returns>
        public IEnumerable<CloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded, BlobRequestOptions options = null, OperationContext operationContext = null)
        {
            if (string.IsNullOrEmpty(prefix))
            {
                return ContainerList;
            }
            else
            {
                List<CloudBlobContainer> prefixContainerList = new List<CloudBlobContainer>();

                foreach (CloudBlobContainer container in ContainerList)
                {
                    if (container.Name.StartsWith(prefix))
                    {
                        prefixContainerList.Add(container);
                    }
                }

                return prefixContainerList;
            }
        }
        /// <summary>
        /// Get a list of cloudblobcontainer in azure
        /// </summary>
        /// <param name="prefix">Container prefix</param>
        /// <param name="detailsIncluded">Container listing details</param>
        /// <param name="options">Blob request option</param>
        /// <param name="operationContext">Operation context</param>
        /// <returns>An enumerable collection of cloudblobcontainer</returns>
        public IEnumerable <CloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded, BlobRequestOptions options, XSCL.OperationContext operationContext)
        {
            //https://ahmet.im/blog/azure-listblobssegmentedasync-listcontainerssegmentedasync-how-to/
            BlobContinuationToken continuationToken = null;
            var results = new List <CloudBlobContainer>();

            do
            {
                try
                {
                    var response = BlobClient.ListContainersSegmentedAsync(prefix, detailsIncluded, null, continuationToken, options, operationContext).Result;
                    continuationToken = response.ContinuationToken;
                    results.AddRange(response.Results);
                }
                catch (AggregateException e) when(e.InnerException is XSCL.StorageException)
                {
                    throw e.InnerException;
                }
            } while (continuationToken != null);
            return(results);
        }
 public Task<ContainerResultSegment> ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext)
 {
     return this.ListContainersSegmentedAsync(prefix, detailsIncluded, maxResults, currentToken, options, operationContext, CancellationToken.None);
 }
 /// <summary>
 /// Get a list of cloudblobcontainer in azure
 /// </summary>
 /// <param name="prefix">Container prefix</param>
 /// <param name="detailsIncluded">Container listing details</param>
 /// <param name="options">Blob request option</param>
 /// <param name="operationContext">Operation context</param>
 /// <returns>An enumerable collection of cloudblobcontainer</returns>
 public ContainerResultSegment ListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext)
 {
     return blobClient.ListContainersSegmented(prefix, detailsIncluded, maxResults, currentToken, options, operationContext);
 }
Exemplo n.º 19
0
 public virtual Task <ContainerResultSegment> ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int?maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext)
 {
     return(this.ListContainersSegmentedAsync(prefix, detailsIncluded, maxResults, currentToken, options, operationContext, CancellationToken.None));
 }
Exemplo n.º 20
0
        public virtual async Task <ContainerResultSegment> ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int?maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this);
            ResultSegment <CloudBlobContainer> resultSegment = await Executor.ExecuteAsync(
                this.ListContainersImpl(prefix, detailsIncluded, currentToken, maxResults, modifiedOptions),
                modifiedOptions.RetryPolicy,
                operationContext,
                cancellationToken).ConfigureAwait(false);

            return(new ContainerResultSegment(resultSegment.Results, (BlobContinuationToken)resultSegment.ContinuationToken));
        }
 /// <summary>
 /// Constructs a web request to return a listing of all containers in this storage account.
 /// </summary>
 /// <param name="uri">A <see cref="System.Uri"/> specifying the Blob service endpoint.</param>
 /// <param name="timeout">An integer specifying the server timeout interval.</param>
 /// <param name="listingContext">A <see cref="ListingContext"/> object.</param>
 /// <param name="detailsIncluded">A <see cref="ContainerListingDetails"/> enumeration value that indicates whether to return container metadata with the listing.</param>
 /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
 /// <returns>A web request for the specified operation.</returns>
 public static HttpWebRequest List(Uri uri, int? timeout, ListingContext listingContext, ContainerListingDetails detailsIncluded, OperationContext operationContext)
 {
     return ContainerHttpWebRequestFactory.List(uri, timeout, listingContext, detailsIncluded, true /* useVersionHeader */, operationContext);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Returns a result segment containing a collection of containers
 /// whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The container name prefix.</param>
 /// <param name="detailsIncluded">A value that indicates whether to return container metadata with the listing.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned 
 /// in the result segment, up to the per-operation limit of 5000. If this value is null, the maximum possible number of results will be returned, up to 5000.</param>         
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
 /// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies execution options, such as retry policy and timeout settings, for the operation.</param>
 /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
 /// <returns>A result segment of containers.</returns>
 private ResultSegment<CloudBlobContainer> ListContainersSegmentedCore(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken continuationToken, BlobRequestOptions options, OperationContext operationContext)
 {
     return Executor.ExecuteSync(
         this.ListContainersImpl(prefix, detailsIncluded, continuationToken, maxResults, options),
         options.RetryPolicy,
         operationContext);
 }
Exemplo n.º 23
0
        /// <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);

            ListingContext 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)
            {
                ListContainersResponse listContainersResponse = ContainerResponse.List(response);

                containersList.AddRange(listContainersResponse.Containers.Select((item) => new CloudBlobContainer(item.Attributes, this)));

                nextMarker = listContainersResponse.NextMarker;
            }

            ResultContinuation 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));
        }
Exemplo n.º 24
0
        /// <summary>
        /// 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="maxResults">The maximum results to return.</param>
        /// <param name="setResult">The result report delegate.</param>
        /// <returns>A <see cref="TaskSequence"/> that lists the containers.</returns>
        private TaskSequence ListContainersImpl(
            string prefix,
            ContainerListingDetails detailsIncluded,
            ResultContinuation continuationToken,
            int? maxResults,
            Action<ResultSegment<CloudBlobContainer>> setResult)
        {
            ResultPagination pagination = new ResultPagination(maxResults.GetValueOrDefault());

            return this.ListContainersImplCore(prefix, detailsIncluded, continuationToken, pagination, setResult);
        }
Exemplo n.º 25
0
 /// <summary>
 /// Begins an asynchronous request to return a result segment containing a collection of containers
 /// whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The container name prefix.</param>
 /// <param name="detailsIncluded">A value that indicates whether to return container metadata with the listing.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned 
 /// in the result segment, up to the per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>         
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param> 
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginListContainersSegmented(
     string prefix,
     ContainerListingDetails detailsIncluded,
     int maxResults,
     ResultContinuation continuationToken,
     AsyncCallback callback,
     object state)
 {
     return TaskImplHelper.BeginImplWithRetry<ResultSegment<CloudBlobContainer>>(
         (setResult) => this.ListContainersImpl(prefix, detailsIncluded, continuationToken, maxResults, setResult),
         this.RetryPolicy,
         callback,
         state);
 }
Exemplo n.º 26
0
 /// <summary>
 /// Begins an asynchronous request to return a result segment containing a collection of containers
 /// whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The container name prefix.</param>
 /// <param name="detailsIncluded">A value that indicates whether to return container metadata with the listing.</param>
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, AsyncCallback callback, object state)
 {
     return this.BeginListContainersSegmented(prefix, detailsIncluded, 0, null, callback, state);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Returns a result segment containing a collection of containers
 /// whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The container name prefix.</param>
 /// <param name="detailsIncluded">A value that indicates whether to return container metadata with the listing.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned 
 /// in the result segment, up to the per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>         
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param> 
 /// <returns>A result segment of containers.</returns>
 public ResultSegment<CloudBlobContainer> ListContainersSegmented(
     string prefix,
     ContainerListingDetails detailsIncluded,
     int maxResults,
     ResultContinuation continuationToken)
 {
     return TaskImplHelper.ExecuteImplWithRetry<ResultSegment<CloudBlobContainer>>(
         (setResult) => this.ListContainersImpl(prefix, detailsIncluded, continuationToken, maxResults, setResult),
         this.RetryPolicy);
 }
Exemplo n.º 28
0
 /// <summary>
 /// Returns an enumerable collection of containers whose names 
 /// begin with the specified prefix and that are retrieved lazily.
 /// </summary>
 /// <param name="prefix">The container name prefix.</param>
 /// <param name="detailsIncluded">A value that indicates whether to return container metadata with the listing.</param>
 /// <returns>An enumerable collection of containers that are retrieved lazily.</returns>
 public IEnumerable<CloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded)
 {
     return CommonUtils.LazyEnumerateSegmented<CloudBlobContainer>(
         (setResult) => this.ListContainersImpl(prefix, detailsIncluded, null, null, setResult),
         this.RetryPolicy);
 }
        /// <summary>
        /// Core implementation for the ListContainers method.
        /// </summary>
        /// <param name="prefix">The container prefix.</param>
        /// <param name="detailsIncluded">The details included.</param>
        /// <param name="currentToken">The continuation token.</param>
        /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the 
        /// per-operation limit of 5000. If this value is <c>null</c>, the maximum possible number of results will be returned, up to 5000.</param>         
        /// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies execution options, such as retry policy and timeout settings, for the operation.</param>
        /// <returns>A <see cref="TaskSequence"/> that lists the containers.</returns>
        private RESTCommand<ResultSegment<CloudBlobContainer>> ListContainersImpl(string prefix, ContainerListingDetails detailsIncluded, BlobContinuationToken currentToken, int? maxResults, BlobRequestOptions options)
        {
            ListingContext listingContext = new ListingContext(prefix, maxResults)
            {
                Marker = currentToken != null ? currentToken.NextMarker : null
            };

            RESTCommand<ResultSegment<CloudBlobContainer>> getCmd = new RESTCommand<ResultSegment<CloudBlobContainer>>(this.Credentials, this.StorageUri);

            options.ApplyToStorageCommand(getCmd);
            getCmd.CommandLocationMode = CommonUtility.GetListingLocationMode(currentToken);
            getCmd.RetrieveResponseStream = true;
            getCmd.Handler = this.AuthenticationHandler;
            getCmd.BuildClient = HttpClientFactory.BuildHttpClient;
            getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, detailsIncluded, cnt, ctx);
            getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex);
            getCmd.PostProcessResponse = (cmd, resp, ctx) =>
            {
                return Task.Factory.StartNew(() =>
                {
                    ListContainersResponse listContainersResponse = new ListContainersResponse(cmd.ResponseStream);
                    List<CloudBlobContainer> containersList = listContainersResponse.Containers.Select(item => new CloudBlobContainer(item.Properties, item.Metadata, item.Name, this)).ToList();
                    BlobContinuationToken continuationToken = null;
                    if (listContainersResponse.NextMarker != null)
                    {
                        continuationToken = new BlobContinuationToken()
                        {
                            NextMarker = listContainersResponse.NextMarker,
                            TargetLocation = cmd.CurrentResult.TargetLocation,
                        };
                    }

                    return new ResultSegment<CloudBlobContainer>(containersList)
                    {
                        ContinuationToken = continuationToken,
                    };
                });
            };

            return getCmd;
        }
Exemplo n.º 30
0
 private RESTCommand <ResultSegment <CloudBlobContainer> > ListContainersImpl(string prefix, ContainerListingDetails detailsIncluded, BlobContinuationToken currentToken, int?maxResults, BlobRequestOptions options)
 {
     throw new System.NotImplementedException();
 }
 /// <summary>
 /// Constructs a web request to return a listing of all containers in this storage account.
 /// </summary>
 /// <param name="uri">A <see cref="System.Uri"/> specifying the Blob service endpoint.</param>
 /// <param name="timeout">An integer specifying the server timeout interval.</param>
 /// <param name="listingContext">A <see cref="ListingContext"/> object.</param>
 /// <param name="detailsIncluded">A <see cref="ContainerListingDetails"/> enumeration value that indicates whether to return container metadata with the listing.</param>
 /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
 /// <returns>A web request for the specified operation.</returns>
 public static HttpWebRequest List(Uri uri, int?timeout, ListingContext listingContext, ContainerListingDetails detailsIncluded, OperationContext operationContext)
 {
     return(ContainerHttpWebRequestFactory.List(uri, timeout, listingContext, detailsIncluded, true /* useVersionHeader */, operationContext));
 }
Exemplo n.º 32
0
        /// <summary>
        /// list all the existing containers
        /// </summary>
        /// <returns>a list of cloudblobcontainer object</returns>
        public List <CloudBlobContainer> GetExistingContainers()
        {
            ContainerListingDetails details = ContainerListingDetails.All;

            return(client.ListContainers(string.Empty, details).ToList());
        }
        /// <summary>
        /// Constructs a web request to return a listing of all containers in this storage account.
        /// </summary>
        /// <param name="uri">A <see cref="System.Uri"/> specifying the Blob service endpoint.</param>
        /// <param name="timeout">An integer specifying the server timeout interval.</param>
        /// <param name="listingContext">A <see cref="ListingContext"/> object.</param>
        /// <param name="detailsIncluded">A <see cref="ContainerListingDetails"/> enumeration value that indicates whether to return container metadata with the listing.</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 that represents the context for the current operation.</param>
        /// <returns>A web request for the specified operation.</returns>
        public static HttpWebRequest List(Uri uri, int?timeout, ListingContext listingContext, ContainerListingDetails detailsIncluded, bool useVersionHeader, OperationContext operationContext)
        {
            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.HasValue)
                {
                    builder.Add("maxresults", listingContext.MaxResults.ToString());
                }
            }

            if ((detailsIncluded & ContainerListingDetails.Metadata) != 0)
            {
                builder.Add("include", "metadata");
            }

            HttpWebRequest request = HttpWebRequestFactory.CreateWebRequest(WebRequestMethods.Http.Get, uri, timeout, builder, useVersionHeader, operationContext);

            return(request);
        }
Exemplo n.º 34
0
        /// <summary>
        /// Core implementation for the ListContainers method.
        /// </summary>
        /// <param name="prefix">The container prefix.</param>
        /// <param name="detailsIncluded">The details included.</param>
        /// <param name="currentToken">The continuation token.</param>
        /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned 
        /// in the result segment, up to the per-operation limit of 5000. If this value is null, the maximum possible number of results will be returned, up to 5000.</param>
        /// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies any additional options for the request.</param>
        /// <returns>A <see cref="ResultSegment{T}"/> that lists the containers.</returns>
        private RESTCommand<ResultSegment<CloudBlobContainer>> ListContainersImpl(string prefix, ContainerListingDetails detailsIncluded, BlobContinuationToken currentToken, int? maxResults, BlobRequestOptions options)
        {
            ListingContext listingContext = new ListingContext(prefix, maxResults)
            {
                Marker = currentToken != null ? currentToken.NextMarker : null
            };

            RESTCommand<ResultSegment<CloudBlobContainer>> getCmd = new RESTCommand<ResultSegment<CloudBlobContainer>>(this.Credentials, this.BaseUri);

            getCmd.ApplyRequestOptions(options);
            getCmd.RetrieveResponseStream = true;
            getCmd.BuildRequestDelegate = (uri, builder, serverTimeout, ctx) => ContainerHttpWebRequestFactory.List(uri, serverTimeout, listingContext, detailsIncluded, ctx);
            getCmd.SignRequest = this.AuthenticationHandler.SignRequest;
            getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex, ctx);
            getCmd.PostProcessResponse = (cmd, resp, ex, ctx) =>
            {
                ListContainersResponse listContainersResponse = new ListContainersResponse(cmd.ResponseStream);
                List<CloudBlobContainer> containersList = new List<CloudBlobContainer>(
                    listContainersResponse.Containers.Select(item => new CloudBlobContainer(item.Properties, item.Metadata, item.Name, this)));
                BlobContinuationToken continuationToken = null;
                if (listContainersResponse.NextMarker != null)
                {
                    continuationToken = new BlobContinuationToken()
                    {
                        NextMarker = listContainersResponse.NextMarker,
                    };
                }

                return new ResultSegment<CloudBlobContainer>(containersList)
                {
                    ContinuationToken = continuationToken,
                };
            };

            return getCmd;
        }
        /// <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 StorageRequestMessage List(Uri uri, int?timeout, ListingContext listingContext, ContainerListingDetails detailsIncluded, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials)
        {
            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.HasValue)
                {
                    builder.Add("maxresults", listingContext.MaxResults.ToString());
                }
            }

            if ((detailsIncluded & ContainerListingDetails.Metadata) != 0)
            {
                builder.Add("include", "metadata");
            }

            StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials);

            return(request);
        }
 /// <summary>
 ///     Returns an enumerable collection of the blobs in the container that are retrieved asynchronously.
 /// </summary>
 /// <param name="blobClient">Cloud blob client.</param>
 /// <param name="prefix">The blob name prefix.</param>
 /// <param name="detailsIncluded">A value that indicates whether to return container metadata with the listing.</param>
 /// <param name="maxResults">
 ///     A non-negative integer value that indicates the maximum number of results to be returned
 ///     in the result segment, up to the per-operation limit of 5000. If this value is null, the maximum possible number of results will be returned, up to 5000.
 /// </param>
 /// <param name="cancellationToken">Cancellation token.</param>
 /// <returns>
 ///     An enumerable collection of objects that implement <see cref="T:Microsoft.WindowsAzure.Storage.Blob.IListBlobItem" /> that are retrieved.
 /// </returns>
 public static Task<List<CloudBlobContainer>> ListContainersAsync(
     this CloudBlobClient blobClient,
     string prefix,
     ContainerListingDetails detailsIncluded,
     int? maxResults,
     CancellationToken cancellationToken = default (CancellationToken))
 {
     return ListContainersImplAsync(blobClient, new List<CloudBlobContainer>(), prefix, detailsIncluded, maxResults, null, cancellationToken);
 }
Exemplo n.º 37
0
 /// <summary>
 /// Get a list of cloudblobcontainer in azure
 /// </summary>
 /// <param name="prefix">Container prefix</param>
 /// <param name="detailsIncluded">Container listing details</param>
 /// <param name="options">Blob request option</param>
 /// <param name="operationContext">Operation context</param>
 /// <returns>An enumerable collection of cloudblobcontainer</returns>
 public ContainerResultSegment ListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int?maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext)
 {
     return(this.BlobClient.ListContainersSegmented(prefix, detailsIncluded, maxResults, currentToken, options, operationContext));
 }
Exemplo n.º 38
0
        /// <summary>
        /// Core implementation for the ListContainers method.
        /// </summary>
        /// <param name="prefix">The container prefix.</param>
        /// <param name="detailsIncluded">The details included.</param>
        /// <param name="currentToken">The continuation token.</param>
        /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the
        /// per-operation limit of 5000. If this value is <c>null</c>, the maximum possible number of results will be returned, up to 5000.</param>
        /// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies execution options, such as retry policy and timeout settings, for the operation.</param>
        /// <returns>A <see cref="TaskSequence"/> that lists the containers.</returns>
        private RESTCommand <ResultSegment <CloudBlobContainer> > ListContainersImpl(string prefix, ContainerListingDetails detailsIncluded, BlobContinuationToken currentToken, int?maxResults, BlobRequestOptions options)
        {
            ListingContext listingContext = new ListingContext(prefix, maxResults)
            {
                Marker = currentToken != null ? currentToken.NextMarker : null
            };

            RESTCommand <ResultSegment <CloudBlobContainer> > getCmd = new RESTCommand <ResultSegment <CloudBlobContainer> >(this.Credentials, this.StorageUri, this.HttpClient);

            options.ApplyToStorageCommand(getCmd);
            getCmd.CommandLocationMode      = CommonUtility.GetListingLocationMode(currentToken);
            getCmd.RetrieveResponseStream   = true;
            getCmd.BuildRequest             = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, detailsIncluded, cnt, ctx, this.GetCanonicalizer(), this.Credentials);
            getCmd.PreProcessResponse       = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex);
            getCmd.PostProcessResponseAsync = async(cmd, resp, ctx, ct) =>
            {
                ListContainersResponse listContainersResponse = await ListContainersResponse.ParseAsync(cmd.ResponseStream, ct).ConfigureAwait(false);

                List <CloudBlobContainer> containersList    = listContainersResponse.Containers.Select(item => new CloudBlobContainer(item.Properties, item.Metadata, item.Name, this)).ToList();
                BlobContinuationToken     continuationToken = null;
                if (listContainersResponse.NextMarker != null)
                {
                    continuationToken = new BlobContinuationToken()
                    {
                        NextMarker     = listContainersResponse.NextMarker,
                        TargetLocation = cmd.CurrentResult.TargetLocation,
                    };
                }

                return(new ResultSegment <CloudBlobContainer>(containersList)
                {
                    ContinuationToken = continuationToken,
                });
            };

            return(getCmd);
        }
Exemplo n.º 39
0
 /// <summary>
 /// Get a list of cloudblobcontainer in azure
 /// </summary>
 /// <param name="prefix">Container prefix</param>
 /// <param name="detailsIncluded">Container listing details</param>
 /// <param name="options">Blob request option</param>
 /// <param name="operationContext">Operation context</param>
 /// <returns>An enumerable collection of cloudblobcontainer</returns>
 public IEnumerable <CloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded, BlobRequestOptions options, OperationContext operationContext)
 {
     return(blobClient.ListContainers(prefix, detailsIncluded, options, operationContext));
 }
Exemplo n.º 40
0
        /// <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);
        }
Exemplo n.º 41
0
        public IAsyncOperation <ContainerResultSegment> ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int?maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext)
        {
            return(AsyncInfo.Run(async(token) =>
            {
                BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this);
                ResultSegment <CloudBlobContainer> resultSegment = await Executor.ExecuteAsync(
                    this.ListContainersImpl(prefix, detailsIncluded, currentToken, maxResults, modifiedOptions),
                    modifiedOptions.RetryPolicy,
                    operationContext,
                    token);

                return new ContainerResultSegment(resultSegment.Results, (BlobContinuationToken)resultSegment.ContinuationToken);
            }));
        }
 /// <summary>
 /// Get a list of cloudblobcontainer in azure
 /// </summary>
 /// <param name="prefix">Container prefix</param>
 /// <param name="detailsIncluded">Container listing details</param>
 /// <param name="options">Blob request option</param>
 /// <param name="operationContext">Operation context</param>
 /// <returns>An enumerable collection of cloudblobcontainer</returns>
 public IEnumerable<CloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded, BlobRequestOptions options, OperationContext operationContext)
 {
     return blobClient.ListContainers(prefix, detailsIncluded, options, operationContext);
 }
 /// <summary>
 /// Get a list of cloudblobcontainer in azure
 /// </summary>
 /// <param name="prefix">Container prefix</param>
 /// <param name="detailsIncluded">Container listing details</param>
 /// <param name="options">Blob request option</param>
 /// <param name="operationContext">Operation context</param>
 /// <returns>An enumerable collection of cloudblobcontainer</returns>
 public ContainerResultSegment ListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext)
 {
     throw new NotImplementedException("Can not create a ContainerResultSegment object");
 }
        public Task<ContainerResultSegment> ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            return Task.Run(async () =>
            {
                BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this);
                ResultSegment<CloudBlobContainer> resultSegment = await Executor.ExecuteAsync(
                    this.ListContainersImpl(prefix, detailsIncluded, currentToken, maxResults, modifiedOptions),
                    modifiedOptions.RetryPolicy,
                    operationContext,
                    cancellationToken);

                return new ContainerResultSegment(resultSegment.Results, (BlobContinuationToken)resultSegment.ContinuationToken);
            }, cancellationToken);
        }
        /// <summary>
        ///     Returns a result segment containing a collection of containers whose names begin with the specified prefix asynchronously.
        /// </summary>
        /// <param name="blobClient">Cloud blob client.</param>
        /// <param name="prefix">The container name prefix.</param>
        /// <param name="detailsIncluded">A value that indicates whether to return container metadata with the listing.</param>
        /// <param name="maxResults">
        ///     A non-negative integer value that indicates the maximum number of results to be returned
        ///     in the result segment, up to the per-operation limit of 5000. If this value is null, the maximum possible number of results will be returned, up to 5000.
        /// </param>
        /// <param name="continuationToken">
        ///     A <see cref="T:Microsoft.WindowsAzure.Storage.Blob.BlobContinuationToken" /> returned by a previous listing operation.
        /// </param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>
        ///     A result segment of containers.
        /// </returns>
        public static Task<ContainerResultSegment> ListContainersSegmentedAsync(
            this CloudBlobClient blobClient,
            string prefix,
            ContainerListingDetails detailsIncluded,
            int? maxResults,
            BlobContinuationToken continuationToken,
            CancellationToken cancellationToken = default (CancellationToken))
        {
            ICancellableAsyncResult asyncResult = blobClient.BeginListContainersSegmented(prefix, detailsIncluded, maxResults, continuationToken, null, null, null, null);
            CancellationTokenRegistration registration = cancellationToken.Register(p => asyncResult.Cancel(), null);

            return Task<ContainerResultSegment>.Factory.FromAsync(
                asyncResult,
                result =>
                    {
                        registration.Dispose();
                        return blobClient.EndListContainersSegmented(result);
                    });
        }
Exemplo n.º 46
0
 public virtual Task <ContainerResultSegment> ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int?maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
 {
     throw new System.NotImplementedException();
 }
 /// <summary>
 /// Returns a result segment containing a collection of containers
 /// whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The container name prefix.</param>
 /// <param name="detailsIncluded">A value that indicates whether to return container metadata with the listing.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned
 /// in the result segment, up to the per-operation limit of 5000. If this value is null, the maximum possible number of results will be returned, up to 5000.</param>
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
 /// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies execution options, such as retry policy and timeout settings, for the operation.</param>
 /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
 /// <returns>A result segment of containers.</returns>
 private ResultSegment <CloudBlobContainer> ListContainersSegmentedCore(string prefix, ContainerListingDetails detailsIncluded, int?maxResults, BlobContinuationToken continuationToken, BlobRequestOptions options, OperationContext operationContext)
 {
     return(Executor.ExecuteSync(
                this.ListContainersImpl(prefix, detailsIncluded, continuationToken, maxResults, options),
                options.RetryPolicy,
                operationContext));
 }
Exemplo n.º 48
0
 public override Task <ContainerResultSegment> ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int?maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Core implementation for the ListContainers method.
        /// </summary>
        /// <param name="prefix">The container prefix.</param>
        /// <param name="detailsIncluded">The details included.</param>
        /// <param name="currentToken">The continuation token.</param>
        /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned
        /// in the result segment, up to the per-operation limit of 5000. If this value is null, the maximum possible number of results will be returned, up to 5000.</param>
        /// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies any additional options for the request.</param>
        /// <returns>A <see cref="ResultSegment{T}"/> that lists the containers.</returns>
        private RESTCommand <ResultSegment <CloudBlobContainer> > ListContainersImpl(string prefix, ContainerListingDetails detailsIncluded, BlobContinuationToken currentToken, int?maxResults, BlobRequestOptions options)
        {
            ListingContext listingContext = new ListingContext(prefix, maxResults)
            {
                Marker = currentToken != null ? currentToken.NextMarker : null
            };

            RESTCommand <ResultSegment <CloudBlobContainer> > getCmd = new RESTCommand <ResultSegment <CloudBlobContainer> >(this.Credentials, this.BaseUri);

            getCmd.ApplyRequestOptions(options);
            getCmd.RetrieveResponseStream = true;
            getCmd.BuildRequestDelegate   = (uri, builder, serverTimeout, ctx) => ContainerHttpWebRequestFactory.List(uri, serverTimeout, listingContext, detailsIncluded, ctx);
            getCmd.SignRequest            = this.AuthenticationHandler.SignRequest;
            getCmd.PreProcessResponse     = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex, ctx);
            getCmd.PostProcessResponse    = (cmd, resp, ex, ctx) =>
            {
                ListContainersResponse    listContainersResponse = new ListContainersResponse(cmd.ResponseStream);
                List <CloudBlobContainer> containersList         = new List <CloudBlobContainer>(
                    listContainersResponse.Containers.Select(item => new CloudBlobContainer(item.Properties, item.Metadata, item.Name, this)));
                BlobContinuationToken continuationToken = null;
                if (listContainersResponse.NextMarker != null)
                {
                    continuationToken = new BlobContinuationToken()
                    {
                        NextMarker = listContainersResponse.NextMarker,
                    };
                }

                return(new ResultSegment <CloudBlobContainer>(containersList)
                {
                    ContinuationToken = continuationToken,
                });
            };

            return(getCmd);
        }
        /// <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 HttpRequestMessage List(Uri uri, int? timeout, ListingContext listingContext, ContainerListingDetails detailsIncluded, HttpContent content, OperationContext operationContext)
        {
            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");
            }

            HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext);
            return request;
        }
Exemplo n.º 51
0
        /// <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;
        }
Exemplo n.º 52
0
 public ContainerResultSegment ListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options = null, OperationContext operationContext = null)
 {
     BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this);
     ResultSegment<CloudBlobContainer> resultSegment = this.ListContainersSegmentedCore(prefix, detailsIncluded, maxResults, currentToken, modifiedOptions, operationContext);
     return new ContainerResultSegment(resultSegment.Results, (BlobContinuationToken)resultSegment.ContinuationToken);
 }
Exemplo n.º 53
0
        /// <summary>
        /// Returns an enumerable collection of BlobContainer.
        /// </summary>
        /// <param name="prefix">A string containing the container name prefix.</param>
        /// <param name="detailsIncluded">A Microsoft.WindowsAzure.Storage.Blob.ContainerListingDetails enumeration value that indicates whether to return container metadata with the listing.</param>
        /// <returns>List of BlobContainer.</returns>
        public List <BlobContainer> ListContainers(string prefix = null, ContainerListingDetails detailsIncluded = ContainerListingDetails.None)
        {
            var containers = this._cloudBlobClient.ListContainers(prefix, detailsIncluded);

            return(containers.Select(i => new BlobContainer(i)).ToList());
        }
Exemplo n.º 54
0
 public ICancellableAsyncResult BeginListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken continuationToken, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state)
 {
     BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this);
     return Executor.BeginExecuteAsync(
         this.ListContainersImpl(prefix, detailsIncluded, continuationToken, maxResults, modifiedOptions),
         modifiedOptions.RetryPolicy,
         operationContext,
         callback,
         state);
 }
Exemplo n.º 55
0
 /// <summary>
 /// Get a list of cloudblobcontainer in azure
 /// </summary>
 /// <param name="prefix">Container prefix</param>
 /// <param name="detailsIncluded">Container listing details</param>
 /// <param name="options">Blob request option</param>
 /// <param name="operationContext">Operation context</param>
 /// <returns>An enumerable collection of cloudblobcontainer</returns>
 public ContainerResultSegment ListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int?maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext)
 {
     throw new NotImplementedException("Can not create a ContainerResultSegment object");
 }
Exemplo n.º 56
0
 public IEnumerable<CloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded, BlobRequestOptions options = null, OperationContext operationContext = null)
 {
     BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this);
     return General.LazyEnumerable(
         token =>
         this.ListContainersSegmentedCore(prefix, detailsIncluded, null /* maxResults */, (BlobContinuationToken)token, modifiedOptions, operationContext),
         long.MaxValue,
         operationContext);
 }
 public Task<ContainerResultSegment> ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken continuationToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
 {
     return AsyncExtensions.TaskFromApm(this.BeginListContainersSegmented, this.EndListContainersSegmented, prefix, detailsIncluded, maxResults, continuationToken, options, operationContext, cancellationToken);
 }
        /// <summary>
        /// Constructs a web request to return a listing of all containers in this storage account.
        /// </summary>
        /// <param name="uri">A <see cref="System.Uri"/> specifying the Blob service endpoint.</param>
        /// <param name="timeout">An integer specifying the server timeout interval.</param>
        /// <param name="listingContext">A <see cref="ListingContext"/> object.</param>
        /// <param name="detailsIncluded">A <see cref="ContainerListingDetails"/> enumeration value that indicates whether to return container metadata with the listing.</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 that represents the context for the current operation.</param>
        /// <returns>A web request for the specified operation.</returns>
        public static HttpWebRequest List(Uri uri, int? timeout, ListingContext listingContext, ContainerListingDetails detailsIncluded, bool useVersionHeader, OperationContext operationContext)
        {
            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.HasValue)
                {
                    builder.Add("maxresults", listingContext.MaxResults.ToString());
                }
            }

            if ((detailsIncluded & ContainerListingDetails.Metadata) != 0)
            {
                builder.Add("include", "metadata");
            }

            HttpWebRequest request = HttpWebRequestFactory.CreateWebRequest(WebRequestMethods.Http.Get, uri, timeout, builder, useVersionHeader, operationContext);
            return request;
        }
        /// <summary>
        ///     Returns an enumerable collection of the blobs in the container that are retrieved asynchronously.
        /// </summary>
        /// <param name="blobClient">Cloud blob client.</param>
        /// <param name="cloudContainers">List of cloud containers.</param>
        /// <param name="prefix">The blob name prefix.</param>
        /// <param name="detailsIncluded">A value that indicates whether to return container metadata with the listing.</param>
        /// <param name="maxResults">
        ///     A non-negative integer value that indicates the maximum number of results to be returned
        ///     in the result segment, up to the per-operation limit of 5000. If this value is null, the maximum possible number of results will be returned, up to 5000.
        /// </param>
        /// <param name="continuationToken">Continuation token.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>
        ///     An enumerable collection of objects that implement <see cref="T:Microsoft.WindowsAzure.Storage.Blob.IListBlobItem" /> that are retrieved.
        /// </returns>
        private static Task<List<CloudBlobContainer>> ListContainersImplAsync(
            this CloudBlobClient blobClient,
            List<CloudBlobContainer> cloudContainers,
            string prefix,
            ContainerListingDetails detailsIncluded,
            int? maxResults,
            BlobContinuationToken continuationToken,
            CancellationToken cancellationToken = default (CancellationToken))
        {
            return blobClient
                .ListContainersSegmentedAsync(prefix, detailsIncluded, maxResults, continuationToken, cancellationToken)
                .Then(result =>
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        cloudContainers.AddRange(result.Results);

                        // Checks whether maxresults entities has been received
                        if (maxResults.HasValue && cloudContainers.Count >= maxResults.Value)
                        {
                            return TaskHelpers.FromResult(cloudContainers.Take(maxResults.Value).ToList());
                        }

                        // Checks whether enumeration has been completed
                        if (result.ContinuationToken != null)
                        {
                            return ListContainersImplAsync(blobClient, cloudContainers, prefix, detailsIncluded, maxResults, result.ContinuationToken, cancellationToken);
                        }

                        return TaskHelpers.FromResult(cloudContainers);
                    });
        }