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

[Key Vault] Rename KeyVaultBackupOperation to KeyVaultBackupResult #19284

Merged
merged 2 commits into from
Jun 17, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ._enums import KeyVaultRoleScope, KeyVaultDataAction
from ._internal.client_base import ApiVersion
from ._models import (
KeyVaultBackupOperation,
KeyVaultBackupResult,
KeyVaultPermission,
KeyVaultRoleAssignment,
KeyVaultRoleAssignmentProperties,
Expand All @@ -17,7 +17,7 @@

__all__ = [
"ApiVersion",
"KeyVaultBackupOperation",
"KeyVaultBackupResult",
"KeyVaultAccessControlClient",
"KeyVaultBackupClient",
"KeyVaultDataAction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from azure.core.polling.base_polling import LROBasePolling

from ._models import KeyVaultBackupOperation
from ._models import KeyVaultBackupResult
from ._internal import KeyVaultClientBase, parse_folder_url
from ._internal.polling import KeyVaultBackupClientPolling

Expand All @@ -27,23 +27,23 @@ class KeyVaultBackupClient(KeyVaultClientBase):

# pylint:disable=protected-access
def begin_backup(self, blob_storage_url, sas_token, **kwargs):
# type: (str, str, **Any) -> LROPoller[KeyVaultBackupOperation]
# type: (str, str, **Any) -> LROPoller[KeyVaultBackupResult]
"""Begin a full backup of the Key Vault.

:param str blob_storage_url: URL of the blob storage container in which the backup will be stored, for example
https://<account>.blob.core.windows.net/backup
:param str sas_token: a Shared Access Signature (SAS) token authorizing access to the blob storage resource
:keyword str continuation_token: a continuation token to restart polling from a saved state
:returns: An :class:`~azure.core.polling.LROPoller` instance. Call `result()` on this object to wait for the
operation to complete and get a :class:`KeyVaultBackupOperation`.
:rtype: ~azure.core.polling.LROPoller[~azure.keyvault.administration.KeyVaultBackupOperation]
operation to complete and get a :class:`KeyVaultBackupResult`.
:rtype: ~azure.core.polling.LROPoller[~azure.keyvault.administration.KeyVaultBackupResult]
"""
polling_interval = kwargs.pop("_polling_interval", 5)
sas_parameter = self._models.SASTokenParameter(storage_resource_uri=blob_storage_url, token=sas_token)
return self._client.begin_full_backup(
vault_base_url=self._vault_url,
azure_storage_blob_container_uri=sas_parameter,
cls=KeyVaultBackupOperation._from_generated,
cls=KeyVaultBackupResult._from_generated,
continuation_token=kwargs.pop("continuation_token", None),
polling=LROBasePolling(lro_algorithms=[KeyVaultBackupClientPolling()], timeout=polling_interval, **kwargs),
**kwargs
Expand All @@ -56,7 +56,7 @@ def begin_restore(self, folder_url, sas_token, **kwargs):
This method restores either a complete Key Vault backup or when ``key_name`` has a value, a single key.

:param str folder_url: URL of the blob holding the backup. This would be the `folder_url` of a
:class:`KeyVaultBackupOperation` returned by :func:`begin_backup`, for example
:class:`KeyVaultBackupResult` returned by :func:`begin_backup`, for example
https://<account>.blob.core.windows.net/backup/mhsm-account-2020090117323313
:param str sas_token: a Shared Access Signature (SAS) token authorizing access to the blob storage resource
:keyword str continuation_token: a continuation token to restart polling from a saved state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def _from_generated(cls, definition):
)


class KeyVaultBackupOperation(object):
"""A Key Vault full backup operation
class KeyVaultBackupResult(object):
"""A Key Vault full backup operation result

:ivar str folder_url: URL of the Azure Blob Storage container containing the backup
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from .._internal import AsyncKeyVaultClientBase, parse_folder_url
from .._internal.polling import KeyVaultBackupClientPolling
from .._models import KeyVaultBackupOperation
from .._models import KeyVaultBackupResult

if TYPE_CHECKING:
# pylint:disable=unused-import
Expand All @@ -28,22 +28,22 @@ class KeyVaultBackupClient(AsyncKeyVaultClientBase):
# pylint:disable=protected-access
async def begin_backup(
self, blob_storage_url: str, sas_token: str, **kwargs: "Any"
) -> "AsyncLROPoller[KeyVaultBackupOperation]":
) -> "AsyncLROPoller[KeyVaultBackupResult]":
"""Begin a full backup of the Key Vault.

:param str blob_storage_url: URL of the blob storage container in which the backup will be stored, for example
https://<account>.blob.core.windows.net/backup
:param str sas_token: a Shared Access Signature (SAS) token authorizing access to the blob storage resource
:keyword str continuation_token: a continuation token to restart polling from a saved state
:returns: An AsyncLROPoller. Call `result()` on this object to get a :class:`KeyVaultBackupOperation`.
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.administration.KeyVaultBackupOperation]
:returns: An AsyncLROPoller. Call `result()` on this object to get a :class:`KeyVaultBackupResult`.
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.administration.KeyVaultBackupResult]
"""
polling_interval = kwargs.pop("_polling_interval", 5)
sas_parameter = self._models.SASTokenParameter(storage_resource_uri=blob_storage_url, token=sas_token)
return await self._client.begin_full_backup(
vault_base_url=self._vault_url,
azure_storage_blob_container_uri=sas_parameter,
cls=KeyVaultBackupOperation._from_generated,
cls=KeyVaultBackupResult._from_generated,
continuation_token=kwargs.pop("continuation_token", None),
polling=AsyncLROBasePolling(
lro_algorithms=[KeyVaultBackupClientPolling()], timeout=polling_interval, **kwargs
Expand All @@ -57,7 +57,7 @@ async def begin_restore(self, folder_url: str, sas_token: str, **kwargs: "Any")
This method restores either a complete Key Vault backup or when ``key_name`` has a value, a single key.

:param str folder_url: URL for the blob storage resource, including the path to the blob holding the
backup. This would be the `folder_url` of a :class:`KeyVaultBackupOperation` returned by
backup. This would be the `folder_url` of a :class:`KeyVaultBackupResult` returned by
:func:`begin_backup`, for example
https://<account>.blob.core.windows.net/backup/mhsm-account-2020090117323313
:param str sas_token: a Shared Access Signature (SAS) token authorizing access to the blob storage resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from datetime import datetime
from functools import partial
import time

Expand All @@ -11,7 +10,7 @@
from azure.identity import DefaultAzureCredential
from azure.keyvault.keys import KeyClient
from azure.keyvault.administration._internal import HttpChallengeCache
from azure.keyvault.administration import KeyVaultBackupClient, KeyVaultBackupOperation
from azure.keyvault.administration import KeyVaultBackupClient
from azure.keyvault.administration._internal import parse_folder_url
from devtools_testutils import ResourceGroupPreparer, StorageAccountPreparer
import pytest
Expand Down