Skip to content

Commit

Permalink
[cosmosdb-preview] Add support for new api version 2024-02-15-preview (
Browse files Browse the repository at this point in the history
…#7271)

* add new sdk

* update version

* update sdk

* cli changes for PRPP

* variable name fix, added test case

* Add mode in copy job

(cherry picked from commit a28144517ad4022098561e83d8607c93933dd36c)

* Add complete job API

(cherry picked from commit 3d721cb)
(cherry picked from commit f4e6f01f99eb1299e8c536423f074e9832b71e16)

* Add test

* history.rst changes

* Add history

* Introduce disable_ttl parameter

* Syntax error fixes

* Update tests

* Fix syntax error

* Change test location to WestCentralUS where 0201 batch1 is completed, add remaining asserts, rerecordings

* Update history file

* Changed cluster deallocate force input to string

* add missing changes from stable Azure/azure-cli#26226

* add stable changes https://github.com/Azure/azure-cli/pull/27175/files

* https://github.com/Azure/azure-cli/pull/27322/files

* add missing stable changes from https://github.com/Azure/azure-cli/pull/26392/files

* Revert "https://github.com/Azure/azure-cli/pull/27322/files"

This reverts commit f779e16.

* add missing stable changes for minimal tls version from Azure/azure-cli#27322

* nit

* Revert "nit"

This reverts commit d4f4abe.

* Revert "add missing stable changes for minimal tls version from Azure/azure-cli#27322"

This reverts commit be4709e.

* fix style checl

* Address multi character short flag issue

* Add missing parameters

* Fix syntax issue

* Remove short flag

* fix test

* poc for test changes

* inital changes in custom.py

* removing recordings

* changes in params as well as test and recording for sql ntbr flow

* fixing imports

* fixing test

* fixing recordings

* config name change from --enable-per-region-per-partition-autoscale to --enable-prpp-autoscale

* re-record tests

* nit style

* Revert "fixing recordings"

This reverts commit ea5c847.

* Revert "removing recordings"

This reverts commit 583371c.

* fixing incorrect merge

* Added test

* 6 out of 8 test failures

* fixing remaining 2 tests

* fixing style issues

* Update HISTORY.rst to reflect changes ported from stable CLI

* re-record cassandra tests

* Update version to 1.0.0 due to breaking changes

* azdev style fixes

* azdev style fixes

* azdev style fixes

* azdev style fixes

* azdev style fixes

* azdev style fixes

* Update HISTORY.rst version to 1.0.0

---------

Co-authored-by: Kushal Warke <kuwarke@microsoft.com>
Co-authored-by: Nitesh Vijay <niteshvijay@microsoft.com>
Co-authored-by: Nitesh Vijay <niteshvijay1995@gmail.com>
Co-authored-by: Min Ho Kang <minhokang@microsoft.com>
Co-authored-by: drewkaufmann <drewkaufmann@microsoft.com>
Co-authored-by: Vivek Agarwal (from Dev Box) <agarwalvivek@microsoft.com>
Co-authored-by: AgarwalVivek <vagarwal1@hawk.iit.edu>
  • Loading branch information
8 people authored Mar 20, 2024
1 parent 76dd266 commit 7e7e029
Show file tree
Hide file tree
Showing 130 changed files with 93,574 additions and 53,018 deletions.
10 changes: 10 additions & 0 deletions src/cosmosdb-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@
Release History
===============
1.0.0
* Add support for Per-Region Per-Partition Autoscale. '--enable-prpp-autoscale' parameter can be used during account create/update.
* Add support for Restore with Time-To-Live Disabled. '--disable-ttl' parameter can be used during restore.
* Add support for online mode in container copy job.
* Add support for minimum allowed TLS version configuration
* BREAKING CHANGE: az cosmosdb create/update: Rename --enable-public-network true/false to --public-network-access ENABLED/DISABLED/SECUREDBYPERIMETER
* BREAKING CHANGE: az cosmosdb restore: Rename --enable-public-network true/false to --public-network-access ENABLED/DISABLED

++++++
0.26.0
* Add '--enable-priority-based-execution' and '--default-priority-level' parameter for create/update database account.
* Add support for cross account container copy
* Add Non-CMK to CMK support
* Removed preview tag from CMK related properties

++++++
0.25.0
* Add support for performing database merge for Sql and MongoDB database account.

Expand Down
10 changes: 10 additions & 0 deletions src/cosmosdb-preview/azext_cosmosdb_preview/_help.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=too-many-lines
# coding=utf-8
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
Expand Down Expand Up @@ -884,6 +885,15 @@
az cosmosdb copy cancel -g "rg1" --account-name "acc1" --job-name "j1"
"""

helps['cosmosdb copy complete'] = """
type: command
short-summary: "Completes an online container copy job."
examples:
- name: Complete job j1
text: |-
az cosmosdb copy complete -g "rg1" --account-name "acc1" --job-name "j1"
"""

helps['cosmosdb sql container merge'] = """
type: command
short-summary: "Merges the partitions of a sql container."
Expand Down
36 changes: 25 additions & 11 deletions src/cosmosdb-preview/azext_cosmosdb_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ def load_arguments(self, _):
c.argument('databases_to_restore', nargs='+', action=CreateDatabaseRestoreResource, is_preview=True, arg_group='Restore')
c.argument('gremlin_databases_to_restore', nargs='+', action=CreateGremlinDatabaseRestoreResource, is_preview=True, arg_group='Restore')
c.argument('tables_to_restore', nargs='+', action=CreateTableRestoreResource, is_preview=True, arg_group='Restore')
c.argument('enable_partition_merge', arg_type=get_three_state_flag(), help="Flag to enable partition merge on the account.")

for scope in ['cosmosdb create', 'cosmosdb update']:
with self.argument_context(scope) as c:
Expand All @@ -324,7 +325,7 @@ def load_arguments(self, _):
c.argument('virtual_network_rules', nargs='+', validator=validate_virtual_network_rules, help='ACL\'s for virtual network')
c.argument('enable_multiple_write_locations', arg_type=get_three_state_flag(), help="Enable Multiple Write Locations")
c.argument('disable_key_based_metadata_write_access', arg_type=get_three_state_flag(), help="Disable write operations on metadata resources (databases, containers, throughput) via account keys")
c.argument('enable_public_network', options_list=['--enable-public-network', '-e'], arg_type=get_three_state_flag(), help="Enable or disable public network access to server.")
c.argument('public_network_access', options_list=['--public-network-access', '-p'], arg_type=get_enum_type(['ENABLED', 'DISABLED', 'SECUREDBYPERIMETER']), help="Sets public network access in server to either Enabled, Disabled, or SecuredByPerimeter.")
c.argument('enable_analytical_storage', arg_type=get_three_state_flag(), help="Flag to enable log storage on the account.")
c.argument('network_acl_bypass', arg_type=get_enum_type(NetworkAclBypass), options_list=['--network-acl-bypass'], help="Flag to enable or disable Network Acl Bypass.")
c.argument('network_acl_bypass_resource_ids', nargs='+', options_list=['--network-acl-bypass-resource-ids', '-i'], help="List of Resource Ids to allow Network Acl Bypass.")
Expand All @@ -340,6 +341,8 @@ def load_arguments(self, _):
c.argument('enable_burst_capacity', arg_type=get_three_state_flag(), help="Flag to enable burst capacity on the account.", is_preview=True)
c.argument('enable_priority_based_execution', options_list=['--enable-priority-based-execution', '--enable-pbe'], arg_type=get_three_state_flag(), help="Flag to enable priority based execution on the account.", is_preview=True)
c.argument('default_priority_level', arg_type=get_enum_type(DefaultPriorityLevel), help="Default Priority Level of Request if not specified.", is_preview=True)
c.argument('enable_prpp_autoscale', arg_type=get_three_state_flag(), help="Enable or disable PerRegionPerPartitionAutoscale.", is_preview=True)
c.argument('enable_partition_merge', arg_type=get_three_state_flag(), help="Flag to enable partition merge on the account.")

with self.argument_context('cosmosdb update') as c:
c.argument('key_uri', help="The URI of the key vault", is_preview=True)
Expand All @@ -354,8 +357,9 @@ def load_arguments(self, _):
c.argument('tables_to_restore', nargs='+', action=CreateTableRestoreResource, is_preview=True)
c.argument('assign_identity', nargs='*', help="Assign system or user assigned identities separated by spaces. Use '[system]' to refer system assigned identity.")
c.argument('default_identity', help="The primary identity to access key vault in CMK related features. e.g. 'FirstPartyIdentity', 'SystemAssignedIdentity' and more.")
c.argument('enable_public_network', options_list=['--enable-public-network', '-e'], arg_type=get_three_state_flag(), help="Enable or disable public network access to server.", is_preview=True)
c.argument('public_network_access', options_list=['--public-network-access', '-p'], arg_type=get_enum_type(['ENABLED', 'DISABLED']), help="Sets public network access in server to either Enabled or Disabled.")
c.argument('source_backup_location', help="This is the location of the source account where backups are located. Provide this value if the source and target are in different locations.", is_preview=True)
c.argument('disable_ttl', options_list=['--disable-ttl'], arg_type=get_three_state_flag(), help="Enable or disable restoring with ttl disabled.", is_preview=True)

# Restorable Database Accounts
with self.argument_context('cosmosdb restorable-database-account show') as c:
Expand Down Expand Up @@ -464,21 +468,24 @@ def load_arguments(self, _):
c.argument('dest_nosql', nargs='+', arg_group='Azure Cosmos DB API for NoSQL container copy', action=AddSqlContainerAction, help='Destination NoSql container details')
c.argument('host_copy_on_src', arg_type=get_three_state_flag(), help=argparse.SUPPRESS)
c.argument('worker_count', type=int, help=argparse.SUPPRESS)
c.argument('mode', help='Copy Mode (Online / Offline)')

for scope in [
'cosmosdb copy list',
'cosmosdb copy show',
'cosmosdb copy pause',
'cosmosdb copy resume',
'cosmosdb copy cancel']:
'cosmosdb copy cancel',
'cosmosdb copy complete']:
with self.argument_context(scope) as c:
c.argument('account_name', options_list=["--account-name", "-a"], id_part=None, required=True, help='Azure Cosmos DB account name where the job is created. Use --dest-account value from create job command.')

