From f4f2d00d7f1b3499e60faa2f9dc42fd1b7c06a5a Mon Sep 17 00:00:00 2001 From: Steve Faulkner Date: Thu, 23 Jul 2020 18:12:58 -0500 Subject: [PATCH] More tweaks --- src/Utils/arm/CassandraResources.ts | 242 +-- src/Utils/arm/Collection.ts | 65 +- src/Utils/arm/CollectionPartition.ts | 47 +- src/Utils/arm/CollectionPartitionRegion.ts | 33 +- src/Utils/arm/CollectionRegion.ts | 33 +- src/Utils/arm/Database.ts | 67 +- src/Utils/arm/DatabaseAccountRegion.ts | 29 +- src/Utils/arm/DatabaseAccounts.ts | 365 ++-- src/Utils/arm/GremlinResources.ts | 242 +-- src/Utils/arm/MongoDBResources.ts | 242 +-- src/Utils/arm/Operations.ts | 19 +- src/Utils/arm/PartitionKeyRangeId.ts | 33 +- src/Utils/arm/PartitionKeyRangeIdRegion.ts | 35 +- src/Utils/arm/Percentile.ts | 27 +- src/Utils/arm/PercentileSourceTarget.ts | 31 +- src/Utils/arm/PercentileTarget.ts | 29 +- src/Utils/arm/RestorableDatabaseAccounts.ts | 55 +- src/Utils/arm/SqlResources.ts | 514 ++--- src/Utils/arm/TableResources.ts | 120 +- src/Utils/arm/types.ts | 1939 ++++++++++--------- tsconfig.strict.json | 1 + utils/armClientGenerator/generator.ts | 114 +- 22 files changed, 2049 insertions(+), 2233 deletions(-) diff --git a/src/Utils/arm/CassandraResources.ts b/src/Utils/arm/CassandraResources.ts index 118cafe0f..3c7d3953d 100644 --- a/src/Utils/arm/CassandraResources.ts +++ b/src/Utils/arm/CassandraResources.ts @@ -4,164 +4,112 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class CassandraResourcesClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/cassandraKeyspaces`; - /* Lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. */ - export async function listCassandraKeyspaces ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces`, { method: "get", }).then((response) => response.json()) - } - + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string + ) {} + /* Lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. */ + async listCassandraKeyspaces(): Promise { + const path = ``; + 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. */ - export async function getCassandraKeyspace ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -keyspaceName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`, { method: "get", }).then((response) => response.json()) - } - + /* Gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the provided name. */ + async getCassandraKeyspace(keyspaceName: string): Promise { + const path = `/${keyspaceName}`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } + /* Create or update an Azure Cosmos DB Cassandra keyspace */ + async createUpdateCassandraKeyspace( + keyspaceName: string, + body: Types.CassandraKeyspaceCreateUpdateParameters + ): Promise { + const path = `/${keyspaceName}`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .then(response => response.json()); + } - /* Create or update an Azure Cosmos DB Cassandra keyspace */ - export async function createUpdateCassandraKeyspace ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -keyspaceName: string - ,body: Types.CassandraKeyspaceCreateUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB Cassandra keyspace. */ + async deleteCassandraKeyspace(keyspaceName: string): Promise { + const path = `/${keyspaceName}`; + 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. */ + async listCassandraTables(keyspaceName: string): Promise { + const path = `/${keyspaceName}/tables`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } - /* Deletes an existing Azure Cosmos DB Cassandra keyspace. */ - export async function deleteCassandraKeyspace ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -keyspaceName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`, { method: "delete", }).then((response) => response.json()) - } - + /* Gets the Cassandra table under an existing Azure Cosmos DB database account. */ + async getCassandraTable(keyspaceName: string, tableName: string): Promise { + const path = `/${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 */ + async createUpdateCassandraTable( + keyspaceName: string, + tableName: string, + body: Types.CassandraTableCreateUpdateParameters + ): Promise { + const path = `/${keyspaceName}/tables/${tableName}`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .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. */ - export async function getCassandraKeyspaceThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -keyspaceName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default`, { method: "get", }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB Cassandra table. */ + async deleteCassandraTable(keyspaceName: string, tableName: string): Promise { + const path = `/${keyspaceName}/tables/${tableName}`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); + } + /* 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, + tableName: string + ): Promise { + const path = `/${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 Keyspace */ - export async function updateCassandraKeyspaceThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -keyspaceName: string - ,body: Types.ThroughputSettingsUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - + /* Update RUs per second of an Azure Cosmos DB Cassandra table */ + async updateCassandraTableThroughput( + keyspaceName: string, + tableName: string, + body: Types.ThroughputSettingsUpdateParameters + ): Promise { + const path = `/${keyspaceName}/tables/${tableName}/throughputSettings/default`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .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 { + const path = `/${keyspaceName}/throughputSettings/default`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).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 { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables`, { method: "get", }).then((response) => response.json()) - } - - - - /* Gets the Cassandra table under an existing Azure Cosmos DB database account. */ - export async function getCassandraTable ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -keyspaceName: string, -tableName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`, { 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, -tableName: string - ,body: Types.CassandraTableCreateUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - - - - /* Deletes an existing Azure Cosmos DB Cassandra table. */ - export async function deleteCassandraTable ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -keyspaceName: string, -tableName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`, { method: "delete", }).then((response) => response.json()) - } - - - - /* Gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB database account with the provided name. */ - export async function getCassandraTableThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -keyspaceName: string, -tableName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default`, { 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, -tableName: string - ,body: Types.ThroughputSettingsUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - \ No newline at end of file + /* Update RUs per second of an Azure Cosmos DB Cassandra Keyspace */ + async updateCassandraKeyspaceThroughput( + keyspaceName: string, + body: Types.ThroughputSettingsUpdateParameters + ): Promise { + const path = `/${keyspaceName}/throughputSettings/default`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .then(response => response.json()); + } +} diff --git a/src/Utils/arm/Collection.ts b/src/Utils/arm/Collection.ts index 56b732b5e..fd577d48d 100644 --- a/src/Utils/arm/Collection.ts +++ b/src/Utils/arm/Collection.ts @@ -4,46 +4,35 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class CollectionClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/databases/${this.databaseRid}/collections/${this.collectionRid}/`; - /* Retrieves the metrics determined by the given filter for the given database account and collection. */ - export async function listMetrics ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseRid: string, -collectionRid: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/metrics`, { method: "get", }).then((response) => response.json()) - } - + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string, + private readonly databaseRid: string, + private readonly collectionRid: string + ) {} + /* Retrieves metric definitions for the given collection. */ + async listMetricDefinitions(): Promise { + const path = `metricDefinitions`; + 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. */ - export async function listUsages ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseRid: string, -collectionRid: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/usages`, { method: "get", }).then((response) => response.json()) - } - + /* Retrieves the metrics determined by the given filter for the given database account and collection. */ + async listMetrics(): Promise { + const path = `metrics`; + 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 { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/metricDefinitions`, { method: "get", }).then((response) => response.json()) - } - \ No newline at end of file + /* Retrieves the usages (most recent storage data) for the given collection. */ + async listUsages(): Promise { + const path = `usages`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } +} diff --git a/src/Utils/arm/CollectionPartition.ts b/src/Utils/arm/CollectionPartition.ts index 1da21132b..50c3bed35 100644 --- a/src/Utils/arm/CollectionPartition.ts +++ b/src/Utils/arm/CollectionPartition.ts @@ -4,32 +4,29 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class CollectionPartitionClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/databases/${this.databaseRid}/collections/${this.collectionRid}/partitions/`; - /* Retrieves the metrics determined by the given filter for the given collection, split by partition. */ - export async function listMetrics ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseRid: string, -collectionRid: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/partitions/metrics`, { method: "get", }).then((response) => response.json()) - } - + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string, + private readonly databaseRid: string, + private readonly collectionRid: string + ) {} + /* Retrieves the metrics determined by the given filter for the given collection, split by partition. */ + async listMetrics(): Promise { + 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, split by partition. */ - export async function listUsages ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseRid: string, -collectionRid: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/partitions/usages`, { method: "get", }).then((response) => response.json()) - } - \ No newline at end of file + /* Retrieves the usages (most recent storage data) for the given collection, split by partition. */ + async listUsages(): Promise { + const path = `usages`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } +} diff --git a/src/Utils/arm/CollectionPartitionRegion.ts b/src/Utils/arm/CollectionPartitionRegion.ts index 4e77f8002..4eb9ddd9c 100644 --- a/src/Utils/arm/CollectionPartitionRegion.ts +++ b/src/Utils/arm/CollectionPartitionRegion.ts @@ -4,19 +4,24 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class CollectionPartitionRegionClient { + private readonly baseUrl = "https://management.azure.com"; + 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`; - /* Retrieves the metrics determined by the given filter for the given collection and region, split by partition. */ - export async function listMetrics ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -region: string, -databaseRid: string, -collectionRid: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/databases/${databaseRid}/collections/${collectionRid}/partitions/metrics`, { method: "get", }).then((response) => response.json()) - } - \ No newline at end of file + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string, + private readonly region: string, + private readonly databaseRid: string, + private readonly collectionRid: string + ) {} + + /* Retrieves the metrics determined by the given filter for the given collection and region, split by partition. */ + async listMetrics(): Promise { + const path = ``; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } +} diff --git a/src/Utils/arm/CollectionRegion.ts b/src/Utils/arm/CollectionRegion.ts index e8a84317b..4fb24a242 100644 --- a/src/Utils/arm/CollectionRegion.ts +++ b/src/Utils/arm/CollectionRegion.ts @@ -4,19 +4,24 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class CollectionRegionClient { + private readonly baseUrl = "https://management.azure.com"; + 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`; - /* Retrieves the metrics determined by the given filter for the given database account, collection and region. */ - export async function listMetrics ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -region: string, -databaseRid: string, -collectionRid: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/databases/${databaseRid}/collections/${collectionRid}/metrics`, { method: "get", }).then((response) => response.json()) - } - \ No newline at end of file + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string, + private readonly region: string, + private readonly databaseRid: string, + private readonly collectionRid: string + ) {} + + /* Retrieves the metrics determined by the given filter for the given database account, collection and region. */ + async listMetrics(): Promise { + const path = ``; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } +} diff --git a/src/Utils/arm/Database.ts b/src/Utils/arm/Database.ts index 94b4a8a2b..afe0a74c9 100644 --- a/src/Utils/arm/Database.ts +++ b/src/Utils/arm/Database.ts @@ -6,47 +6,32 @@ import * as Types from "./types"; -/* Retrieves the metrics determined by the given filter for the given database account and database. */ -export async function listMetrics( - subscriptionId: string, - resourceGroupName: string, - accountName: string, - databaseRid: string -): Promise { - return window - .fetch( - `https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/metrics`, - { method: "get" } - ) - .then(response => response.json()); -} +export class DatabaseClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/databases/${this.databaseRid}/`; -/* Retrieves the usages (most recent data) for the given database. */ -export async function listUsages( - subscriptionId: string, - resourceGroupName: string, - accountName: string, - databaseRid: string -): Promise { - return window - .fetch( - `https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/usages`, - { method: "get" } - ) - .then(response => response.json()); -} + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string, + private readonly databaseRid: string + ) {} -/* Retrieves metric definitions for the given database. */ -export async function listMetricDefinitions( - subscriptionId: string, - resourceGroupName: string, - accountName: string, - databaseRid: string -): Promise { - return window - .fetch( - `https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/metricDefinitions`, - { method: "get" } - ) - .then(response => response.json()); + /* Retrieves metric definitions for the given database. */ + async listMetricDefinitions(): Promise { + const path = `metricDefinitions`; + 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 { + 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 { + const path = `usages`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } } diff --git a/src/Utils/arm/DatabaseAccountRegion.ts b/src/Utils/arm/DatabaseAccountRegion.ts index 31b087b86..ae9a86cc7 100644 --- a/src/Utils/arm/DatabaseAccountRegion.ts +++ b/src/Utils/arm/DatabaseAccountRegion.ts @@ -6,17 +6,20 @@ import * as Types from "./types"; -/* Retrieves the metrics determined by the given filter for the given database account and region. */ -export async function listMetrics( - subscriptionId: string, - resourceGroupName: string, - accountName: string, - region: string -): Promise { - return window - .fetch( - `https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/metrics`, - { method: "get" } - ) - .then(response => response.json()); +export class DatabaseAccountRegionClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/region/${this.region}/metrics`; + + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string, + private readonly region: string + ) {} + + /* Retrieves the metrics determined by the given filter for the given database account and region. */ + async listMetrics(): Promise { + const path = ``; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } } diff --git a/src/Utils/arm/DatabaseAccounts.ts b/src/Utils/arm/DatabaseAccounts.ts index f8100a998..02b975744 100644 --- a/src/Utils/arm/DatabaseAccounts.ts +++ b/src/Utils/arm/DatabaseAccounts.ts @@ -4,215 +4,194 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class DatabaseAccountsClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/`; - /* Retrieves the properties of an existing Azure Cosmos DB database account. */ - export async function get ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`, { method: "get", }).then((response) => response.json()) - } - + /* 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 { + 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 { + const path = `subscriptions/${subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts`; + 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. */ - export async function update ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - ,body: Types.DatabaseAccountUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`, { method: "patch", body: JSON.stringify(body) }).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 { + 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, + resourceGroupName: string, + accountName: string + ): Promise { + 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()); + } - /* Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account. */ - export async function createOrUpdate ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - ,body: Types.DatabaseAccountCreateUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - + /* Updates the properties of an existing Azure Cosmos DB database account. */ + async update( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + body: Types.DatabaseAccountUpdateParameters + ): Promise { + const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "patch", body: JSON.stringify(body) }) + .then(response => response.json()); + } + /* Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account. */ + async createOrUpdate( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + body: Types.DatabaseAccountCreateUpdateParameters + ): Promise { + const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .then(response => response.json()); + } - /* Deletes an existing Azure Cosmos DB database account. */ - export async function delete ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`, { method: "delete", }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB database account. */ + async delete(subscriptionId: string, resourceGroupName: string, accountName: string): Promise { + 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()); + } + /* 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( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + body: Types.FailoverPolicies + ): Promise { + const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/failoverPriorityChange`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "post", body: JSON.stringify(body) }) + .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. */ - export async function failoverPriorityChange ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - ,body: Types.FailoverPolicies - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/failoverPriorityChange`, { method: "post", body: JSON.stringify(body) }).then((response) => response.json()) - } - + /* Lists the connection strings for the specified Azure Cosmos DB database account. */ + async listConnectionStrings( + subscriptionId: string, + resourceGroupName: string, + accountName: string + ): Promise { + 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 { + 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()); + } - /* Lists all the Azure Cosmos DB database accounts available under the subscription. */ - export async function list ( - subscriptionId: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts`, { method: "get", }).then((response) => response.json()) - } - + /* Retrieves metric definitions for the given database account. */ + async listMetricDefinitions( + subscriptionId: string, + resourceGroupName: string, + accountName: string + ): Promise { + 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()); + } + /* Retrieves the metrics determined by the given filter for the given database account. */ + async listMetrics( + subscriptionId: string, + resourceGroupName: string, + accountName: string + ): Promise { + 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()); + } - /* Lists all the Azure Cosmos DB database accounts available under the given resource group. */ - export async function listByResourceGroup ( - subscriptionId: string, -resourceGroupName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts`, { method: "get", }).then((response) => response.json()) - } - + /* Offline the specified region for the specified Azure Cosmos DB database account. */ + async offlineRegion( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + body: Types.RegionForOnlineOffline + ): Promise { + const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/offlineRegion`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "post", body: JSON.stringify(body) }) + .then(response => response.json()); + } + /* Online the specified region for the specified Azure Cosmos DB database account. */ + async onlineRegion( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + body: Types.RegionForOnlineOffline + ): Promise { + const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/onlineRegion`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "post", body: JSON.stringify(body) }) + .then(response => response.json()); + } - /* Lists the access keys for the specified Azure Cosmos DB database account. */ - export async function listKeys ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/listKeys`, { method: "post", }).then((response) => response.json()) - } - + /* Lists the read-only access keys for the specified Azure Cosmos DB database account. */ + async getReadOnlyKeys( + subscriptionId: string, + resourceGroupName: string, + accountName: string + ): Promise { + 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()); + } + /* Lists the read-only access keys for the specified Azure Cosmos DB database account. */ + async listReadOnlyKeys( + subscriptionId: string, + resourceGroupName: string, + accountName: string + ): Promise { + 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()); + } - /* Lists the connection strings for the specified Azure Cosmos DB database account. */ - export async function listConnectionStrings ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/listConnectionStrings`, { method: "post", }).then((response) => response.json()) - } - + /* Regenerates an access key for the specified Azure Cosmos DB database account. */ + async regenerateKey( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + body: Types.DatabaseAccountRegenerateKeyParameters + ): Promise { + const path = `subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/regenerateKey`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "post", body: JSON.stringify(body) }) + .then(response => response.json()); + } - - /* Offline the specified region for the specified Azure Cosmos DB database account. */ - export async function offlineRegion ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - ,body: Types.RegionForOnlineOffline - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/offlineRegion`, { method: "post", body: JSON.stringify(body) }).then((response) => response.json()) - } - - - - /* Online the specified region for the specified Azure Cosmos DB database account. */ - export async function onlineRegion ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - ,body: Types.RegionForOnlineOffline - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/onlineRegion`, { method: "post", body: JSON.stringify(body) }).then((response) => response.json()) - } - - - - /* Lists the read-only access keys for the specified Azure Cosmos DB database account. */ - export async function getReadOnlyKeys ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/readonlykeys`, { method: "get", }).then((response) => response.json()) - } - - - - /* Lists the read-only access keys for the specified Azure Cosmos DB database account. */ - export async function listReadOnlyKeys ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/readonlykeys`, { method: "post", }).then((response) => response.json()) - } - - - - /* Regenerates an access key for the specified Azure Cosmos DB database account. */ - export async function regenerateKey ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - ,body: Types.DatabaseAccountRegenerateKeyParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/regenerateKey`, { method: "post", body: JSON.stringify(body) }).then((response) => response.json()) - } - - - - /* 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. */ - export async function checkNameExists ( - accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/providers/Microsoft.DocumentDB/databaseAccountNames/${accountName}`, { 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, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/metrics`, { 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 { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/usages`, { 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 { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/metricDefinitions`, { method: "get", }).then((response) => response.json()) - } - \ No newline at end of file + /* Retrieves the usages (most recent data) for the given database account. */ + async listUsages( + subscriptionId: string, + resourceGroupName: string, + accountName: string + ): Promise { + 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()); + } +} diff --git a/src/Utils/arm/GremlinResources.ts b/src/Utils/arm/GremlinResources.ts index 9a408e67b..4def1a9c2 100644 --- a/src/Utils/arm/GremlinResources.ts +++ b/src/Utils/arm/GremlinResources.ts @@ -4,164 +4,112 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class GremlinResourcesClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/gremlinDatabases`; - /* Lists the Gremlin databases under an existing Azure Cosmos DB database account. */ - export async function listGremlinDatabases ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases`, { method: "get", }).then((response) => response.json()) - } - + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string + ) {} + /* Lists the Gremlin databases under an existing Azure Cosmos DB database account. */ + async listGremlinDatabases(): Promise { + const path = ``; + 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. */ - export async function getGremlinDatabase ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`, { method: "get", }).then((response) => response.json()) - } - + /* Gets the Gremlin databases under an existing Azure Cosmos DB database account with the provided name. */ + async getGremlinDatabase(databaseName: string): Promise { + const path = `/${databaseName}`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } + /* Create or update an Azure Cosmos DB Gremlin database */ + async createUpdateGremlinDatabase( + databaseName: string, + body: Types.GremlinDatabaseCreateUpdateParameters + ): Promise { + const path = `/${databaseName}`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .then(response => response.json()); + } - /* Create or update an Azure Cosmos DB Gremlin database */ - export async function createUpdateGremlinDatabase ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - ,body: Types.GremlinDatabaseCreateUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB Gremlin database. */ + async deleteGremlinDatabase(databaseName: string): Promise { + const path = `/${databaseName}`; + 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. */ + async listGremlinGraphs(databaseName: string): Promise { + const path = `/${databaseName}/graphs`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } - /* Deletes an existing Azure Cosmos DB Gremlin database. */ - export async function deleteGremlinDatabase ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`, { method: "delete", }).then((response) => response.json()) - } - + /* Gets the Gremlin graph under an existing Azure Cosmos DB database account. */ + async getGremlinGraph(databaseName: string, graphName: string): Promise { + const path = `/${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 */ + async createUpdateGremlinGraph( + databaseName: string, + graphName: string, + body: Types.GremlinGraphCreateUpdateParameters + ): Promise { + const path = `/${databaseName}/graphs/${graphName}`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .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. */ - export async function getGremlinDatabaseThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default`, { method: "get", }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB Gremlin graph. */ + async deleteGremlinGraph(databaseName: string, graphName: string): Promise { + const path = `/${databaseName}/graphs/${graphName}`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); + } + /* Gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with the provided name. */ + async getGremlinGraphThroughput( + databaseName: string, + graphName: string + ): Promise { + const path = `/${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 database */ - export async function updateGremlinDatabaseThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - ,body: Types.ThroughputSettingsUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - + /* Update RUs per second of an Azure Cosmos DB Gremlin graph */ + async updateGremlinGraphThroughput( + databaseName: string, + graphName: string, + body: Types.ThroughputSettingsUpdateParameters + ): Promise { + const path = `/${databaseName}/graphs/${graphName}/throughputSettings/default`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .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 { + const path = `/${databaseName}/throughputSettings/default`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).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 { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs`, { method: "get", }).then((response) => response.json()) - } - - - - /* Gets the Gremlin graph under an existing Azure Cosmos DB database account. */ - export async function getGremlinGraph ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -graphName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`, { 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, -graphName: string - ,body: Types.GremlinGraphCreateUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - - - - /* Deletes an existing Azure Cosmos DB Gremlin graph. */ - export async function deleteGremlinGraph ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -graphName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`, { method: "delete", }).then((response) => response.json()) - } - - - - /* Gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with the provided name. */ - export async function getGremlinGraphThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -graphName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default`, { 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, -graphName: string - ,body: Types.ThroughputSettingsUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - \ No newline at end of file + /* Update RUs per second of an Azure Cosmos DB Gremlin database */ + async updateGremlinDatabaseThroughput( + databaseName: string, + body: Types.ThroughputSettingsUpdateParameters + ): Promise { + const path = `/${databaseName}/throughputSettings/default`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .then(response => response.json()); + } +} diff --git a/src/Utils/arm/MongoDBResources.ts b/src/Utils/arm/MongoDBResources.ts index 8528fca97..08817412c 100644 --- a/src/Utils/arm/MongoDBResources.ts +++ b/src/Utils/arm/MongoDBResources.ts @@ -4,164 +4,112 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class MongoDBResourcesClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/mongodbDatabases`; - /* Lists the MongoDB databases under an existing Azure Cosmos DB database account. */ - export async function listMongoDBDatabases ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases`, { method: "get", }).then((response) => response.json()) - } - + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string + ) {} + /* Lists the MongoDB databases under an existing Azure Cosmos DB database account. */ + async listMongoDBDatabases(): Promise { + const path = ``; + 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. */ - export async function getMongoDBDatabase ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`, { method: "get", }).then((response) => response.json()) - } - + /* Gets the MongoDB databases under an existing Azure Cosmos DB database account with the provided name. */ + async getMongoDBDatabase(databaseName: string): Promise { + const path = `/${databaseName}`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } + /* Create or updates Azure Cosmos DB MongoDB database */ + async createUpdateMongoDBDatabase( + databaseName: string, + body: Types.MongoDBDatabaseCreateUpdateParameters + ): Promise { + const path = `/${databaseName}`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .then(response => response.json()); + } - /* Create or updates Azure Cosmos DB MongoDB database */ - export async function createUpdateMongoDBDatabase ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - ,body: Types.MongoDBDatabaseCreateUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB MongoDB database. */ + async deleteMongoDBDatabase(databaseName: string): Promise { + const path = `/${databaseName}`; + 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. */ + async listMongoDBCollections(databaseName: string): Promise { + const path = `/${databaseName}/collections`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } - /* Deletes an existing Azure Cosmos DB MongoDB database. */ - export async function deleteMongoDBDatabase ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`, { method: "delete", }).then((response) => response.json()) - } - + /* Gets the MongoDB collection under an existing Azure Cosmos DB database account. */ + async getMongoDBCollection(databaseName: string, collectionName: string): Promise { + const path = `/${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 */ + async createUpdateMongoDBCollection( + databaseName: string, + collectionName: string, + body: Types.MongoDBCollectionCreateUpdateParameters + ): Promise { + const path = `/${databaseName}/collections/${collectionName}`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .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. */ - export async function getMongoDBDatabaseThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default`, { method: "get", }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB MongoDB Collection. */ + async deleteMongoDBCollection(databaseName: string, collectionName: string): Promise { + const path = `/${databaseName}/collections/${collectionName}`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); + } + /* 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, + collectionName: string + ): Promise { + const path = `/${databaseName}/collections/${collectionName}/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 */ - export async function updateMongoDBDatabaseThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - ,body: Types.ThroughputSettingsUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - + /* Update the RUs per second of an Azure Cosmos DB MongoDB collection */ + async updateMongoDBCollectionThroughput( + databaseName: string, + collectionName: string, + body: Types.ThroughputSettingsUpdateParameters + ): Promise { + const path = `/${databaseName}/collections/${collectionName}/throughputSettings/default`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .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 { + const path = `/${databaseName}/throughputSettings/default`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).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 { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections`, { method: "get", }).then((response) => response.json()) - } - - - - /* Gets the MongoDB collection under an existing Azure Cosmos DB database account. */ - export async function getMongoDBCollection ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -collectionName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`, { 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, -collectionName: string - ,body: Types.MongoDBCollectionCreateUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - - - - /* Deletes an existing Azure Cosmos DB MongoDB Collection. */ - export async function deleteMongoDBCollection ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -collectionName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`, { method: "delete", }).then((response) => response.json()) - } - - - - /* Gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB database account with the provided name. */ - export async function getMongoDBCollectionThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -collectionName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default`, { 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, -collectionName: string - ,body: Types.ThroughputSettingsUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - \ No newline at end of file + /* Update RUs per second of the an Azure Cosmos DB MongoDB database */ + async updateMongoDBDatabaseThroughput( + databaseName: string, + body: Types.ThroughputSettingsUpdateParameters + ): Promise { + const path = `/${databaseName}/throughputSettings/default`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .then(response => response.json()); + } +} diff --git a/src/Utils/arm/Operations.ts b/src/Utils/arm/Operations.ts index 02c63d2d0..5b0316680 100644 --- a/src/Utils/arm/Operations.ts +++ b/src/Utils/arm/Operations.ts @@ -4,14 +4,15 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class OperationsClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/providers/Microsoft.DocumentDB/operations`; - /* Lists all of the available Cosmos DB Resource Provider operations. */ - export async function list ( - - - ) : Promise { - return window.fetch(`https://management.azure.com/providers/Microsoft.DocumentDB/operations`, { method: "get", }).then((response) => response.json()) - } - \ No newline at end of file + /* Lists all of the available Cosmos DB Resource Provider operations. */ + async list(): Promise { + const path = ``; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } +} diff --git a/src/Utils/arm/PartitionKeyRangeId.ts b/src/Utils/arm/PartitionKeyRangeId.ts index 3249dd2b9..9278f0f72 100644 --- a/src/Utils/arm/PartitionKeyRangeId.ts +++ b/src/Utils/arm/PartitionKeyRangeId.ts @@ -4,19 +4,24 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class PartitionKeyRangeIdClient { + private readonly baseUrl = "https://management.azure.com"; + 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`; - /* Retrieves the metrics determined by the given filter for the given partition key range id. */ - export async function listMetrics ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseRid: string, -collectionRid: string, -partitionKeyRangeId: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/partitionKeyRangeId/${partitionKeyRangeId}/metrics`, { method: "get", }).then((response) => response.json()) - } - \ No newline at end of file + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string, + private readonly databaseRid: string, + private readonly collectionRid: string, + private readonly partitionKeyRangeId: string + ) {} + + /* Retrieves the metrics determined by the given filter for the given partition key range id. */ + async listMetrics(): Promise { + const path = ``; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } +} diff --git a/src/Utils/arm/PartitionKeyRangeIdRegion.ts b/src/Utils/arm/PartitionKeyRangeIdRegion.ts index cf1035349..f5c59bba1 100644 --- a/src/Utils/arm/PartitionKeyRangeIdRegion.ts +++ b/src/Utils/arm/PartitionKeyRangeIdRegion.ts @@ -4,20 +4,25 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class PartitionKeyRangeIdRegionClient { + private readonly baseUrl = "https://management.azure.com"; + 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`; - /* Retrieves the metrics determined by the given filter for the given partition key range id and region. */ - export async function listMetrics ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -region: string, -databaseRid: string, -collectionRid: string, -partitionKeyRangeId: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/databases/${databaseRid}/collections/${collectionRid}/partitionKeyRangeId/${partitionKeyRangeId}/metrics`, { method: "get", }).then((response) => response.json()) - } - \ No newline at end of file + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string, + private readonly region: string, + private readonly databaseRid: string, + private readonly collectionRid: string, + private readonly partitionKeyRangeId: string + ) {} + + /* Retrieves the metrics determined by the given filter for the given partition key range id and region. */ + async listMetrics(): Promise { + const path = ``; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } +} diff --git a/src/Utils/arm/Percentile.ts b/src/Utils/arm/Percentile.ts index edce71e34..739a1bbd5 100644 --- a/src/Utils/arm/Percentile.ts +++ b/src/Utils/arm/Percentile.ts @@ -4,16 +4,21 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class PercentileClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/percentile/metrics`; - /* Retrieves the metrics determined by the given filter for the given database account. This url is only for PBS and Replication Latency data */ - export async function listMetrics ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/percentile/metrics`, { method: "get", }).then((response) => response.json()) - } - \ No newline at end of file + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + 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 { + const path = ``; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } +} diff --git a/src/Utils/arm/PercentileSourceTarget.ts b/src/Utils/arm/PercentileSourceTarget.ts index dc5d6e60c..fe2240b76 100644 --- a/src/Utils/arm/PercentileSourceTarget.ts +++ b/src/Utils/arm/PercentileSourceTarget.ts @@ -4,18 +4,23 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class PercentileSourceTargetClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/sourceRegion/${this.sourceRegion}/targetRegion/${this.targetRegion}/percentile/metrics`; - /* 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 */ - export async function listMetrics ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -sourceRegion: string, -targetRegion: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sourceRegion/${sourceRegion}/targetRegion/${targetRegion}/percentile/metrics`, { method: "get", }).then((response) => response.json()) - } - \ No newline at end of file + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string, + private readonly sourceRegion: string, + 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 { + const path = ``; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } +} diff --git a/src/Utils/arm/PercentileTarget.ts b/src/Utils/arm/PercentileTarget.ts index cb4107e14..b7fffaeb7 100644 --- a/src/Utils/arm/PercentileTarget.ts +++ b/src/Utils/arm/PercentileTarget.ts @@ -4,17 +4,22 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class PercentileTargetClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/targetRegion/${this.targetRegion}/percentile/metrics`; - /* Retrieves the metrics determined by the given filter for the given account target region. This url is only for PBS and Replication Latency data */ - export async function listMetrics ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -targetRegion: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/targetRegion/${targetRegion}/percentile/metrics`, { method: "get", }).then((response) => response.json()) - } - \ No newline at end of file + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string, + 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 { + const path = ``; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } +} diff --git a/src/Utils/arm/RestorableDatabaseAccounts.ts b/src/Utils/arm/RestorableDatabaseAccounts.ts index b865a4f23..17ad0d702 100644 --- a/src/Utils/arm/RestorableDatabaseAccounts.ts +++ b/src/Utils/arm/RestorableDatabaseAccounts.ts @@ -4,37 +4,34 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class RestorableDatabaseAccountsClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/providers/Microsoft.DocumentDB/`; - /* Lists all the restorable Azure Cosmos DB database accounts available under the subscription and in a region. */ - export async function listByLocation ( - subscriptionId: string, -location: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/providers/Microsoft.DocumentDB/locations/${location}/restorableDatabaseAccounts`, { method: "get", }).then((response) => response.json()) - } - + 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 + ): Promise { + const path = `locations/${location}/restorableDatabaseAccounts`; + 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. */ - export async function list ( - subscriptionId: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts`, { method: "get", }).then((response) => response.json()) - } - + /* Retrieves the properties of an existing Azure Cosmos DB restorable database account. */ + async getByLocation( + location: string, + instanceId: string + ): Promise { + const path = `locations/${location}/restorableDatabaseAccounts/${instanceId}`; + 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, -instanceId: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/providers/Microsoft.DocumentDB/locations/${location}/restorableDatabaseAccounts/${instanceId}`, { method: "get", }).then((response) => response.json()) - } - \ No newline at end of file + /* Lists all the restorable Azure Cosmos DB database accounts available under the subscription. */ + async list(): Promise { + const path = `restorableDatabaseAccounts`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } +} diff --git a/src/Utils/arm/SqlResources.ts b/src/Utils/arm/SqlResources.ts index b426b349f..a75442672 100644 --- a/src/Utils/arm/SqlResources.ts +++ b/src/Utils/arm/SqlResources.ts @@ -4,341 +4,231 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class SqlResourcesClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/sqlDatabases`; - /* Lists the SQL databases under an existing Azure Cosmos DB database account. */ - export async function listSqlDatabases ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases`, { method: "get", }).then((response) => response.json()) - } - + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string + ) {} + /* Lists the SQL databases under an existing Azure Cosmos DB database account. */ + async listSqlDatabases(): Promise { + const path = ``; + 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. */ - export async function getSqlDatabase ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`, { method: "get", }).then((response) => response.json()) - } - + /* Gets the SQL database under an existing Azure Cosmos DB database account with the provided name. */ + async getSqlDatabase(databaseName: string): Promise { + const path = `/${databaseName}`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } + /* Create or update an Azure Cosmos DB SQL database */ + async createUpdateSqlDatabase( + databaseName: string, + body: Types.SqlDatabaseCreateUpdateParameters + ): Promise { + const path = `/${databaseName}`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .then(response => response.json()); + } - /* Create or update an Azure Cosmos DB SQL database */ - export async function createUpdateSqlDatabase ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - ,body: Types.SqlDatabaseCreateUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB SQL database. */ + async deleteSqlDatabase(databaseName: string): Promise { + const path = `/${databaseName}`; + 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. */ + async listSqlContainers(databaseName: string): Promise { + const path = `/${databaseName}/containers`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } - /* Deletes an existing Azure Cosmos DB SQL database. */ - export async function deleteSqlDatabase ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`, { method: "delete", }).then((response) => response.json()) - } - + /* Gets the SQL container under an existing Azure Cosmos DB database account. */ + async getSqlContainer(databaseName: string, containerName: string): Promise { + const path = `/${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 */ + async createUpdateSqlContainer( + databaseName: string, + containerName: string, + body: Types.SqlContainerCreateUpdateParameters + ): Promise { + const path = `/${databaseName}/containers/${containerName}`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .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. */ - export async function getSqlDatabaseThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default`, { method: "get", }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB SQL container. */ + async deleteSqlContainer(databaseName: string, containerName: string): Promise { + const path = `/${databaseName}/containers/${containerName}`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "delete" }).then(response => response.json()); + } + /* Lists the SQL storedProcedure under an existing Azure Cosmos DB database account. */ + async listSqlStoredProcedures( + databaseName: string, + containerName: string + ): Promise { + const path = `/${databaseName}/containers/${containerName}/storedProcedures`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } - /* Update RUs per second of an Azure Cosmos DB SQL database */ - export async function updateSqlDatabaseThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string - ,body: Types.ThroughputSettingsUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - + /* Gets the SQL storedProcedure under an existing Azure Cosmos DB database account. */ + async getSqlStoredProcedure( + databaseName: string, + containerName: string, + storedProcedureName: string + ): Promise { + const path = `/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } + /* Create or update an Azure Cosmos DB SQL storedProcedure */ + async createUpdateSqlStoredProcedure( + databaseName: string, + containerName: string, + storedProcedureName: string, + body: Types.SqlStoredProcedureCreateUpdateParameters + ): Promise { + const path = `/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`; + 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 { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers`, { method: "get", }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB SQL storedProcedure. */ + async deleteSqlStoredProcedure( + databaseName: string, + containerName: string, + storedProcedureName: string + ): Promise { + const path = `/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`; + 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. */ + async getSqlContainerThroughput( + databaseName: string, + containerName: string + ): Promise { + const path = `/${databaseName}/containers/${containerName}/throughputSettings/default`; + 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. */ - export async function getSqlContainer ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -containerName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`, { method: "get", }).then((response) => response.json()) - } - + /* Update RUs per second of an Azure Cosmos DB SQL container */ + async updateSqlContainerThroughput( + databaseName: string, + containerName: string, + body: Types.ThroughputSettingsUpdateParameters + ): Promise { + 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 { + const path = `/${databaseName}/containers/${containerName}/triggers`; + 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, -containerName: string - ,body: Types.SqlContainerCreateUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`, { method: "put", body: JSON.stringify(body) }).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 { + 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 { + 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 container. */ - export async function deleteSqlContainer ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -containerName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`, { method: "delete", }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB SQL trigger. */ + async deleteSqlTrigger(databaseName: string, containerName: string, triggerName: string): Promise { + 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 { + const path = `/${databaseName}/containers/${containerName}/userDefinedFunctions`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } - /* Gets the RUs per second of the SQL container under an existing Azure Cosmos DB database account. */ - export async function getSqlContainerThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -containerName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default`, { method: "get", }).then((response) => response.json()) - } - + /* Gets the SQL userDefinedFunction under an existing Azure Cosmos DB database account. */ + async getSqlUserDefinedFunction( + databaseName: string, + containerName: string, + userDefinedFunctionName: string + ): Promise { + const path = `/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } + /* Create or update an Azure Cosmos DB SQL userDefinedFunction */ + async createUpdateSqlUserDefinedFunction( + databaseName: string, + containerName: string, + userDefinedFunctionName: string, + body: Types.SqlUserDefinedFunctionCreateUpdateParameters + ): Promise { + const path = `/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .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 { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB SQL userDefinedFunction. */ + async deleteSqlUserDefinedFunction( + databaseName: string, + containerName: string, + userDefinedFunctionName: string + ): Promise { + const path = `/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`; + 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. */ + async getSqlDatabaseThroughput(databaseName: string): Promise { + const path = `/${databaseName}/throughputSettings/default`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).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 { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures`, { 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, -containerName: string, -storedProcedureName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`, { method: "get", }).then((response) => response.json()) - } - - - - /* Create or update an Azure Cosmos DB SQL storedProcedure */ - export async function createUpdateSqlStoredProcedure ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -containerName: string, -storedProcedureName: string - ,body: Types.SqlStoredProcedureCreateUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - - - - /* Deletes an existing Azure Cosmos DB SQL storedProcedure. */ - export async function deleteSqlStoredProcedure ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -containerName: string, -storedProcedureName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`, { method: "delete", }).then((response) => response.json()) - } - - - - /* Lists the SQL userDefinedFunction under an existing Azure Cosmos DB database account. */ - export async function listSqlUserDefinedFunctions ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -containerName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions`, { method: "get", }).then((response) => response.json()) - } - - - - /* Gets the SQL userDefinedFunction under an existing Azure Cosmos DB database account. */ - export async function getSqlUserDefinedFunction ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -containerName: string, -userDefinedFunctionName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`, { method: "get", }).then((response) => response.json()) - } - - - - /* Create or update an Azure Cosmos DB SQL userDefinedFunction */ - export async function createUpdateSqlUserDefinedFunction ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -containerName: string, -userDefinedFunctionName: string - ,body: Types.SqlUserDefinedFunctionCreateUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - - - - /* Deletes an existing Azure Cosmos DB SQL userDefinedFunction. */ - export async function deleteSqlUserDefinedFunction ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -containerName: string, -userDefinedFunctionName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`, { method: "delete", }).then((response) => response.json()) - } - - - - /* Lists the SQL trigger under an existing Azure Cosmos DB database account. */ - export async function listSqlTriggers ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -databaseName: string, -containerName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers`, { 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 { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`, { 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 { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`, { method: "put", body: JSON.stringify(body) }).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 { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`, { method: "delete", }).then((response) => response.json()) - } - \ No newline at end of file + /* Update RUs per second of an Azure Cosmos DB SQL database */ + async updateSqlDatabaseThroughput( + databaseName: string, + body: Types.ThroughputSettingsUpdateParameters + ): Promise { + const path = `/${databaseName}/throughputSettings/default`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .then(response => response.json()); + } +} diff --git a/src/Utils/arm/TableResources.ts b/src/Utils/arm/TableResources.ts index feaff8c12..e44a316ee 100644 --- a/src/Utils/arm/TableResources.ts +++ b/src/Utils/arm/TableResources.ts @@ -4,81 +4,61 @@ Run "npm run generateARMClients" to regenerate */ -import * as Types from "./types" +import * as Types from "./types"; +export class TableResourcesClient { + private readonly baseUrl = "https://management.azure.com"; + private readonly basePath = `/subscriptions/${this.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${this.accountName}/tables`; - /* Lists the Tables under an existing Azure Cosmos DB database account. */ - export async function listTables ( - subscriptionId: string, -resourceGroupName: string, -accountName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables`, { method: "get", }).then((response) => response.json()) - } - + constructor( + private readonly subscriptionId: string, + private readonly resourceGroupName: string, + private readonly accountName: string + ) {} + /* Lists the Tables under an existing Azure Cosmos DB database account. */ + async listTables(): Promise { + const path = ``; + 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. */ - export async function getTable ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -tableName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`, { method: "get", }).then((response) => response.json()) - } - + /* Gets the Tables under an existing Azure Cosmos DB database account with the provided name. */ + async getTable(tableName: string): Promise { + const path = `/${tableName}`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } + /* Create or update an Azure Cosmos DB Table */ + async createUpdateTable( + tableName: string, + body: Types.TableCreateUpdateParameters + ): Promise { + const path = `/${tableName}`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .then(response => response.json()); + } - /* Create or update an Azure Cosmos DB Table */ - export async function createUpdateTable ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -tableName: string - ,body: Types.TableCreateUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - + /* Deletes an existing Azure Cosmos DB Table. */ + async deleteTable(tableName: string): Promise { + const path = `/${tableName}`; + 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. */ + async getTableThroughput(tableName: string): Promise { + const path = `/${tableName}/throughputSettings/default`; + return window.fetch(this.baseUrl + this.basePath + path, { method: "get" }).then(response => response.json()); + } - /* Deletes an existing Azure Cosmos DB Table. */ - export async function deleteTable ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -tableName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`, { 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. */ - export async function getTableThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -tableName: string - - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default`, { method: "get", }).then((response) => response.json()) - } - - - - /* Update RUs per second of an Azure Cosmos DB Table */ - export async function updateTableThroughput ( - subscriptionId: string, -resourceGroupName: string, -accountName: string, -tableName: string - ,body: Types.ThroughputSettingsUpdateParameters - ) : Promise { - return window.fetch(`https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default`, { method: "put", body: JSON.stringify(body) }).then((response) => response.json()) - } - \ No newline at end of file + /* Update RUs per second of an Azure Cosmos DB Table */ + async updateTableThroughput( + tableName: string, + body: Types.ThroughputSettingsUpdateParameters + ): Promise { + const path = `/${tableName}/throughputSettings/default`; + return window + .fetch(this.baseUrl + this.basePath + path, { method: "put", body: JSON.stringify(body) }) + .then(response => response.json()); + } +} diff --git a/src/Utils/arm/types.ts b/src/Utils/arm/types.ts index eef8aba32..f47a106b8 100644 --- a/src/Utils/arm/types.ts +++ b/src/Utils/arm/types.ts @@ -5,1257 +5,1310 @@ */ export interface DatabaseAccountsListResult { - /* List of database account and their properties. */ - readonly value: DatabaseAccountGetResults[] - } + /* List of database account and their properties. */ + readonly value: DatabaseAccountGetResults[]; +} export interface SqlDatabaseListResult { - /* List of SQL databases and their properties. */ - readonly value: SqlDatabaseGetResults[] - } + /* List of SQL databases and their properties. */ + readonly value: SqlDatabaseGetResults[]; +} export interface SqlContainerListResult { - /* List of containers and their properties. */ - readonly value: SqlContainerGetResults[] - } + /* List of containers and their properties. */ + readonly value: SqlContainerGetResults[]; +} export interface SqlStoredProcedureListResult { - /* List of storedProcedures and their properties. */ - readonly value: SqlStoredProcedureGetResults[] - } + /* List of storedProcedures and their properties. */ + readonly value: SqlStoredProcedureGetResults[]; +} export interface SqlUserDefinedFunctionListResult { - /* List of userDefinedFunctions and their properties. */ - readonly value: SqlUserDefinedFunctionGetResults[] - } + /* List of userDefinedFunctions and their properties. */ + readonly value: SqlUserDefinedFunctionGetResults[]; +} export interface SqlTriggerListResult { - /* List of triggers and their properties. */ - readonly value: SqlTriggerGetResults[] - } + /* List of triggers and their properties. */ + readonly value: SqlTriggerGetResults[]; +} export interface MongoDBDatabaseListResult { - /* List of MongoDB databases and their properties. */ - readonly value: MongoDBDatabaseGetResults[] - } + /* List of MongoDB databases and their properties. */ + readonly value: MongoDBDatabaseGetResults[]; +} export interface MongoDBCollectionListResult { - /* List of MongoDB collections and their properties. */ - readonly value: MongoDBCollectionGetResults[] - } + /* List of MongoDB collections and their properties. */ + readonly value: MongoDBCollectionGetResults[]; +} export interface TableListResult { - /* List of Table and their properties. */ - readonly value: TableGetResults[] - } + /* List of Table and their properties. */ + readonly value: TableGetResults[]; +} export interface CassandraKeyspaceListResult { - /* List of Cassandra keyspaces and their properties. */ - readonly value: CassandraKeyspaceGetResults[] - } + /* List of Cassandra keyspaces and their properties. */ + readonly value: CassandraKeyspaceGetResults[]; +} export interface CassandraTableListResult { - /* List of Cassandra tables and their properties. */ - readonly value: CassandraTableGetResults[] - } + /* List of Cassandra tables and their properties. */ + readonly value: CassandraTableGetResults[]; +} export interface GremlinDatabaseListResult { - /* List of Gremlin databases and their properties. */ - readonly value: GremlinDatabaseGetResults[] - } + /* List of Gremlin databases and their properties. */ + readonly value: GremlinDatabaseGetResults[]; +} export interface GremlinGraphListResult { - /* List of graphs and their properties. */ - readonly value: GremlinGraphGetResults[] - } + /* List of graphs and their properties. */ + readonly value: GremlinGraphGetResults[]; +} export interface ErrorResponse { - /* Error code. */ - code: string - /* Error message indicating why the operation failed. */ - message: string} + /* Error code. */ + code: string; + /* Error message indicating why the operation failed. */ + message: string; +} export interface ErrorResponseUpdatedFormat { - /* undefined */ - error: unknown - } + /* undefined */ + error: unknown; +} export interface FailoverPolicies { - /* List of failover policies. */ - failoverPolicies: FailoverPolicy[] - } + /* List of failover policies. */ + failoverPolicies: FailoverPolicy[]; +} export interface FailoverPolicy { - /* The unique identifier of the region in which the database account replicates to. Example: <accountName>-<locationName>. */ - readonly id: string - /* The name of the region in which the database account exists. */ - locationName: string - /* The failover priority of the region. 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. */ - failoverPriority: number} + /* The unique identifier of the region in which the database account replicates to. Example: <accountName>-<locationName>. */ + readonly id: string; + /* The name of the region in which the database account exists. */ + locationName: string; + /* The failover priority of the region. 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. */ + failoverPriority: number; +} export interface RegionForOnlineOffline { - /* Cosmos DB region, with spaces between words and each word capitalized. */ - region: string} + /* Cosmos DB region, with spaces between words and each word capitalized. */ + region: string; +} export interface Location { - /* The unique identifier of the region within the database account. Example: <accountName>-<locationName>. */ - readonly id: string - /* The name of the region. */ - locationName: string - /* The connection endpoint for the specific region. Example: https://<accountName>-<locationName>.documents.azure.com:443/ */ - readonly documentEndpoint: string - /* undefined */ - provisioningState: ProvisioningState - - /* The failover priority of the region. 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. */ - failoverPriority: number - /* Flag to indicate whether or not this region is an AvailabilityZone region */ - isZoneRedundant: boolean} + /* The unique identifier of the region within the database account. Example: <accountName>-<locationName>. */ + readonly id: string; + /* The name of the region. */ + locationName: string; + /* The connection endpoint for the specific region. Example: https://<accountName>-<locationName>.documents.azure.com:443/ */ + readonly documentEndpoint: string; + /* undefined */ + provisioningState: ProvisioningState; + + /* The failover priority of the region. 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. */ + failoverPriority: number; + /* Flag to indicate whether or not this region is an AvailabilityZone region */ + isZoneRedundant: boolean; +} export interface ARMResourceProperties { - /* The unique resource identifier of the ARM resource. */ - readonly id: string - /* The name of the ARM resource. */ - readonly name: string - /* The type of Azure resource. */ - readonly type: string - /* The location of the resource group to which the resource belongs. */ - location: string - /* undefined */ - tags: Tags - - /* undefined */ - identity: ManagedServiceIdentity - } + /* The unique resource identifier of the ARM resource. */ + readonly id: string; + /* The name of the ARM resource. */ + readonly name: string; + /* The type of Azure resource. */ + readonly type: string; + /* The location of the resource group to which the resource belongs. */ + location: string; + /* undefined */ + tags: Tags; + + /* undefined */ + identity: ManagedServiceIdentity; +} export interface ARMProxyResource { - /* The unique resource identifier of the database account. */ - readonly id: string - /* The name of the database account. */ - readonly name: string - /* The type of Azure resource. */ - readonly type: string} + /* The unique resource identifier of the database account. */ + readonly id: string; + /* The name of the database account. */ + readonly name: string; + /* The type of Azure resource. */ + readonly type: string; +} export type DatabaseAccountGetResults = ARMResourceProperties & { - /* Indicates the type of database account. This can only be set at database account creation. */ - kind: string - /* undefined */ - properties: DatabaseAccountGetProperties - - /* The system meta data relating to this resource. */ - readonly systemData: unknown - } + /* Indicates the type of database account. This can only be set at database account creation. */ + kind: string; + /* undefined */ + properties: DatabaseAccountGetProperties; + + /* The system meta data relating to this resource. */ + readonly systemData: unknown; +}; export interface ExtendedResourceProperties { - /* A system generated property. A unique identifier. */ - readonly _rid: string - /* A system generated property that denotes the last updated timestamp of the resource. */ - readonly _ts: undefined - /* A system generated property representing the resource etag required for optimistic concurrency control. */ - readonly _etag: string} + /* A system generated property. A unique identifier. */ + readonly _rid: string; + /* A system generated property that denotes the last updated timestamp of the resource. */ + readonly _ts: undefined; + /* A system generated property representing the resource etag required for optimistic concurrency control. */ + readonly _etag: string; +} export type ThroughputSettingsGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB resource throughput */ - properties: ThroughputSettingsGetProperties - } + /* The properties of an Azure Cosmos DB resource throughput */ + properties: ThroughputSettingsGetProperties; +}; export interface ThroughputSettingsGetProperties { - /* undefined */ - resource: undefined} + /* undefined */ + resource: undefined; +} export type SqlDatabaseGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB SQL database */ - properties: SqlDatabaseGetProperties - } + /* The properties of an Azure Cosmos DB SQL database */ + properties: SqlDatabaseGetProperties; +}; export interface SqlDatabaseGetProperties { - /* undefined */ - resource: undefined - /* undefined */ - options: undefined} + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} export type SqlContainerGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB container */ - properties: SqlContainerGetProperties - } + /* The properties of an Azure Cosmos DB container */ + properties: SqlContainerGetProperties; +}; export interface SqlContainerGetProperties { - /* undefined */ - resource: undefined - /* undefined */ - options: undefined} + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} export type SqlStoredProcedureGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB storedProcedure */ - properties: SqlStoredProcedureGetProperties - } + /* The properties of an Azure Cosmos DB storedProcedure */ + properties: SqlStoredProcedureGetProperties; +}; export interface SqlStoredProcedureGetProperties { - /* undefined */ - resource: undefined} + /* undefined */ + resource: undefined; +} export type SqlUserDefinedFunctionGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB userDefinedFunction */ - properties: SqlUserDefinedFunctionGetProperties - } + /* The properties of an Azure Cosmos DB userDefinedFunction */ + properties: SqlUserDefinedFunctionGetProperties; +}; export interface SqlUserDefinedFunctionGetProperties { - /* undefined */ - resource: undefined} + /* undefined */ + resource: undefined; +} export type SqlTriggerGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB trigger */ - properties: SqlTriggerGetProperties - } + /* The properties of an Azure Cosmos DB trigger */ + properties: SqlTriggerGetProperties; +}; export interface SqlTriggerGetProperties { - /* undefined */ - resource: undefined} + /* undefined */ + resource: undefined; +} export type MongoDBDatabaseGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB MongoDB database */ - properties: MongoDBDatabaseGetProperties - } + /* The properties of an Azure Cosmos DB MongoDB database */ + properties: MongoDBDatabaseGetProperties; +}; export interface MongoDBDatabaseGetProperties { - /* undefined */ - resource: undefined - /* undefined */ - options: undefined} + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} export type MongoDBCollectionGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB MongoDB collection */ - properties: MongoDBCollectionGetProperties - } + /* The properties of an Azure Cosmos DB MongoDB collection */ + properties: MongoDBCollectionGetProperties; +}; export interface MongoDBCollectionGetProperties { - /* undefined */ - resource: undefined - /* undefined */ - options: undefined} + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} export type TableGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB Table */ - properties: TableGetProperties - } + /* The properties of an Azure Cosmos DB Table */ + properties: TableGetProperties; +}; export interface TableGetProperties { - /* undefined */ - resource: undefined - /* undefined */ - options: undefined} + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} export type CassandraKeyspaceGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB Cassandra keyspace */ - properties: CassandraKeyspaceGetProperties - } + /* The properties of an Azure Cosmos DB Cassandra keyspace */ + properties: CassandraKeyspaceGetProperties; +}; export interface CassandraKeyspaceGetProperties { - /* undefined */ - resource: undefined - /* undefined */ - options: undefined} + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} export type CassandraTableGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB Cassandra table */ - properties: CassandraTableGetProperties - } + /* The properties of an Azure Cosmos DB Cassandra table */ + properties: CassandraTableGetProperties; +}; export interface CassandraTableGetProperties { - /* undefined */ - resource: undefined - /* undefined */ - options: undefined} + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} export type GremlinDatabaseGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB SQL database */ - properties: GremlinDatabaseGetProperties - } + /* The properties of an Azure Cosmos DB SQL database */ + properties: GremlinDatabaseGetProperties; +}; export interface GremlinDatabaseGetProperties { - /* undefined */ - resource: undefined - /* undefined */ - options: undefined} + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} export type GremlinGraphGetResults = ARMResourceProperties & { - /* The properties of an Azure Cosmos DB Gremlin graph */ - properties: GremlinGraphGetProperties - } + /* The properties of an Azure Cosmos DB Gremlin graph */ + properties: GremlinGraphGetProperties; +}; export interface GremlinGraphGetProperties { - /* undefined */ - resource: undefined - /* undefined */ - options: undefined} + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} export interface ConsistencyPolicy { - /* The default consistency level and configuration settings of the Cosmos DB account. */ - defaultConsistencyLevel: string - /* When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated. Accepted range for this value is 1 – 2,147,483,647. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. */ - maxStalenessPrefix: number - /* When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 5 - 86400. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. */ - maxIntervalInSeconds: number} + /* The default consistency level and configuration settings of the Cosmos DB account. */ + defaultConsistencyLevel: string; + /* When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated. Accepted range for this value is 1 – 2,147,483,647. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. */ + maxStalenessPrefix: number; + /* When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 5 - 86400. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. */ + maxIntervalInSeconds: number; +} export interface DatabaseAccountGetProperties { - /* undefined */ - provisioningState: ProvisioningState - - /* The connection endpoint for the Cosmos DB database account. */ - readonly documentEndpoint: string - /* The offer type for the Cosmos DB database account. Default value: Standard. */ - readonly databaseAccountOfferType: DatabaseAccountOfferType - - /* List of IpRules. */ - ipRules: IPRules - - /* Flag to indicate whether to enable/disable Virtual Network ACL rules. */ - isVirtualNetworkFilterEnabled: boolean - /* Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. */ - enableAutomaticFailover: boolean - /* The consistency policy for the Cosmos DB database account. */ - consistencyPolicy: ConsistencyPolicy - - /* List of Cosmos DB capabilities for the account */ - capabilities: Capability[] - - /* An array that contains the write location for the Cosmos DB account. */ - readonly writeLocations: Location[] - - /* An array that contains of the read locations enabled for the Cosmos DB account. */ - readonly readLocations: Location[] - - /* An array that contains all of the locations enabled for the Cosmos DB account. */ - readonly locations: Location[] - - /* An array that contains the regions ordered by their failover priorities. */ - readonly failoverPolicies: FailoverPolicy[] - - /* List of Virtual Network ACL rules configured for the Cosmos DB account. */ - virtualNetworkRules: VirtualNetworkRule[] - - /* List of Private Endpoint Connections configured for the Cosmos DB account. */ - readonly privateEndpointConnections: PrivateEndpointConnection[] - - /* Enables the account to write in multiple locations */ - enableMultipleWriteLocations: boolean - /* Enables the cassandra connector on the Cosmos DB C* account */ - enableCassandraConnector: boolean - /* The cassandra connector offer type for the Cosmos DB database C* account. */ - connectorOffer: ConnectorOffer - - /* Disable write operations on metadata resources (databases, containers, throughput) via account keys */ - disableKeyBasedMetadataWriteAccess: boolean - /* The URI of the key vault */ - keyVaultKeyUri: string - /* Whether requests from Public Network are allowed */ - publicNetworkAccess: PublicNetworkAccess - - /* Flag to indicate whether Free Tier is enabled. */ - enableFreeTier: boolean - /* API specific properties. */ - apiProperties: ApiProperties - - /* Flag to indicate whether to enable storage analytics. */ - enableAnalyticalStorage: boolean - /* A unique identifier assigned to the database account */ - readonly instanceId: string - /* Enum to indicate the mode of account creation. */ - createMode: CreateMode - - /* Parameters to indicate the information about the restore. */ - restoreParameters: RestoreParameters - - /* The object representing the policy for taking backups on an account. */ - backupPolicy: BackupPolicy - } + /* undefined */ + provisioningState: ProvisioningState; + + /* The connection endpoint for the Cosmos DB database account. */ + readonly documentEndpoint: string; + /* The offer type for the Cosmos DB database account. Default value: Standard. */ + readonly databaseAccountOfferType: DatabaseAccountOfferType; + + /* List of IpRules. */ + ipRules: IPRules; + + /* Flag to indicate whether to enable/disable Virtual Network ACL rules. */ + isVirtualNetworkFilterEnabled: boolean; + /* Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. */ + enableAutomaticFailover: boolean; + /* The consistency policy for the Cosmos DB database account. */ + consistencyPolicy: ConsistencyPolicy; + + /* List of Cosmos DB capabilities for the account */ + capabilities: Capability[]; + + /* An array that contains the write location for the Cosmos DB account. */ + readonly writeLocations: Location[]; + + /* An array that contains of the read locations enabled for the Cosmos DB account. */ + readonly readLocations: Location[]; + + /* An array that contains all of the locations enabled for the Cosmos DB account. */ + readonly locations: Location[]; + + /* An array that contains the regions ordered by their failover priorities. */ + readonly failoverPolicies: FailoverPolicy[]; + + /* List of Virtual Network ACL rules configured for the Cosmos DB account. */ + virtualNetworkRules: VirtualNetworkRule[]; + + /* List of Private Endpoint Connections configured for the Cosmos DB account. */ + readonly privateEndpointConnections: PrivateEndpointConnection[]; + + /* Enables the account to write in multiple locations */ + enableMultipleWriteLocations: boolean; + /* Enables the cassandra connector on the Cosmos DB C* account */ + enableCassandraConnector: boolean; + /* The cassandra connector offer type for the Cosmos DB database C* account. */ + connectorOffer: ConnectorOffer; + + /* Disable write operations on metadata resources (databases, containers, throughput) via account keys */ + disableKeyBasedMetadataWriteAccess: boolean; + /* The URI of the key vault */ + keyVaultKeyUri: string; + /* Whether requests from Public Network are allowed */ + publicNetworkAccess: PublicNetworkAccess; + + /* Flag to indicate whether Free Tier is enabled. */ + enableFreeTier: boolean; + /* API specific properties. */ + apiProperties: ApiProperties; + + /* Flag to indicate whether to enable storage analytics. */ + enableAnalyticalStorage: boolean; + /* A unique identifier assigned to the database account */ + readonly instanceId: string; + /* Enum to indicate the mode of account creation. */ + createMode: CreateMode; + + /* Parameters to indicate the information about the restore. */ + restoreParameters: RestoreParameters; + + /* The object representing the policy for taking backups on an account. */ + backupPolicy: BackupPolicy; +} export interface DatabaseAccountCreateUpdateProperties { - /* The consistency policy for the Cosmos DB account. */ - consistencyPolicy: ConsistencyPolicy - - /* An array that contains the georeplication locations enabled for the Cosmos DB account. */ - locations: Location[] - - /* The offer type for the database */ - databaseAccountOfferType: DatabaseAccountOfferType - - /* List of IpRules. */ - ipRules: IPRules - - /* Flag to indicate whether to enable/disable Virtual Network ACL rules. */ - isVirtualNetworkFilterEnabled: boolean - /* Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. */ - enableAutomaticFailover: boolean - /* List of Cosmos DB capabilities for the account */ - capabilities: Capability[] - - /* List of Virtual Network ACL rules configured for the Cosmos DB account. */ - virtualNetworkRules: VirtualNetworkRule[] - - /* Enables the account to write in multiple locations */ - enableMultipleWriteLocations: boolean - /* Enables the cassandra connector on the Cosmos DB C* account */ - enableCassandraConnector: boolean - /* The cassandra connector offer type for the Cosmos DB database C* account. */ - connectorOffer: ConnectorOffer - - /* Disable write operations on metadata resources (databases, containers, throughput) via account keys */ - disableKeyBasedMetadataWriteAccess: boolean - /* The URI of the key vault */ - keyVaultKeyUri: string - /* Whether requests from Public Network are allowed */ - publicNetworkAccess: PublicNetworkAccess - - /* Flag to indicate whether Free Tier is enabled. */ - enableFreeTier: boolean - /* API specific properties. Currently, supported only for MongoDB API. */ - apiProperties: ApiProperties - - /* Flag to indicate whether to enable storage analytics. */ - enableAnalyticalStorage: boolean - /* Enum to indicate the mode of account creation. */ - createMode: CreateMode - - /* The object representing the policy for taking backups on an account. */ - backupPolicy: BackupPolicy - } + /* The consistency policy for the Cosmos DB account. */ + consistencyPolicy: ConsistencyPolicy; + + /* An array that contains the georeplication locations enabled for the Cosmos DB account. */ + locations: Location[]; + + /* The offer type for the database */ + databaseAccountOfferType: DatabaseAccountOfferType; + + /* List of IpRules. */ + ipRules: IPRules; + + /* Flag to indicate whether to enable/disable Virtual Network ACL rules. */ + isVirtualNetworkFilterEnabled: boolean; + /* Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. */ + enableAutomaticFailover: boolean; + /* List of Cosmos DB capabilities for the account */ + capabilities: Capability[]; + + /* List of Virtual Network ACL rules configured for the Cosmos DB account. */ + virtualNetworkRules: VirtualNetworkRule[]; + + /* Enables the account to write in multiple locations */ + enableMultipleWriteLocations: boolean; + /* Enables the cassandra connector on the Cosmos DB C* account */ + enableCassandraConnector: boolean; + /* The cassandra connector offer type for the Cosmos DB database C* account. */ + connectorOffer: ConnectorOffer; + + /* Disable write operations on metadata resources (databases, containers, throughput) via account keys */ + disableKeyBasedMetadataWriteAccess: boolean; + /* The URI of the key vault */ + keyVaultKeyUri: string; + /* Whether requests from Public Network are allowed */ + publicNetworkAccess: PublicNetworkAccess; + + /* Flag to indicate whether Free Tier is enabled. */ + enableFreeTier: boolean; + /* API specific properties. Currently, supported only for MongoDB API. */ + apiProperties: ApiProperties; + + /* Flag to indicate whether to enable storage analytics. */ + enableAnalyticalStorage: boolean; + /* Enum to indicate the mode of account creation. */ + createMode: CreateMode; + + /* The object representing the policy for taking backups on an account. */ + backupPolicy: BackupPolicy; +} export type RestoreReqeustDatabaseAccountCreateUpdateProperties = DatabaseAccountCreateUpdateProperties & { - /* Parameters to indicate the information about the restore. */ - restoreParameters: RestoreParameters - } + /* Parameters to indicate the information about the restore. */ + restoreParameters: RestoreParameters; +}; export type DatabaseAccountCreateUpdateParameters = ARMResourceProperties & { - /* Indicates the type of database account. This can only be set at database account creation. */ - kind: string - /* undefined */ - properties: DatabaseAccountCreateUpdateProperties - } + /* Indicates the type of database account. This can only be set at database account creation. */ + kind: string; + /* undefined */ + properties: DatabaseAccountCreateUpdateProperties; +}; export interface DatabaseAccountUpdateProperties { - /* The consistency policy for the Cosmos DB account. */ - consistencyPolicy: ConsistencyPolicy - - /* An array that contains the georeplication locations enabled for the Cosmos DB account. */ - locations: Location[] - - /* List of IpRules. */ - ipRules: IPRules - - /* Flag to indicate whether to enable/disable Virtual Network ACL rules. */ - isVirtualNetworkFilterEnabled: boolean - /* Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. */ - enableAutomaticFailover: boolean - /* List of Cosmos DB capabilities for the account */ - capabilities: Capability[] - - /* List of Virtual Network ACL rules configured for the Cosmos DB account. */ - virtualNetworkRules: VirtualNetworkRule[] - - /* Enables the account to write in multiple locations */ - enableMultipleWriteLocations: boolean - /* Enables the cassandra connector on the Cosmos DB C* account */ - enableCassandraConnector: boolean - /* The cassandra connector offer type for the Cosmos DB database C* account. */ - connectorOffer: ConnectorOffer - - /* Disable write operations on metadata resources (databases, containers, throughput) via account keys */ - disableKeyBasedMetadataWriteAccess: boolean - /* The URI of the key vault */ - keyVaultKeyUri: string - /* Whether requests from Public Network are allowed */ - publicNetworkAccess: PublicNetworkAccess - - /* Flag to indicate whether Free Tier is enabled. */ - enableFreeTier: boolean - /* API specific properties. Currently, supported only for MongoDB API. */ - apiProperties: ApiProperties - - /* Flag to indicate whether to enable storage analytics. */ - enableAnalyticalStorage: boolean - /* The object representing the policy for taking backups on an account. */ - backupPolicy: BackupPolicy - } + /* The consistency policy for the Cosmos DB account. */ + consistencyPolicy: ConsistencyPolicy; + + /* An array that contains the georeplication locations enabled for the Cosmos DB account. */ + locations: Location[]; + + /* List of IpRules. */ + ipRules: IPRules; + + /* Flag to indicate whether to enable/disable Virtual Network ACL rules. */ + isVirtualNetworkFilterEnabled: boolean; + /* Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. */ + enableAutomaticFailover: boolean; + /* List of Cosmos DB capabilities for the account */ + capabilities: Capability[]; + + /* List of Virtual Network ACL rules configured for the Cosmos DB account. */ + virtualNetworkRules: VirtualNetworkRule[]; + + /* Enables the account to write in multiple locations */ + enableMultipleWriteLocations: boolean; + /* Enables the cassandra connector on the Cosmos DB C* account */ + enableCassandraConnector: boolean; + /* The cassandra connector offer type for the Cosmos DB database C* account. */ + connectorOffer: ConnectorOffer; + + /* Disable write operations on metadata resources (databases, containers, throughput) via account keys */ + disableKeyBasedMetadataWriteAccess: boolean; + /* The URI of the key vault */ + keyVaultKeyUri: string; + /* Whether requests from Public Network are allowed */ + publicNetworkAccess: PublicNetworkAccess; + + /* Flag to indicate whether Free Tier is enabled. */ + enableFreeTier: boolean; + /* API specific properties. Currently, supported only for MongoDB API. */ + apiProperties: ApiProperties; + + /* Flag to indicate whether to enable storage analytics. */ + enableAnalyticalStorage: boolean; + /* The object representing the policy for taking backups on an account. */ + backupPolicy: BackupPolicy; +} export interface DatabaseAccountUpdateParameters { - /* undefined */ - tags: Tags - - /* The location of the resource group to which the resource belongs. */ - location: string - /* undefined */ - properties: DatabaseAccountUpdateProperties - } + /* undefined */ + tags: Tags; + + /* The location of the resource group to which the resource belongs. */ + location: string; + /* undefined */ + properties: DatabaseAccountUpdateProperties; +} export interface DatabaseAccountListReadOnlyKeysResult { - /* Base 64 encoded value of the primary read-only key. */ - readonly primaryReadonlyMasterKey: string - /* Base 64 encoded value of the secondary read-only key. */ - readonly secondaryReadonlyMasterKey: string} + /* Base 64 encoded value of the primary read-only key. */ + readonly primaryReadonlyMasterKey: string; + /* Base 64 encoded value of the secondary read-only key. */ + readonly secondaryReadonlyMasterKey: string; +} export type DatabaseAccountListKeysResult = DatabaseAccountListReadOnlyKeysResult & { - /* Base 64 encoded value of the primary read-write key. */ - readonly primaryMasterKey: string - /* Base 64 encoded value of the secondary read-write key. */ - readonly secondaryMasterKey: string} + /* Base 64 encoded value of the primary read-write key. */ + readonly primaryMasterKey: string; + /* Base 64 encoded value of the secondary read-write key. */ + readonly secondaryMasterKey: string; +}; export interface DatabaseAccountConnectionString { - /* Value of the connection string */ - readonly connectionString: string - /* Description of the connection string */ - readonly description: string} + /* Value of the connection string */ + readonly connectionString: string; + /* Description of the connection string */ + readonly description: string; +} export interface DatabaseAccountListConnectionStringsResult { - /* An array that contains the connection strings for the Cosmos DB account. */ - connectionStrings: DatabaseAccountConnectionString[] - } + /* An array that contains the connection strings for the Cosmos DB account. */ + connectionStrings: DatabaseAccountConnectionString[]; +} export interface DatabaseAccountRegenerateKeyParameters { - /* The access key to regenerate. */ - keyKind: string} + /* The access key to regenerate. */ + keyKind: string; +} - - /* The offer type for the Cosmos DB database account. */ - export type DatabaseAccountOfferType = "Standard" +/* The offer type for the Cosmos DB database account. */ +export type DatabaseAccountOfferType = "Standard"; export type ThroughputSettingsUpdateParameters = ARMResourceProperties & { - /* Properties to update Azure Cosmos DB resource throughput. */ - properties: ThroughputSettingsUpdateProperties - } + /* Properties to update Azure Cosmos DB resource throughput. */ + properties: ThroughputSettingsUpdateProperties; +}; export interface ThroughputSettingsUpdateProperties { - /* The standard JSON format of a resource throughput */ - resource: ThroughputSettingsResource - } + /* The standard JSON format of a resource throughput */ + resource: ThroughputSettingsResource; +} export type SqlDatabaseCreateUpdateParameters = ARMResourceProperties & { - /* Properties to create and update Azure Cosmos DB SQL database. */ - properties: SqlDatabaseCreateUpdateProperties - } + /* Properties to create and update Azure Cosmos DB SQL database. */ + properties: SqlDatabaseCreateUpdateProperties; +}; export interface SqlDatabaseCreateUpdateProperties { - /* The standard JSON format of a SQL database */ - resource: SqlDatabaseResource - - /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ - options: CreateUpdateOptions - } + /* The standard JSON format of a SQL database */ + resource: SqlDatabaseResource; + + /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ + options: CreateUpdateOptions; +} export type SqlContainerCreateUpdateParameters = ARMResourceProperties & { - /* Properties to create and update Azure Cosmos DB container. */ - properties: SqlContainerCreateUpdateProperties - } + /* Properties to create and update Azure Cosmos DB container. */ + properties: SqlContainerCreateUpdateProperties; +}; export interface SqlContainerCreateUpdateProperties { - /* The standard JSON format of a container */ - resource: SqlContainerResource - - /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ - options: CreateUpdateOptions - } + /* The standard JSON format of a container */ + resource: SqlContainerResource; + + /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ + options: CreateUpdateOptions; +} export type SqlStoredProcedureCreateUpdateParameters = ARMResourceProperties & { - /* Properties to create and update Azure Cosmos DB storedProcedure. */ - properties: SqlStoredProcedureCreateUpdateProperties - } + /* Properties to create and update Azure Cosmos DB storedProcedure. */ + properties: SqlStoredProcedureCreateUpdateProperties; +}; export interface SqlStoredProcedureCreateUpdateProperties { - /* The standard JSON format of a storedProcedure */ - resource: SqlStoredProcedureResource - - /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ - options: CreateUpdateOptions - } + /* The standard JSON format of a storedProcedure */ + resource: SqlStoredProcedureResource; + + /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ + options: CreateUpdateOptions; +} export type SqlUserDefinedFunctionCreateUpdateParameters = ARMResourceProperties & { - /* Properties to create and update Azure Cosmos DB userDefinedFunction. */ - properties: SqlUserDefinedFunctionCreateUpdateProperties - } + /* Properties to create and update Azure Cosmos DB userDefinedFunction. */ + properties: SqlUserDefinedFunctionCreateUpdateProperties; +}; export interface SqlUserDefinedFunctionCreateUpdateProperties { - /* The standard JSON format of a userDefinedFunction */ - resource: SqlUserDefinedFunctionResource - - /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ - options: CreateUpdateOptions - } + /* The standard JSON format of a userDefinedFunction */ + resource: SqlUserDefinedFunctionResource; + + /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ + options: CreateUpdateOptions; +} export type SqlTriggerCreateUpdateParameters = ARMResourceProperties & { - /* Properties to create and update Azure Cosmos DB trigger. */ - properties: SqlTriggerCreateUpdateProperties - } + /* Properties to create and update Azure Cosmos DB trigger. */ + properties: SqlTriggerCreateUpdateProperties; +}; export interface SqlTriggerCreateUpdateProperties { - /* The standard JSON format of a trigger */ - resource: SqlTriggerResource - - /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ - options: CreateUpdateOptions - } + /* The standard JSON format of a trigger */ + resource: SqlTriggerResource; + + /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ + options: CreateUpdateOptions; +} export type MongoDBDatabaseCreateUpdateParameters = ARMResourceProperties & { - /* Properties to create and update Azure Cosmos DB MongoDB database. */ - properties: MongoDBDatabaseCreateUpdateProperties - } + /* Properties to create and update Azure Cosmos DB MongoDB database. */ + properties: MongoDBDatabaseCreateUpdateProperties; +}; export interface MongoDBDatabaseCreateUpdateProperties { - /* The standard JSON format of a MongoDB database */ - resource: MongoDBDatabaseResource - - /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ - options: CreateUpdateOptions - } + /* The standard JSON format of a MongoDB database */ + resource: MongoDBDatabaseResource; + + /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ + options: CreateUpdateOptions; +} export type MongoDBCollectionCreateUpdateParameters = ARMResourceProperties & { - /* Properties to create and update Azure Cosmos DB MongoDB collection. */ - properties: MongoDBCollectionCreateUpdateProperties - } + /* Properties to create and update Azure Cosmos DB MongoDB collection. */ + properties: MongoDBCollectionCreateUpdateProperties; +}; export interface MongoDBCollectionCreateUpdateProperties { - /* The standard JSON format of a MongoDB collection */ - resource: MongoDBCollectionResource - - /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ - options: CreateUpdateOptions - } + /* The standard JSON format of a MongoDB collection */ + resource: MongoDBCollectionResource; + + /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ + options: CreateUpdateOptions; +} export type TableCreateUpdateParameters = ARMResourceProperties & { - /* Properties to create and update Azure Cosmos DB Table. */ - properties: TableCreateUpdateProperties - } + /* Properties to create and update Azure Cosmos DB Table. */ + properties: TableCreateUpdateProperties; +}; export interface TableCreateUpdateProperties { - /* The standard JSON format of a Table */ - resource: TableResource - - /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ - options: CreateUpdateOptions - } + /* The standard JSON format of a Table */ + resource: TableResource; + + /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ + options: CreateUpdateOptions; +} export type CassandraKeyspaceCreateUpdateParameters = ARMResourceProperties & { - /* Properties to create and update Azure Cosmos DB Cassandra keyspace. */ - properties: CassandraKeyspaceCreateUpdateProperties - } + /* Properties to create and update Azure Cosmos DB Cassandra keyspace. */ + properties: CassandraKeyspaceCreateUpdateProperties; +}; export interface CassandraKeyspaceCreateUpdateProperties { - /* The standard JSON format of a Cassandra keyspace */ - resource: CassandraKeyspaceResource - - /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ - options: CreateUpdateOptions - } + /* The standard JSON format of a Cassandra keyspace */ + resource: CassandraKeyspaceResource; + + /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ + options: CreateUpdateOptions; +} export type CassandraTableCreateUpdateParameters = ARMResourceProperties & { - /* Properties to create and update Azure Cosmos DB Cassandra table. */ - properties: CassandraTableCreateUpdateProperties - } + /* Properties to create and update Azure Cosmos DB Cassandra table. */ + properties: CassandraTableCreateUpdateProperties; +}; export interface CassandraTableCreateUpdateProperties { - /* The standard JSON format of a Cassandra table */ - resource: CassandraTableResource - - /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ - options: CreateUpdateOptions - } + /* The standard JSON format of a Cassandra table */ + resource: CassandraTableResource; + + /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ + options: CreateUpdateOptions; +} export type GremlinDatabaseCreateUpdateParameters = ARMResourceProperties & { - /* Properties to create and update Azure Cosmos DB Gremlin database. */ - properties: GremlinDatabaseCreateUpdateProperties - } + /* Properties to create and update Azure Cosmos DB Gremlin database. */ + properties: GremlinDatabaseCreateUpdateProperties; +}; export interface GremlinDatabaseCreateUpdateProperties { - /* The standard JSON format of a Gremlin database */ - resource: GremlinDatabaseResource - - /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ - options: CreateUpdateOptions - } + /* The standard JSON format of a Gremlin database */ + resource: GremlinDatabaseResource; + + /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ + options: CreateUpdateOptions; +} export type GremlinGraphCreateUpdateParameters = ARMResourceProperties & { - /* Properties to create and update Azure Cosmos DB Gremlin graph. */ - properties: GremlinGraphCreateUpdateProperties - } + /* Properties to create and update Azure Cosmos DB Gremlin graph. */ + properties: GremlinGraphCreateUpdateProperties; +}; export interface GremlinGraphCreateUpdateProperties { - /* The standard JSON format of a Gremlin graph */ - resource: GremlinGraphResource - - /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ - options: CreateUpdateOptions - } + /* The standard JSON format of a Gremlin graph */ + resource: GremlinGraphResource; + + /* A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. */ + options: CreateUpdateOptions; +} export interface ThroughputSettingsResource { - /* Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both. */ - throughput: number - /* Cosmos DB resource for autoscale settings. Either throughput is required or autoscaleSettings is required, but not both. */ - autoscaleSettings: AutoscaleSettingsResource - - /* The minimum throughput of the resource */ - readonly minimumThroughput: string - /* The throughput replace is pending */ - readonly offerReplacePending: string} + /* Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both. */ + throughput: number; + /* Cosmos DB resource for autoscale settings. Either throughput is required or autoscaleSettings is required, but not both. */ + autoscaleSettings: AutoscaleSettingsResource; + + /* The minimum throughput of the resource */ + readonly minimumThroughput: string; + /* The throughput replace is pending */ + readonly offerReplacePending: string; +} export interface AutoscaleSettingsResource { - /* Represents maximum throughput container can scale up to. */ - maxThroughput: number - /* Cosmos DB resource auto-upgrade policy */ - autoUpgradePolicy: AutoUpgradePolicyResource - - /* Represents target maximum throughput container can scale up to once offer is no longer in pending state. */ - readonly targetMaxThroughput: number} + /* Represents maximum throughput container can scale up to. */ + maxThroughput: number; + /* Cosmos DB resource auto-upgrade policy */ + autoUpgradePolicy: AutoUpgradePolicyResource; + + /* Represents target maximum throughput container can scale up to once offer is no longer in pending state. */ + readonly targetMaxThroughput: number; +} export interface AutoUpgradePolicyResource { - /* Represents throughput policy which service must adhere to for auto-upgrade */ - throughputPolicy: ThroughputPolicyResource - } + /* Represents throughput policy which service must adhere to for auto-upgrade */ + throughputPolicy: ThroughputPolicyResource; +} export interface ThroughputPolicyResource { - /* Determines whether the ThroughputPolicy is active or not */ - isEnabled: boolean - /* Represents the percentage by which throughput can increase every time throughput policy kicks in. */ - incrementPercent: number} + /* Determines whether the ThroughputPolicy is active or not */ + isEnabled: boolean; + /* Represents the percentage by which throughput can increase every time throughput policy kicks in. */ + incrementPercent: number; +} export interface OptionsResource { - /* Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. */ - throughput: number - /* Specifies the Autoscale settings. */ - autoscaleSettings: AutoscaleSettings - } + /* Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. */ + throughput: number; + /* Specifies the Autoscale settings. */ + autoscaleSettings: AutoscaleSettings; +} export interface SqlDatabaseResource { - /* Name of the Cosmos DB SQL database */ - id: string} + /* Name of the Cosmos DB SQL database */ + id: string; +} export interface SqlContainerResource { - /* Name of the Cosmos DB SQL container */ - id: string - /* The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container */ - indexingPolicy: IndexingPolicy - - /* The configuration of the partition key to be used for partitioning data into multiple partitions */ - partitionKey: ContainerPartitionKey - - /* Default time to live */ - defaultTtl: number - /* The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. */ - uniqueKeyPolicy: UniqueKeyPolicy - - /* The conflict resolution policy for the container. */ - conflictResolutionPolicy: ConflictResolutionPolicy - } + /* Name of the Cosmos DB SQL container */ + id: string; + /* The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container */ + indexingPolicy: IndexingPolicy; + + /* The configuration of the partition key to be used for partitioning data into multiple partitions */ + partitionKey: ContainerPartitionKey; + + /* Default time to live */ + defaultTtl: number; + /* The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. */ + uniqueKeyPolicy: UniqueKeyPolicy; + + /* The conflict resolution policy for the container. */ + conflictResolutionPolicy: ConflictResolutionPolicy; +} export interface IndexingPolicy { - /* Indicates if the indexing policy is automatic */ - automatic: boolean - /* Indicates the indexing mode. */ - indexingMode: string - /* List of paths to include in the indexing */ - includedPaths: IncludedPath[] - - /* List of paths to exclude from indexing */ - excludedPaths: ExcludedPath[] - - /* List of composite path list */ - compositeIndexes: CompositePathList[] - - /* List of spatial specifics */ - spatialIndexes: SpatialSpec[] - } + /* Indicates if the indexing policy is automatic */ + automatic: boolean; + /* Indicates the indexing mode. */ + indexingMode: string; + /* List of paths to include in the indexing */ + includedPaths: IncludedPath[]; + + /* List of paths to exclude from indexing */ + excludedPaths: ExcludedPath[]; + + /* List of composite path list */ + compositeIndexes: CompositePathList[]; + + /* List of spatial specifics */ + spatialIndexes: SpatialSpec[]; +} export interface ExcludedPath { - /* The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) */ - path: string} + /* The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) */ + path: string; +} export interface IncludedPath { - /* The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) */ - path: string - /* List of indexes for this path */ - indexes: Indexes[] - } + /* The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) */ + path: string; + /* List of indexes for this path */ + indexes: Indexes[]; +} export interface Indexes { - /* The datatype for which the indexing behavior is applied to. */ - dataType: string - /* The precision of the index. -1 is maximum precision. */ - precision: number - /* Indicates the type of index. */ - kind: string} + /* The datatype for which the indexing behavior is applied to. */ + dataType: string; + /* The precision of the index. -1 is maximum precision. */ + precision: number; + /* Indicates the type of index. */ + kind: string; +} - - /* List of composite path */ - export type CompositePathList = CompositePath[] - export interface CompositePath { - /* The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) */ - path: string - /* Sort order for composite paths. */ - order: string} +/* List of composite path */ +export type CompositePathList = CompositePath[]; +export interface CompositePath { + /* The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) */ + path: string; + /* Sort order for composite paths. */ + order: string; +} export interface SpatialSpec { - /* The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) */ - path: string - /* List of path's spatial type */ - types: SpatialType[] - } + /* The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) */ + path: string; + /* List of path's spatial type */ + types: SpatialType[]; +} - - /* Indicates the spatial type of index. */ - export type SpatialType = "Point" | "LineString" | "Polygon" | "MultiPolygon" +/* Indicates the spatial type of index. */ +export type SpatialType = "Point" | "LineString" | "Polygon" | "MultiPolygon"; export interface ContainerPartitionKey { - /* List of paths using which data within the container can be partitioned */ - paths: Path[] - - /* Indicates the kind of algorithm used for partitioning */ - kind: string - /* Indicates the version of the partition key definition */ - version: number} + /* List of paths using which data within the container can be partitioned */ + paths: Path[]; + /* Indicates the kind of algorithm used for partitioning */ + kind: string; + /* Indicates the version of the partition key definition */ + version: number; +} - /* A path. These typically start with root (/path) */ - export type Path = string - export interface UniqueKeyPolicy { - /* List of unique keys on that enforces uniqueness constraint on documents in the collection in the Azure Cosmos DB service. */ - uniqueKeys: UniqueKey[] - } +/* A path. These typically start with root (/path) */ +export type Path = string; +export interface UniqueKeyPolicy { + /* List of unique keys on that enforces uniqueness constraint on documents in the collection in the Azure Cosmos DB service. */ + uniqueKeys: UniqueKey[]; +} export interface UniqueKey { - /* List of paths must be unique for each document in the Azure Cosmos DB service */ - paths: Path[] - } + /* List of paths must be unique for each document in the Azure Cosmos DB service */ + paths: Path[]; +} export interface ConflictResolutionPolicy { - /* Indicates the conflict resolution mode. */ - mode: string - /* The conflict resolution path in the case of LastWriterWins mode. */ - conflictResolutionPath: string - /* The procedure to resolve conflicts in the case of custom mode. */ - conflictResolutionProcedure: string} + /* Indicates the conflict resolution mode. */ + mode: string; + /* The conflict resolution path in the case of LastWriterWins mode. */ + conflictResolutionPath: string; + /* The procedure to resolve conflicts in the case of custom mode. */ + conflictResolutionProcedure: string; +} export interface SqlStoredProcedureResource { - /* Name of the Cosmos DB SQL storedProcedure */ - id: string - /* Body of the Stored Procedure */ - body: string} + /* Name of the Cosmos DB SQL storedProcedure */ + id: string; + /* Body of the Stored Procedure */ + body: string; +} export interface SqlUserDefinedFunctionResource { - /* Name of the Cosmos DB SQL userDefinedFunction */ - id: string - /* Body of the User Defined Function */ - body: string} + /* Name of the Cosmos DB SQL userDefinedFunction */ + id: string; + /* Body of the User Defined Function */ + body: string; +} export interface SqlTriggerResource { - /* Name of the Cosmos DB SQL trigger */ - id: string - /* Body of the Trigger */ - body: string - /* Type of the Trigger */ - triggerType: string - /* The operation the trigger is associated with */ - triggerOperation: string} + /* Name of the Cosmos DB SQL trigger */ + id: string; + /* Body of the Trigger */ + body: string; + /* Type of the Trigger */ + triggerType: string; + /* The operation the trigger is associated with */ + triggerOperation: string; +} export interface MongoDBDatabaseResource { - /* Name of the Cosmos DB MongoDB database */ - id: string} + /* Name of the Cosmos DB MongoDB database */ + id: string; +} export interface MongoDBCollectionResource { - /* Name of the Cosmos DB MongoDB collection */ - id: string - /* A key-value pair of shard keys to be applied for the request. */ - shardKey: ShardKeys - - /* List of index keys */ - indexes: MongoIndex[] - - /* Analytical TTL. */ - analyticalStorageTtl: number} + /* Name of the Cosmos DB MongoDB collection */ + id: string; + /* A key-value pair of shard keys to be applied for the request. */ + shardKey: ShardKeys; + /* List of index keys */ + indexes: MongoIndex[]; - /* The shard key and partition kind pair, only support "Hash" partition kind */ - export type ShardKeys = { [key: string]: string} - export interface MongoIndex { - /* Cosmos DB MongoDB collection index keys */ - key: MongoIndexKeys - - /* Cosmos DB MongoDB collection index key options */ - options: MongoIndexOptions - } + /* Analytical TTL. */ + analyticalStorageTtl: number; +} + +/* The shard key and partition kind pair, only support "Hash" partition kind */ +export type ShardKeys = { [key: string]: string }; +export interface MongoIndex { + /* Cosmos DB MongoDB collection index keys */ + key: MongoIndexKeys; + + /* Cosmos DB MongoDB collection index key options */ + options: MongoIndexOptions; +} export interface MongoIndexKeys { - /* List of keys for each MongoDB collection in the Azure Cosmos DB service */ - keys: Key[] - } + /* List of keys for each MongoDB collection in the Azure Cosmos DB service */ + keys: Key[]; +} - - /* A Key. */ - export type Key = string - export interface MongoIndexOptions { - /* Expire after seconds */ - expireAfterSeconds: number - /* Is unique or not */ - unique: boolean} +/* A Key. */ +export type Key = string; +export interface MongoIndexOptions { + /* Expire after seconds */ + expireAfterSeconds: number; + /* Is unique or not */ + unique: boolean; +} export interface TableResource { - /* Name of the Cosmos DB table */ - id: string} + /* Name of the Cosmos DB table */ + id: string; +} export interface CassandraKeyspaceResource { - /* Name of the Cosmos DB Cassandra keyspace */ - id: string} + /* Name of the Cosmos DB Cassandra keyspace */ + id: string; +} export interface CassandraTableResource { - /* Name of the Cosmos DB Cassandra table */ - id: string - /* Time to live of the Cosmos DB Cassandra table */ - defaultTtl: number - /* Schema of the Cosmos DB Cassandra table */ - schema: CassandraSchema - - /* Analytical TTL. */ - analyticalStorageTtl: number} + /* Name of the Cosmos DB Cassandra table */ + id: string; + /* Time to live of the Cosmos DB Cassandra table */ + defaultTtl: number; + /* Schema of the Cosmos DB Cassandra table */ + schema: CassandraSchema; + + /* Analytical TTL. */ + analyticalStorageTtl: number; +} export interface CassandraSchema { - /* List of Cassandra table columns. */ - columns: Column[] - - /* List of partition key. */ - partitionKeys: CassandraPartitionKey[] - - /* List of cluster key. */ - clusterKeys: ClusterKey[] - } + /* List of Cassandra table columns. */ + columns: Column[]; + + /* List of partition key. */ + partitionKeys: CassandraPartitionKey[]; + + /* List of cluster key. */ + clusterKeys: ClusterKey[]; +} export interface Column { - /* Name of the Cosmos DB Cassandra table column */ - name: string - /* Type of the Cosmos DB Cassandra table column */ - type: string} + /* Name of the Cosmos DB Cassandra table column */ + name: string; + /* Type of the Cosmos DB Cassandra table column */ + type: string; +} export interface CassandraPartitionKey { - /* Name of the Cosmos DB Cassandra table partition key */ - name: string} + /* Name of the Cosmos DB Cassandra table partition key */ + name: string; +} export interface ClusterKey { - /* Name of the Cosmos DB Cassandra table cluster key */ - name: string - /* Order of the Cosmos DB Cassandra table cluster key, only support "Asc" and "Desc" */ - orderBy: string} + /* Name of the Cosmos DB Cassandra table cluster key */ + name: string; + /* Order of the Cosmos DB Cassandra table cluster key, only support "Asc" and "Desc" */ + orderBy: string; +} export interface GremlinDatabaseResource { - /* Name of the Cosmos DB Gremlin database */ - id: string} + /* Name of the Cosmos DB Gremlin database */ + id: string; +} export interface GremlinGraphResource { - /* Name of the Cosmos DB Gremlin graph */ - id: string - /* The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the graph */ - indexingPolicy: IndexingPolicy - - /* The configuration of the partition key to be used for partitioning data into multiple partitions */ - partitionKey: ContainerPartitionKey - - /* Default time to live */ - defaultTtl: number - /* The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. */ - uniqueKeyPolicy: UniqueKeyPolicy - - /* The conflict resolution policy for the graph. */ - conflictResolutionPolicy: ConflictResolutionPolicy - } + /* Name of the Cosmos DB Gremlin graph */ + id: string; + /* The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the graph */ + indexingPolicy: IndexingPolicy; + + /* The configuration of the partition key to be used for partitioning data into multiple partitions */ + partitionKey: ContainerPartitionKey; + + /* Default time to live */ + defaultTtl: number; + /* The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. */ + uniqueKeyPolicy: UniqueKeyPolicy; + + /* The conflict resolution policy for the graph. */ + conflictResolutionPolicy: ConflictResolutionPolicy; +} export interface CreateUpdateOptions { - /* Request Units per second. For example, "throughput": 10000. */ - throughput: number - /* Specifies the Autoscale settings. */ - autoscaleSettings: AutoscaleSettings - } + /* Request Units per second. For example, "throughput": 10000. */ + throughput: number; + /* Specifies the Autoscale settings. */ + autoscaleSettings: AutoscaleSettings; +} export interface AutoscaleSettings { - /* Represents maximum throughput, the resource can scale up to. */ - maxThroughput: number} + /* Represents maximum throughput, the resource can scale up to. */ + maxThroughput: number; +} export interface Capability { - /* Name of the Cosmos DB capability. For example, "name": "EnableCassandra". Current values also include "EnableTable" and "EnableGremlin". */ - name: string} + /* Name of the Cosmos DB capability. For example, "name": "EnableCassandra". Current values also include "EnableTable" and "EnableGremlin". */ + name: string; +} +/* Tags are a list of key-value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. For example, the default experience for a template type is set with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", "Graph", "DocumentDB", and "MongoDB". */ +export type Tags = { [key: string]: string }; +export interface ManagedServiceIdentity { + /* The principal id of the system assigned identity. This property will only be provided for a system assigned identity. */ + readonly principalId: string; + /* The tenant id of the system assigned identity. This property will only be provided for a system assigned identity. */ + readonly tenantId: string; + /* The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. */ + type: string; +} - /* Tags are a list of key-value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. For example, the default experience for a template type is set with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", "Graph", "DocumentDB", and "MongoDB". */ - export type Tags = { [key: string]: string} - export interface ManagedServiceIdentity { - /* The principal id of the system assigned identity. This property will only be provided for a system assigned identity. */ - readonly principalId: string - /* The tenant id of the system assigned identity. This property will only be provided for a system assigned identity. */ - readonly tenantId: string - /* The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. */ - type: string} +/* The status of the Cosmos DB account at the time the operation was called. The status can be one of following. 'Creating' – the Cosmos DB account is being created. When an account is in Creating state, only properties that are specified as input for the Create Cosmos DB account operation are returned. 'Succeeded' – the Cosmos DB account is active for use. 'Updating' – the Cosmos DB account is being updated. 'Deleting' – the Cosmos DB account is being deleted. 'Failed' – the Cosmos DB account failed creation. 'DeletionFailed' – the Cosmos DB account deletion failed. */ +export type ProvisioningState = string; - - /* The status of the Cosmos DB account at the time the operation was called. The status can be one of following. 'Creating' – the Cosmos DB account is being created. When an account is in Creating state, only properties that are specified as input for the Create Cosmos DB account operation are returned. 'Succeeded' – the Cosmos DB account is active for use. 'Updating' – the Cosmos DB account is being updated. 'Deleting' – the Cosmos DB account is being deleted. 'Failed' – the Cosmos DB account failed creation. 'DeletionFailed' – the Cosmos DB account deletion failed. */ - export type ProvisioningState = string - - /* Array of IpAddressOrRange objects. */ - export type IPRules = IpAddressOrRange[] - export interface IpAddressOrRange { - /* A single IPv4 address or a single IPv4 address range in CIDR format. Provided IPs must be well-formatted and cannot be contained in one of the following ranges: 10.0.0.0/8, 100.64.0.0/10, 172.16.0.0/12, 192.168.0.0/16, since these are not enforceable by the IP address filter. Example of valid inputs: “23.40.210.245” or “23.40.210.0/8”. */ - ipAddressOrRange: string} +/* Array of IpAddressOrRange objects. */ +export type IPRules = IpAddressOrRange[]; +export interface IpAddressOrRange { + /* A single IPv4 address or a single IPv4 address range in CIDR format. Provided IPs must be well-formatted and cannot be contained in one of the following ranges: 10.0.0.0/8, 100.64.0.0/10, 172.16.0.0/12, 192.168.0.0/16, since these are not enforceable by the IP address filter. Example of valid inputs: “23.40.210.245” or “23.40.210.0/8”. */ + ipAddressOrRange: string; +} export interface VirtualNetworkRule { - /* Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}. */ - id: string - /* Create firewall rule before the virtual network has vnet service endpoint enabled. */ - ignoreMissingVNetServiceEndpoint: boolean} + /* Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}. */ + id: string; + /* Create firewall rule before the virtual network has vnet service endpoint enabled. */ + ignoreMissingVNetServiceEndpoint: boolean; +} export type PrivateEndpointConnection = unknown & { - /* Resource properties. */ - properties: PrivateEndpointConnectionProperties - } + /* Resource properties. */ + properties: PrivateEndpointConnectionProperties; +}; export interface PrivateEndpointConnectionProperties { - /* Private endpoint which the connection belongs to. */ - privateEndpoint: PrivateEndpointProperty - - /* Connection State of the Private Endpoint Connection. */ - privateLinkServiceConnectionState: PrivateLinkServiceConnectionStateProperty - } + /* Private endpoint which the connection belongs to. */ + privateEndpoint: PrivateEndpointProperty; + + /* Connection State of the Private Endpoint Connection. */ + privateLinkServiceConnectionState: PrivateLinkServiceConnectionStateProperty; +} export interface PrivateEndpointProperty { - /* Resource id of the private endpoint. */ - id: string} + /* Resource id of the private endpoint. */ + id: string; +} export interface PrivateLinkServiceConnectionStateProperty { - /* The private link service connection status. */ - status: string - /* Any action that is required beyond basic workflow (approve/ reject/ disconnect) */ - readonly actionsRequired: string} + /* The private link service connection status. */ + status: string; + /* Any action that is required beyond basic workflow (approve/ reject/ disconnect) */ + readonly actionsRequired: string; +} export interface Operation { - /* Operation name: {provider}/{resource}/{operation} */ - name: string - /* The object that represents the operation. */ - display: undefined} + /* Operation name: {provider}/{resource}/{operation} */ + name: string; + /* The object that represents the operation. */ + display: undefined; +} export interface OperationListResult { - /* List of operations supported by the Resource Provider. */ - value: Operation[] - - /* URL to get the next set of operation list results if there are any. */ - nextLink: string} + /* List of operations supported by the Resource Provider. */ + value: Operation[]; + + /* URL to get the next set of operation list results if there are any. */ + nextLink: string; +} export interface UsagesResult { - /* The list of usages for the database. A usage is a point in time metric */ - readonly value: Usage[] - } + /* The list of usages for the database. A usage is a point in time metric */ + readonly value: Usage[]; +} export interface Usage { - /* The unit of the metric. */ - unit: UnitType - - /* The name information for the metric. */ - readonly name: MetricName - - /* The quota period used to summarize the usage values. */ - readonly quotaPeriod: string - /* Maximum value for this metric */ - readonly limit: number - /* Current value for this metric */ - readonly currentValue: number} + /* The unit of the metric. */ + unit: UnitType; + + /* The name information for the metric. */ + readonly name: MetricName; + + /* The quota period used to summarize the usage values. */ + readonly quotaPeriod: string; + /* Maximum value for this metric */ + readonly limit: number; + /* Current value for this metric */ + readonly currentValue: number; +} export interface PartitionUsagesResult { - /* The list of partition-level usages for the database. A usage is a point in time metric */ - readonly value: PartitionUsage[] - } + /* The list of partition-level usages for the database. A usage is a point in time metric */ + readonly value: PartitionUsage[]; +} export type PartitionUsage = Usage & { - /* The partition id (GUID identifier) of the usages. */ - readonly partitionId: string - /* The partition key range id (integer identifier) of the usages. */ - readonly partitionKeyRangeId: string} + /* The partition id (GUID identifier) of the usages. */ + readonly partitionId: string; + /* The partition key range id (integer identifier) of the usages. */ + readonly partitionKeyRangeId: string; +}; export interface MetricDefinitionsListResult { - /* The list of metric definitions for the account. */ - readonly value: MetricDefinition[] - } + /* The list of metric definitions for the account. */ + readonly value: MetricDefinition[]; +} export interface MetricDefinition { - /* The list of metric availabilities for the account. */ - readonly metricAvailabilities: MetricAvailability[] - - /* The primary aggregation type of the metric. */ - readonly primaryAggregationType: string - /* The unit of the metric. */ - unit: UnitType - - /* The resource uri of the database. */ - readonly resourceUri: string - /* The name information for the metric. */ - readonly name: MetricName - } + /* The list of metric availabilities for the account. */ + readonly metricAvailabilities: MetricAvailability[]; + + /* The primary aggregation type of the metric. */ + readonly primaryAggregationType: string; + /* The unit of the metric. */ + unit: UnitType; + + /* The resource uri of the database. */ + readonly resourceUri: string; + /* The name information for the metric. */ + readonly name: MetricName; +} export interface MetricAvailability { - /* The time grain to be used to summarize the metric values. */ - readonly timeGrain: string - /* The retention for the metric values. */ - readonly retention: string} + /* The time grain to be used to summarize the metric values. */ + readonly timeGrain: string; + /* The retention for the metric values. */ + readonly retention: string; +} export interface MetricListResult { - /* The list of metrics for the account. */ - readonly value: Metric[] - } + /* The list of metrics for the account. */ + readonly value: Metric[]; +} export interface Metric { - /* The start time for the metric (ISO-8601 format). */ - readonly startTime: string - /* The end time for the metric (ISO-8601 format). */ - readonly endTime: string - /* The time grain to be used to summarize the metric values. */ - readonly timeGrain: string - /* The unit of the metric. */ - unit: UnitType - - /* The name information for the metric. */ - readonly name: MetricName - - /* The metric values for the specified time window and timestep. */ - readonly metricValues: MetricValue[] - } + /* The start time for the metric (ISO-8601 format). */ + readonly startTime: string; + /* The end time for the metric (ISO-8601 format). */ + readonly endTime: string; + /* The time grain to be used to summarize the metric values. */ + readonly timeGrain: string; + /* The unit of the metric. */ + unit: UnitType; + + /* The name information for the metric. */ + readonly name: MetricName; + + /* The metric values for the specified time window and timestep. */ + readonly metricValues: MetricValue[]; +} export interface MetricName { - /* The name of the metric. */ - readonly value: string - /* The friendly name of the metric. */ - readonly localizedValue: string} + /* The name of the metric. */ + readonly value: string; + /* The friendly name of the metric. */ + readonly localizedValue: string; +} export interface MetricValue { - /* The number of values for the metric. */ - readonly _count: number - /* The average value of the metric. */ - readonly average: number - /* The max value of the metric. */ - readonly maximum: number - /* The min value of the metric. */ - readonly minimum: number - /* The metric timestamp (ISO-8601 format). */ - readonly timestamp: string - /* The total value of the metric. */ - readonly total: number} + /* The number of values for the metric. */ + readonly _count: number; + /* The average value of the metric. */ + readonly average: number; + /* The max value of the metric. */ + readonly maximum: number; + /* The min value of the metric. */ + readonly minimum: number; + /* The metric timestamp (ISO-8601 format). */ + readonly timestamp: string; + /* The total value of the metric. */ + readonly total: number; +} export interface PercentileMetricListResult { - /* The list of percentile metrics for the account. */ - readonly value: PercentileMetric[] - } + /* The list of percentile metrics for the account. */ + readonly value: PercentileMetric[]; +} export interface PercentileMetric { - /* The start time for the metric (ISO-8601 format). */ - readonly startTime: string - /* The end time for the metric (ISO-8601 format). */ - readonly endTime: string - /* The time grain to be used to summarize the metric values. */ - readonly timeGrain: string - /* The unit of the metric. */ - unit: UnitType - - /* The name information for the metric. */ - readonly name: MetricName - - /* The percentile metric values for the specified time window and timestep. */ - readonly metricValues: PercentileMetricValue[] - } + /* The start time for the metric (ISO-8601 format). */ + readonly startTime: string; + /* The end time for the metric (ISO-8601 format). */ + readonly endTime: string; + /* The time grain to be used to summarize the metric values. */ + readonly timeGrain: string; + /* The unit of the metric. */ + unit: UnitType; + + /* The name information for the metric. */ + readonly name: MetricName; + + /* The percentile metric values for the specified time window and timestep. */ + readonly metricValues: PercentileMetricValue[]; +} export type PercentileMetricValue = MetricValue & { - /* The 10th percentile value for the metric. */ - readonly P10: number - /* The 25th percentile value for the metric. */ - readonly P25: number - /* The 50th percentile value for the metric. */ - readonly P50: number - /* The 75th percentile value for the metric. */ - readonly P75: number - /* The 90th percentile value for the metric. */ - readonly P90: number - /* The 95th percentile value for the metric. */ - readonly P95: number - /* The 99th percentile value for the metric. */ - readonly P99: number} + /* The 10th percentile value for the metric. */ + readonly P10: number; + /* The 25th percentile value for the metric. */ + readonly P25: number; + /* The 50th percentile value for the metric. */ + readonly P50: number; + /* The 75th percentile value for the metric. */ + readonly P75: number; + /* The 90th percentile value for the metric. */ + readonly P90: number; + /* The 95th percentile value for the metric. */ + readonly P95: number; + /* The 99th percentile value for the metric. */ + readonly P99: number; +}; export interface PartitionMetricListResult { - /* The list of partition-level metrics for the account. */ - readonly value: PartitionMetric[] - } + /* The list of partition-level metrics for the account. */ + readonly value: PartitionMetric[]; +} export type PartitionMetric = Metric & { - /* The partition id (GUID identifier) of the metric values. */ - readonly partitionId: string - /* The partition key range id (integer identifier) of the metric values. */ - readonly partitionKeyRangeId: string} + /* The partition id (GUID identifier) of the metric values. */ + readonly partitionId: string; + /* The partition key range id (integer identifier) of the metric values. */ + readonly partitionKeyRangeId: string; +}; +/* The unit of the metric. */ +export type UnitType = "Count" | "Bytes" | "Seconds" | "Percent" | "CountPerSecond" | "BytesPerSecond" | "Milliseconds"; - /* The unit of the metric. */ - export type UnitType = "Count" | "Bytes" | "Seconds" | "Percent" | "CountPerSecond" | "BytesPerSecond" | "Milliseconds" +/* The cassandra connector offer type for the Cosmos DB C* database account. */ +export type ConnectorOffer = "Small"; - /* The cassandra connector offer type for the Cosmos DB C* database account. */ - export type ConnectorOffer = "Small" - - /* Whether requests from Public Network are allowed */ - export type PublicNetworkAccess = "Enabled" | "Disabled" +/* Whether requests from Public Network are allowed */ +export type PublicNetworkAccess = "Enabled" | "Disabled"; export interface ApiProperties { - /* Describes the ServerVersion of an a MongoDB account. */ - serverVersion: string} + /* Describes the ServerVersion of an a MongoDB account. */ + serverVersion: string; +} - - /* Enum to indicate the mode of account creation. */ - export type CreateMode = "Default" | "Restore" +/* Enum to indicate the mode of account creation. */ +export type CreateMode = "Default" | "Restore"; export interface RestoreParameters { - /* Describes the mode of the restore. */ - restoreMode: string - /* Path of the source account from which the restore has to be initiated */ - restoreSource: string - /* Time to which the account has to be restored (ISO-8601 format). */ - restoreTimestampInUtc: string - /* List of specific databases to restore. */ - databasesToRestore: DatabaseRestoreResource[] - } + /* Describes the mode of the restore. */ + restoreMode: string; + /* Path of the source account from which the restore has to be initiated */ + restoreSource: string; + /* Time to which the account has to be restored (ISO-8601 format). */ + restoreTimestampInUtc: string; + /* List of specific databases to restore. */ + databasesToRestore: DatabaseRestoreResource[]; +} export interface DatabaseRestoreResource { - /* The name of the database to restore. */ - databaseName: string - /* The names of the collections to restore. */ - collectionNames: CollectionName[] - } + /* The name of the database to restore. */ + databaseName: string; + /* The names of the collections to restore. */ + collectionNames: CollectionName[]; +} - - /* The name of the collection. */ - export type CollectionName = string - export interface BackupPolicy { - /* Describes the mode of backups. */ - type: string} +/* The name of the collection. */ +export type CollectionName = string; +export interface BackupPolicy { + /* Describes the mode of backups. */ + type: string; +} export type PeriodicModeBackupPolicy = BackupPolicy & { - /* Configuration values for periodic mode backup */ - periodicModeProperties: PeriodicModeProperties - } + /* Configuration values for periodic mode backup */ + periodicModeProperties: PeriodicModeProperties; +}; - - /* The object representing continuous mode backup policy. */ - export type ContinuousModeBackupPolicy = BackupPolicy - export interface PeriodicModeProperties { - /* An integer representing the interval in minutes between two backups */ - backupIntervalInMinutes: number - /* An integer representing the time (in hours) that each backup is retained */ - backupRetentionIntervalInHours: number} +/* The object representing continuous mode backup policy. */ +export type ContinuousModeBackupPolicy = BackupPolicy; +export interface PeriodicModeProperties { + /* An integer representing the interval in minutes between two backups */ + backupIntervalInMinutes: number; + /* An integer representing the time (in hours) that each backup is retained */ + backupRetentionIntervalInHours: number; +} export interface RestorableDatabaseAccountsListResult { - /* List of restorable database accounts and their properties. */ - readonly value: RestorableDatabaseAccountGetResult[] - } + /* List of restorable database accounts and their properties. */ + readonly value: RestorableDatabaseAccountGetResult[]; +} export type RestorableDatabaseAccountGetResult = ARMResourceProperties & { - /* The properties of a restorable database account. */ - properties: RestorableDatabaseAccountProperties - } + /* The properties of a restorable database account. */ + properties: RestorableDatabaseAccountProperties; +}; export interface RestorableDatabaseAccountProperties { - /* The name of the global database account */ - accountName: string - /* The creation time of the restorable database account (ISO-8601 format). */ - creationTime: string - /* The time at which the restorable database account has been deleted (ISO-8601 format). */ - deletionTime: string} - + /* The name of the global database account */ + accountName: string; + /* The creation time of the restorable database account (ISO-8601 format). */ + creationTime: string; + /* The time at which the restorable database account has been deleted (ISO-8601 format). */ + deletionTime: string; +} diff --git a/tsconfig.strict.json b/tsconfig.strict.json index 73ef2aa79..b53292317 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -47,6 +47,7 @@ "./src/Explorer/Controls/Toolbar/KeyCodes.ts", "./src/Explorer/Notebook/FileSystemUtil.ts", "./src/Explorer/Notebook/NTeractUtil.ts", + "./src/Explorer/Notebook/NotebookComponent/__mocks__/rx-jupyter.ts", "./src/Explorer/Notebook/NotebookComponent/actions.ts", "./src/Explorer/Notebook/NotebookComponent/loadTransform.ts", "./src/Explorer/Notebook/NotebookComponent/reducers.ts", diff --git a/utils/armClientGenerator/generator.ts b/utils/armClientGenerator/generator.ts index e22e1eb4a..794b3c9df 100644 --- a/utils/armClientGenerator/generator.ts +++ b/utils/armClientGenerator/generator.ts @@ -24,7 +24,12 @@ const outputDir = path.join(__dirname, "../../src/Utils/arm/"); mkdirp.sync(outputDir); // Buckets for grouping operations based on their name -const namespaces: { [key: string]: string[] } = {}; +interface Client { + paths: string[]; + functions: string[]; + constructorParams: string[]; +} +const clients: { [key: string]: Client } = {}; // Mapping for OpenAPI types to TypeScript types const propertyMap: { [key: string]: string } = { @@ -63,9 +68,7 @@ function parametersFromPath(path: string) { // TODO: Remove any. String.matchAll is a real thing. // eslint-disable-next-line @typescript-eslint/no-explicit-any const matches = (path as any).matchAll(/{(\w+)}/g); - return Array.from(matches) - .map((match: string[]) => `${match[1]}: string`) - .join(",\n"); + return Array.from(matches).map((match: string[]) => match[1]); } type Operation = { responses: { [key: string]: { schema: { $ref: string } } } }; @@ -168,43 +171,102 @@ async function main() { } } - // STEP 2: Convert all paths and operations to simple fetch functions. - // Functions are grouped into objects based on resource types + // STEP 2: Group all paths by output client and extract common constructor parameters + // Functions are grouped into clients based on operation name for (const path in schema.paths) { for (const method in schema.paths[path]) { const operation = schema.paths[path][method]; - const bodyParameter = operation.parameters.find( - (parameter: { in: string; required: boolean }) => parameter.in === "body" && parameter.required === true - ); - const [namespace, operationName] = operation.operationId.split("_"); - if (namespaces[namespace] === undefined) { - namespaces[namespace] = []; + const [namespace] = operation.operationId.split("_"); + if (clients[namespace] === undefined) { + clients[namespace] = { paths: [], functions: [], constructorParams: [] }; + clients[namespace]; + } + if (!clients[namespace].paths.includes(path)) { + clients[namespace].paths.push(path); } - namespaces[namespace].push(` - /* ${operation.description} */ - export async function ${camelize(operationName)} ( - ${parametersFromPath(path)} - ${bodyParam(bodyParameter, "Types")} - ) : Promise<${responseType(operation, "Types")}> { - return window.fetch(\`https://management.azure.com${path.replace(/{/g, "${")}\`, { method: "${method}", ${ - bodyParameter ? "body: JSON.stringify(body)" : "" - } }).then((response) => response.json()) - } - `); } } // Write all grouped fetch functions to objects - for (const namespace in namespaces) { + for (const clientName in clients) { const outputClient: string[] = [""]; outputClient.push(`import * as Types from "./types"\n\n`); - outputClient.push(namespaces[namespace].join("\n\n")); - writeOutputFile(`./${namespace}.ts`, outputClient); + 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 method in schema.paths[path]) { + const operation = schema.paths[path][method]; + const [, methodName] = operation.operationId.split("_"); + const bodyParameter = operation.parameters.find( + (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(` + /* ${operation.description} */ + async ${camelize(methodName)} ( + ${methodParameters.map(p => `${p}: string`).join(",\n")} + ${bodyParam(bodyParameter, "Types")} + ) : Promise<${responseType(operation, "Types")}> { + const path = \`${path.replace(basePath, "").replace(/{/g, "${")}\` + return window.fetch(this.baseUrl + this.basePath + path, { method: "${method}", ${ + bodyParameter ? "body: JSON.stringify(body)" : "" + } }).then((response) => response.json()) + } + `); + // clients[clientName].functions.push(` + // /* ${operation.description} */ + // async ${camelize(methodName)} ( + // ${parametersFromPath(path)} + // ${bodyParam(bodyParameter, "Types")} + // ) : Promise<${responseType(operation, "Types")}> { + // return window.fetch(\`https://management.azure.com${path.replace(/{/g, "${")}\`, { method: "${method}", ${ + // bodyParameter ? "body: JSON.stringify(body)" : "" + // } }).then((response) => response.json()) + // } + // `); + // outputClient.push(clients[client].join("\n\n")); + } + } + outputClient.push(`}`); + writeOutputFile(`./${clientName}.ts`, outputClient); } 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 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[]) { components.unshift(`/* AUTOGENERATED FILE