Skip to content

Commit

Permalink
fix typing for paging methods (Azure#13410)
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft authored and rakshith91 committed Sep 4, 2020
1 parent fc02f42 commit 4357c10
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
2 changes: 2 additions & 0 deletions sdk/keyvault/azure-keyvault-certificates/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Release History

## 4.2.1 (Unreleased)
### Fixed
- Correct typing for paging methods


## 4.2.0 (2020-08-11)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

if TYPE_CHECKING:
# pylint:disable=unused-import
from typing import Any, Dict, List, Optional, Iterable
from typing import Any, Dict, Iterable, List, Optional
from azure.core.paging import ItemPaged


class CertificateClient(KeyVaultClientBase):
Expand Down Expand Up @@ -530,7 +531,7 @@ def restore_certificate_backup(self, backup, **kwargs):

@distributed_trace
def list_deleted_certificates(self, **kwargs):
# type: (**Any) -> Iterable[DeletedCertificate]
# type: (**Any) -> ItemPaged[DeletedCertificate]
"""Lists the currently-recoverable deleted certificates. Possible only if vault is soft-delete enabled.
Requires certificates/get/list permission. Retrieves the certificates in the current vault which
Expand Down Expand Up @@ -566,7 +567,7 @@ def list_deleted_certificates(self, **kwargs):

@distributed_trace
def list_properties_of_certificates(self, **kwargs):
# type: (**Any) -> Iterable[CertificateProperties]
# type: (**Any) -> ItemPaged[CertificateProperties]
"""List identifiers and properties of all certificates in the vault.
Requires certificates/list permission.
Expand Down Expand Up @@ -598,7 +599,7 @@ def list_properties_of_certificates(self, **kwargs):

@distributed_trace
def list_properties_of_certificate_versions(self, certificate_name, **kwargs):
# type: (str, **Any) -> Iterable[CertificateProperties]
# type: (str, **Any) -> ItemPaged[CertificateProperties]
"""List the identifiers and properties of a certificate's versions.
Requires certificates/list permission.
Expand Down Expand Up @@ -989,7 +990,7 @@ def delete_issuer(self, issuer_name, **kwargs):

@distributed_trace
def list_properties_of_issuers(self, **kwargs):
# type: (**Any) -> Iterable[IssuerProperties]
# type: (**Any) -> ItemPaged[IssuerProperties]
"""Lists properties of the certificate issuers for the key vault.
Requires the certificates/manageissuers/getissuers permission.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
# ------------------------------------
# pylint:disable=too-many-lines,too-many-public-methods
import base64
from typing import Any, AsyncIterable, Optional, Iterable, List, Dict, Union
from typing import Any, Optional, Iterable, List, Dict, Union
from functools import partial

from azure.core.polling import async_poller
from azure.core.tracing.decorator import distributed_trace
from azure.core.tracing.decorator_async import distributed_trace_async
from azure.core.async_paging import AsyncItemPaged

from .. import (
KeyVaultCertificate,
Expand Down Expand Up @@ -504,7 +505,7 @@ async def restore_certificate_backup(self, backup: bytes, **kwargs: "Any") -> Ke
return KeyVaultCertificate._from_certificate_bundle(certificate_bundle=bundle)

@distributed_trace
def list_deleted_certificates(self, **kwargs: "Any") -> AsyncIterable[DeletedCertificate]:
def list_deleted_certificates(self, **kwargs: "Any") -> AsyncItemPaged[DeletedCertificate]:
"""Lists the currently-recoverable deleted certificates. Possible only if vault is soft-delete enabled.
Requires certificates/get/list permission. Retrieves the certificates in the current vault which
Expand Down Expand Up @@ -536,7 +537,7 @@ def list_deleted_certificates(self, **kwargs: "Any") -> AsyncIterable[DeletedCer
)

@distributed_trace
def list_properties_of_certificates(self, **kwargs: "Any") -> AsyncIterable[CertificateProperties]:
def list_properties_of_certificates(self, **kwargs: "Any") -> AsyncItemPaged[CertificateProperties]:
"""List identifiers and properties of all certificates in the vault.
Requires certificates/list permission.
Expand Down Expand Up @@ -568,7 +569,7 @@ def list_properties_of_certificates(self, **kwargs: "Any") -> AsyncIterable[Cert
@distributed_trace
def list_properties_of_certificate_versions(
self, certificate_name: str, **kwargs: "Any"
) -> AsyncIterable[CertificateProperties]:
) -> AsyncItemPaged[CertificateProperties]:
"""List the identifiers and properties of a certificate's versions.
Requires certificates/list permission.
Expand Down Expand Up @@ -965,7 +966,7 @@ async def delete_issuer(self, issuer_name: str, **kwargs: "Any") -> CertificateI
return CertificateIssuer._from_issuer_bundle(issuer_bundle=issuer_bundle)

@distributed_trace
def list_properties_of_issuers(self, **kwargs: "Any") -> AsyncIterable[IssuerProperties]:
def list_properties_of_issuers(self, **kwargs: "Any") -> AsyncItemPaged[IssuerProperties]:
"""Lists properties of the certificate issuers for the key vault.
Requires the certificates/manageissuers/getissuers permission.
Expand Down
2 changes: 2 additions & 0 deletions sdk/keyvault/azure-keyvault-keys/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Release History

## 4.2.1 (Unreleased)
### Fixed
- Correct typing for async paging methods


## 4.2.0 (2020-08-11)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
if TYPE_CHECKING:
# pylint:disable=ungrouped-imports
from datetime import datetime
from typing import Any, AsyncIterable, Optional, List, Union
from azure.core.async_paging import AsyncItemPaged
from typing import Any, Optional, List, Union
from .. import KeyType


Expand Down Expand Up @@ -256,7 +257,7 @@ async def get_deleted_key(self, name: str, **kwargs: "Any") -> DeletedKey:
return DeletedKey._from_deleted_key_bundle(bundle)

@distributed_trace
def list_deleted_keys(self, **kwargs: "Any") -> "AsyncIterable[DeletedKey]":
def list_deleted_keys(self, **kwargs: "Any") -> "AsyncItemPaged[DeletedKey]":
"""List all deleted keys, including the public part of each. Possible only in a vault with soft-delete enabled.
Requires keys/list permission.
Expand All @@ -281,7 +282,7 @@ def list_deleted_keys(self, **kwargs: "Any") -> "AsyncIterable[DeletedKey]":
)

@distributed_trace
def list_properties_of_keys(self, **kwargs: "Any") -> "AsyncIterable[KeyProperties]":
def list_properties_of_keys(self, **kwargs: "Any") -> "AsyncItemPaged[KeyProperties]":
"""List identifiers and properties of all keys in the vault. Requires keys/list permission.
:returns: An iterator of keys without their cryptographic material or version information
Expand All @@ -304,7 +305,7 @@ def list_properties_of_keys(self, **kwargs: "Any") -> "AsyncIterable[KeyProperti
)

@distributed_trace
def list_properties_of_key_versions(self, name: str, **kwargs: "Any") -> "AsyncIterable[KeyProperties]":
def list_properties_of_key_versions(self, name: str, **kwargs: "Any") -> "AsyncItemPaged[KeyProperties]":
"""List the identifiers and properties of a key's versions. Requires keys/list permission.
:param str name: The name of the key
Expand Down
3 changes: 2 additions & 1 deletion sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Release History

## 4.2.1 (Unreleased)

### Fixed
- Correct typing for async paging methods

## 4.2.0 (2020-08-11)
### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from typing import Any, AsyncIterable, Optional, Dict
from typing import Any, Optional, Dict
from functools import partial

from azure.core.tracing.decorator import distributed_trace
from azure.core.tracing.decorator_async import distributed_trace_async
from azure.core.async_paging import AsyncItemPaged

from .._models import KeyVaultSecret, DeletedSecret, SecretProperties
from .._shared import AsyncKeyVaultClientBase
Expand Down Expand Up @@ -165,7 +166,7 @@ async def update_secret_properties(
return SecretProperties._from_secret_bundle(bundle) # pylint: disable=protected-access

@distributed_trace
def list_properties_of_secrets(self, **kwargs: "Any") -> AsyncIterable[SecretProperties]:
def list_properties_of_secrets(self, **kwargs: "Any") -> AsyncItemPaged[SecretProperties]:
"""List identifiers and attributes of all secrets in the vault. Requires secrets/list permission.
List items don't include secret values. Use :func:`get_secret` to get a secret's value.
Expand All @@ -189,7 +190,7 @@ def list_properties_of_secrets(self, **kwargs: "Any") -> AsyncIterable[SecretPro
)

@distributed_trace
def list_properties_of_secret_versions(self, name: str, **kwargs: "Any") -> AsyncIterable[SecretProperties]:
def list_properties_of_secret_versions(self, name: str, **kwargs: "Any") -> AsyncItemPaged[SecretProperties]:
"""List properties of all versions of a secret, excluding their values. Requires secrets/list permission.
List items don't include secret values. Use :func:`get_secret` to get a secret's value.
Expand Down Expand Up @@ -321,7 +322,7 @@ async def get_deleted_secret(self, name: str, **kwargs: "Any") -> DeletedSecret:
return DeletedSecret._from_deleted_secret_bundle(bundle)

@distributed_trace
def list_deleted_secrets(self, **kwargs: "Any") -> AsyncIterable[DeletedSecret]:
def list_deleted_secrets(self, **kwargs: "Any") -> AsyncItemPaged[DeletedSecret]:
"""Lists all deleted secrets. Possible only in vaults with soft-delete enabled.
Requires secrets/list permission.
Expand Down

0 comments on commit 4357c10

Please sign in to comment.