for scope in [
'cosmosdb copy show',
'cosmosdb copy pause',
'cosmosdb copy resume',
'cosmosdb copy cancel']:
'cosmosdb copy cancel',
'cosmosdb copy complete']:
with self.argument_context(scope) as c:
c.argument('job_name', options_list=['--job-name', '-n'], help='Name of the container copy job.', required=True)

Expand Down Expand Up @@ -563,43 +570,50 @@ def load_arguments(self, _):
with self.argument_context('cosmosdb sql database restore') as c:
c.argument('account_name', account_name_type, id_part=None, required=True)
c.argument('database_name', options_list=['--name', '-n'], help="Database name", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the database needs to be restored to.", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the database needs to be restored to.", required=False)
c.argument('disable_ttl', options_list=['--disable-ttl'], arg_type=get_three_state_flag(), help="Enable or disable restoring with ttl disabled.", is_preview=True, required=False)

# SQL collection restore
with self.argument_context('cosmosdb sql container restore') as c:
c.argument('account_name', account_name_type, id_part=None, required=True)
c.argument('database_name', database_name_type, required=True)
c.argument('container_name', options_list=['--name', '-n'], help="Container name", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the container needs to be restored to.", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the container needs to be restored to.", required=False)
c.argument('disable_ttl', options_list=['--disable-ttl'], arg_type=get_three_state_flag(), help="Enable or disable restoring with ttl disabled.", is_preview=True, required=False)

