Skip to content
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

Add CosmosDB RP API Version 2024-09-01-preview #7885

Merged
merged 28 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
89a598f
update SDK for 2024-09-01-preview version
carjackson-msft Aug 13, 2024
5018aa1
update SDK for 2024-09-01-preview version
carjackson-msft Aug 14, 2024
8468f1f
bump version
carjackson-msft Aug 16, 2024
806ba36
Initial commit
srwshkrshnn Sep 9, 2024
266b8a6
Addressed comments
srwshkrshnn Sep 12, 2024
4fc88f8
Merge pull request #8 from srwshkrshnn/dev/2024-09-01-preview
carjackson-msft Sep 12, 2024
3dda6e0
fix line endings to lf
carjackson-msft Sep 12, 2024
d2ac22d
Merge pull request #9 from carjackson-msft/fixLineEndings
carjackson-msft Sep 12, 2024
ddaf9d9
bump version properly
carjackson-msft Sep 12, 2024
a479bd7
add back missing file
carjackson-msft Sep 13, 2024
feb41d7
Recordings for the new preview API version
pjohari-ms Sep 17, 2024
893191b
nit: fix style/linter errors
carjackson-msft Sep 18, 2024
2d4ee91
Merge branch 'dev/2024-09-01-preview' of https://github.com/carjackso…
carjackson-msft Sep 18, 2024
da6ead7
update release version per pipeline.
carjackson-msft Sep 18, 2024
9a5aa2a
Merge branch 'main' of https://github.com/carjackson-msft/azure-cli-e…
carjackson-msft Sep 19, 2024
fcb94c1
re-record tests
carjackson-msft Sep 23, 2024
43ff48e
re-record tests
carjackson-msft Sep 24, 2024
4764940
Fixed linter error
srwshkrshnn Sep 25, 2024
d2653e8
Merge pull request #10 from srwshkrshnn/dev/2024-09-01-preview
carjackson-msft Sep 26, 2024
9a82382
Fixing linter issues
srwshkrshnn Sep 27, 2024
46965d1
Merge pull request #11 from srwshkrshnn/dev/2024-09-01-preview
carjackson-msft Sep 27, 2024
986fc1f
Revert "update release version per pipeline."
carjackson-msft Sep 30, 2024
5bf33e2
Reapply "update release version per pipeline."
carjackson-msft Oct 2, 2024
f728390
Source versioning
pjohari-ms Oct 15, 2024
217e413
1.1.0 Versioning instead of 1.0.X
pjohari-ms Oct 15, 2024
5709ed5
Merge remote-tracking branch 'azure/main' into dev/2024-09-01-preview
pjohari-ms Oct 16, 2024
9e3ee3b
Recorded again after updating cli-dev
pjohari-ms Oct 18, 2024
7d02f13
Rerecorded tests. Correctly
pjohari-ms Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/cosmosdb-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

Release History
===============
1.1.0b1
* Add support for Mongo (vCore) destination in container copy jobs.

+++++++
1.0.1
* Add support for CapacityMode in Global Database Accounts
* Add support for DistributedQuery flag in SqlDedicatedGateway
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
Expand Up @@ -824,6 +824,13 @@
Usage: --dest-mongo database=XX collection=XX'
database: Database name.
collection: Collection name.
- name: --dest-mongo-vcore
short-summary: "Destination Mongo(vCore) collection"
long-summary: |
Usage: --dest-mongo-vcore database=XX collection=XX connectionStringKeyVaultUri=XX'
database: Database name.
collection: Collection name.
connectionStringKeyVaultUri: Link to Azure KeyVault secret containing connection string.

