Example #1
0
 public GetQueuesAsyncCollection(
     QueueServiceClient client,
     QueueTraits traits,
     string prefix)
 {
     _client = client;
     _traits = traits;
     _prefix = prefix;
 }
Example #2
0
        internal static IEnumerable <string> AsIncludeTypes(this QueueTraits traits) =>
        ((traits & QueueTraits.Metadata) == QueueTraits.Metadata)
                ?
        new string[]
        {
            Constants.Queue.QueueTraitsMetadata
        }

                                                                     :
        Array.Empty <string>();
        /// <summary>
        /// Convert the details into a <see cref="ListQueuesIncludeType"/> value.
        /// </summary>
        /// <returns>A <see cref="ListQueuesIncludeType"/> value.</returns>
        internal static IEnumerable <ListQueuesIncludeType> AsIncludeTypes(this QueueTraits traits) =>
        ((traits & QueueTraits.Metadata) == QueueTraits.Metadata)
                ?
        new ListQueuesIncludeType[]
        {
            ListQueuesIncludeType.Metadata
        }

                                                                               :
        Array.Empty <ListQueuesIncludeType>();
Example #4
0
        /// <summary>
        /// Returns a single segment of containers starting from the specified marker.
        ///
        /// For more information, see
        /// <see href="https://docs.microsoft.com/rest/api/storageservices/list-queues1">
        /// List Queues</see>.
        /// </summary>
        /// <param name="marker">
        /// Marker from the previous request.
        /// </param>
        /// <param name="traits">
        /// Optional trait options for shaping the queues.
        /// </param>
        /// <param name="prefix">
        /// Optional string that filters the results to return only queues
        /// whose name begins with the specified <paramref name="prefix"/>.
        /// </param>
        /// <param name="pageSizeHint">
        /// Optional hint to specify the desired size of the page returned.
        /// </param>
        /// <param name="async">
        /// Whether to invoke the operation asynchronously.
        /// </param>
        /// <param name="cancellationToken">
        /// <see cref="CancellationToken"/>
        /// </param>
        /// <returns>
        /// A single segment of containers starting from the specified marker, including the next marker if appropriate.
        /// </returns>
        /// <remarks>
        /// Use an empty marker to start enumeration from the beginning. Queue names are returned in lexicographic order.
        /// After getting a segment, process it, and then call ListQueuesSegmentAsync again (passing in the next marker) to get the next segment.
        /// </remarks>
        internal async Task <Response <QueuesSegment> > GetQueuesInternal(
            string marker,
            QueueTraits traits,
            string prefix,
            int?pageSizeHint,
            bool async,
            CancellationToken cancellationToken)
        {
            using (Pipeline.BeginLoggingScope(nameof(QueueServiceClient)))
            {
                Pipeline.LogMethodEnter(
                    nameof(QueueServiceClient),
                    message:
                    $"{nameof(Uri)}: {Uri}\n" +
                    $"{nameof(marker)}: {marker}\n" +
                    $"{nameof(traits)}: {traits}\n" +
                    $"{nameof(prefix)}: {prefix}");
                try
                {
                    IEnumerable <ListQueuesIncludeType> includeTypes = traits.AsIncludeTypes();
                    Response <QueuesSegment>            response     = await QueueRestClient.Service.ListQueuesSegmentAsync(
                        ClientDiagnostics,
                        Pipeline,
                        Uri,
                        version : Version.ToVersionString(),
                        marker : marker,
                        prefix : prefix,
                        maxresults : pageSizeHint,
                        include : includeTypes.Any()?includeTypes : null,
                        async : async,
                        operationName : $"{nameof(QueueServiceClient)}.{nameof(GetQueues)}",
                        cancellationToken : cancellationToken)
                                                                       .ConfigureAwait(false);

                    if ((traits & QueueTraits.Metadata) != QueueTraits.Metadata)
                    {
                        IEnumerable <QueueItem> queueItems = response.Value.QueueItems;
                        foreach (QueueItem queueItem in queueItems)
                        {
                            queueItem.Metadata = null;
                        }
                    }
                    return(response);
                }
                catch (Exception ex)
                {
                    Pipeline.LogException(ex);
                    throw;
                }
                finally
                {
                    Pipeline.LogMethodExit(nameof(QueueServiceClient));
                }
            }
        }
