cosmosdb: add support for default ttl (#3761)

* documentdb cli minor improvement

* updates help description for credentials
* minor change to formatting of failure error message
* --coll-name changed to --collection-name

* documentdb: minor error message change

* pyproj updated to include all cosmosdb files

* cosmosdb: add support for collection default ttl

* cosmosdb: history file updated

* updated pyproj files

* fixed code style

* cosmosdb: review comments addressed

* addressed code style issue

* code style issue fixed

* logic simplified

* fixed history

* remove unwanted stashed changes

* remove unwanted files
This commit is contained in:
Mohammad Derakhshani 2017-06-19 22:04:16 -07:00 коммит произвёл Travis Prescott
Родитель 0ffb6b2c62
Коммит 0ef94e4176
6 изменённых файлов: 46 добавлений и 10 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -83,4 +83,5 @@ test_results/
artifacts/
# Nose test output
.noseids
.noseids

Просмотреть файл

@ -295,6 +295,18 @@
<Compile Include="command_modules\azure-cli-dls\setup.py" />
<Compile Include="command_modules\azure-cli-dls\tests\test_dls_commands.py" />
<Compile Include="command_modules\azure-cli-dls\tests\__init__.py" />
<Compile Include="command_modules\azure-cli-cosmosdb\azure\cli\command_modules\cosmosdb\commands.py" />
<Compile Include="command_modules\azure-cli-cosmosdb\azure\cli\command_modules\cosmosdb\custom.py" />
<Compile Include="command_modules\azure-cli-cosmosdb\azure\cli\command_modules\cosmosdb\_client_factory.py" />
<Compile Include="command_modules\azure-cli-cosmosdb\azure\cli\command_modules\cosmosdb\_exception_handler.py" />
<Compile Include="command_modules\azure-cli-cosmosdb\azure\cli\command_modules\cosmosdb\_help.py" />
<Compile Include="command_modules\azure-cli-cosmosdb\azure\cli\command_modules\cosmosdb\_params.py" />
<Compile Include="command_modules\azure-cli-cosmosdb\azure\cli\command_modules\cosmosdb\_command_type.py" />
<Compile Include="command_modules\azure-cli-cosmosdb\azure\cli\command_modules\cosmosdb\__init__.py" />
<Compile Include="command_modules\azure-cli-cosmosdb\azure_bdist_wheel.py" />
<Compile Include="command_modules\azure-cli-cosmosdb\setup.py" />
<Compile Include="command_modules\azure-cli-cosmosdb\tests\test_documentdb_commands.py" />
<Compile Include="command_modules\azure-cli-cosmosdb\tests\__init__.py" />
<Compile Include="command_modules\azure-cli-feedback\azure\cli\command_modules\feedback\commands.py" />
<Compile Include="command_modules\azure-cli-feedback\azure\cli\command_modules\feedback\custom.py" />
<Compile Include="command_modules\azure-cli-feedback\azure\cli\command_modules\feedback\_help.py">
@ -863,6 +875,12 @@
<Folder Include="command_modules\azure-cli-dls\azure\cli\command_modules\" />
<Folder Include="command_modules\azure-cli-dls\azure\cli\command_modules\dls\" />
<Folder Include="command_modules\azure-cli-dls\tests\" />
<Folder Include="command_modules\azure-cli-cosmosdb\" />
<Folder Include="command_modules\azure-cli-cosmosdb\azure\" />
<Folder Include="command_modules\azure-cli-cosmosdb\azure\cli\" />
<Folder Include="command_modules\azure-cli-cosmosdb\azure\cli\command_modules\" />
<Folder Include="command_modules\azure-cli-cosmosdb\azure\cli\command_modules\cosmosdb\" />
<Folder Include="command_modules\azure-cli-cosmosdb\tests\" />
<Folder Include="command_modules\azure-cli-feedback\" />
<Folder Include="command_modules\azure-cli-feedback\azure\" />
<Folder Include="command_modules\azure-cli-feedback\azure\cli\" />
@ -1073,6 +1091,7 @@
<Content Include="command_modules\azure-cli-dls\HISTORY.rst" />
<Content Include="command_modules\azure-cli-dls\MANIFEST.in" />
<Content Include="command_modules\azure-cli-dls\README.rst" />
<Content Include="command_modules\azure-cli-cosmosdb\HISTORY.rst" />
<Content Include="command_modules\azure-cli-feedback\HISTORY.rst" />
<Content Include="command_modules\azure-cli-find\HISTORY.rst" />
<Content Include="command_modules\azure-cli-find\MANIFEST.in" />
@ -1153,4 +1172,4 @@
</ItemGroup>
<Import Project="$(PtvsTargetsFile)" Condition="Exists($(PtvsTargetsFile))" />
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" Condition="!Exists($(PtvsTargetsFile))" />
</Project>
</Project>

Просмотреть файл

@ -243,7 +243,6 @@
<Compile Include="command_modules\azure-cli-dls\setup.py" />
<Compile Include="command_modules\azure-cli-dls\tests\test_dls_commands.py" />
<Compile Include="command_modules\azure-cli-dls\tests\__init__.py" />
<Compile Include="command_modules\azure-cli-documentdb\setup.py" />
<Compile Include="command_modules\azure-cli-feedback\azure\cli\command_modules\feedback\commands.py" />
<Compile Include="command_modules\azure-cli-feedback\azure\cli\command_modules\feedback\custom.py" />
<Compile Include="command_modules\azure-cli-feedback\azure\cli\command_modules\feedback\_help.py">
@ -936,4 +935,4 @@
</Interpreter>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
</Project>
</Project>

Просмотреть файл

@ -2,6 +2,12 @@
Release History
===============
unreleased
++++++++++++++++++
* Added Support for Collection Default TTL.
0.1.8 (2017-06-13)
++++++++++++++++++
* Remove useless line-too-long suppression
@ -14,6 +20,7 @@ Release History
0.1.6 (2017-05-09)
++++++++++++++++++
* Rename documentdb module to cosmosdb.
0.1.5 (2017-05-05)

Просмотреть файл

@ -90,3 +90,5 @@ register_cli_argument('cosmosdb collection', 'indexing_policy',
options_list=('--indexing-policy'),
help='Indexing Policy, you can enter it as a string or as a file, e.g., --indexing-policy @policy-file.json)',
type=shell_safe_json_parse, completer=FilesCompleter())
register_cli_argument('cosmosdb collection', 'default_ttl', help='Default TTL', type=int)

Просмотреть файл

@ -217,19 +217,23 @@ def cli_cosmosdb_collection_delete(client, database_id, collection_id):
def _populate_collection_definition(collection,
partition_key_path=None,
default_ttl=None,
indexing_policy=None):
changed = False
if all(arg is None for arg in [partition_key_path, default_ttl, indexing_policy]):
return False
if partition_key_path:
if partition_key_path is not None:
if 'partitionKey' not in collection:
collection['partitionKey'] = {}
collection['partitionKey'] = {'paths': [partition_key_path]}
changed = True
if indexing_policy:
changed = True
if default_ttl is not None:
collection['defaultTtl'] = default_ttl
if indexing_policy is not None:
collection['indexingPolicy'] = indexing_policy
return changed
return True
def cli_cosmosdb_collection_create(client,
@ -237,6 +241,7 @@ def cli_cosmosdb_collection_create(client,
collection_id,
throughput=None,
partition_key_path=None,
default_ttl=None,
indexing_policy=DEFAULT_INDEXING_POLICY):
"""Creates an Azure Cosmos DB collection """
collection = {'id': collection_id}
@ -247,6 +252,7 @@ def cli_cosmosdb_collection_create(client,
_populate_collection_definition(collection,
partition_key_path,
default_ttl,
indexing_policy)
created_collection = client.CreateCollection(_get_database_link(database_id), collection,
@ -268,6 +274,7 @@ def cli_cosmosdb_collection_update(client,
database_id,
collection_id,
throughput=None,
default_ttl=None,
indexing_policy=None):
"""Updates an Azure Cosmos DB collection """
logger.debug('reading collection')
@ -276,6 +283,7 @@ def cli_cosmosdb_collection_update(client,
if (_populate_collection_definition(collection,
None,
default_ttl,
indexing_policy)):
logger.debug('replacing collection')
result['collection'] = client.ReplaceCollection(