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

[keyvault] fix include_pending param and 2016-10-01 compatibility #13161

Merged
merged 8 commits into from
Sep 3, 2020
Merged
1 change: 1 addition & 0 deletions sdk/keyvault/azure-keyvault-certificates/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 4.2.1 (Unreleased)
### Fixed
- Correct typing for paging methods
- Fixed incompatibility issues with API version 2016-10-01


## 4.2.0 (2020-08-11)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,11 @@ def list_deleted_certificates(self, **kwargs):
"""
max_page_size = kwargs.pop("max_page_size", None)

if self.api_version == "2016-10-01" and kwargs.get("include_pending"):
Copy link
Contributor

Choose a reason for hiding this comment

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

In Public Cloud, the service allows requests for 2016-10-01 to specify includePending. Maybe it sends back an error in other clouds where 2016-10-01 is the only supported version. Perhaps it just silently ignores the parameter? In any case, behavior like that is why we leave request validation to the service.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main reason why I'm throwing here is because of the generated code based off of the swagger. Since it's not mentioned as a parameter, it never gets popped from kwargs, so eventually request is going to throw an error saying "i don't know what include_pending is". If we want to expose include_pending for 2016-10-01, we'd have to change the swagger

raise NotImplementedError(
"The 'include_pending' parameter to `list_deleted_certificates` "
"is only available for API versions v7.0 and up"
)
return self._client.get_deleted_certificates(
vault_base_url=self._vault_url,
maxresults=max_page_size,
Expand Down Expand Up @@ -589,6 +594,12 @@ def list_properties_of_certificates(self, **kwargs):
"""
max_page_size = kwargs.pop("max_page_size", None)

if self.api_version == "2016-10-01" and kwargs.get("include_pending"):
raise NotImplementedError(
"The 'include_pending' parameter to `list_properties_of_certificates` "
"is only available for API versions v7.0 and up"
)

return self._client.get_certificates(
vault_base_url=self._vault_url,
maxresults=max_page_size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,65 +37,13 @@ class KeyVaultClient(KeyVaultClientOperationsMixin, MultiApiClientMixin, _SDKCli
missing in profile.
:param profile: A profile definition, from KnownProfiles to dict.
:type profile: azure.profiles.KnownProfiles
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
"""

DEFAULT_API_VERSION = '7.1'
DEFAULT_API_VERSION = '2016-10-01'
_PROFILE_TAG = "azure.keyvault.KeyVaultClient"
LATEST_PROFILE = ProfileDefinition({
_PROFILE_TAG: {
None: DEFAULT_API_VERSION,
'backup_key': '7.0',
'backup_secret': '7.0',
'backup_storage_account': '7.0',
'create_key': '7.0',
'decrypt': '7.0',
'delete_key': '7.0',
'delete_sas_definition': '7.0',
'delete_secret': '7.0',
'delete_storage_account': '7.0',
'encrypt': '7.0',
'get_deleted_key': '7.0',
'get_deleted_keys': '7.0',
'get_deleted_sas_definition': '7.0',
'get_deleted_sas_definitions': '7.0',
'get_deleted_secret': '7.0',
'get_deleted_secrets': '7.0',
'get_deleted_storage_account': '7.0',
'get_deleted_storage_accounts': '7.0',
'get_key': '7.0',
'get_key_versions': '7.0',
'get_keys': '7.0',
'get_sas_definition': '7.0',
'get_sas_definitions': '7.0',
'get_secret': '7.0',
'get_secret_versions': '7.0',
'get_secrets': '7.0',
'get_storage_account': '7.0',
'get_storage_accounts': '7.0',
'import_key': '7.0',
'purge_deleted_key': '7.0',
'purge_deleted_secret': '7.0',
'purge_deleted_storage_account': '7.0',
'recover_deleted_key': '7.0',
'recover_deleted_sas_definition': '7.0',
'recover_deleted_secret': '7.0',
'recover_deleted_storage_account': '7.0',
'regenerate_storage_account_key': '7.0',
'restore_key': '7.0',
'restore_secret': '7.0',
'restore_storage_account': '7.0',
'set_sas_definition': '7.0',
'set_secret': '7.0',
'set_storage_account': '7.0',
'sign': '7.0',
'unwrap_key': '7.0',
'update_key': '7.0',
'update_sas_definition': '7.0',
'update_secret': '7.0',
'update_storage_account': '7.0',
'verify': '7.0',
'wrap_key': '7.0',
}},
_PROFILE_TAG + " latest"
)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,65 +37,13 @@ class KeyVaultClient(KeyVaultClientOperationsMixin, MultiApiClientMixin, _SDKCli
missing in profile.
:param profile: A profile definition, from KnownProfiles to dict.
:type profile: azure.profiles.KnownProfiles
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
"""

DEFAULT_API_VERSION = '7.1'
DEFAULT_API_VERSION = '2016-10-01'
_PROFILE_TAG = "azure.keyvault.KeyVaultClient"
LATEST_PROFILE = ProfileDefinition({
_PROFILE_TAG: {
None: DEFAULT_API_VERSION,
'backup_key': '7.0',
'backup_secret': '7.0',
'backup_storage_account': '7.0',
'create_key': '7.0',
'decrypt': '7.0',
'delete_key': '7.0',
'delete_sas_definition': '7.0',
'delete_secret': '7.0',
'delete_storage_account': '7.0',
'encrypt': '7.0',
'get_deleted_key': '7.0',
'get_deleted_keys': '7.0',
'get_deleted_sas_definition': '7.0',
'get_deleted_sas_definitions': '7.0',
'get_deleted_secret': '7.0',
'get_deleted_secrets': '7.0',
'get_deleted_storage_account': '7.0',
'get_deleted_storage_accounts': '7.0',
'get_key': '7.0',
'get_key_versions': '7.0',
'get_keys': '7.0',
'get_sas_definition': '7.0',
'get_sas_definitions': '7.0',
'get_secret': '7.0',
'get_secret_versions': '7.0',
'get_secrets': '7.0',
'get_storage_account': '7.0',
'get_storage_accounts': '7.0',
'import_key': '7.0',
'purge_deleted_key': '7.0',
'purge_deleted_secret': '7.0',
'purge_deleted_storage_account': '7.0',
'recover_deleted_key': '7.0',
'recover_deleted_sas_definition': '7.0',
'recover_deleted_secret': '7.0',
'recover_deleted_storage_account': '7.0',
'regenerate_storage_account_key': '7.0',
'restore_key': '7.0',
'restore_secret': '7.0',
'restore_storage_account': '7.0',
'set_sas_definition': '7.0',
'set_secret': '7.0',
'set_storage_account': '7.0',
'sign': '7.0',
'unwrap_key': '7.0',
'update_key': '7.0',
'update_sas_definition': '7.0',
'update_secret': '7.0',
'update_storage_account': '7.0',
'verify': '7.0',
'wrap_key': '7.0',
}},
_PROFILE_TAG + " latest"
)
Expand Down