Example #5
0
 /// <summary>
 /// Returns a single segment of containers starting from the specified marker.
 /// For more information, see <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/list-queues1"/>
 /// </summary>
 /// <param name="marker">
 /// Marker from the previous request.
 /// </param>
 /// <param name="traits">
 /// Optional trait options for shaping the queues.
 /// </param>
 /// <param name="prefix">
 /// Optional string that filters the results to return only queues
 /// whose name begins with the specified <paramref name="prefix"/>.
 /// </param>
 /// <param name="pageSizeHint">
 /// Optional hint to specify the desired size of the page returned.
 /// </param>
 /// <param name="async">
 /// Whether to invoke the operation asynchronously.
 /// </param>
 /// <param name="cancellationToken">
 /// <see cref="CancellationToken"/>
 /// </param>
 /// <returns>
 /// A single segment of containers starting from the specified marker, including the next marker if appropriate.
 /// </returns>
 /// <remarks>
 /// Use an empty marker to start enumeration from the beginning. Queue names are returned in lexicographic order.
 /// After getting a segment, process it, and then call ListQueuesSegmentAsync again (passing in the next marker) to get the next segment.
 /// </remarks>
 internal async Task <Response <QueuesSegment> > GetQueuesInternal(
     string marker,
     QueueTraits traits,
     string prefix,
     int?pageSizeHint,
     bool async,
     CancellationToken cancellationToken)
 {
     using (Pipeline.BeginLoggingScope(nameof(QueueServiceClient)))
     {
         Pipeline.LogMethodEnter(
             nameof(QueueServiceClient),
             message:
             $"{nameof(Uri)}: {Uri}\n" +
             $"{nameof(marker)}: {marker}\n" +
             $"{nameof(traits)}: {traits}\n" +
             $"{nameof(prefix)}: {prefix}");
         try
         {
             IEnumerable <ListQueuesIncludeType> includeTypes = traits.AsIncludeTypes();
             return(await QueueRestClient.Service.ListQueuesSegmentAsync(
                        ClientDiagnostics,
                        Pipeline,
                        Uri,
                        marker : marker,
                        prefix : prefix,
                        maxresults : pageSizeHint,
                        include : includeTypes.Any()?includeTypes : null,
                        async : async,
                        cancellationToken : cancellationToken)
                    .ConfigureAwait(false));
         }
         catch (Exception ex)
         {
             Pipeline.LogException(ex);
             throw;
         }
         finally
         {
             Pipeline.LogMethodExit(nameof(QueueServiceClient));
         }
     }
 }
