Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KV moved paging return type to ItemPaged #6558

Merged
merged 2 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 19 additions & 6 deletions sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,12 @@ def list_deleted_keys(self, **kwargs):
:dedent: 8
"""
max_page_size = kwargs.get("max_page_size", None)
pages = self._client.get_deleted_keys(self._vault_url, maxresults=max_page_size, **kwargs)
return (DeletedKey._from_deleted_key_item(item) for item in pages)
return self._client.get_deleted_keys(
self._vault_url,
maxresults=max_page_size,
cls=lambda objs: [DeletedKey._from_deleted_key_item(x) for x in objs],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume objs is a single page already received, so the comprehension doesn't entail additional I/O?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct, objs is a real list already in memory, from a single JSON

**kwargs
)

@distributed_trace
def list_keys(self, **kwargs):
Expand All @@ -381,8 +385,12 @@ def list_keys(self, **kwargs):
:dedent: 8
"""
max_page_size = kwargs.get("max_page_size", None)
pages = self._client.get_keys(self._vault_url, maxresults=max_page_size, **kwargs)
return (KeyBase._from_key_item(item) for item in pages)
return self._client.get_keys(
self._vault_url,
maxresults=max_page_size,
cls=lambda objs: [KeyBase._from_key_item(x) for x in objs],
**kwargs
)

