Exemplo n.º 1
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));
                }
            }
        }
Exemplo n.º 2
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));
         }
     }
 }
        /// <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();
                }
            }
        }