Skip to content

Commit d29b8a0

Browse files
committed
Fix parameter naming: enable_soft_deletion instead of enabled_soft_deletion
- Updated _params.py to use enable_soft_deletion parameter name - Updated custom.py function signatures and implementations - Updated _help.py examples to use --enable-soft-deletion - Updated test file to use correct CLI option - Removed unnecessary linter exclusions for soft delete parameters - Kept required linter exclusions for list commands (no_ids_for_list_commands)
1 parent ef2395c commit d29b8a0

File tree

5 files changed

+11
-29
lines changed

5 files changed

+11
-29
lines changed

linter_exclusions.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3505,15 +3505,6 @@ neon postgres project:
35053505
rule_exclusions:
35063506
- require_wait_command_if_no_wait
35073507

3508-
cosmosdb update:
3509-
parameters:
3510-
soft_deletion_retention_period_in_minutes:
3511-
rule_exclusions:
3512-
- unrecognized_help_parameter
3513-
min_minutes_before_permanent_deletion_allowed:
3514-
rule_exclusions:
3515-
- unrecognized_help_parameter
3516-
35173508
cosmosdb sql softdeleted-database list:
35183509
rule_exclusions:
35193510
- no_ids_for_list_commands

src/cosmosdb-preview/azext_cosmosdb_preview/_help.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -564,25 +564,13 @@
564564
Default: single region account in the location of the specified resource group.
565565
Failover priority values are 0 for write regions and greater than 0 for read regions. A failover priority value must be unique and less than the total number of regions.
566566
Multiple locations can be specified by using more than one `--locations` argument.
567-
- name: --enabled-soft-deletion
568-
short-summary: Enable or disable soft deletion on the account
569-
long-summary: |
570-
When enabled, deleted databases and containers are retained for the configured retention period and can be recovered.
571-
- name: --sd-retention
572-
short-summary: Soft deletion retention period in minutes
573-
long-summary: |
574-
The retention period for soft-deleted resources. Must be at least equal to min-minutes-before-permanent-deletion-allowed.
575-
- name: --min-purge-minutes
576-
short-summary: Minimum minutes before permanent deletion is allowed
577-
long-summary: |
578-
The minimum time that must pass after soft-deletion before a resource can be permanently deleted (purged).
579567
examples:
580568
- name: Update an Azure Cosmos DB database account. (autogenerated)
581569
text: az cosmosdb update --capabilities EnableGremlin --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup
582570
- name: Update an Azure Cosmos DB database account to enable materialized views.
583571
text: az cosmosdb update --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --enable-materialized-views true
584572
- name: Enable soft deletion with 1440 minutes (24 hours) retention.
585-
text: az cosmosdb update --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --enabled-soft-deletion true --sd-retention 1440 --min-purge-minutes 60
573+
text: az cosmosdb update --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --enable-soft-deletion true --sd-retention 1440 --min-purge-minutes 60
586574
"""
587575

588576
# restore account

src/cosmosdb-preview/azext_cosmosdb_preview/_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,9 @@ def load_arguments(self, _):
486486

487487
with self.argument_context('cosmosdb update') as c:
488488
c.argument('key_uri', help="The URI of the key vault", is_preview=True)
489+
c.argument('enable_soft_deletion', arg_type=get_three_state_flag(), help="Flag to enable or disable soft deletion on the account.", is_preview=True, arg_group='Soft Delete')
490+
c.argument('soft_deletion_retention_period_in_minutes', options_list=['--soft-deletion-retention-period-in-minutes', '--sd-retention'], type=int, help="Soft deletion retention period in minutes. Must be at least equal to min_minutes_before_permanent_deletion_allowed.", is_preview=True, arg_group='Soft Delete')
491+
c.argument('min_minutes_before_permanent_deletion_allowed', options_list=['--min-minutes-before-permanent-deletion-allowed', '--min-purge-minutes'], type=int, help="Minimum minutes before permanent deletion is allowed for soft-deleted resources.", is_preview=True, arg_group='Soft Delete')
489492

490493
with self.argument_context('cosmosdb restore') as c:
491494
c.argument('target_database_account_name', options_list=['--target-database-account-name', '-n'], help='Name of the new target Cosmos DB database account after the restore')

src/cosmosdb-preview/azext_cosmosdb_preview/custom.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ def cli_cosmosdb_update(client,
956956
enable_prpp_autoscale=None,
957957
enable_partition_merge=None,
958958
capacity_mode=None,
959-
enabled_soft_deletion=None,
959+
enable_soft_deletion=None,
960960
soft_deletion_retention_period_in_minutes=None,
961961
min_minutes_before_permanent_deletion_allowed=None):
962962
"""Update an existing Azure Cosmos DB database account. """
@@ -1026,12 +1026,12 @@ def cli_cosmosdb_update(client,
10261026
analytical_storage_configuration.schema_type = analytical_storage_schema_type
10271027

10281028
soft_delete_configuration = None
1029-
if enabled_soft_deletion is not None or \
1029+
if enable_soft_deletion is not None or \
10301030
soft_deletion_retention_period_in_minutes is not None or \
10311031
min_minutes_before_permanent_deletion_allowed is not None:
10321032
from azext_cosmosdb_preview.vendored_sdks.azure_mgmt_cosmosdb.models import SoftDeleteConfiguration
10331033
soft_delete_configuration = SoftDeleteConfiguration(
1034-
enabled_soft_deletion=enabled_soft_deletion,
1034+
enable_soft_deletion=enable_soft_deletion,
10351035
soft_deletion_retention_period_in_minutes=soft_deletion_retention_period_in_minutes,
10361036
min_minutes_before_permanent_deletion_allowed=min_minutes_before_permanent_deletion_allowed
10371037
)
@@ -1216,7 +1216,7 @@ def _create_database_account(client,
12161216
disable_ttl=None,
12171217
enable_partition_merge=None,
12181218
capacity_mode=None,
1219-
enabled_soft_deletion=None,
1219+
enable_soft_deletion=None,
12201220
soft_deletion_retention_period_in_minutes=None,
12211221
min_minutes_before_permanent_deletion_allowed=None):
12221222
consistency_policy = None
@@ -1299,12 +1299,12 @@ def _create_database_account(client,
12991299
analytical_storage_configuration.schema_type = analytical_storage_schema_type
13001300

13011301
soft_delete_configuration = None
1302-
if enabled_soft_deletion is not None or \
1302+
if enable_soft_deletion is not None or \
13031303
soft_deletion_retention_period_in_minutes is not None or \
13041304
min_minutes_before_permanent_deletion_allowed is not None:
13051305
from azext_cosmosdb_preview.vendored_sdks.azure_mgmt_cosmosdb.models import SoftDeleteConfiguration
13061306
soft_delete_configuration = SoftDeleteConfiguration(
1307-
enabled_soft_deletion=enabled_soft_deletion,
1307+
enabled_soft_deletion=enable_soft_deletion,
13081308
soft_deletion_retention_period_in_minutes=soft_deletion_retention_period_in_minutes,
13091309
min_minutes_before_permanent_deletion_allowed=min_minutes_before_permanent_deletion_allowed
13101310
)

src/cosmosdb-preview/azext_cosmosdb_preview/tests/latest/test_cosmosdb_softdelete_scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _create_account_with_soft_delete(self, account_name, resource_group, locatio
4646
logger.info("Enabling soft delete on account")
4747
self.cmd(
4848
'az cosmosdb update -n {acc} -g {rg} '
49-
'--enabled-soft-deletion true '
49+
'--enable-soft-deletion true '
5050
'--sd-retention 0 '
5151
'--min-purge-minutes 0'
5252
)

0 commit comments

Comments
 (0)