Repository navigation
[SQL] Add short-term backup retention immutability support #34207
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
Open
svmicano
wants to merge
9
commits into
Azure:dev
Choose a base branch
from
svmicano:svmicano/sql-str-immutability
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+12,734
−26,206
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3fe1251
[SQL] Add short-term backup retention immutability support
svmicano 83de964
{SQL} Record MI STR scenarios and verify locking through policy GET
svmicano 48ea9ad
{SQL} Record SQL DB STR scenarios with policy readiness polling
svmicano 78d3a92
{SQL} Record policy-only immutability locking on an enabled test data…
svmicano 3333619
{SQL} Preserve STR wait policy-name compatibility
svmicano 93e16b8
{SQL} Return STR policy resource after async updates
svmicano 9451dbe
[SQL] Generate short-term retention operations with AAZ
svmicano e2b0117
[SQL] Validate generated STR examples against public commands
svmicano 03307dd
[SQL] Preserve integer STR differential backup intervals
svmicano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/azure-cli/azure/cli/command_modules/sql/_str_policy.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| """Compatibility adapters for the generated STR commands.""" | ||
|
|
||
| from azure.cli.core.aaz import AAZCommand, AAZHttpOperation | ||
| from azure.cli.core.azclierror import InvalidArgumentValueError | ||
|
|
||
| from .aaz.latest.sql.db.str_policy import Set as _DatabasePolicySet, Show as _DatabasePolicyShow | ||
| from .aaz.latest.sql.midb.short_term_retention_policy import ( | ||
| Set as _ManagedDatabasePolicySet, Show as _ManagedDatabasePolicyShow, | ||
| ) | ||
| from .aaz.latest.sql.midb.short_term_retention_policy.restorable_dropped import ( | ||
| Set as _DroppedDatabasePolicySet, Show as _DroppedDatabasePolicyShow, | ||
| ) | ||
|
|
||
|
|
||
| class _ShortTermRetentionPolicy(AAZCommand): | ||
| def _handler(self, command_args): | ||
| # Internal command_args bypass CLI parsing/defaults; None means omitted, not JSON null. | ||
| args = {key: value for key, value in command_args.items() if value is not None} | ||
| args.setdefault("policy_name", "default") | ||
| return super()._handler(args) | ||
|
|
||
|
|
||
| class _PolicySetOperation(AAZHttpOperation): # pylint: disable=abstract-method | ||
| def __call__(self, *args, **kwargs): | ||
| session = self.client.send_request(request=self.make_request(), stream=False, **kwargs) | ||
| if session.http_response.status_code in (200, 202): | ||
| # Keep ARM's final policy GET after Azure-AsyncOperation, rather than the | ||
| # spec's Location result, which can report an inconsistent immutability status. | ||
| return self.client.build_lro_polling( | ||
| self.ctx.args.no_wait, session, self.on_200, self.on_error, | ||
| path_format_arguments=self.url_parameters, | ||
| ) | ||
| return self.on_error(session.http_response) | ||
|
|
||
|
|
||
| class DatabasePolicyShow(_ShortTermRetentionPolicy, _DatabasePolicyShow): | ||
| pass | ||
|
|
||
|
|
||
| class DatabasePolicySet(_ShortTermRetentionPolicy, _DatabasePolicySet): | ||
| class BackupShortTermRetentionPoliciesCreateOrUpdate( | ||
| _PolicySetOperation, _DatabasePolicySet.BackupShortTermRetentionPoliciesCreateOrUpdate): | ||
| @property | ||
| def content(self): | ||
| content = super().content | ||
| properties = content["properties"] | ||
| if "diffBackupIntervalInHours" in properties: | ||
| # The Swagger number enum generates floats, but SQL requires integer JSON tokens. | ||
| interval = properties["diffBackupIntervalInHours"] | ||
| integer_interval = int(interval) | ||
| if integer_interval != interval: | ||
| raise InvalidArgumentValueError("--diffbackup-hours must be a whole number of hours.") | ||
| properties["diffBackupIntervalInHours"] = integer_interval | ||
| return content | ||
|
|
||
|
|
||
| class ManagedDatabasePolicyShow(_ShortTermRetentionPolicy, _ManagedDatabasePolicyShow): | ||
| pass | ||
|
|
||
|
|
||
| class ManagedDatabasePolicySet(_ShortTermRetentionPolicy, _ManagedDatabasePolicySet): | ||
| class ManagedBackupShortTermRetentionPoliciesCreateOrUpdate( | ||
| _PolicySetOperation, _ManagedDatabasePolicySet.ManagedBackupShortTermRetentionPoliciesCreateOrUpdate): | ||
| pass | ||
|
|
||
|
|
||
| class DroppedDatabasePolicyShow(_ShortTermRetentionPolicy, _DroppedDatabasePolicyShow): | ||
| pass | ||
|
|
||
|
|
||
| class DroppedDatabasePolicySet(_ShortTermRetentionPolicy, _DroppedDatabasePolicySet): | ||
| class ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdate( | ||
| _PolicySetOperation, | ||
| _DroppedDatabasePolicySet.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdate): | ||
| pass | ||
20 changes: 20 additions & 0 deletions
20
src/azure-cli/azure/cli/command_modules/sql/aaz/latest/sql/db/__cmd_group.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
|
|
||
|
|
||
| class __CMDGroup(AAZCommandGroup): | ||
| """Manage databases. | ||
| """ | ||
| pass | ||
|
|
||
|
|
||
| __all__ = ["__CMDGroup"] |
11 changes: 11 additions & 0 deletions
11
src/azure-cli/azure/cli/command_modules/sql/aaz/latest/sql/db/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from .__cmd_group import * |
20 changes: 20 additions & 0 deletions
20
src/azure-cli/azure/cli/command_modules/sql/aaz/latest/sql/db/str_policy/__cmd_group.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
|
|
||
|
|
||
| class __CMDGroup(AAZCommandGroup): | ||
| """Manage SQL database short-term retention policies. | ||
| """ | ||
| pass | ||
|
|
||
|
|
||
| __all__ = ["__CMDGroup"] |
13 changes: 13 additions & 0 deletions
13
src/azure-cli/azure/cli/command_modules/sql/aaz/latest/sql/db/str_policy/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from .__cmd_group import * | ||
| from ._set import * | ||
| from ._show import * |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
svmicano
/aazsub directory. You can refer to the following for more information https://azure.github.io/aaz-dev-tools/There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in
e2b0117fd6(AAZ migration commit9451dbe62e). The six STR GET/PUT bases are now generated with aaz-dev-tools 4.7.1 under the SQLaazdirectory. The remaining custom layer preserves the existing public handlers and the already-tested final policy GET behavior; request/response schemas are generated.Upstream command models: Azure/aaz#1130. Both PR descriptions are cross-linked.
Validation: 47 offline tests passed, including all five recorded scenarios and execution of all four generated public-command examples; SQL AAZ metadata verification, flake8, compilation, and adapter pylint passed. No new live resource operations were performed. Full legacy-module pylint has no new diagnostics versus its parent; local environment limitations are documented in the PR.