Example #6
0
 /// <summary>
 /// The <see cref="GetQueuesAsync"/> operation returns an async
 /// collection of queues in the storage account.  Enumerating the
 /// queues may make multiple requests to the service while fetching
 /// all the values.  Queue names are returned in lexicographic order.
 ///
 /// For more information, see <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/list-queues1"/>
 /// </summary>
 /// <param name="traits">
 /// Optional trait options for shaping the queues.
 /// </param>
 /// <param name="prefix">
 /// Optional string that filters the results to return only queues
 /// whose name begins with the specified <paramref name="prefix"/>.
 /// </param>
 /// <param name="cancellationToken">
 /// <see cref="CancellationToken"/>
 /// </param>
 /// <returns>
 /// The queues in the storage account.
 /// </returns>
 /// <remarks>
 /// Use an empty marker to start enumeration from the beginning. Queue names are returned in lexicographic order.
 /// After getting a segment, process it, and then call ListQueuesSegment again (passing in the next marker) to get the next segment.
 /// </remarks>
 public virtual AsyncPageable <QueueItem> GetQueuesAsync(
     QueueTraits traits = QueueTraits.None,
     string prefix      = default,
     CancellationToken cancellationToken = default) =>
 new GetQueuesAsyncCollection(this, traits, prefix).ToAsyncCollection(cancellationToken);
        /// <summary>
        /// Returns a single segment of containers starting from the specified marker.
        ///
        /// For more information, see
        /// <see href="https://docs.microsoft.com/rest/api/storageservices/list-queues1">
        /// List Queues</see>.
        /// </summary>
        /// <param name="marker">
        /// Marker from the previous request.
        /// </param>
        /// <param name="traits">
        /// Optional trait options for shaping the queues.
        /// </param>
        /// <param name="prefix">
        /// Optional string that filters the results to return only queues
        /// whose name begins with the specified <paramref name="prefix"/>.
        /// </param>
        /// <param name="pageSizeHint">
        /// Optional hint to specify the desired size of the page returned.
        /// </param>
        /// <param name="async">
        /// Whether to invoke the operation asynchronously.
        /// </param>
        /// <param name="cancellationToken">
        /// <see cref="CancellationToken"/>
        /// </param>
        /// <returns>
        /// A single segment of containers starting from the specified marker, including the next marker if appropriate.
        /// </returns>
        /// <remarks>
        /// Use an empty marker to start enumeration from the beginning. Queue names are returned in lexicographic order.
        /// After getting a segment, process it, and then call ListQueuesSegmentAsync again (passing in the next marker) to get the next segment.
        /// </remarks>
        internal async Task <Response <ListQueuesSegmentResponse> > GetQueuesInternal(
            string marker,
            QueueTraits traits,
            string prefix,
            int?pageSizeHint,
            bool async,
            CancellationToken cancellationToken)
        {
            using (ClientConfiguration.Pipeline.BeginLoggingScope(nameof(QueueServiceClient)))
            {
                ClientConfiguration.Pipeline.LogMethodEnter(
                    nameof(QueueServiceClient),
                    message:
                    $"{nameof(Uri)}: {Uri}\n" +
                    $"{nameof(marker)}: {marker}\n" +
                    $"{nameof(traits)}: {traits}\n" +
                    $"{nameof(prefix)}: {prefix}");

                DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope($"{nameof(QueueServiceClient)}.{nameof(GetQueues)}");

                try
                {
                    ResponseWithHeaders <ListQueuesSegmentResponse, ServiceListQueuesSegmentHeaders> response;

                    scope.Start();
                    IEnumerable <string> includeTypes = traits.AsIncludeTypes();
                    if (async)
                    {
                        response = await _serviceRestClient.ListQueuesSegmentAsync(
                            prefix : prefix,
                            marker : marker,
                            maxresults : pageSizeHint,
                            include : includeTypes.Any()?includeTypes : null,
                            cancellationToken : cancellationToken)
                                   .ConfigureAwait(false);
                    }
                    else
                    {
                        response = _serviceRestClient.ListQueuesSegment(
                            prefix: prefix,
                            marker: marker,
                            maxresults: pageSizeHint,
                            include: includeTypes.Any() ? includeTypes : null,
                            cancellationToken: cancellationToken);
                    }

                    if ((traits & QueueTraits.Metadata) != QueueTraits.Metadata)
                    {
                        IEnumerable <QueueItem> queueItems = response.Value.QueueItems;
                        foreach (QueueItem queueItem in queueItems)
                        {
                            queueItem.Metadata = null;
                        }
                    }
                    return(response);
                }
                catch (Exception ex)
                {
                    ClientConfiguration.Pipeline.LogException(ex);
                    scope.Failed(ex);
                    throw;
                }
                finally
                {
                    ClientConfiguration.Pipeline.LogMethodExit(nameof(QueueServiceClient));
                    scope.Dispose();
                }
            }
        }