Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5237f10
Add generated SDK
vinhms Apr 27, 2022
3250f89
fix import
vinhms Apr 30, 2022
3bfe7bc
fix import again
vinhms May 2, 2022
36c8ccd
add continuous 7 tests and recordings
vinhms May 3, 2022
8ee0c1c
fix oldest restorable time
vinhms May 3, 2022
4fe2943
add oldest restorable test
vinhms May 3, 2022
724e926
fix lint and style
vinhms May 4, 2022
181c63a
add all recordings
vinhms May 4, 2022
2f51ba7
fix lint
vinhms May 10, 2022
b9f94f7
fix import
vinhms Apr 30, 2022
843966d
fix import again
vinhms May 2, 2022
fe6c6cb
add continuous 7 tests and recordings
vinhms May 3, 2022
8a3721c
fix oldest restorable time
vinhms May 3, 2022
3c0c461
add oldest restorable test
vinhms May 3, 2022
29a094d
fix lint and style
vinhms May 4, 2022
b0b7470
fix lint
vinhms May 10, 2022
3c441a5
merge latest
vinhms May 17, 2022
734aa84
Merge branch 'Azure:main' into main
vinhms May 17, 2022
ac9e2ec
revert changes in vendored_sdks folder
vinhms May 17, 2022
8f43e6e
Merge branch 'main' of https://github.com/vinhms/azure-cli-extensions
vinhms May 17, 2022
4cf020b
added merge commands for sql and mongo
amar-sagare May 17, 2022
0964a53
rerun all tests
vinhms May 17, 2022
06c49d9
Merge branch 'main' of https://github.com/vinhms/azure-cli-extensions
vinhms May 17, 2022
92895da
fix some stylings
vinhms May 17, 2022
02e0b57
az cli tests for merge
amar-sagare May 17, 2022
e2c3f73
Merge branch 'main' of https://github.com/vinhms/azure-cli-extensions…
amar-sagare May 17, 2022
12110a7
pylint fixes
amar-sagare May 17, 2022
a72e2ce
pylint fixes
amar-sagare May 18, 2022
fa8f9e9
more pylint fixes
amar-sagare May 18, 2022
d3674df
adding back simulation switch
amar-sagare May 18, 2022
7c15d76
linter checks
amar-sagare May 18, 2022
ec26843
revert is-simulation switch
amar-sagare May 18, 2022
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
6 changes: 6 additions & 0 deletions src/cosmosdb-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Release History
===============

0.17.0
++++++
* Add support for new Continuous 7 Days backup mode
* Add oldest restorable timestamp to indicate when the accounts can be restored to

0.16.0
++++++
* Create and manage data transfer jobs.
Expand Down
21 changes: 21 additions & 0 deletions src/cosmosdb-preview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This package provides commands to
- Create a new Azure Cosmos DB database account with materialized views
- Update an Azure Cosmos DB database account to enable materialized views
- Create/Delete a cosmosdb materialized views builder service resource
- Provision and update database account with Continuous 7 days backup mode

## How to use ##

