Skip to content

Commit

Permalink
KV moved paging return type to ItemPaged (Azure#6558)
Browse files Browse the repository at this point in the history
* KV with latest autorest

* Make KV return ItemPaged from azure-core
  • Loading branch information
lmazuel authored and rakshith91 committed Aug 2, 2019
1 parent c0b67e7 commit a32e066
Show file tree
Hide file tree
Showing 24 changed files with 498 additions and 242 deletions.
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],
**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

0 comments on commit a32e066

Please sign in to comment.