Functional version

This commit is contained in:
Steve Faulkner
2020-07-23 19:02:09 -05:00
parent 0c255a55c8
commit ad115a2cce
20 changed files with 1204 additions and 1080 deletions

View File

@@ -6,110 +6,150 @@
import * as Types from "./types"; import * as Types from "./types";
export class CassandraResourcesClient { /* Lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. */
private readonly baseUrl = "https://management.azure.com"; export async function listCassandraKeyspaces(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/cassandraKeyspaces`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string
private readonly subscriptionId: string, ): Promise<Types.CassandraKeyspaceListResult> {
private readonly resourceGroupName: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces`;
private readonly accountName: string
) {}
/* Lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. */
async listCassandraKeyspaces(): Promise<Types.CassandraKeyspaceListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the provided name. */ /* Gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the provided name. */
async getCassandraKeyspace(keyspaceName: string): Promise<Types.CassandraKeyspaceGetResults> { export async function getCassandraKeyspace(
const path = `/${keyspaceName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
keyspaceName: string
): Promise<Types.CassandraKeyspaceGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Create or update an Azure Cosmos DB Cassandra keyspace */ /* Create or update an Azure Cosmos DB Cassandra keyspace */
async createUpdateCassandraKeyspace( export async function createUpdateCassandraKeyspace(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
keyspaceName: string, keyspaceName: string,
body: Types.CassandraKeyspaceCreateUpdateParameters body: Types.CassandraKeyspaceCreateUpdateParameters
): Promise<Types.CassandraKeyspaceGetResults | void> { ): Promise<Types.CassandraKeyspaceGetResults | void> {
const path = `/${keyspaceName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB Cassandra keyspace. */ /* Deletes an existing Azure Cosmos DB Cassandra keyspace. */
async deleteCassandraKeyspace(keyspaceName: string): Promise<void | void> { export async function deleteCassandraKeyspace(
const path = `/${keyspaceName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
keyspaceName: string
): Promise<void | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }
/* Lists the Cassandra table under an existing Azure Cosmos DB database account. */ /* Gets the RUs per second of the Cassandra Keyspace under an existing Azure Cosmos DB database account with the provided name. */
async listCassandraTables(keyspaceName: string): Promise<Types.CassandraTableListResult> { export async function getCassandraKeyspaceThroughput(
const path = `/${keyspaceName}/tables`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
keyspaceName: string
): Promise<Types.ThroughputSettingsGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Gets the Cassandra table under an existing Azure Cosmos DB database account. */ /* Update RUs per second of an Azure Cosmos DB Cassandra Keyspace */
async getCassandraTable(keyspaceName: string, tableName: string): Promise<Types.CassandraTableGetResults> { export async function updateCassandraKeyspaceThroughput(
const path = `/${keyspaceName}/tables/${tableName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
keyspaceName: string,
body: Types.ThroughputSettingsUpdateParameters
): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default`;
return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json());
}
/* Lists the Cassandra table under an existing Azure Cosmos DB database account. */
export async function listCassandraTables(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
keyspaceName: string
): Promise<Types.CassandraTableListResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Create or update an Azure Cosmos DB Cassandra Table */ /* Gets the Cassandra table under an existing Azure Cosmos DB database account. */
async createUpdateCassandraTable( export async function getCassandraTable(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
keyspaceName: string,
tableName: string
): Promise<Types.CassandraTableGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Create or update an Azure Cosmos DB Cassandra Table */
export async function createUpdateCassandraTable(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
keyspaceName: string, keyspaceName: string,
tableName: string, tableName: string,
body: Types.CassandraTableCreateUpdateParameters body: Types.CassandraTableCreateUpdateParameters
): Promise<Types.CassandraTableGetResults | void> { ): Promise<Types.CassandraTableGetResults | void> {
const path = `/${keyspaceName}/tables/${tableName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB Cassandra table. */ /* Deletes an existing Azure Cosmos DB Cassandra table. */
async deleteCassandraTable(keyspaceName: string, tableName: string): Promise<void | void> { export async function deleteCassandraTable(
const path = `/${keyspaceName}/tables/${tableName}`; subscriptionId: string,
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); resourceGroupName: string,
} accountName: string,
/* Gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB database account with the provided name. */
async getCassandraTableThroughput(
keyspaceName: string, keyspaceName: string,
tableName: string tableName: string
): Promise<Types.ThroughputSettingsGetResults> { ): Promise<void | void> {
const path = `/${keyspaceName}/tables/${tableName}/throughputSettings/default`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }
/* Update RUs per second of an Azure Cosmos DB Cassandra table */ /* Gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB database account with the provided name. */
async updateCassandraTableThroughput( export async function getCassandraTableThroughput(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
keyspaceName: string,
tableName: string
): Promise<Types.ThroughputSettingsGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Update RUs per second of an Azure Cosmos DB Cassandra table */
export async function updateCassandraTableThroughput(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
keyspaceName: string, keyspaceName: string,
tableName: string, tableName: string,
body: Types.ThroughputSettingsUpdateParameters body: Types.ThroughputSettingsUpdateParameters
): Promise<Types.ThroughputSettingsGetResults | void> { ): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/${keyspaceName}/tables/${tableName}/throughputSettings/default`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
}
/* Gets the RUs per second of the Cassandra Keyspace under an existing Azure Cosmos DB database account with the provided name. */
async getCassandraKeyspaceThroughput(keyspaceName: string): Promise<Types.ThroughputSettingsGetResults> {
const path = `/${keyspaceName}/throughputSettings/default`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Update RUs per second of an Azure Cosmos DB Cassandra Keyspace */
async updateCassandraKeyspaceThroughput(
keyspaceName: string,
body: Types.ThroughputSettingsUpdateParameters
): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/${keyspaceName}/throughputSettings/default`;
return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json());
}
} }

View File

@@ -6,33 +6,38 @@
import * as Types from "./types"; import * as Types from "./types";
export class CollectionClient { /* Retrieves the metrics determined by the given filter for the given database account and collection. */
private readonly baseUrl = "https://management.azure.com"; export async function listMetrics(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/databases/${this.databaseRid}/collections/${this.collectionRid}/`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string,
private readonly subscriptionId: string, databaseRid: string,
private readonly resourceGroupName: string, collectionRid: string
private readonly accountName: string, ): Promise<Types.MetricListResult> {
private readonly databaseRid: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/metrics`;
private readonly collectionRid: string return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
) {} }
/* Retrieves metric definitions for the given collection. */ /* Retrieves the usages (most recent storage data) for the given collection. */
async listMetricDefinitions(): Promise<Types.MetricDefinitionsListResult> { export async function listUsages(
const path = `metricDefinitions`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseRid: string,
collectionRid: string
): Promise<Types.UsagesResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/usages`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Retrieves metric definitions for the given collection. */
export async function listMetricDefinitions(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseRid: string,
collectionRid: string
): Promise<Types.MetricDefinitionsListResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/metricDefinitions`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Retrieves the metrics determined by the given filter for the given database account and collection. */
async listMetrics(): Promise<Types.MetricListResult> {
const path = `metrics`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Retrieves the usages (most recent storage data) for the given collection. */
async listUsages(): Promise<Types.UsagesResult> {
const path = `usages`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,27 +6,26 @@
import * as Types from "./types"; import * as Types from "./types";
export class CollectionPartitionClient { /* Retrieves the metrics determined by the given filter for the given collection, split by partition. */
private readonly baseUrl = "https://management.azure.com"; export async function listMetrics(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/databases/${this.databaseRid}/collections/${this.collectionRid}/partitions/`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string,
private readonly subscriptionId: string, databaseRid: string,
private readonly resourceGroupName: string, collectionRid: string
private readonly accountName: string, ): Promise<Types.PartitionMetricListResult> {
private readonly databaseRid: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/partitions/metrics`;
private readonly collectionRid: string return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
) {} }
/* Retrieves the metrics determined by the given filter for the given collection, split by partition. */ /* Retrieves the usages (most recent storage data) for the given collection, split by partition. */
async listMetrics(): Promise<Types.PartitionMetricListResult> { export async function listUsages(
const path = `metrics`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseRid: string,
collectionRid: string
): Promise<Types.PartitionUsagesResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/partitions/usages`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Retrieves the usages (most recent storage data) for the given collection, split by partition. */
async listUsages(): Promise<Types.PartitionUsagesResult> {
const path = `usages`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,22 +6,15 @@
import * as Types from "./types"; import * as Types from "./types";
export class CollectionPartitionRegionClient { /* Retrieves the metrics determined by the given filter for the given collection and region, split by partition. */
private readonly baseUrl = "https://management.azure.com"; export async function listMetrics(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/region/${this.region}/databases/${this.databaseRid}/collections/${this.collectionRid}/partitions/metrics`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string,
private readonly subscriptionId: string, region: string,
private readonly resourceGroupName: string, databaseRid: string,
private readonly accountName: string, collectionRid: string
private readonly region: string, ): Promise<Types.PartitionMetricListResult> {
private readonly databaseRid: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/databases/${databaseRid}/collections/${collectionRid}/partitions/metrics`;
private readonly collectionRid: string
) {}
/* Retrieves the metrics determined by the given filter for the given collection and region, split by partition. */
async listMetrics(): Promise<Types.PartitionMetricListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,22 +6,15 @@
import * as Types from "./types"; import * as Types from "./types";
export class CollectionRegionClient { /* Retrieves the metrics determined by the given filter for the given database account, collection and region. */
private readonly baseUrl = "https://management.azure.com"; export async function listMetrics(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/region/${this.region}/databases/${this.databaseRid}/collections/${this.collectionRid}/metrics`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string,
private readonly subscriptionId: string, region: string,
private readonly resourceGroupName: string, databaseRid: string,
private readonly accountName: string, collectionRid: string
private readonly region: string, ): Promise<Types.MetricListResult> {
private readonly databaseRid: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/databases/${databaseRid}/collections/${collectionRid}/metrics`;
private readonly collectionRid: string
) {}
/* Retrieves the metrics determined by the given filter for the given database account, collection and region. */
async listMetrics(): Promise<Types.MetricListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,32 +6,35 @@
import * as Types from "./types"; import * as Types from "./types";
export class DatabaseClient { /* Retrieves the metrics determined by the given filter for the given database account and database. */
private readonly baseUrl = "https://management.azure.com"; export async function listMetrics(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/databases/${this.databaseRid}/`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string,
private readonly subscriptionId: string, databaseRid: string
private readonly resourceGroupName: string, ): Promise<Types.MetricListResult> {
private readonly accountName: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/metrics`;
private readonly databaseRid: string return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
) {} }
/* Retrieves metric definitions for the given database. */ /* Retrieves the usages (most recent data) for the given database. */
async listMetricDefinitions(): Promise<Types.MetricDefinitionsListResult> { export async function listUsages(
const path = `metricDefinitions`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseRid: string
): Promise<Types.UsagesResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/usages`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Retrieves metric definitions for the given database. */
export async function listMetricDefinitions(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseRid: string
): Promise<Types.MetricDefinitionsListResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/metricDefinitions`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Retrieves the metrics determined by the given filter for the given database account and database. */
async listMetrics(): Promise<Types.MetricListResult> {
const path = `metrics`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Retrieves the usages (most recent data) for the given database. */
async listUsages(): Promise<Types.UsagesResult> {
const path = `usages`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,20 +6,13 @@
import * as Types from "./types"; import * as Types from "./types";
export class DatabaseAccountRegionClient { /* Retrieves the metrics determined by the given filter for the given database account and region. */
private readonly baseUrl = "https://management.azure.com"; export async function listMetrics(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/region/${this.region}/metrics`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string,
private readonly subscriptionId: string, region: string
private readonly resourceGroupName: string, ): Promise<Types.MetricListResult> {
private readonly accountName: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/metrics`;
private readonly region: string
) {}
/* Retrieves the metrics determined by the given filter for the given database account and region. */
async listMetrics(): Promise<Types.MetricListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,192 +6,191 @@
import * as Types from "./types"; import * as Types from "./types";
export class DatabaseAccountsClient { /* Retrieves the properties of an existing Azure Cosmos DB database account. */
private readonly baseUrl = "https://management.azure.com"; export async function get(
private readonly basePath = `/`;
/* 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. */
async checkNameExists(accountName: string): Promise<void | void> {
const path = `providers/Microsoft.DocumentDB/databaseAccountNames/${accountName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "head" }).then(response => response.json());
}
/* Lists all the Azure Cosmos DB database accounts available under the subscription. */
async list(subscriptionId: string): Promise<Types.DatabaseAccountsListResult> {
const path = `subscriptions/${subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Lists all the Azure Cosmos DB database accounts available under the given resource group. */
async listByResourceGroup(
subscriptionId: string,
resourceGroupName: string
): Promise<Types.DatabaseAccountsListResult> {
const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Retrieves the properties of an existing Azure Cosmos DB database account. */
async get(
subscriptionId: string, subscriptionId: string,
resourceGroupName: string, resourceGroupName: string,
accountName: string accountName: string
): 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 window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Updates the properties of an existing Azure Cosmos DB database account. */ /* Updates the properties of an existing Azure Cosmos DB database account. */
async update( export async function update(
subscriptionId: string, subscriptionId: string,
resourceGroupName: string, resourceGroupName: string,
accountName: string, accountName: string,
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 window return window
.fetch(this.baseUrl + this.basePath + path, { method: "patch", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "patch", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* 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. */
async createOrUpdate( export async function createOrUpdate(
subscriptionId: string, subscriptionId: string,
resourceGroupName: string, resourceGroupName: string,
accountName: string, accountName: string,
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 window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB database account. */ /* Deletes an existing Azure Cosmos DB database account. */
async destroy(subscriptionId: string, resourceGroupName: string, accountName: string): Promise<void | void> { export async function destroy(
const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string
): Promise<void | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }
/* Changes the failover priority for the Azure Cosmos DB database account. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists. */ /* Changes the failover priority for the Azure Cosmos DB database account. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists. */
async failoverPriorityChange( export async function failoverPriorityChange(
subscriptionId: string, subscriptionId: string,
resourceGroupName: string, resourceGroupName: string,
accountName: string, accountName: string,
body: Types.FailoverPolicies body: Types.FailoverPolicies
): Promise<void | void> { ): Promise<void | 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 window return window
.fetch(this.baseUrl + this.basePath + path, { method: "post", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "post", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Lists the connection strings for the specified Azure Cosmos DB database account. */ /* Lists all the Azure Cosmos DB database accounts available under the subscription. */
async listConnectionStrings( export async function list(subscriptionId: string): Promise<Types.DatabaseAccountsListResult> {
subscriptionId: string, const path = `/subscriptions/${subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts`;
resourceGroupName: string,
accountName: string
): Promise<Types.DatabaseAccountListConnectionStringsResult> {
const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/listConnectionStrings`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "post" }).then(response => response.json());
}
/* Lists the access keys for the specified Azure Cosmos DB database account. */
async listKeys(
subscriptionId: string,
resourceGroupName: string,
accountName: string
): Promise<Types.DatabaseAccountListKeysResult> {
const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/listKeys`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "post" }).then(response => response.json());
}
/* Retrieves metric definitions for the given database account. */
async listMetricDefinitions(
subscriptionId: string,
resourceGroupName: string,
accountName: string
): Promise<Types.MetricDefinitionsListResult> {
const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/metricDefinitions`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Retrieves the metrics determined by the given filter for the given database account. */ /* Lists all the Azure Cosmos DB database accounts available under the given resource group. */
async listMetrics( export async function listByResourceGroup(
subscriptionId: string,
resourceGroupName: string
): Promise<Types.DatabaseAccountsListResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Lists the access keys for the specified Azure Cosmos DB database account. */
export async function listKeys(
subscriptionId: string, subscriptionId: string,
resourceGroupName: string, resourceGroupName: string,
accountName: string accountName: string
): Promise<Types.MetricListResult> { ): Promise<Types.DatabaseAccountListKeysResult> {
const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/metrics`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/listKeys`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "post" }).then(response => response.json());
} }
/* Offline the specified region for the specified Azure Cosmos DB database account. */ /* Lists the connection strings for the specified Azure Cosmos DB database account. */
async offlineRegion( export async function listConnectionStrings(
subscriptionId: string,
resourceGroupName: string,
accountName: string
): Promise<Types.DatabaseAccountListConnectionStringsResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/listConnectionStrings`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "post" }).then(response => response.json());
}
/* Offline the specified region for the specified Azure Cosmos DB database account. */
export async function offlineRegion(
subscriptionId: string, subscriptionId: string,
resourceGroupName: string, resourceGroupName: string,
accountName: string, accountName: string,
body: Types.RegionForOnlineOffline body: Types.RegionForOnlineOffline
): Promise<void | void | Types.ErrorResponse> { ): Promise<void | 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 window return window
.fetch(this.baseUrl + this.basePath + path, { method: "post", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "post", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Online the specified region for the specified Azure Cosmos DB database account. */ /* Online the specified region for the specified Azure Cosmos DB database account. */
async onlineRegion( export async function onlineRegion(
subscriptionId: string, subscriptionId: string,
resourceGroupName: string, resourceGroupName: string,
accountName: string, accountName: string,
body: Types.RegionForOnlineOffline body: Types.RegionForOnlineOffline
): Promise<void | void | Types.ErrorResponse> { ): Promise<void | 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 window return window
.fetch(this.baseUrl + this.basePath + path, { method: "post", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "post", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* 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. */
async getReadOnlyKeys( export async function getReadOnlyKeys(
subscriptionId: string, subscriptionId: string,
resourceGroupName: string, resourceGroupName: string,
accountName: string accountName: string
): Promise<Types.DatabaseAccountListReadOnlyKeysResult> { ): Promise<Types.DatabaseAccountListReadOnlyKeysResult> {
const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/readonlykeys`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/readonlykeys`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* 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. */
async listReadOnlyKeys( export async function listReadOnlyKeys(
subscriptionId: string, subscriptionId: string,
resourceGroupName: string, resourceGroupName: string,
accountName: string accountName: string
): Promise<Types.DatabaseAccountListReadOnlyKeysResult> { ): Promise<Types.DatabaseAccountListReadOnlyKeysResult> {
const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/readonlykeys`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/readonlykeys`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "post" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "post" }).then(response => response.json());
} }
/* Regenerates an access key for the specified Azure Cosmos DB database account. */ /* Regenerates an access key for the specified Azure Cosmos DB database account. */
async regenerateKey( export async function regenerateKey(
subscriptionId: string, subscriptionId: string,
resourceGroupName: string, resourceGroupName: string,
accountName: string, accountName: string,
body: Types.DatabaseAccountRegenerateKeyParameters body: Types.DatabaseAccountRegenerateKeyParameters
): Promise<void | void> { ): Promise<void | 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 window return window
.fetch(this.baseUrl + this.basePath + path, { method: "post", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "post", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Retrieves the usages (most recent data) for the given database account. */ /* 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. */
async listUsages( export async function checkNameExists(accountName: string): Promise<void | void> {
const path = `/providers/Microsoft.DocumentDB/databaseAccountNames/${accountName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "head" }).then(response => response.json());
}
/* Retrieves the metrics determined by the given filter for the given database account. */
export async function listMetrics(
subscriptionId: string, subscriptionId: string,
resourceGroupName: string, resourceGroupName: string,
accountName: string accountName: string
): Promise<Types.UsagesResult> { ): Promise<Types.MetricListResult> {
const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/usages`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/metrics`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Retrieves the usages (most recent data) for the given database account. */
export async function listUsages(
subscriptionId: string,
resourceGroupName: string,
accountName: string
): Promise<Types.UsagesResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/usages`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Retrieves metric definitions for the given database account. */
export async function listMetricDefinitions(
subscriptionId: string,
resourceGroupName: string,
accountName: string
): Promise<Types.MetricDefinitionsListResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/metricDefinitions`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,110 +6,150 @@
import * as Types from "./types"; import * as Types from "./types";
export class GremlinResourcesClient { /* Lists the Gremlin databases under an existing Azure Cosmos DB database account. */
private readonly baseUrl = "https://management.azure.com"; export async function listGremlinDatabases(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/gremlinDatabases`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string
private readonly subscriptionId: string, ): Promise<Types.GremlinDatabaseListResult> {
private readonly resourceGroupName: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases`;
private readonly accountName: string
) {}
/* Lists the Gremlin databases under an existing Azure Cosmos DB database account. */
async listGremlinDatabases(): Promise<Types.GremlinDatabaseListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Gets the Gremlin databases under an existing Azure Cosmos DB database account with the provided name. */ /* Gets the Gremlin databases under an existing Azure Cosmos DB database account with the provided name. */
async getGremlinDatabase(databaseName: string): Promise<Types.GremlinDatabaseGetResults> { export async function getGremlinDatabase(
const path = `/${databaseName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string
): Promise<Types.GremlinDatabaseGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Create or update an Azure Cosmos DB Gremlin database */ /* Create or update an Azure Cosmos DB Gremlin database */
async createUpdateGremlinDatabase( export async function createUpdateGremlinDatabase(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
body: Types.GremlinDatabaseCreateUpdateParameters body: Types.GremlinDatabaseCreateUpdateParameters
): Promise<Types.GremlinDatabaseGetResults | void> { ): Promise<Types.GremlinDatabaseGetResults | void> {
const path = `/${databaseName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB Gremlin database. */ /* Deletes an existing Azure Cosmos DB Gremlin database. */
async deleteGremlinDatabase(databaseName: string): Promise<void | void> { export async function deleteGremlinDatabase(
const path = `/${databaseName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string
): Promise<void | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }
/* Lists the Gremlin graph under an existing Azure Cosmos DB database account. */ /* Gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB database account with the provided name. */
async listGremlinGraphs(databaseName: string): Promise<Types.GremlinGraphListResult> { export async function getGremlinDatabaseThroughput(
const path = `/${databaseName}/graphs`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string
): Promise<Types.ThroughputSettingsGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Gets the Gremlin graph under an existing Azure Cosmos DB database account. */ /* Update RUs per second of an Azure Cosmos DB Gremlin database */
async getGremlinGraph(databaseName: string, graphName: string): Promise<Types.GremlinGraphGetResults> { export async function updateGremlinDatabaseThroughput(
const path = `/${databaseName}/graphs/${graphName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
body: Types.ThroughputSettingsUpdateParameters
): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default`;
return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json());
}
/* Lists the Gremlin graph under an existing Azure Cosmos DB database account. */
export async function listGremlinGraphs(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string
): Promise<Types.GremlinGraphListResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Create or update an Azure Cosmos DB Gremlin graph */ /* Gets the Gremlin graph under an existing Azure Cosmos DB database account. */
async createUpdateGremlinGraph( export async function getGremlinGraph(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
graphName: string
): Promise<Types.GremlinGraphGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Create or update an Azure Cosmos DB Gremlin graph */
export async function createUpdateGremlinGraph(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
graphName: string, graphName: string,
body: Types.GremlinGraphCreateUpdateParameters body: Types.GremlinGraphCreateUpdateParameters
): Promise<Types.GremlinGraphGetResults | void> { ): Promise<Types.GremlinGraphGetResults | void> {
const path = `/${databaseName}/graphs/${graphName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB Gremlin graph. */ /* Deletes an existing Azure Cosmos DB Gremlin graph. */
async deleteGremlinGraph(databaseName: string, graphName: string): Promise<void | void> { export async function deleteGremlinGraph(
const path = `/${databaseName}/graphs/${graphName}`; subscriptionId: string,
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); resourceGroupName: string,
} accountName: string,
/* Gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with the provided name. */
async getGremlinGraphThroughput(
databaseName: string, databaseName: string,
graphName: string graphName: string
): Promise<Types.ThroughputSettingsGetResults> { ): Promise<void | void> {
const path = `/${databaseName}/graphs/${graphName}/throughputSettings/default`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }
/* Update RUs per second of an Azure Cosmos DB Gremlin graph */ /* Gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with the provided name. */
async updateGremlinGraphThroughput( export async function getGremlinGraphThroughput(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
graphName: string
): Promise<Types.ThroughputSettingsGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Update RUs per second of an Azure Cosmos DB Gremlin graph */
export async function updateGremlinGraphThroughput(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
graphName: string, graphName: string,
body: Types.ThroughputSettingsUpdateParameters body: Types.ThroughputSettingsUpdateParameters
): Promise<Types.ThroughputSettingsGetResults | void> { ): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/${databaseName}/graphs/${graphName}/throughputSettings/default`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
}
/* Gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB database account with the provided name. */
async getGremlinDatabaseThroughput(databaseName: string): Promise<Types.ThroughputSettingsGetResults> {
const path = `/${databaseName}/throughputSettings/default`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Update RUs per second of an Azure Cosmos DB Gremlin database */
async updateGremlinDatabaseThroughput(
databaseName: string,
body: Types.ThroughputSettingsUpdateParameters
): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/${databaseName}/throughputSettings/default`;
return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json());
}
} }

View File

@@ -6,110 +6,150 @@
import * as Types from "./types"; import * as Types from "./types";
export class MongoDBResourcesClient { /* Lists the MongoDB databases under an existing Azure Cosmos DB database account. */
private readonly baseUrl = "https://management.azure.com"; export async function listMongoDBDatabases(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/mongodbDatabases`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string
private readonly subscriptionId: string, ): Promise<Types.MongoDBDatabaseListResult> {
private readonly resourceGroupName: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases`;
private readonly accountName: string
) {}
/* Lists the MongoDB databases under an existing Azure Cosmos DB database account. */
async listMongoDBDatabases(): Promise<Types.MongoDBDatabaseListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Gets the MongoDB databases under an existing Azure Cosmos DB database account with the provided name. */ /* Gets the MongoDB databases under an existing Azure Cosmos DB database account with the provided name. */
async getMongoDBDatabase(databaseName: string): Promise<Types.MongoDBDatabaseGetResults> { export async function getMongoDBDatabase(
const path = `/${databaseName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string
): Promise<Types.MongoDBDatabaseGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Create or updates Azure Cosmos DB MongoDB database */ /* Create or updates Azure Cosmos DB MongoDB database */
async createUpdateMongoDBDatabase( export async function createUpdateMongoDBDatabase(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
body: Types.MongoDBDatabaseCreateUpdateParameters body: Types.MongoDBDatabaseCreateUpdateParameters
): Promise<Types.MongoDBDatabaseGetResults | void> { ): Promise<Types.MongoDBDatabaseGetResults | void> {
const path = `/${databaseName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB MongoDB database. */ /* Deletes an existing Azure Cosmos DB MongoDB database. */
async deleteMongoDBDatabase(databaseName: string): Promise<void | void> { export async function deleteMongoDBDatabase(
const path = `/${databaseName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string
): Promise<void | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }
/* Lists the MongoDB collection under an existing Azure Cosmos DB database account. */ /* Gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB database account with the provided name. */
async listMongoDBCollections(databaseName: string): Promise<Types.MongoDBCollectionListResult> { export async function getMongoDBDatabaseThroughput(
const path = `/${databaseName}/collections`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string
): Promise<Types.ThroughputSettingsGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Gets the MongoDB collection under an existing Azure Cosmos DB database account. */ /* Update RUs per second of the an Azure Cosmos DB MongoDB database */
async getMongoDBCollection(databaseName: string, collectionName: string): Promise<Types.MongoDBCollectionGetResults> { export async function updateMongoDBDatabaseThroughput(
const path = `/${databaseName}/collections/${collectionName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
body: Types.ThroughputSettingsUpdateParameters
): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default`;
return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json());
}
/* Lists the MongoDB collection under an existing Azure Cosmos DB database account. */
export async function listMongoDBCollections(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string
): Promise<Types.MongoDBCollectionListResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Create or update an Azure Cosmos DB MongoDB Collection */ /* Gets the MongoDB collection under an existing Azure Cosmos DB database account. */
async createUpdateMongoDBCollection( export async function getMongoDBCollection(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
collectionName: string
): Promise<Types.MongoDBCollectionGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Create or update an Azure Cosmos DB MongoDB Collection */
export async function createUpdateMongoDBCollection(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
collectionName: string, collectionName: string,
body: Types.MongoDBCollectionCreateUpdateParameters body: Types.MongoDBCollectionCreateUpdateParameters
): Promise<Types.MongoDBCollectionGetResults | void> { ): Promise<Types.MongoDBCollectionGetResults | void> {
const path = `/${databaseName}/collections/${collectionName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB MongoDB Collection. */ /* Deletes an existing Azure Cosmos DB MongoDB Collection. */
async deleteMongoDBCollection(databaseName: string, collectionName: string): Promise<void | void> { export async function deleteMongoDBCollection(
const path = `/${databaseName}/collections/${collectionName}`; subscriptionId: string,
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); resourceGroupName: string,
} accountName: string,
/* Gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB database account with the provided name. */
async getMongoDBCollectionThroughput(
databaseName: string, databaseName: string,
collectionName: string collectionName: string
): Promise<Types.ThroughputSettingsGetResults> { ): Promise<void | void> {
const path = `/${databaseName}/collections/${collectionName}/throughputSettings/default`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }
/* Update the RUs per second of an Azure Cosmos DB MongoDB collection */ /* Gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB database account with the provided name. */
async updateMongoDBCollectionThroughput( export async function getMongoDBCollectionThroughput(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
collectionName: string
): Promise<Types.ThroughputSettingsGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Update the RUs per second of an Azure Cosmos DB MongoDB collection */
export async function updateMongoDBCollectionThroughput(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
collectionName: string, collectionName: string,
body: Types.ThroughputSettingsUpdateParameters body: Types.ThroughputSettingsUpdateParameters
): Promise<Types.ThroughputSettingsGetResults | void> { ): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/${databaseName}/collections/${collectionName}/throughputSettings/default`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
}
/* Gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB database account with the provided name. */
async getMongoDBDatabaseThroughput(databaseName: string): Promise<Types.ThroughputSettingsGetResults> {
const path = `/${databaseName}/throughputSettings/default`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Update RUs per second of the an Azure Cosmos DB MongoDB database */
async updateMongoDBDatabaseThroughput(
databaseName: string,
body: Types.ThroughputSettingsUpdateParameters
): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/${databaseName}/throughputSettings/default`;
return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json());
}
} }

View File

@@ -6,13 +6,8 @@
import * as Types from "./types"; import * as Types from "./types";
export class OperationsClient { /* Lists all of the available Cosmos DB Resource Provider operations. */
private readonly baseUrl = "https://management.azure.com"; export async function list(): Promise<Types.OperationListResult> {
private readonly basePath = `/providers/Microsoft.DocumentDB/operations`; const path = `/providers/Microsoft.DocumentDB/operations`;
/* Lists all of the available Cosmos DB Resource Provider operations. */
async list(): Promise<Types.OperationListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,22 +6,15 @@
import * as Types from "./types"; import * as Types from "./types";
export class PartitionKeyRangeIdClient { /* Retrieves the metrics determined by the given filter for the given partition key range id. */
private readonly baseUrl = "https://management.azure.com"; export async function listMetrics(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/databases/${this.databaseRid}/collections/${this.collectionRid}/partitionKeyRangeId/${this.partitionKeyRangeId}/metrics`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string,
private readonly subscriptionId: string, databaseRid: string,
private readonly resourceGroupName: string, collectionRid: string,
private readonly accountName: string, partitionKeyRangeId: string
private readonly databaseRid: string, ): Promise<Types.PartitionMetricListResult> {
private readonly collectionRid: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/partitionKeyRangeId/${partitionKeyRangeId}/metrics`;
private readonly partitionKeyRangeId: string
) {}
/* Retrieves the metrics determined by the given filter for the given partition key range id. */
async listMetrics(): Promise<Types.PartitionMetricListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,23 +6,16 @@
import * as Types from "./types"; import * as Types from "./types";
export class PartitionKeyRangeIdRegionClient { /* Retrieves the metrics determined by the given filter for the given partition key range id and region. */
private readonly baseUrl = "https://management.azure.com"; export async function listMetrics(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/region/${this.region}/databases/${this.databaseRid}/collections/${this.collectionRid}/partitionKeyRangeId/${this.partitionKeyRangeId}/metrics`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string,
private readonly subscriptionId: string, region: string,
private readonly resourceGroupName: string, databaseRid: string,
private readonly accountName: string, collectionRid: string,
private readonly region: string, partitionKeyRangeId: string
private readonly databaseRid: string, ): Promise<Types.PartitionMetricListResult> {
private readonly collectionRid: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/databases/${databaseRid}/collections/${collectionRid}/partitionKeyRangeId/${partitionKeyRangeId}/metrics`;
private readonly partitionKeyRangeId: string
) {}
/* Retrieves the metrics determined by the given filter for the given partition key range id and region. */
async listMetrics(): Promise<Types.PartitionMetricListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,19 +6,12 @@
import * as Types from "./types"; import * as Types from "./types";
export class PercentileClient { /* Retrieves the metrics determined by the given filter for the given database account. This url is only for PBS and Replication Latency data */
private readonly baseUrl = "https://management.azure.com"; export async function listMetrics(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/percentile/metrics`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string
private readonly subscriptionId: string, ): Promise<Types.PercentileMetricListResult> {
private readonly resourceGroupName: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/percentile/metrics`;
private readonly accountName: string
) {}
/* Retrieves the metrics determined by the given filter for the given database account. This url is only for PBS and Replication Latency data */
async listMetrics(): Promise<Types.PercentileMetricListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,21 +6,14 @@
import * as Types from "./types"; import * as Types from "./types";
export class PercentileSourceTargetClient { /* Retrieves the metrics determined by the given filter for the given account, source and target region. This url is only for PBS and Replication Latency data */
private readonly baseUrl = "https://management.azure.com"; export async function listMetrics(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/sourceRegion/${this.sourceRegion}/targetRegion/${this.targetRegion}/percentile/metrics`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string,
private readonly subscriptionId: string, sourceRegion: string,
private readonly resourceGroupName: string, targetRegion: string
private readonly accountName: string, ): Promise<Types.PercentileMetricListResult> {
private readonly sourceRegion: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sourceRegion/${sourceRegion}/targetRegion/${targetRegion}/percentile/metrics`;
private readonly targetRegion: string
) {}
/* Retrieves the metrics determined by the given filter for the given account, source and target region. This url is only for PBS and Replication Latency data */
async listMetrics(): Promise<Types.PercentileMetricListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,20 +6,13 @@
import * as Types from "./types"; import * as Types from "./types";
export class PercentileTargetClient { /* Retrieves the metrics determined by the given filter for the given account target region. This url is only for PBS and Replication Latency data */
private readonly baseUrl = "https://management.azure.com"; export async function listMetrics(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/targetRegion/${this.targetRegion}/percentile/metrics`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string,
private readonly subscriptionId: string, targetRegion: string
private readonly resourceGroupName: string, ): Promise<Types.PercentileMetricListResult> {
private readonly accountName: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/targetRegion/${targetRegion}/percentile/metrics`;
private readonly targetRegion: string
) {}
/* Retrieves the metrics determined by the given filter for the given account target region. This url is only for PBS and Replication Latency data */
async listMetrics(): Promise<Types.PercentileMetricListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,32 +6,29 @@
import * as Types from "./types"; import * as Types from "./types";
export class RestorableDatabaseAccountsClient { /* Lists all the restorable Azure Cosmos DB database accounts available under the subscription and in a region. */
private readonly baseUrl = "https://management.azure.com"; export async function listByLocation(
private readonly basePath = `/subscriptions/${this.subscriptionId}/providers/Microsoft.DocumentDB/`; subscriptionId: string,
constructor(private readonly subscriptionId: string) {}
/* Lists all the restorable Azure Cosmos DB database accounts available under the subscription and in a region. */
async listByLocation(
location: string location: string
): Promise<Types.RestorableDatabaseAccountsListResult | Types.ErrorResponseUpdatedFormat> { ): Promise<Types.RestorableDatabaseAccountsListResult | Types.ErrorResponseUpdatedFormat> {
const path = `locations/${location}/restorableDatabaseAccounts`; const path = `/subscriptions/${subscriptionId}/providers/Microsoft.DocumentDB/locations/${location}/restorableDatabaseAccounts`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Retrieves the properties of an existing Azure Cosmos DB restorable database account. */ /* Lists all the restorable Azure Cosmos DB database accounts available under the subscription. */
async getByLocation( export async function list(
subscriptionId: string
): Promise<Types.RestorableDatabaseAccountsListResult | Types.ErrorResponseUpdatedFormat> {
const path = `/subscriptions/${subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Retrieves the properties of an existing Azure Cosmos DB restorable database account. */
export async function getByLocation(
subscriptionId: string,
location: string, location: string,
instanceId: string instanceId: string
): Promise<Types.RestorableDatabaseAccountGetResult | Types.ErrorResponseUpdatedFormat> { ): Promise<Types.RestorableDatabaseAccountGetResult | Types.ErrorResponseUpdatedFormat> {
const path = `locations/${location}/restorableDatabaseAccounts/${instanceId}`; const path = `/subscriptions/${subscriptionId}/providers/Microsoft.DocumentDB/locations/${location}/restorableDatabaseAccounts/${instanceId}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Lists all the restorable Azure Cosmos DB database accounts available under the subscription. */
async list(): Promise<Types.RestorableDatabaseAccountsListResult | Types.ErrorResponseUpdatedFormat> {
const path = `restorableDatabaseAccounts`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
} }

View File

@@ -6,229 +6,312 @@
import * as Types from "./types"; import * as Types from "./types";
export class SqlResourcesClient { /* Lists the SQL databases under an existing Azure Cosmos DB database account. */
private readonly baseUrl = "https://management.azure.com"; export async function listSqlDatabases(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/sqlDatabases`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string
private readonly subscriptionId: string, ): Promise<Types.SqlDatabaseListResult> {
private readonly resourceGroupName: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases`;
private readonly accountName: string
) {}
/* Lists the SQL databases under an existing Azure Cosmos DB database account. */
async listSqlDatabases(): Promise<Types.SqlDatabaseListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Gets the SQL database under an existing Azure Cosmos DB database account with the provided name. */ /* Gets the SQL database under an existing Azure Cosmos DB database account with the provided name. */
async getSqlDatabase(databaseName: string): Promise<Types.SqlDatabaseGetResults> { export async function getSqlDatabase(
const path = `/${databaseName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string
): Promise<Types.SqlDatabaseGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Create or update an Azure Cosmos DB SQL database */ /* Create or update an Azure Cosmos DB SQL database */
async createUpdateSqlDatabase( export async function createUpdateSqlDatabase(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
body: Types.SqlDatabaseCreateUpdateParameters body: Types.SqlDatabaseCreateUpdateParameters
): Promise<Types.SqlDatabaseGetResults | void> { ): Promise<Types.SqlDatabaseGetResults | void> {
const path = `/${databaseName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB SQL database. */ /* Deletes an existing Azure Cosmos DB SQL database. */
async deleteSqlDatabase(databaseName: string): Promise<void | void> { export async function deleteSqlDatabase(
const path = `/${databaseName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string
): Promise<void | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }
/* Lists the SQL container under an existing Azure Cosmos DB database account. */ /* Gets the RUs per second of the SQL database under an existing Azure Cosmos DB database account with the provided name. */
async listSqlContainers(databaseName: string): Promise<Types.SqlContainerListResult> { export async function getSqlDatabaseThroughput(
const path = `/${databaseName}/containers`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string
): Promise<Types.ThroughputSettingsGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Gets the SQL container under an existing Azure Cosmos DB database account. */ /* Update RUs per second of an Azure Cosmos DB SQL database */
async getSqlContainer(databaseName: string, containerName: string): Promise<Types.SqlContainerGetResults> { export async function updateSqlDatabaseThroughput(
const path = `/${databaseName}/containers/${containerName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
body: Types.ThroughputSettingsUpdateParameters
): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default`;
return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json());
}
/* Lists the SQL container under an existing Azure Cosmos DB database account. */
export async function listSqlContainers(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string
): Promise<Types.SqlContainerListResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Create or update an Azure Cosmos DB SQL container */ /* Gets the SQL container under an existing Azure Cosmos DB database account. */
async createUpdateSqlContainer( export async function getSqlContainer(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
containerName: string
): Promise<Types.SqlContainerGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Create or update an Azure Cosmos DB SQL container */
export async function createUpdateSqlContainer(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
containerName: string, containerName: string,
body: Types.SqlContainerCreateUpdateParameters body: Types.SqlContainerCreateUpdateParameters
): Promise<Types.SqlContainerGetResults | void> { ): Promise<Types.SqlContainerGetResults | void> {
const path = `/${databaseName}/containers/${containerName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB SQL container. */ /* Deletes an existing Azure Cosmos DB SQL container. */
async deleteSqlContainer(databaseName: string, containerName: string): Promise<void | void> { export async function deleteSqlContainer(
const path = `/${databaseName}/containers/${containerName}`; subscriptionId: string,
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); resourceGroupName: string,
} accountName: string,
/* Lists the SQL storedProcedure under an existing Azure Cosmos DB database account. */
async listSqlStoredProcedures(
databaseName: string, databaseName: string,
containerName: string containerName: string
): Promise<Types.SqlStoredProcedureListResult> { ): Promise<void | void> {
const path = `/${databaseName}/containers/${containerName}/storedProcedures`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }
/* Gets the SQL storedProcedure under an existing Azure Cosmos DB database account. */ /* Gets the RUs per second of the SQL container under an existing Azure Cosmos DB database account. */
async getSqlStoredProcedure( export async function getSqlContainerThroughput(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
containerName: string
): Promise<Types.ThroughputSettingsGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Update RUs per second of an Azure Cosmos DB SQL container */
export async function updateSqlContainerThroughput(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
containerName: string,
body: Types.ThroughputSettingsUpdateParameters
): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default`;
return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json());
}
/* Lists the SQL storedProcedure under an existing Azure Cosmos DB database account. */
export async function listSqlStoredProcedures(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
containerName: string
): Promise<Types.SqlStoredProcedureListResult> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Gets the SQL storedProcedure under an existing Azure Cosmos DB database account. */
export async function getSqlStoredProcedure(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
containerName: string, containerName: string,
storedProcedureName: string storedProcedureName: string
): Promise<Types.SqlStoredProcedureGetResults> { ): Promise<Types.SqlStoredProcedureGetResults> {
const path = `/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Create or update an Azure Cosmos DB SQL storedProcedure */ /* Create or update an Azure Cosmos DB SQL storedProcedure */
async createUpdateSqlStoredProcedure( export async function createUpdateSqlStoredProcedure(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
containerName: string, containerName: string,
storedProcedureName: string, storedProcedureName: string,
body: Types.SqlStoredProcedureCreateUpdateParameters body: Types.SqlStoredProcedureCreateUpdateParameters
): Promise<Types.SqlStoredProcedureGetResults | void> { ): Promise<Types.SqlStoredProcedureGetResults | void> {
const path = `/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB SQL storedProcedure. */ /* Deletes an existing Azure Cosmos DB SQL storedProcedure. */
async deleteSqlStoredProcedure( export async function deleteSqlStoredProcedure(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
containerName: string, containerName: string,
storedProcedureName: string storedProcedureName: string
): Promise<void | void> { ): Promise<void | void> {
const path = `/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }
/* Gets the RUs per second of the SQL container under an existing Azure Cosmos DB database account. */ /* Lists the SQL userDefinedFunction under an existing Azure Cosmos DB database account. */
async getSqlContainerThroughput( export async function listSqlUserDefinedFunctions(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
containerName: string containerName: string
): Promise<Types.ThroughputSettingsGetResults> { ): Promise<Types.SqlUserDefinedFunctionListResult> {
const path = `/${databaseName}/containers/${containerName}/throughputSettings/default`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Update RUs per second of an Azure Cosmos DB SQL container */ /* Gets the SQL userDefinedFunction under an existing Azure Cosmos DB database account. */
async updateSqlContainerThroughput( export async function getSqlUserDefinedFunction(
databaseName: string, subscriptionId: string,
containerName: string, resourceGroupName: string,
body: Types.ThroughputSettingsUpdateParameters accountName: string,
): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/${databaseName}/containers/${containerName}/throughputSettings/default`;
return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json());
}
/* Lists the SQL trigger under an existing Azure Cosmos DB database account. */
async listSqlTriggers(databaseName: string, containerName: string): Promise<Types.SqlTriggerListResult> {
const path = `/${databaseName}/containers/${containerName}/triggers`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Gets the SQL trigger under an existing Azure Cosmos DB database account. */
async getSqlTrigger(
databaseName: string,
containerName: string,
triggerName: string
): Promise<Types.SqlTriggerGetResults> {
const path = `/${databaseName}/containers/${containerName}/triggers/${triggerName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Create or update an Azure Cosmos DB SQL trigger */
async createUpdateSqlTrigger(
databaseName: string,
containerName: string,
triggerName: string,
body: Types.SqlTriggerCreateUpdateParameters
): Promise<Types.SqlTriggerGetResults | void> {
const path = `/${databaseName}/containers/${containerName}/triggers/${triggerName}`;
return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json());
}
/* Deletes an existing Azure Cosmos DB SQL trigger. */
async deleteSqlTrigger(databaseName: string, containerName: string, triggerName: string): Promise<void | void> {
const path = `/${databaseName}/containers/${containerName}/triggers/${triggerName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
}
/* Lists the SQL userDefinedFunction under an existing Azure Cosmos DB database account. */
async listSqlUserDefinedFunctions(
databaseName: string,
containerName: string
): Promise<Types.SqlUserDefinedFunctionListResult> {
const path = `/${databaseName}/containers/${containerName}/userDefinedFunctions`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Gets the SQL userDefinedFunction under an existing Azure Cosmos DB database account. */
async getSqlUserDefinedFunction(
databaseName: string, databaseName: string,
containerName: string, containerName: string,
userDefinedFunctionName: string userDefinedFunctionName: string
): Promise<Types.SqlUserDefinedFunctionGetResults> { ): Promise<Types.SqlUserDefinedFunctionGetResults> {
const path = `/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Create or update an Azure Cosmos DB SQL userDefinedFunction */ /* Create or update an Azure Cosmos DB SQL userDefinedFunction */
async createUpdateSqlUserDefinedFunction( export async function createUpdateSqlUserDefinedFunction(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
containerName: string, containerName: string,
userDefinedFunctionName: string, userDefinedFunctionName: string,
body: Types.SqlUserDefinedFunctionCreateUpdateParameters body: Types.SqlUserDefinedFunctionCreateUpdateParameters
): Promise<Types.SqlUserDefinedFunctionGetResults | void> { ): Promise<Types.SqlUserDefinedFunctionGetResults | void> {
const path = `/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB SQL userDefinedFunction. */ /* Deletes an existing Azure Cosmos DB SQL userDefinedFunction. */
async deleteSqlUserDefinedFunction( export async function deleteSqlUserDefinedFunction(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string, databaseName: string,
containerName: string, containerName: string,
userDefinedFunctionName: string userDefinedFunctionName: string
): Promise<void | void> { ): Promise<void | void> {
const path = `/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }
/* Gets the RUs per second of the SQL database under an existing Azure Cosmos DB database account with the provided name. */ /* Lists the SQL trigger under an existing Azure Cosmos DB database account. */
async getSqlDatabaseThroughput(databaseName: string): Promise<Types.ThroughputSettingsGetResults> { export async function listSqlTriggers(
const path = `/${databaseName}/throughputSettings/default`; subscriptionId: string,
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); resourceGroupName: string,
} accountName: string,
/* Update RUs per second of an Azure Cosmos DB SQL database */
async updateSqlDatabaseThroughput(
databaseName: string, databaseName: string,
body: Types.ThroughputSettingsUpdateParameters containerName: string
): Promise<Types.ThroughputSettingsGetResults | void> { ): Promise<Types.SqlTriggerListResult> {
const path = `/${databaseName}/throughputSettings/default`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Gets the SQL trigger under an existing Azure Cosmos DB database account. */
export async function getSqlTrigger(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
containerName: string,
triggerName: string
): Promise<Types.SqlTriggerGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
}
/* Create or update an Azure Cosmos DB SQL trigger */
export async function createUpdateSqlTrigger(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
containerName: string,
triggerName: string,
body: Types.SqlTriggerCreateUpdateParameters
): Promise<Types.SqlTriggerGetResults | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB SQL trigger. */
export async function deleteSqlTrigger(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
databaseName: string,
containerName: string,
triggerName: string
): Promise<void | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }

View File

@@ -6,59 +6,73 @@
import * as Types from "./types"; import * as Types from "./types";
export class TableResourcesClient { /* Lists the Tables under an existing Azure Cosmos DB database account. */
private readonly baseUrl = "https://management.azure.com"; export async function listTables(
private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/tables`; subscriptionId: string,
resourceGroupName: string,
constructor( accountName: string
private readonly subscriptionId: string, ): Promise<Types.TableListResult> {
private readonly resourceGroupName: string, const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables`;
private readonly accountName: string
) {}
/* Lists the Tables under an existing Azure Cosmos DB database account. */
async listTables(): Promise<Types.TableListResult> {
const path = ``;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Gets the Tables under an existing Azure Cosmos DB database account with the provided name. */ /* Gets the Tables under an existing Azure Cosmos DB database account with the provided name. */
async getTable(tableName: string): Promise<Types.TableGetResults> { export async function getTable(
const path = `/${tableName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
tableName: string
): Promise<Types.TableGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Create or update an Azure Cosmos DB Table */ /* Create or update an Azure Cosmos DB Table */
async createUpdateTable( export async function createUpdateTable(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
tableName: string, tableName: string,
body: Types.TableCreateUpdateParameters body: Types.TableCreateUpdateParameters
): Promise<Types.TableGetResults | void> { ): Promise<Types.TableGetResults | void> {
const path = `/${tableName}`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
} }
/* Deletes an existing Azure Cosmos DB Table. */ /* Deletes an existing Azure Cosmos DB Table. */
async deleteTable(tableName: string): Promise<void | void> { export async function deleteTable(
const path = `/${tableName}`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
tableName: string
): Promise<void | void> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json());
} }
/* Gets the RUs per second of the Table under an existing Azure Cosmos DB database account with the provided name. */ /* Gets the RUs per second of the Table under an existing Azure Cosmos DB database account with the provided name. */
async getTableThroughput(tableName: string): Promise<Types.ThroughputSettingsGetResults> { export async function getTableThroughput(
const path = `/${tableName}/throughputSettings/default`; subscriptionId: string,
resourceGroupName: string,
accountName: string,
tableName: string
): Promise<Types.ThroughputSettingsGetResults> {
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default`;
return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json());
} }
/* Update RUs per second of an Azure Cosmos DB Table */ /* Update RUs per second of an Azure Cosmos DB Table */
async updateTableThroughput( export async function updateTableThroughput(
subscriptionId: string,
resourceGroupName: string,
accountName: string,
tableName: string, tableName: string,
body: Types.ThroughputSettingsUpdateParameters body: Types.ThroughputSettingsUpdateParameters
): Promise<Types.ThroughputSettingsGetResults | void> { ): Promise<Types.ThroughputSettingsGetResults | void> {
const path = `/${tableName}/throughputSettings/default`; const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default`;
return window return window
.fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) })
.then(response => response.json()); .then(response => response.json());
}
} }

View File

@@ -191,11 +191,6 @@ async function main() {
for (const clientName in clients) { for (const clientName in clients) {
const outputClient: string[] = [""]; const outputClient: string[] = [""];
outputClient.push(`import * as Types from "./types"\n\n`); outputClient.push(`import * as Types from "./types"\n\n`);
outputClient.push(`export class ${clientName}Client {\n\n`);
outputClient.push(`private readonly baseUrl = "https://management.azure.com"\n`);
const basePath = buildBasePath(clients[clientName].paths);
outputClient.push(`private readonly basePath = \`${basePath.replace(/{/g, "${this.")}\`\n\n`);
outputClient.push(buildConstructor(clients[clientName]));
for (const path of clients[clientName].paths) { for (const path of clients[clientName].paths) {
for (const method in schema.paths[path]) { for (const method in schema.paths[path]) {
const operation = schema.paths[path][method]; const operation = schema.paths[path][method];
@@ -203,15 +198,15 @@ async function main() {
const bodyParameter = operation.parameters.find( const bodyParameter = operation.parameters.find(
(parameter: { in: string; required: boolean }) => parameter.in === "body" && parameter.required === true (parameter: { in: string; required: boolean }) => parameter.in === "body" && parameter.required === true
); );
const constructorParameters = constructorParams(clients[clientName]);
const methodParameters = parametersFromPath(path).filter(p => !constructorParameters.includes(p));
outputClient.push(` outputClient.push(`
/* ${operation.description} */ /* ${operation.description} */
async ${sanitize(camelize(methodName))} ( export async function ${sanitize(camelize(methodName))} (
${methodParameters.map(p => `${p}: string`).join(",\n")} ${parametersFromPath(path)
.map(p => `${p}: string`)
.join(",\n")}
${bodyParam(bodyParameter, "Types")} ${bodyParam(bodyParameter, "Types")}
) : Promise<${responseType(operation, "Types")}> { ) : Promise<${responseType(operation, "Types")}> {
const path = \`${path.replace(basePath, "").replace(/{/g, "${")}\` const path = \`${path.replace(/{/g, "${")}\`
return window.fetch(this.baseUrl + this.basePath + path, { method: "${method}", ${ return window.fetch(this.baseUrl + this.basePath + path, { method: "${method}", ${
bodyParameter ? "body: JSON.stringify(body)" : "" bodyParameter ? "body: JSON.stringify(body)" : ""
} }).then((response) => response.json()) } }).then((response) => response.json())
@@ -219,25 +214,12 @@ async function main() {
`); `);
} }
} }
outputClient.push(`}`);
writeOutputFile(`./${clientName}.ts`, outputClient); writeOutputFile(`./${clientName}.ts`, outputClient);
} }
writeOutputFile("./types.ts", outputTypes); writeOutputFile("./types.ts", outputTypes);
} }
function buildBasePath(strings: string[]) {
const sortArr = strings.sort();
const arrFirstElem = strings[0];
const arrLastElem = sortArr[sortArr.length - 1];
const arrFirstElemLength = arrFirstElem.length;
let i = 0;
while (i < arrFirstElemLength && arrFirstElem.charAt(i) === arrLastElem.charAt(i)) {
i++;
}
return arrFirstElem.substring(0, i);
}
function sanitize(name: string) { function sanitize(name: string) {
if (name === "delete") { if (name === "delete") {
return "destroy"; return "destroy";
@@ -245,23 +227,6 @@ function sanitize(name: string) {
return name; return name;
} }
function buildConstructor(client: Client) {
const params = constructorParams(client);
if (params.length === 0) {
return "";
}
return `\nconstructor(${params.map(p => `private readonly ${p}: string`).join(",")}){}\n`;
}
function constructorParams(client: Client) {
let commonParams = parametersFromPath(client.paths[0]);
for (const path of client.paths) {
const params = parametersFromPath(path);
commonParams = commonParams.filter(p => params.includes(p));
}
return commonParams;
}
function writeOutputFile(outputPath: string, components: string[]) { function writeOutputFile(outputPath: string, components: string[]) {
components.unshift(`/* components.unshift(`/*
AUTOGENERATED FILE AUTOGENERATED FILE