@distributed_trace
def list_key_versions(self, name, **kwargs):
Expand All @@ -407,8 +415,13 @@ def list_key_versions(self, name, **kwargs):
:dedent: 8
"""
max_page_size = kwargs.get("max_page_size", None)
pages = self._client.get_key_versions(self._vault_url, name, maxresults=max_page_size, **kwargs)
return (KeyBase._from_key_item(item) for item in pages)
return self._client.get_key_versions(
self._vault_url,
name,
maxresults=max_page_size,
cls=lambda objs: [KeyBase._from_key_item(x) for x in objs],
**kwargs
)

@distributed_trace
def purge_deleted_key(self, name, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def parse_vault_id(url):

try:
from .async_challenge_auth_policy import AsyncChallengeAuthPolicy
from .async_client_base import AsyncKeyVaultClientBase, AsyncPagingAdapter
from .async_client_base import AsyncKeyVaultClientBase

__all__.extend(["AsyncChallengeAuthPolicy", "AsyncKeyVaultClientBase", "AsyncPagingAdapter"])
__all__.extend(["AsyncChallengeAuthPolicy", "AsyncKeyVaultClientBase"])
except (SyntaxError, ImportError):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ def prepare_request(next_link=None):

async def extract_data_async(response):
deserialized = self._deserialize('KeyListResult', response)
return deserialized.next_link, AsyncList(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, AsyncList(list_of_elem)

async def get_next_async(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -494,7 +497,10 @@ def prepare_request(next_link=None):

async def extract_data_async(response):
deserialized = self._deserialize('KeyListResult', response)
return deserialized.next_link, AsyncList(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, AsyncList(list_of_elem)

async def get_next_async(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -1174,7 +1180,10 @@ def prepare_request(next_link=None):

async def extract_data_async(response):
deserialized = self._deserialize('DeletedKeyListResult', response)
return deserialized.next_link, AsyncList(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, AsyncList(list_of_elem)

async def get_next_async(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -1678,7 +1687,10 @@ def prepare_request(next_link=None):

async def extract_data_async(response):
deserialized = self._deserialize('SecretListResult', response)
return deserialized.next_link, AsyncList(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, AsyncList(list_of_elem)

async def get_next_async(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -1749,7 +1761,10 @@ def prepare_request(next_link=None):

async def extract_data_async(response):
deserialized = self._deserialize('SecretListResult', response)
return deserialized.next_link, AsyncList(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, AsyncList(list_of_elem)

async def get_next_async(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -1817,7 +1832,10 @@ def prepare_request(next_link=None):

async def extract_data_async(response):
deserialized = self._deserialize('DeletedSecretListResult', response)
return deserialized.next_link, AsyncList(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, AsyncList(list_of_elem)

async def get_next_async(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -2170,7 +2188,10 @@ def prepare_request(next_link=None):

async def extract_data_async(response):
deserialized = self._deserialize('CertificateListResult', response)
return deserialized.next_link, AsyncList(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, AsyncList(list_of_elem)

async def get_next_async(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -2464,7 +2485,10 @@ def prepare_request(next_link=None):

async def extract_data_async(response):
deserialized = self._deserialize('CertificateIssuerListResult', response)
return deserialized.next_link, AsyncList(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, AsyncList(list_of_elem)

async def get_next_async(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -2951,7 +2975,10 @@ def prepare_request(next_link=None):

async def extract_data_async(response):
deserialized = self._deserialize('CertificateListResult', response)
return deserialized.next_link, AsyncList(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, AsyncList(list_of_elem)

async def get_next_async(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -3533,7 +3560,10 @@ def prepare_request(next_link=None):

async def extract_data_async(response):
deserialized = self._deserialize('DeletedCertificateListResult', response)
return deserialized.next_link, AsyncList(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, AsyncList(list_of_elem)

async def get_next_async(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -3768,7 +3798,10 @@ def prepare_request(next_link=None):

async def extract_data_async(response):
deserialized = self._deserialize('StorageListResult', response)
return deserialized.next_link, AsyncList(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, AsyncList(list_of_elem)

async def get_next_async(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -4158,7 +4191,10 @@ def prepare_request(next_link=None):

async def extract_data_async(response):
deserialized = self._deserialize('SasDefinitionListResult', response)
return deserialized.next_link, AsyncList(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, AsyncList(list_of_elem)

async def get_next_async(next_link=None):
request = prepare_request(next_link)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,14 +692,6 @@ def __init__(self, **kwargs):
self.tags = kwargs.get('tags', None)


class CloudError(Model):
"""CloudError.
"""

_attribute_map = {
}


class Contact(Model):
"""The contact information for the vault certificates.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,14 +692,6 @@ def __init__(self, *, certificate_policy=None, certificate_attributes=None, tags
self.tags = tags


class CloudError(Model):
"""CloudError.
"""

_attribute_map = {
}


class Contact(Model):
"""The contact information for the vault certificates.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ def prepare_request(next_link=None):

def extract_data(response):
deserialized = self._deserialize('KeyListResult', response)
return deserialized.next_link, iter(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -494,7 +497,10 @@ def prepare_request(next_link=None):

def extract_data(response):
deserialized = self._deserialize('KeyListResult', response)
return deserialized.next_link, iter(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -1174,7 +1180,10 @@ def prepare_request(next_link=None):

def extract_data(response):
deserialized = self._deserialize('DeletedKeyListResult', response)
return deserialized.next_link, iter(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -1678,7 +1687,10 @@ def prepare_request(next_link=None):

def extract_data(response):
deserialized = self._deserialize('SecretListResult', response)
return deserialized.next_link, iter(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -1749,7 +1761,10 @@ def prepare_request(next_link=None):

def extract_data(response):
deserialized = self._deserialize('SecretListResult', response)
return deserialized.next_link, iter(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -1817,7 +1832,10 @@ def prepare_request(next_link=None):

def extract_data(response):
deserialized = self._deserialize('DeletedSecretListResult', response)
return deserialized.next_link, iter(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -2170,7 +2188,10 @@ def prepare_request(next_link=None):

def extract_data(response):
deserialized = self._deserialize('CertificateListResult', response)
return deserialized.next_link, iter(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -2464,7 +2485,10 @@ def prepare_request(next_link=None):

def extract_data(response):
deserialized = self._deserialize('CertificateIssuerListResult', response)
return deserialized.next_link, iter(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -2951,7 +2975,10 @@ def prepare_request(next_link=None):

def extract_data(response):
deserialized = self._deserialize('CertificateListResult', response)
return deserialized.next_link, iter(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -3533,7 +3560,10 @@ def prepare_request(next_link=None):

def extract_data(response):
deserialized = self._deserialize('DeletedCertificateListResult', response)
return deserialized.next_link, iter(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -3768,7 +3798,10 @@ def prepare_request(next_link=None):

def extract_data(response):
deserialized = self._deserialize('StorageListResult', response)
return deserialized.next_link, iter(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)
Expand Down Expand Up @@ -4158,7 +4191,10 @@ def prepare_request(next_link=None):

def extract_data(response):
deserialized = self._deserialize('SasDefinitionListResult', response)
return deserialized.next_link, iter(deserialized.value)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)
Expand Down
Loading