Skip to content

Commit

Permalink
[CosmosDB] az cosmosdb delete: Add --no-wait (#29190)
Browse files Browse the repository at this point in the history
* Support for CosmosDB delete no-await

* Wire up a delete

* Update src/azure-cli/azure/cli/command_modules/cosmosdb/commands.py

Co-authored-by: Yishi Wang <[email protected]>

* Update src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py

---------

Co-authored-by: Daniel Marbach <[email protected]>
Co-authored-by: Yishi Wang <[email protected]>
  • Loading branch information
3 people authored Jul 30, 2024
1 parent 45d1bb5 commit 0350d00
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@
- name: Deletes an Azure Cosmos DB database account. (autogenerated)
text: az cosmosdb delete --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup
crafted: true
- name: an Azure Cosmos DB database account without waiting for the long-running operation to finish.
text: az cosmosdb delete --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --no-wait
"""

helps['cosmosdb failover-priority-change'] = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def load_command_table(self, _):
g.command('list-connection-strings', 'list_connection_strings', table_transformer=list_connection_strings_output, deprecate_info=g.deprecate(redirect='cosmosdb keys list --type connection-strings', hide=True))
g.custom_command('regenerate-key', 'cli_cosmosdb_regenerate_key', deprecate_info=g.deprecate(redirect='cosmosdb keys regenerate', hide=True))
g.command('check-name-exists', 'check_name_exists')
g.command('delete', 'begin_delete', confirmation=True)
g.custom_command('delete', 'cli_cosmosdb_delete', confirmation=True, supports_no_wait=True)
g.command('failover-priority-change', 'begin_failover_priority_change')
g.custom_command('create', 'cli_cosmosdb_create', transform=transform_db_account_json_output)
g.custom_command('update', 'cli_cosmosdb_update', transform=transform_db_account_json_output)
Expand Down
5 changes: 5 additions & 0 deletions src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,11 @@ def cli_cosmosdb_update(client,
return docdb_account


def cli_cosmosdb_delete(client, resource_group_name, account_name, no_wait=False):
return sdk_no_wait(no_wait, client.begin_delete,
resource_group_name=resource_group_name, account_name=account_name)


def cli_cosmosdb_list(client, resource_group_name=None):
""" Lists all Azure Cosmos DB database accounts within a given resource group or subscription. """
if resource_group_name:
Expand Down

0 comments on commit 0350d00

Please sign in to comment.