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
Move Storage Queue to new Paging (#6447)
* Move Storage Queue to new Paging

* Working Storage queue on new paging

* Fix types

* First shot of blob tests update

* Fixing blob tests

* File to new paging

* Doc fix

* Feedbacks from @annatisch

* Fix last @annatisch comment

* Simplify paging contract

* Fix storage queue after new paging contract
  • Loading branch information
lmazuel authored Jul 25, 2019
commit fbe02eebbf55877745449367a486bf5628281636
2 changes: 0 additions & 2 deletions sdk/core/azure-core/azure/core/async_paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ async def __anext__(self):
self.continuation_token, self._current_page = await self._extract_data(
self._response
)
if not self._current_page:
raise StopAsyncIteration("End of paging")

# If current_page was a sync list, wrap it async-like
if isinstance(self._current_page, collections.abc.Iterable):
Expand Down
2 changes: 0 additions & 2 deletions sdk/core/azure-core/azure/core/paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ def __next__(self):
self._did_a_call_already = True

self.continuation_token, self._current_page = self._extract_data(self._response)
if not self._current_page:
raise StopIteration("End of paging")

return iter(self._current_page)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
except ImportError:
from urlparse import urlparse # type: ignore

from azure.core.paging import ItemPaged

from ._shared.shared_access_signature import SharedAccessSignature
from ._shared.models import LocationMode, Services
from ._shared.utils import (
Expand Down Expand Up @@ -380,12 +382,11 @@ def set_service_properties(
def list_containers(
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
):
# type: (...) -> ContainerPropertiesPaged
# type: (...) -> ItemPaged[ContainerProperties]
"""Returns a generator to list the containers under the specified account.

The generator will lazily follow the continuation tokens returned by
Expand All @@ -397,17 +398,13 @@ def list_containers(
:param bool include_metadata:
Specifies that container metadata be returned in the response.
The default value is `False`.
: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 container names to retrieve per API
call. If the request does not specify the server will return up to 5,000 items.
:param int timeout:
The timeout parameter is expressed in seconds.
:returns: An iterable (auto-paging) of ContainerProperties.
:rtype: ~azure.core.blob.models.ContainerPropertiesPaged
:rtype: ~azure.core.paging.ItemPaged[~azure.core.blob.models.ContainerProperties]

Example:
.. literalinclude:: ../tests/test_blob_samples_service.py
Expand All @@ -424,8 +421,8 @@ def list_containers(
include=include,
timeout=timeout,
**kwargs)
return ContainerPropertiesPaged(
command, prefix=name_starts_with, results_per_page=results_per_page, marker=marker)
return ItemPaged(
command, prefix=name_starts_with, results_per_page=results_per_page, page_iterator_class=ContainerPropertiesPaged)

def create_container(
self, name, # type: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from urlparse import urlparse # type: ignore
from urllib2 import quote, unquote # type: ignore

from azure.core.paging import ItemPaged

import six

from ._shared.shared_access_signature import BlobSharedAccessSignature
Expand Down Expand Up @@ -658,8 +660,8 @@ def set_container_access_policy(
except StorageErrorException as error:
process_storage_error(error)

def list_blobs(self, name_starts_with=None, include=None, marker=None, timeout=None, **kwargs):
# type: (Optional[str], Optional[Any], Optional[str], Optional[int], **Any) -> Iterable[BlobProperties]
def list_blobs(self, name_starts_with=None, include=None, timeout=None, **kwargs):
# type: (Optional[str], Optional[Any], Optional[int], **Any) -> ItemPaged[BlobProperties]
"""Returns a generator to list the blobs under the specified container.
The generator will lazily follow the continuation tokens returned by
the service.
Expand All @@ -670,14 +672,10 @@ def list_blobs(self, name_starts_with=None, include=None, marker=None, timeout=N
:param list[str] include:
Specifies one or more additional datasets to include in the response.
Options include: 'snapshots', 'metadata', 'uncommittedblobs', 'copy', 'deleted'.
: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 timeout:
The timeout parameter is expressed in seconds.
:returns: An iterable (auto-paging) response of BlobProperties.
:rtype: ~azure.storage.blob.models.BlobPropertiesPaged
:rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.models.BlobProperties]

Example:
.. literalinclude:: ../tests/test_blob_samples_containers.py
Expand All @@ -696,17 +694,19 @@ def list_blobs(self, name_starts_with=None, include=None, marker=None, timeout=N
include=include,
timeout=timeout,
**kwargs)
return BlobPropertiesPaged(command, prefix=name_starts_with, results_per_page=results_per_page, marker=marker)
return ItemPaged(
command, prefix=name_starts_with, results_per_page=results_per_page,
page_iterator_class=BlobPropertiesPaged)


def walk_blobs(
self, name_starts_with=None, # type: Optional[str]
include=None, # type: Optional[Any]
delimiter="/", # type: str
marker=None, # type: Optional[str]
timeout=None, # type: Optional[int]
**kwargs # type: Optional[Any]
):
# type: (...) -> Iterable[BlobProperties]
# type: (...) -> ItemPaged[BlobProperties]
"""Returns a generator to list the blobs under the specified container.
The generator will lazily follow the continuation tokens returned by
the service. This operation will list blobs in accordance with a hierarchy,
Expand All @@ -723,20 +723,15 @@ def walk_blobs(
element in the response body that acts as a placeholder for all blobs whose
names begin with the same substring up to the appearance of the delimiter
character. The delimiter may be a single character or a string.
: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 timeout:
The timeout parameter is expressed in seconds.
:returns: An iterable (auto-paging) response of BlobProperties.
:rtype: ~azure.storage.blob.models.BlobPrefix
:rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.models.BlobProperties]
"""
if include and not isinstance(include, list):
include = [include]

results_per_page = kwargs.pop('results_per_page', None)
marker = kwargs.pop('marker', "")
command = functools.partial(
self._client.container.list_blob_hierarchy_segment,
delimiter=delimiter,
Expand All @@ -747,7 +742,6 @@ def walk_blobs(
command,
prefix=name_starts_with,
results_per_page=results_per_page,
marker=marker,
delimiter=delimiter)

def upload_blob(
Expand Down
Loading