Create Cassandra Keyspace via ARM (#142)
This commit is contained in:
parent
cb5fe5316e
commit
2752d6af00
|
@ -421,7 +421,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
|
||||||
startKey: number
|
startKey: number
|
||||||
): void {
|
): void {
|
||||||
if (EnvironmentUtility.isAadUser()) {
|
if (EnvironmentUtility.isAadUser()) {
|
||||||
this._createKeyspaceUsingRP(this.container.armEndpoint(), createDatabaseParameters, autoPilotSettings, startKey);
|
this._createKeyspaceUsingRP(createDatabaseParameters, autoPilotSettings, startKey);
|
||||||
} else {
|
} else {
|
||||||
this._createKeyspaceUsingProxy(createDatabaseParameters.offerThroughput, startKey);
|
this._createKeyspaceUsingProxy(createDatabaseParameters.offerThroughput, startKey);
|
||||||
}
|
}
|
||||||
|
@ -450,12 +450,11 @@ export default class AddDatabasePane extends ContextualPaneBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _createKeyspaceUsingRP(
|
private _createKeyspaceUsingRP(
|
||||||
armEndpoint: string,
|
|
||||||
createKeyspaceParameters: DataModels.RpParameters,
|
createKeyspaceParameters: DataModels.RpParameters,
|
||||||
autoPilotSettings: DataModels.RpOptions,
|
autoPilotSettings: DataModels.RpOptions,
|
||||||
startKey: number
|
startKey: number
|
||||||
): void {
|
): void {
|
||||||
AddDbUtilities.createCassandraKeyspace(armEndpoint, createKeyspaceParameters, autoPilotSettings).then(() => {
|
AddDbUtilities.createCassandraKeyspace(createKeyspaceParameters, autoPilotSettings).then(() => {
|
||||||
Promise.all([refreshCachedOffers(), refreshCachedResources()]).then(() => {
|
Promise.all([refreshCachedOffers(), refreshCachedResources()]).then(() => {
|
||||||
this._onCreateDatabaseSuccess(createKeyspaceParameters.offerThroughput, startKey);
|
this._onCreateDatabaseSuccess(createKeyspaceParameters.offerThroughput, startKey);
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||||
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
|
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
|
||||||
import { userContext } from "../UserContext";
|
import { userContext } from "../UserContext";
|
||||||
|
import { createUpdateCassandraKeyspace } from "../Utils/arm/generatedClients/2020-04-01/cassandraResources";
|
||||||
|
|
||||||
export class AddDbUtilities {
|
export class AddDbUtilities {
|
||||||
// todo - remove any
|
// todo - remove any
|
||||||
|
@ -47,7 +48,6 @@ export class AddDbUtilities {
|
||||||
|
|
||||||
// todo - remove any
|
// todo - remove any
|
||||||
public static async createCassandraKeyspace(
|
public static async createCassandraKeyspace(
|
||||||
armEndpoint: string,
|
|
||||||
params: DataModels.RpParameters,
|
params: DataModels.RpParameters,
|
||||||
rpOptions: DataModels.RpOptions
|
rpOptions: DataModels.RpOptions
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
|
@ -70,9 +70,11 @@ export class AddDbUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await AddDbUtilities.getRpClient<DataModels.CreateDatabaseWithRpResponse>(armEndpoint).putAsync(
|
await createUpdateCassandraKeyspace(
|
||||||
AddDbUtilities._getCassandraKeyspaceUri(params),
|
userContext.subscriptionId,
|
||||||
DataExplorerConstants.ArmApiVersions.publicVersion,
|
userContext.resourceGroup,
|
||||||
|
userContext.databaseAccount?.name,
|
||||||
|
params.db,
|
||||||
rpPayloadToCreateKeyspace
|
rpPayloadToCreateKeyspace
|
||||||
);
|
);
|
||||||
} catch (reason) {
|
} catch (reason) {
|
||||||
|
@ -159,10 +161,7 @@ export class AddDbUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static _handleCreationError(reason: any, params: DataModels.RpParameters, dbType: string = "database") {
|
private static _handleCreationError(reason: any, params: DataModels.RpParameters, dbType: string = "database") {
|
||||||
NotificationConsoleUtils.logConsoleMessage(
|
NotificationConsoleUtils.logConsoleError(`Error creating ${dbType}: ${JSON.stringify(reason)}, Payload: ${params}`);
|
||||||
ConsoleDataType.Error,
|
|
||||||
`Error creating ${dbType}: ${JSON.stringify(reason)}, Payload: ${params}`
|
|
||||||
);
|
|
||||||
if (reason.status === HttpStatusCodes.Forbidden) {
|
if (reason.status === HttpStatusCodes.Forbidden) {
|
||||||
sendMessage({ type: MessageTypes.ForbiddenError });
|
sendMessage({ type: MessageTypes.ForbiddenError });
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -39,7 +39,7 @@ export async function createUpdateCassandraKeyspace(
|
||||||
body: Types.CassandraKeyspaceCreateUpdateParameters
|
body: Types.CassandraKeyspaceCreateUpdateParameters
|
||||||
): Promise<Types.CassandraKeyspaceGetResults | void> {
|
): Promise<Types.CassandraKeyspaceGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB Cassandra keyspace. */
|
/* Deletes an existing Azure Cosmos DB Cassandra keyspace. */
|
||||||
|
@ -73,7 +73,7 @@ export async function updateCassandraKeyspaceThroughput(
|
||||||
body: Types.ThroughputSettingsUpdateParameters
|
body: Types.ThroughputSettingsUpdateParameters
|
||||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Migrate an Azure Cosmos DB Cassandra Keyspace from manual throughput to autoscale */
|
/* Migrate an Azure Cosmos DB Cassandra Keyspace from manual throughput to autoscale */
|
||||||
|
@ -131,7 +131,7 @@ export async function createUpdateCassandraTable(
|
||||||
body: Types.CassandraTableCreateUpdateParameters
|
body: Types.CassandraTableCreateUpdateParameters
|
||||||
): Promise<Types.CassandraTableGetResults | void> {
|
): Promise<Types.CassandraTableGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB Cassandra table. */
|
/* Deletes an existing Azure Cosmos DB Cassandra table. */
|
||||||
|
@ -168,7 +168,7 @@ export async function updateCassandraTableThroughput(
|
||||||
body: Types.ThroughputSettingsUpdateParameters
|
body: Types.ThroughputSettingsUpdateParameters
|
||||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale */
|
/* Migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale */
|
||||||
|
|
|
@ -27,13 +27,7 @@ export async function update(
|
||||||
body: Types.DatabaseAccountUpdateParameters
|
body: Types.DatabaseAccountUpdateParameters
|
||||||
): Promise<Types.DatabaseAccountGetResults> {
|
): Promise<Types.DatabaseAccountGetResults> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`;
|
||||||
return armRequest({
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PATCH", apiVersion, body });
|
||||||
host: configContext.ARM_ENDPOINT,
|
|
||||||
path,
|
|
||||||
method: "PATCH",
|
|
||||||
apiVersion,
|
|
||||||
body: JSON.stringify(body)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account. */
|
/* Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account. */
|
||||||
|
@ -44,7 +38,7 @@ export async function createOrUpdate(
|
||||||
body: Types.DatabaseAccountCreateUpdateParameters
|
body: Types.DatabaseAccountCreateUpdateParameters
|
||||||
): Promise<Types.DatabaseAccountGetResults> {
|
): Promise<Types.DatabaseAccountGetResults> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB database account. */
|
/* Deletes an existing Azure Cosmos DB database account. */
|
||||||
|
@ -61,7 +55,7 @@ export async function failoverPriorityChange(
|
||||||
body: Types.FailoverPolicies
|
body: Types.FailoverPolicies
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/failoverPriorityChange`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/failoverPriorityChange`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lists all the Azure Cosmos DB database accounts available under the subscription. */
|
/* Lists all the Azure Cosmos DB database accounts available under the subscription. */
|
||||||
|
@ -107,7 +101,7 @@ export async function offlineRegion(
|
||||||
body: Types.RegionForOnlineOffline
|
body: Types.RegionForOnlineOffline
|
||||||
): Promise<void | Types.ErrorResponse> {
|
): Promise<void | Types.ErrorResponse> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/offlineRegion`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/offlineRegion`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Online the specified region for the specified Azure Cosmos DB database account. */
|
/* Online the specified region for the specified Azure Cosmos DB database account. */
|
||||||
|
@ -118,7 +112,7 @@ export async function onlineRegion(
|
||||||
body: Types.RegionForOnlineOffline
|
body: Types.RegionForOnlineOffline
|
||||||
): Promise<void | Types.ErrorResponse> {
|
): Promise<void | Types.ErrorResponse> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/onlineRegion`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/onlineRegion`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lists the read-only access keys for the specified Azure Cosmos DB database account. */
|
/* Lists the read-only access keys for the specified Azure Cosmos DB database account. */
|
||||||
|
@ -149,7 +143,7 @@ export async function regenerateKey(
|
||||||
body: Types.DatabaseAccountRegenerateKeyParameters
|
body: Types.DatabaseAccountRegenerateKeyParameters
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/regenerateKey`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/regenerateKey`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checks that the Azure Cosmos DB account name already exists. A valid account name may contain only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters. */
|
/* Checks that the Azure Cosmos DB account name already exists. A valid account name may contain only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters. */
|
||||||
|
|
|
@ -39,7 +39,7 @@ export async function createUpdateGremlinDatabase(
|
||||||
body: Types.GremlinDatabaseCreateUpdateParameters
|
body: Types.GremlinDatabaseCreateUpdateParameters
|
||||||
): Promise<Types.GremlinDatabaseGetResults | void> {
|
): Promise<Types.GremlinDatabaseGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB Gremlin database. */
|
/* Deletes an existing Azure Cosmos DB Gremlin database. */
|
||||||
|
@ -73,7 +73,7 @@ export async function updateGremlinDatabaseThroughput(
|
||||||
body: Types.ThroughputSettingsUpdateParameters
|
body: Types.ThroughputSettingsUpdateParameters
|
||||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale */
|
/* Migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale */
|
||||||
|
@ -131,7 +131,7 @@ export async function createUpdateGremlinGraph(
|
||||||
body: Types.GremlinGraphCreateUpdateParameters
|
body: Types.GremlinGraphCreateUpdateParameters
|
||||||
): Promise<Types.GremlinGraphGetResults | void> {
|
): Promise<Types.GremlinGraphGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB Gremlin graph. */
|
/* Deletes an existing Azure Cosmos DB Gremlin graph. */
|
||||||
|
@ -168,7 +168,7 @@ export async function updateGremlinGraphThroughput(
|
||||||
body: Types.ThroughputSettingsUpdateParameters
|
body: Types.ThroughputSettingsUpdateParameters
|
||||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Migrate an Azure Cosmos DB Gremlin graph from manual throughput to autoscale */
|
/* Migrate an Azure Cosmos DB Gremlin graph from manual throughput to autoscale */
|
||||||
|
|
|
@ -39,7 +39,7 @@ export async function createUpdateMongoDBDatabase(
|
||||||
body: Types.MongoDBDatabaseCreateUpdateParameters
|
body: Types.MongoDBDatabaseCreateUpdateParameters
|
||||||
): Promise<Types.MongoDBDatabaseGetResults | void> {
|
): Promise<Types.MongoDBDatabaseGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB MongoDB database. */
|
/* Deletes an existing Azure Cosmos DB MongoDB database. */
|
||||||
|
@ -73,7 +73,7 @@ export async function updateMongoDBDatabaseThroughput(
|
||||||
body: Types.ThroughputSettingsUpdateParameters
|
body: Types.ThroughputSettingsUpdateParameters
|
||||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale */
|
/* Migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale */
|
||||||
|
@ -131,7 +131,7 @@ export async function createUpdateMongoDBCollection(
|
||||||
body: Types.MongoDBCollectionCreateUpdateParameters
|
body: Types.MongoDBCollectionCreateUpdateParameters
|
||||||
): Promise<Types.MongoDBCollectionGetResults | void> {
|
): Promise<Types.MongoDBCollectionGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB MongoDB Collection. */
|
/* Deletes an existing Azure Cosmos DB MongoDB Collection. */
|
||||||
|
@ -168,7 +168,7 @@ export async function updateMongoDBCollectionThroughput(
|
||||||
body: Types.ThroughputSettingsUpdateParameters
|
body: Types.ThroughputSettingsUpdateParameters
|
||||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Migrate an Azure Cosmos DB MongoDB collection from manual throughput to autoscale */
|
/* Migrate an Azure Cosmos DB MongoDB collection from manual throughput to autoscale */
|
||||||
|
|
|
@ -39,7 +39,7 @@ export async function createUpdateSqlDatabase(
|
||||||
body: Types.SqlDatabaseCreateUpdateParameters
|
body: Types.SqlDatabaseCreateUpdateParameters
|
||||||
): Promise<Types.SqlDatabaseGetResults | void> {
|
): Promise<Types.SqlDatabaseGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB SQL database. */
|
/* Deletes an existing Azure Cosmos DB SQL database. */
|
||||||
|
@ -73,7 +73,7 @@ export async function updateSqlDatabaseThroughput(
|
||||||
body: Types.ThroughputSettingsUpdateParameters
|
body: Types.ThroughputSettingsUpdateParameters
|
||||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Migrate an Azure Cosmos DB SQL database from manual throughput to autoscale */
|
/* Migrate an Azure Cosmos DB SQL database from manual throughput to autoscale */
|
||||||
|
@ -131,7 +131,7 @@ export async function createUpdateSqlContainer(
|
||||||
body: Types.SqlContainerCreateUpdateParameters
|
body: Types.SqlContainerCreateUpdateParameters
|
||||||
): Promise<Types.SqlContainerGetResults | void> {
|
): Promise<Types.SqlContainerGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB SQL container. */
|
/* Deletes an existing Azure Cosmos DB SQL container. */
|
||||||
|
@ -168,7 +168,7 @@ export async function updateSqlContainerThroughput(
|
||||||
body: Types.ThroughputSettingsUpdateParameters
|
body: Types.ThroughputSettingsUpdateParameters
|
||||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Migrate an Azure Cosmos DB SQL container from manual throughput to autoscale */
|
/* Migrate an Azure Cosmos DB SQL container from manual throughput to autoscale */
|
||||||
|
@ -231,7 +231,7 @@ export async function createUpdateSqlStoredProcedure(
|
||||||
body: Types.SqlStoredProcedureCreateUpdateParameters
|
body: Types.SqlStoredProcedureCreateUpdateParameters
|
||||||
): Promise<Types.SqlStoredProcedureGetResults | void> {
|
): Promise<Types.SqlStoredProcedureGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB SQL storedProcedure. */
|
/* Deletes an existing Azure Cosmos DB SQL storedProcedure. */
|
||||||
|
@ -283,7 +283,7 @@ export async function createUpdateSqlUserDefinedFunction(
|
||||||
body: Types.SqlUserDefinedFunctionCreateUpdateParameters
|
body: Types.SqlUserDefinedFunctionCreateUpdateParameters
|
||||||
): Promise<Types.SqlUserDefinedFunctionGetResults | void> {
|
): Promise<Types.SqlUserDefinedFunctionGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB SQL userDefinedFunction. */
|
/* Deletes an existing Azure Cosmos DB SQL userDefinedFunction. */
|
||||||
|
@ -335,7 +335,7 @@ export async function createUpdateSqlTrigger(
|
||||||
body: Types.SqlTriggerCreateUpdateParameters
|
body: Types.SqlTriggerCreateUpdateParameters
|
||||||
): Promise<Types.SqlTriggerGetResults | void> {
|
): Promise<Types.SqlTriggerGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB SQL trigger. */
|
/* Deletes an existing Azure Cosmos DB SQL trigger. */
|
||||||
|
|
|
@ -39,7 +39,7 @@ export async function createUpdateTable(
|
||||||
body: Types.TableCreateUpdateParameters
|
body: Types.TableCreateUpdateParameters
|
||||||
): Promise<Types.TableGetResults | void> {
|
): Promise<Types.TableGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes an existing Azure Cosmos DB Table. */
|
/* Deletes an existing Azure Cosmos DB Table. */
|
||||||
|
@ -73,7 +73,7 @@ export async function updateTableThroughput(
|
||||||
body: Types.ThroughputSettingsUpdateParameters
|
body: Types.ThroughputSettingsUpdateParameters
|
||||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default`;
|
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default`;
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Migrate an Azure Cosmos DB Table from manual throughput to autoscale */
|
/* Migrate an Azure Cosmos DB Table from manual throughput to autoscale */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -102,31 +102,31 @@ interface Property {
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const propertyToType = (property: Property, prop: string) => {
|
const propertyToType = (property: Property, prop: string, required: boolean) => {
|
||||||
if (property) {
|
if (property) {
|
||||||
if (property.allOf) {
|
if (property.allOf) {
|
||||||
outputTypes.push(`
|
outputTypes.push(`
|
||||||
/* ${property.description || "undocumented"} */
|
/* ${property.description || "undocumented"} */
|
||||||
${property.readOnly ? "readonly " : ""}${prop}: ${property.allOf
|
${property.readOnly ? "readonly " : ""}${prop}${
|
||||||
.map((allof: { $ref: string }) => refToType(allof.$ref))
|
required ? "" : "?"
|
||||||
.join(" & ")}`);
|
}: ${property.allOf.map((allof: { $ref: string }) => refToType(allof.$ref)).join(" & ")}`);
|
||||||
} else if (property.$ref) {
|
} else if (property.$ref) {
|
||||||
const type = refToType(property.$ref);
|
const type = refToType(property.$ref);
|
||||||
outputTypes.push(`
|
outputTypes.push(`
|
||||||
/* ${property.description || "undocumented"} */
|
/* ${property.description || "undocumented"} */
|
||||||
${property.readOnly ? "readonly " : ""}${prop}: ${type}
|
${property.readOnly ? "readonly " : ""}${prop}${required ? "" : "?"}: ${type}
|
||||||
`);
|
`);
|
||||||
} else if (property.type === "array") {
|
} else if (property.type === "array") {
|
||||||
const type = refToType(property.items.$ref);
|
const type = refToType(property.items.$ref);
|
||||||
outputTypes.push(`
|
outputTypes.push(`
|
||||||
/* ${property.description || "undocumented"} */
|
/* ${property.description || "undocumented"} */
|
||||||
${property.readOnly ? "readonly " : ""}${prop}: ${type}[]
|
${property.readOnly ? "readonly " : ""}${prop}${required ? "" : "?"}: ${type}[]
|
||||||
`);
|
`);
|
||||||
} else if (property.type === "object") {
|
} else if (property.type === "object") {
|
||||||
const type = refToType(property.$ref);
|
const type = refToType(property.$ref);
|
||||||
outputTypes.push(`
|
outputTypes.push(`
|
||||||
/* ${property.description || "undocumented"} */
|
/* ${property.description || "undocumented"} */
|
||||||
${property.readOnly ? "readonly " : ""}${prop}: ${type}
|
${property.readOnly ? "readonly " : ""}${prop}${required ? "" : "?"}: ${type}
|
||||||
`);
|
`);
|
||||||
} else {
|
} else {
|
||||||
if (property.type === undefined) {
|
if (property.type === undefined) {
|
||||||
|
@ -135,7 +135,7 @@ const propertyToType = (property: Property, prop: string) => {
|
||||||
}
|
}
|
||||||
outputTypes.push(`
|
outputTypes.push(`
|
||||||
/* ${property.description || "undocumented"} */
|
/* ${property.description || "undocumented"} */
|
||||||
${property.readOnly ? "readonly " : ""}${prop}: ${
|
${property.readOnly ? "readonly " : ""}${prop}${required ? "" : "?"}: ${
|
||||||
propertyMap[property.type] ? propertyMap[property.type] : property.type
|
propertyMap[property.type] ? propertyMap[property.type] : property.type
|
||||||
}`);
|
}`);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ async function main() {
|
||||||
}
|
}
|
||||||
for (const prop in schema.definitions[definition].properties) {
|
for (const prop in schema.definitions[definition].properties) {
|
||||||
const property = schema.definitions[definition].properties[prop];
|
const property = schema.definitions[definition].properties[prop];
|
||||||
propertyToType(property, prop);
|
propertyToType(property, prop, schema.definitions[definition].required?.includes(prop));
|
||||||
}
|
}
|
||||||
outputTypes.push(`}`);
|
outputTypes.push(`}`);
|
||||||
outputTypes.push("\n\n");
|
outputTypes.push("\n\n");
|
||||||
|
@ -245,7 +245,7 @@ async function main() {
|
||||||
) : Promise<${responseType(operation, "Types")}> {
|
) : Promise<${responseType(operation, "Types")}> {
|
||||||
const path = \`${path.replace(/{/g, "${")}\`
|
const path = \`${path.replace(/{/g, "${")}\`
|
||||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "${method.toLocaleUpperCase()}", apiVersion, ${
|
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "${method.toLocaleUpperCase()}", apiVersion, ${
|
||||||
bodyParameter ? "body: JSON.stringify(body)" : ""
|
bodyParameter ? "body" : ""
|
||||||
} })
|
} })
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
|
Loading…
Reference in New Issue