# MongoDB database restore
with self.argument_context('cosmosdb mongodb database restore') as c:
c.argument('account_name', account_name_type, id_part=None, required=True)
c.argument('database_name', options_list=['--name', '-n'], help="Database name", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the database needs to be restored to.", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the database needs to be restored to.", required=False)
c.argument('disable_ttl', options_list=['--disable-ttl'], arg_type=get_three_state_flag(), help="Enable or disable restoring with ttl disabled.", is_preview=True, required=False)

# MongoDB collection restore
with self.argument_context('cosmosdb mongodb collection restore') as c:
c.argument('account_name', account_name_type, id_part=None, required=True)
c.argument('database_name', database_name_type, required=True)
c.argument('collection_name', options_list=['--name', '-n'], help="Collection name", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the collection needs to be restored to.", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the collection needs to be restored to.", required=False)
c.argument('disable_ttl', options_list=['--disable-ttl'], arg_type=get_three_state_flag(), help="Enable or disable restoring with ttl disabled.", is_preview=True, required=False)

# Gremlin database restore
with self.argument_context('cosmosdb gremlin database restore') as c:
c.argument('account_name', account_name_type, id_part=None, required=True)
c.argument('database_name', options_list=['--name', '-n'], help="Name of the CosmosDB Gremlin database name", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the database needs to be restored to.", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the database needs to be restored to.", required=False)
c.argument('disable_ttl', options_list=['--disable-ttl'], arg_type=get_three_state_flag(), help="Enable or disable restoring with ttl disabled.", is_preview=True, required=False)

# Gremlin Graph restore
with self.argument_context('cosmosdb gremlin graph restore') as c:
c.argument('account_name', account_name_type, id_part=None, required=True)
c.argument('database_name', database_name_type, required=True, help='Name of the CosmosDB Gremlin database name')
c.argument('graph_name', options_list=['--name', '-n'], help="Name of the CosmosDB Gremlin graph name", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the graph needs to be restored to.", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the graph needs to be restored to.", required=False)
c.argument('disable_ttl', options_list=['--disable-ttl'], arg_type=get_three_state_flag(), help="Enable or disable restoring with ttl disabled.", is_preview=True, required=False)

# Table restore
with self.argument_context('cosmosdb table restore') as c:
c.argument('account_name', account_name_type, id_part=None, required=True)
c.argument('table_name', options_list=['--table-name', '-n'], required=True, help='Name of the CosmosDB Table name')
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the Table needs to be restored to.", required=True)
c.argument('restore_timestamp', options_list=['--restore-timestamp', '-t'], action=UtcDatetimeAction, help="The timestamp to which the Table needs to be restored to.", required=False)
c.argument('disable_ttl', options_list=['--disable-ttl'], arg_type=get_three_state_flag(), help="Enable or disable restoring with ttl disabled.", is_preview=True, required=False)
1 change: 1 addition & 0 deletions src/cosmosdb-preview/azext_cosmosdb_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def load_command_table(self, _):
g.command('pause', 'pause')
g.command('resume', 'resume')
g.command('cancel', 'cancel')
g.command('complete', 'complete')

# Merge partitions for Sql containers
cosmosdb_sql_sdk = CliCommandType(
Expand Down
Loading

0 comments on commit 7e7e029

Please sign in to comment.