Skip to content

Commit 328b744

Browse files
shlawrence227Sheril Maria Lawrence
and
Sheril Maria Lawrence
authored
[CosmosDB] az cosmosdb offline-region: New command to support offline region for cosmosdb account (#30781)
Co-authored-by: Sheril Maria Lawrence <shlawrence@microsoft.com>
1 parent f82d963 commit 328b744

File tree

6 files changed

+983
-1
lines changed

6 files changed

+983
-1
lines changed

src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py

+9
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,15 @@
309309
crafted: true
310310
"""
311311

312+
helps['cosmosdb offline-region'] = """
313+
type: command
314+
short-summary: Offline the specified region for the specified Azure Cosmos DB database account.
315+
examples:
316+
- name: Offlines North Europe regional account for the Azure Cosmos DB database account MyCosmosDBDatabaseAccount.
317+
text: az cosmosdb offline-region --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --region NorthEurope
318+
crafted: true
319+
"""
320+
312321
helps['cosmosdb gremlin'] = """
313322
type: group
314323
short-summary: Manage Gremlin resources of Azure Cosmos DB account.

src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py

+3
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ def load_arguments(self, _):
142142
c.argument('failover_parameters', options_list=['--failover-policies'], validator=validate_failover_policies,
143143
help="space-separated failover policies in 'regionName=failoverPriority' format. Number of policies must match the number of regions the account is currently replicated. All regionName values must match those of the regions the account is currently replicated. All failoverPriority values must be unique. There must be one failoverPriority value zero (0) specified. All remaining failoverPriority values can be any positive integer and they don't have to be contiguos, neither written in any specific order. E.g eastus=0 westus=1", nargs='+')
144144

145+
with self.argument_context('cosmosdb offline-region') as c:
146+
c.argument('region', help='The region to offline for the CosmosDB account.')
147+
145148
with self.argument_context('cosmosdb network-rule list') as c:
146149
c.argument('account_name', id_part=None)
147150

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

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def load_command_table(self, _):
167167
g.command('check-name-exists', 'check_name_exists')
168168
g.custom_command('delete', 'cli_cosmosdb_delete', confirmation=True, supports_no_wait=True)
169169
g.command('failover-priority-change', 'begin_failover_priority_change')
170+
g.custom_command('offline-region', 'cli_offline_region')
170171
g.custom_command('create', 'cli_cosmosdb_create', transform=transform_db_account_json_output)
171172
g.custom_command('update', 'cli_cosmosdb_update', transform=transform_db_account_json_output)
172173
g.custom_command('list', 'cli_cosmosdb_list', transform=transform_db_account_list_output)

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

+15-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
DedicatedGatewayType,
7373
ServiceType,
7474
MongoRoleDefinitionCreateUpdateParameters,
75-
MongoUserDefinitionCreateUpdateParameters
75+
MongoUserDefinitionCreateUpdateParameters,
76+
RegionForOnlineOffline
7677
)
7778

7879
logger = get_logger(__name__)
@@ -3523,3 +3524,16 @@ def cli_cosmosdb_service_update(client,
35233524
)
35243525

35253526
return client.begin_create(resource_group_name, account_name, service_name, create_update_parameters=params)
3527+
3528+
3529+
def cli_offline_region(client,
3530+
account_name,
3531+
resource_group_name,
3532+
region):
3533+
3534+
region_parameter_for_offline = RegionForOnlineOffline(region=region)
3535+
return client.begin_offline_region(
3536+
resource_group_name=resource_group_name,
3537+
account_name=account_name,
3538+
region_parameter_for_offline=region_parameter_for_offline
3539+
)

0 commit comments

Comments
 (0)