examples:
- name: Copy Azure Cosmos DB API for NoSQL container in same account
Expand All @@ -838,6 +845,9 @@
- name: Copy Azure Cosmos DB API for MongoDB collection
text: |-
az cosmosdb copy create -g "rg1" --job-name "j1" --src-account "acc1" --dest-account "acc1" --src-mongo database=d1 collection=c1 --dest-mongo database=d2 collection=c2
- name: Copy Azure Cosmos DB API from MongoDB(RU) collection to Mongo(vCore) collection
text: |-
az cosmosdb copy create -g "rg1" --job-name "j1" --src-account "acc1" --src-mongo database=d1 collection=c1 --dest-mongo-vcore database=d2 collection=c2 connectionStringKeyVaultUri=<link_to_Azure_KeyVault_secret>
"""

helps['cosmosdb copy list'] = """
Expand Down
6 changes: 4 additions & 2 deletions src/cosmosdb-preview/azext_cosmosdb_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
CreateTableRestoreResource,
AddCassandraTableAction,
AddMongoCollectionAction,
AddMongoVCoreCollectionAction,
AddSqlContainerAction,
CreateTargetPhysicalPartitionThroughputInfoAction,
CreateSourcePhysicalPartitionThroughputInfoAction,
Expand Down Expand Up @@ -468,10 +469,11 @@ def load_arguments(self, _):
c.argument('src_account', help='Name of the Azure Cosmos DB source database account.', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part='name')
c.argument('dest_account', help='Name of the Azure Cosmos DB destination database account.', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part='name')
c.argument('src_cassandra', nargs='+', arg_group='Azure Cosmos DB API for Apache Cassandra table copy', action=AddCassandraTableAction, help='Source Cassandra table details')
c.argument('src_mongo', nargs='+', arg_group='Azure Cosmos DB API for MongoDB collection copy', action=AddMongoCollectionAction, help='Source Mongo collection details')
c.argument('src_mongo', nargs='+', arg_group='Azure Cosmos DB API for MongoDB (RU) collection copy', action=AddMongoCollectionAction, help='Source Mongo collection details')
c.argument('src_nosql', nargs='+', arg_group='Azure Cosmos DB API for NoSQL container copy', action=AddSqlContainerAction, help='Source NoSql container details')
c.argument('dest_cassandra', nargs='+', arg_group='Azure Cosmos DB API for Apache Cassandra table copy', action=AddCassandraTableAction, help='Destination Cassandra table details')
c.argument('dest_mongo', nargs='+', arg_group='Azure Cosmos DB API for MongoDB collection copy', action=AddMongoCollectionAction, help='Destination Mongo collection details')
c.argument('dest_mongo', nargs='+', arg_group='Azure Cosmos DB API for MongoDB (RU) collection copy', action=AddMongoCollectionAction, help='Destination Mongo collection details')
c.argument('dest_mongo_vcore', nargs='+', arg_group='Azure Cosmos DB API for MongoDB (vCore) collection copy', action=AddMongoVCoreCollectionAction, help='Destination Mongo vCore collection details')
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)
Expand Down
49 changes: 49 additions & 0 deletions src/cosmosdb-preview/azext_cosmosdb_preview/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
GremlinDatabaseRestoreResource,
CosmosCassandraDataTransferDataSourceSink,
CosmosMongoDataTransferDataSourceSink,
CosmosMongoVCoreDataTransferDataSourceSink,
CosmosSqlDataTransferDataSourceSink,
PhysicalPartitionThroughputInfoResource,
PhysicalPartitionId
Expand Down Expand Up @@ -184,6 +185,54 @@ def __call__(self, parser, namespace, values, option_string=None):
namespace.mongo_collection = mongo_collection


class AddMongoVCoreCollectionAction(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
if not values:
# pylint: disable=line-too-long
raise CLIError(f'usage error: {option_string} [KEY=VALUE ...]')

database_name = None
collection_name = None
host_name = None
connection_string_key_vault_uri = None

for (k, v) in (x.split('=', 1) for x in values):
kl = k.lower()
if kl == 'database':
database_name = v

elif kl == 'collection':
collection_name = v

elif kl == 'hostname':
host_name = v

elif kl == 'connectionstringkeyvaulturi':
connection_string_key_vault_uri = v

else:
raise CLIError(
f'Unsupported Key {k} is provided for {option_string} component. All'
' possible keys are: database, collection, hostname, connectionstringkeyvaulturi'
)

if database_name is None:
raise CLIError(f'usage error: missing key database in {option_string} component')

if collection_name is None:
raise CLIError(f'usage error: missing key collection in {option_string} component')

if host_name is None and connection_string_key_vault_uri is None:
raise CLIError(f'usage error: missing keys hostName and connectionStringKeyVaultUri in {option_string} component')

mongo_vcore_collection = CosmosMongoVCoreDataTransferDataSourceSink(database_name=database_name, collection_name=collection_name, host_name=host_name, connection_string_key_vault_uri=connection_string_key_vault_uri)

if option_string == "--dest-mongo-vcore":
namespace.dest_mongo_vcore = mongo_vcore_collection
else:
namespace.mongo_vcore_collection = mongo_vcore_collection


class AddSqlContainerAction(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
if not values:
Expand Down
16 changes: 12 additions & 4 deletions src/cosmosdb-preview/azext_cosmosdb_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1675,21 +1675,26 @@ def cosmosdb_data_transfer_copy_job(client,

def cosmosdb_copy_job(client,
resource_group_name,
dest_account,
src_account,
dest_account=None,
src_cassandra=None,
dest_cassandra=None,
src_nosql=None,
dest_nosql=None,
src_mongo=None,
dest_mongo=None,
dest_mongo_vcore=None,
job_name=None,
worker_count=0,
host_copy_on_src=False,
mode="Offline"):
job_create_properties = {}
is_cross_account = src_account != dest_account
if dest_account is None and dest_mongo_vcore is None:
raise CLIError('Invalid input: dest_account is a required parameter')

is_cross_account = False if dest_mongo_vcore is not None else src_account != dest_account
remote_account_name = dest_account if host_copy_on_src else src_account
host_account_name = src_account if (dest_mongo_vcore is not None or host_copy_on_src) else dest_account

source = None
if src_cassandra is not None:
Expand Down Expand Up @@ -1746,6 +1751,11 @@ def cosmosdb_copy_job(client,
else:
destination = dest_mongo

if dest_mongo_vcore is not None:
if destination is not None:
raise CLIError('Invalid input: multiple destination components')
destination = dest_mongo_vcore

if destination is None:
raise CLIError('destination component is missing')
job_create_properties['destination'] = destination
Expand All @@ -1761,8 +1771,6 @@ def cosmosdb_copy_job(client,
if job_name is None:
job_name = _gen_guid()

host_account_name = src_account if host_copy_on_src else dest_account

return client.create(resource_group_name=resource_group_name,
account_name=host_account_name,
job_name=job_name,
Expand Down
Loading
Loading