Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Working Storage queue on new paging
  • Loading branch information
lmazuel committed Jul 24, 2019
commit 4b8f72939958fbe203003a8a9c991c3f1687d787
21 changes: 8 additions & 13 deletions sdk/storage/azure-storage-queue/azure/storage/queue/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,7 @@ def _get_next_cb(self, continuation_token):
process_storage_error(error)

def _extract_data_cb(self, messages):
if not messages:
return None, None
return "TOKEN_IGNORED", iter([QueueMessage._from_generated(q) for q in messages]) # pylint: disable=protected-access
return "TOKEN_IGNORED", [QueueMessage._from_generated(q) for q in messages] # pylint: disable=protected-access


class QueueProperties(DictMixin):
Expand Down Expand Up @@ -297,12 +295,9 @@ class QueuePropertiesPaged(PageIterator):
begin with the specified prefix.
:param int results_per_page: The maximum number of queue names to retrieve per
call.
:param str marker: An opaque continuation token.
:param str continuation_token: An opaque continuation token.
"""
def __init__(self, command, prefix=None, results_per_page=None, marker=None, continuation_token=None):
if continuation_token is not None:
raise ValueError("This operation does not support continuation token")

def __init__(self, command, prefix=None, results_per_page=None, continuation_token=None):
super(QueuePropertiesPaged, self).__init__(
self._get_next_cb,
self._extract_data_cb,
Expand All @@ -312,13 +307,13 @@ def __init__(self, command, prefix=None, results_per_page=None, marker=None, con
self.prefix = prefix
self.current_marker = None
self.results_per_page = results_per_page
self.next_marker = marker or ""
self.continuation_token = continuation_token or ""
self.location_mode = None

def _get_next_cb(self, continuation_token):
try:
return self._get_next(
marker=self.next_marker or None,
return self._command(
marker=self.continuation_token or None,
maxresults=self.results_per_page,
cls=return_context_and_deserialized,
use_location=self.location_mode)
Expand All @@ -331,9 +326,9 @@ def _extract_data_cb(self, get_next_return):
self.prefix = self._response.prefix
self.current_marker = self._response.marker
self.results_per_page = self._response.max_results
self.next_marker = self._response.next_marker or None
self.continuation_token = self._response.next_marker or None

return self.next_marker, iter([QueueProperties._from_generated(q) for q in self._response.queue_items]) # pylint: disable=protected-access
return self.continuation_token, [QueueProperties._from_generated(q) for q in self._response.queue_items] # pylint: disable=protected-access


class QueuePermissions(object):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ def set_service_properties( # type: ignore
def list_queues(
self, name_starts_with=None, # type: Optional[str]
include_metadata=False, # type: Optional[bool]
marker=None, # type: Optional[str]
results_per_page=None, # type: Optional[int]
timeout=None, # type: Optional[int]
**kwargs
Expand All @@ -320,10 +319,6 @@ def list_queues(
begin with the specified prefix.
:param bool include_metadata:
Specifies that queue metadata be returned in the response.
:param str marker:
An opaque continuation token. This value can be retrieved from the
next_marker field of a previous generator object. If specified,
this generator will begin returning results from this point.
:param int results_per_page:
The maximum number of queue names to retrieve per API
call. If the request does not specify the server will return up to 5,000 items.
Expand All @@ -350,7 +345,7 @@ def list_queues(
timeout=timeout,
**kwargs)
return ItemPaged(
command, prefix=name_starts_with, results_per_page=results_per_page, marker=marker,
command, prefix=name_starts_with, results_per_page=results_per_page,
page_iterator_class=QueuePropertiesPaged
)

Expand Down
Loading