EnableGremlin capability to create post-GA graphs, fixes #352 (#376)

This commit is contained in:
Stephen Weatherford (MSFT) 2018-03-02 14:52:50 -08:00 коммит произвёл GitHub
Родитель 136709a289
Коммит d4f48794f0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 15 добавлений и 10 удалений

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

@ -711,7 +711,7 @@
},
"dependencies": {
"antlr4ts": "^0.4.0-alpha.4",
"azure-arm-cosmosdb": "^1.0.0-preview",
"azure-arm-cosmosdb": "^1.1.0-preview",
"azure-arm-resource": "^3.0.0-preview",
"azure-graph": "^2.2.0",
"copy-paste": "^1.3.0",

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

@ -6,7 +6,7 @@
import * as vscode from 'vscode';
import { ResourceModels, ResourceManagementClient, SubscriptionClient, SubscriptionModels } from 'azure-arm-resource';
import CosmosDBManagementClient = require("azure-arm-cosmosdb");
import { DatabaseAccount } from 'azure-arm-cosmosdb/lib/models';
import { DatabaseAccount, Capability } from 'azure-arm-cosmosdb/lib/models';
import { IAzureNode, UserCancelledError } from 'vscode-azureextensionui';
export async function createCosmosDBAccount(subscriptionNode: IAzureNode, showCreatingNode: (label: string) => void): Promise<DatabaseAccount> {
@ -28,16 +28,21 @@ export async function createCosmosDBAccount(subscriptionNode: IAzureNode, showCr
return await vscode.window.withProgress({ location: vscode.ProgressLocation.Window }, async (progress) => {
showCreatingNode(accountName);
progress.report({ message: `Cosmos DB: Creating account '${accountName}'` });
const docDBClient = new CosmosDBManagementClient(
subscriptionNode.credentials, subscriptionNode.subscription.subscriptionId);
await docDBClient.databaseAccounts.createOrUpdate(resourceGroupPick.resourceGroup.name,
accountName,
{
location: locationPick.location.name,
locations: [{ locationName: locationPick.location.name }],
kind: apiPick.kind,
tags: { defaultExperience: apiPick.defaultExperience }
});
let options = {
location: locationPick.location.name,
locations: [{ locationName: locationPick.location.name }],
kind: apiPick.kind,
tags: { defaultExperience: apiPick.defaultExperience },
capabilities: [
]
};
if (apiPick.defaultExperience === 'Graph') {
options.capabilities.push(<Capability>{ name: "EnableGremlin" });
}
await docDBClient.databaseAccounts.createOrUpdate(resourceGroupPick.resourceGroup.name, accountName, options);
// createOrUpdate always returns an empty object - so we have to get the DatabaseAccount separately
return await docDBClient.databaseAccounts.get(resourceGroupPick.resourceGroup.name, accountName);