Expand All @@ -30,6 +31,16 @@ az cosmosdb create \
--backup-policy-type "Continuous"
```

#### Create a new CosmosDB continuous backup Account with 7 days retention ####

```sh
az cosmosdb create \
--resource-group "my-rg" \
--name "my-continuous-backup-account" \
--backup-policy-type "Continuous"
--continuous-tier "Continuous7Days"
```

#### Convert a periodic backup policy CosmosDB account to continuous backup Account ####

```sh
Expand All @@ -39,6 +50,16 @@ az cosmosdb update \
--backup-policy-type "Continuous"
```

#### Convert a periodic backup policy CosmosDB account to continuous backup Account with 7 days retention ####

```sh
az cosmosdb update \
--resource-group "my-rg" \
--name "my-continuous-backup-account" \
--backup-policy-type "Continuous" \
--continuous-tier "Continuous7Days"
```

#### List all the CosmosDB accounts that can be restored (live and deleted) ####

This command returns all the continuous mode backup accounts that can be restored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def cf_mongo_db_resources(cli_ctx, _):
return cf_cosmosdb_preview(cli_ctx).mongo_db_resources


def cf_sql_resources(cli_ctx, _):
return cf_cosmosdb_preview(cli_ctx).sql_resources


def cf_gremlin_resources(cli_ctx, _):
return cf_cosmosdb_preview(cli_ctx).gremlin_resources

Expand Down Expand Up @@ -70,5 +74,9 @@ def cf_restorable_table_resources(cli_ctx, _):
return cf_cosmosdb_preview(cli_ctx).restorable_table_resources


def cf_restorable_database_accounts(cli_ctx, _):
return cf_cosmosdb_preview(cli_ctx).restorable_database_accounts


def cf_data_transfer_job(cli_ctx, _):
return cf_cosmosdb_preview(cli_ctx).data_transfer_jobs
18 changes: 18 additions & 0 deletions src/cosmosdb-preview/azext_cosmosdb_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,3 +624,21 @@
text: |-
az cosmosdb dts cancel --account-name "ddb1" --job-name "j1" -g "rg1"
"""

helps['cosmosdb sql container merge'] = """
type: command
short-summary: "Merges the partitions of a sql container."
examples:
- name: merge partitions of container my-container
text: |-
az cosmosdb sql container merge -g my-resource-group -a my-account -d my-db --name my-container
"""

helps['cosmosdb mongodb collection merge'] = """
type: command
short-summary: "Merges the partitions of a mongodb collection."
examples:
- name: merge partitions of collection my-mongodb-collection
text: |-
az cosmosdb mongodb collection merge -g my-resource-group -a my-account -d my-db --name my-mongodb-collection
"""
27 changes: 27 additions & 0 deletions src/cosmosdb-preview/azext_cosmosdb_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
from azext_cosmosdb_preview.actions import (
CreateGremlinDatabaseRestoreResource, CreateTableRestoreResource, AddCassandraTableAction, AddSqlContainerAction)

from azext_cosmosdb_preview.vendored_sdks.azure_mgmt_cosmosdb.models import (
ContinuousTier
)

from azure.cli.core.commands.parameters import (
tags_type, get_resource_name_completion_list, name_type, get_enum_type, get_three_state_flag, get_location_type)

Expand Down Expand Up @@ -210,6 +214,7 @@ def load_arguments(self, _):
c.argument('default_identity', help="The primary identity to access key vault in CMK related features. e.g. 'FirstPartyIdentity', 'SystemAssignedIdentity' and more.", is_preview=True)
c.argument('analytical_storage_schema_type', options_list=['--analytical-storage-schema-type', '--as-schema'], arg_type=get_enum_type(AnalyticalStorageSchemaType), help="Schema type for analytical storage.", arg_group='Analytical Storage Configuration')
c.argument('backup_policy_type', arg_type=get_enum_type(BackupPolicyType), help="The type of backup policy of the account to create", arg_group='Backup Policy')
c.argument('continuous_tier', arg_type=get_enum_type(ContinuousTier), help="The tier of Continuous backup", arg_group='Backup Policy')
c.argument('enable_materialized_views', options_list=['--enable-materialized-views', '--enable-mv'], arg_type=get_three_state_flag(), help="Flag to enable MaterializedViews on the account.", is_preview=True)

with self.argument_context('cosmosdb restore') as c:
Expand All @@ -221,6 +226,15 @@ def load_arguments(self, _):
c.argument('gremlin_databases_to_restore', nargs='+', action=CreateGremlinDatabaseRestoreResource, is_preview=True)
c.argument('tables_to_restore', nargs='+', action=CreateTableRestoreResource, is_preview=True)

# Restorable Database Accounts
with self.argument_context('cosmosdb restorable-database-account show') as c:
c.argument('location', options_list=['--location', '-l'], help="Location", required=False)
c.argument('instance_id', options_list=['--instance-id', '-i'], help="InstanceId of the Account", required=False)

with self.argument_context('cosmosdb restorable-database-account list') as c:
c.argument('location', options_list=['--location', '-l'], help="Location", required=False)
c.argument('account_name', options_list=['--account-name', '-n'], help="Name of the Account", required=False, id_part=None)

# Restorable Sql Containers
with self.argument_context('cosmosdb sql restorable-container') as c:
c.argument('location', options_list=['--location', '-l'], help="Location", required=True)
Expand Down Expand Up @@ -304,3 +318,16 @@ def load_arguments(self, _):
'cosmosdb dts cancel']:
with self.argument_context(scope) as c:
c.argument('job_name', options_list=['--job-name', '-n'], help='Name of the Data Transfer Job.')

# Sql container partition merge
database_name_type = CLIArgumentType(options_list=['--database-name', '-d'], help='Database name.')
with self.argument_context('cosmosdb sql container merge') as c:
c.argument('account_name', account_name_type, id_part=None, required=True, help='Name of the CosmosDB database account')
c.argument('database_name', database_name_type, required=True, help='Name of the CosmosDB database name')
c.argument('container_name', options_list=['--name', '-n'], required=True, help='Name of the CosmosDB collection')

# mongodb collection partition merge
with self.argument_context('cosmosdb mongodb collection merge') as c:
c.argument('account_name', account_name_type, id_part=None, required=True, help='Name of the CosmosDB database account')
c.argument('database_name', database_name_type, required=True, help='Name of the mongoDB database')
c.argument('container_name', options_list=['--name', '-n'], required=True, help='Name of the mongoDB collection')
27 changes: 27 additions & 0 deletions src/cosmosdb-preview/azext_cosmosdb_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
cf_cassandra_data_center,
cf_service,
cf_mongo_db_resources,
cf_sql_resources,
cf_db_accounts,
cf_gremlin_resources,
cf_table_resources,
Expand All @@ -21,6 +22,7 @@
cf_restorable_gremlin_resources,
cf_restorable_tables,
cf_restorable_table_resources,
cf_restorable_database_accounts,
cf_data_transfer_job
)

Expand Down Expand Up @@ -117,8 +119,13 @@ def load_command_table(self, _):
operations_tmpl='azext_cosmosdb_preview.vendored_sdks.azure_mgmt_cosmosdb.operations#RestorableTableResourcesOperations.{}',
client_factory=cf_restorable_table_resources)

cosmosdb_restorable_database_accounts_sdk = CliCommandType(
operations_tmpl='azure.mgmt.cosmosdb.operations#RestorableDatabaseAccountsOperations.{}',
client_factory=cf_restorable_database_accounts)

# define commands
# Restorable apis for sql,mongodb,gremlin and table
# Provisioning/migrate Continuous 7 days accounts
with self.command_group('cosmosdb', cosmosdb_sdk, client_factory=cf_db_accounts) as g:
g.custom_command('restore', 'cli_cosmosdb_restore', is_preview=True)
g.custom_command('create', 'cli_cosmosdb_create', is_preview=True)
Expand Down Expand Up @@ -147,6 +154,10 @@ def load_command_table(self, _):
with self.command_group('cosmosdb table restorable-resource', cosmosdb_restorable_table_resources_sdk, client_factory=cf_restorable_table_resources, is_preview=True) as g:
g.command('list', 'list')

with self.command_group('cosmosdb restorable-database-account', cosmosdb_restorable_database_accounts_sdk, client_factory=cf_restorable_database_accounts) as g:
g.custom_show_command('show', 'cli_cosmosdb_restorable_database_account_get_by_location')
g.custom_command('list', 'cli_cosmosdb_restorable_database_account_list')

# Retrieve backup info for gremlin
cosmosdb_gremlin_sdk = CliCommandType(
operations_tmpl='azure.mgmt.cosmosdb.operations#GremlinResourcesOperations.{}',
Expand Down Expand Up @@ -176,3 +187,19 @@ def load_command_table(self, _):
g.command('pause', 'pause')
g.command('resume', 'resume')
g.command('cancel', 'cancel')

# Merge partitions for Sql containers
cosmosdb_sql_sdk = CliCommandType(
operations_tmpl='azure.mgmt.cosmosdb.operations#SqlResourcesOperations.{}',
client_factory=cf_sql_resources)

with self.command_group('cosmosdb sql container', cosmosdb_sql_sdk, client_factory=cf_sql_resources) as g:
g.custom_command('merge', 'cli_begin_list_sql_container_partition_merge', is_preview=True)

# Merge partitions for mongodb collections
cosmosdb_mongo_sdk = CliCommandType(
operations_tmpl='azext_cosmosdb_preview.vendored_sdks.azure_mgmt_cosmosdb.operations#MongoDBResourcesOperations.{}',
client_factory=cf_mongo_db_resources)

with self.command_group('cosmosdb mongodb collection', cosmosdb_mongo_sdk, client_factory=cf_mongo_db_resources) as g:
g.custom_command('merge', 'cli_begin_list_mongo_db_collection_partition_merge', is_preview=True)
Loading