diff --git a/.eslintignore b/.eslintignore index b84affcd7..5154698a5 100644 --- a/.eslintignore +++ b/.eslintignore @@ -298,7 +298,6 @@ src/Utils/DatabaseAccountUtils.ts src/Utils/JunoUtils.ts src/Utils/MessageValidation.ts src/Utils/NotebookConfigurationUtils.ts -src/Utils/NotificationConsoleUtils.ts src/Utils/OfferUtils.test.ts src/Utils/OfferUtils.ts src/Utils/PricingUtils.test.ts diff --git a/package-lock.json b/package-lock.json index d64976f5f..1eadc9cc2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6024,6 +6024,16 @@ "natural-compare": "^1.4.0", "pretty-format": "^24.9.0", "semver": "^6.2.0" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + } } }, "jest-validate": { @@ -7577,11 +7587,40 @@ "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==", "dev": true }, + "@types/mkdirp": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/mkdirp/-/mkdirp-1.0.1.tgz", + "integrity": "sha512-HkGSK7CGAXncr8Qn/0VqNtExEE+PHMWb+qlR1faHMao7ng6P3tAaoWWBMdva0gL5h4zprjIO89GJOLXsMcDm1Q==", + "requires": { + "@types/node": "*" + } + }, "@types/node": { "version": "12.11.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.11.1.tgz", "integrity": "sha512-TJtwsqZ39pqcljJpajeoofYRfeZ7/I/OMUQ5pR4q5wOKf2ocrUvBAZUMhWsOvKx3dVc/aaV5GluBivt0sWqA5A==" }, + "@types/node-fetch": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.7.tgz", + "integrity": "sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw==", + "requires": { + "@types/node": "*", + "form-data": "^3.0.0" + }, + "dependencies": { + "form-data": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "@types/normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz", @@ -7681,6 +7720,11 @@ "@types/react": "*" } }, + "@types/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==" + }, "@types/shallowequal": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/shallowequal/-/shallowequal-1.1.1.tgz", @@ -8403,7 +8447,6 @@ "graceful-fs": "^4.1.11", "lru-cache": "^4.1.1", "mississippi": "^2.0.0", - "mkdirp": "^0.5.1", "move-concurrently": "^1.0.1", "promise-inflight": "^1.0.1", "rimraf": "^2.6.2", @@ -9342,6 +9385,15 @@ "pkg-dir": "^3.0.0" } }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, "pify": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", @@ -10661,6 +10713,14 @@ "run-queue": "^1.0.0" }, "dependencies": { + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + }, "rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -19781,6 +19841,16 @@ "mkdirp": "^0.5.1", "slash": "^2.0.0", "source-map": "^0.6.0" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + } } }, "jest-validate": { @@ -20364,6 +20434,16 @@ "dev": true, "optional": true }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "optional": true, + "requires": { + "minimist": "^1.2.5" + } + }, "promise": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", @@ -21314,12 +21394,9 @@ } }, "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "requires": { - "minimist": "^1.2.5" - } + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" }, "mkdirp-classic": { "version": "0.5.3", @@ -21365,6 +21442,14 @@ "run-queue": "^1.0.3" }, "dependencies": { + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + }, "rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -21704,6 +21789,14 @@ "tar": "^4" }, "dependencies": { + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + }, "rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -22198,11 +22291,11 @@ "integrity": "sha1-GMKw3ZNqRpClKfgjH1ig/bakffo=" }, "p-retry": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-3.0.1.tgz", - "integrity": "sha512-XE6G4+YTTkT2a0UWb2kjZe8xNwf8bIbnqpc/IS/idOBVhyves0mK5OJgeocjx7q5pvX/6m23xuzVPYT1uGM73w==", - "dev": true, + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.2.0.tgz", + "integrity": "sha512-jPH38/MRh263KKcq0wBNOGFJbm+U6784RilTmHjB/HM9kH9V8WlCpVUcdOmip9cjXOh6MxZ5yk1z2SjDUJfWmA==", "requires": { + "@types/retry": "^0.12.0", "retry": "^0.12.0" } }, @@ -22603,6 +22696,15 @@ "requires": { "ms": "^2.1.1" } + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } } } }, @@ -23971,8 +24073,7 @@ "retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", - "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=", - "dev": true + "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=" }, "reusify": { "version": "1.0.4", @@ -25503,6 +25604,16 @@ "mkdirp": "^0.5.0", "safe-buffer": "^5.1.2", "yallist": "^3.0.3" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + } } }, "tar-fs": { @@ -25860,6 +25971,14 @@ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + }, "yargs-parser": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz", @@ -26928,6 +27047,15 @@ "readable-stream": "^2.0.1" } }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, "readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -27039,6 +27167,15 @@ "integrity": "sha512-wdlPY2tm/9XBr7QkKlq0WQVgiuGTX6YWPyRyBviSoScBuLfTVQhvwg6wJ369GJ/1nPfTLMfnrFIfjqVg6d+jQQ==", "dev": true }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, "ws": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", @@ -27251,6 +27388,15 @@ "readable-stream": "^2.0.1" } }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, "readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -27330,6 +27476,15 @@ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, + "p-retry": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-3.0.1.tgz", + "integrity": "sha512-XE6G4+YTTkT2a0UWb2kjZe8xNwf8bIbnqpc/IS/idOBVhyves0mK5OJgeocjx7q5pvX/6m23xuzVPYT1uGM73w==", + "dev": true, + "requires": { + "retry": "^0.12.0" + } + }, "schema-utils": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz", @@ -27558,6 +27713,17 @@ "dev": true, "requires": { "mkdirp": "^0.5.1" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + } } }, "write-file-atomic": { diff --git a/package.json b/package.json index 51ab3b989..a8cf78f2a 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,8 @@ "@nteract/transform-vega": "7.0.6", "@octokit/rest": "17.9.2", "@phosphor/widgets": "1.9.3", + "@types/mkdirp": "1.0.1", + "@types/node-fetch": "2.5.7", "@uifabric/react-cards": "0.109.110", "@uifabric/styling": "7.13.7", "abort-controller": "3.0.0", @@ -61,9 +63,11 @@ "jquery-typeahead": "2.10.6", "jquery-ui-dist": "1.12.1", "knockout": "3.5.1", + "mkdirp": "1.0.4", "monaco-editor": "0.15.6", "object.entries": "1.1.0", "office-ui-fabric-react": "7.121.10", + "p-retry": "4.2.0", "plotly.js-cartesian-dist-min": "1.52.3", "promise-polyfill": "8.1.0", "promise.prototype.finally": "3.1.0", @@ -149,6 +153,7 @@ "less-vars-loader": "1.1.0", "mini-css-extract-plugin": "0.4.3", "monaco-editor-webpack-plugin": "1.7.0", + "node-fetch": "2.6.0", "prettier": "1.19.1", "puppeteer": "4.0.0", "raw-loader": "0.5.1", @@ -189,7 +194,8 @@ "build:contracts": "npm run compile:contracts", "strictEligibleFiles": "node ./strict-migration-tools/index.js", "autoAddStrictEligibleFiles": "node ./strict-migration-tools/autoAdd.js", - "compile:fullStrict": "tsc -p ./tsconfig.json --strictNullChecks" + "compile:fullStrict": "tsc -p ./tsconfig.json --strictNullChecks", + "generateARMClients": "ts-node --compiler-options '{\"module\":\"commonjs\"}' utils/armClientGenerator/generator.ts" }, "repository": { "type": "git", diff --git a/src/Common/CosmosClient.ts b/src/Common/CosmosClient.ts index cf7af7aaf..598230853 100644 --- a/src/Common/CosmosClient.ts +++ b/src/Common/CosmosClient.ts @@ -2,7 +2,7 @@ import * as Cosmos from "@azure/cosmos"; import { RequestInfo, setAuthorizationTokenHeaderUsingMasterKey } from "@azure/cosmos"; import { DatabaseAccount } from "../Contracts/DataModels"; import { HttpHeaders, EmulatorMasterKey } from "./Constants"; -import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils"; import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent"; import { config, Platform } from "../Config"; diff --git a/src/Common/DataAccessUtilityBase.ts b/src/Common/DataAccessUtilityBase.ts index a8e92f0e7..c62943a39 100644 --- a/src/Common/DataAccessUtilityBase.ts +++ b/src/Common/DataAccessUtilityBase.ts @@ -377,16 +377,6 @@ export function deleteConflict( ); } -export function deleteCollection(collection: ViewModels.Collection, options: any): Q.Promise { - return Q( - CosmosClient.client() - .database(collection.databaseId) - .container(collection.id()) - .delete() - .then(() => refreshCachedResources()) - ); -} - export function deleteDatabase(database: ViewModels.Database, options: any): Q.Promise { return Q( CosmosClient.client() diff --git a/src/Common/DocumentClientUtilityBase.ts b/src/Common/DocumentClientUtilityBase.ts index 5b0fd7397..5c12073bd 100644 --- a/src/Common/DocumentClientUtilityBase.ts +++ b/src/Common/DocumentClientUtilityBase.ts @@ -10,7 +10,7 @@ import * as Logger from "./Logger"; import { sendMessage } from "./MessageHandler"; import { MessageTypes } from "../Contracts/ExplorerContracts"; import { MinimalQueryIterator, nextPage } from "./IteratorUtilities"; -import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils"; import { RequestOptions } from "@azure/cosmos/dist-esm"; import StoredProcedure from "../Explorer/Tree/StoredProcedure"; import ConflictId from "../Explorer/Tree/ConflictId"; @@ -730,39 +730,6 @@ export function deleteConflict( return deferred.promise; } -export function deleteCollection(collection: ViewModels.Collection, options: any = {}): Q.Promise { - var deferred = Q.defer(); - - const id = NotificationConsoleUtils.logConsoleMessage( - ConsoleDataType.InProgress, - `Deleting container ${collection.id()}` - ); - DataAccessUtilityBase.deleteCollection(collection, options) - .then( - (response: any) => { - NotificationConsoleUtils.logConsoleMessage( - ConsoleDataType.Info, - `Successfully deleted container ${collection.id()}` - ); - deferred.resolve(response); - }, - (error: any) => { - NotificationConsoleUtils.logConsoleMessage( - ConsoleDataType.Error, - `Error while deleting container ${collection.id()}:\n ${JSON.stringify(error)}` - ); - Logger.logError(JSON.stringify(error), "DeleteCollection", error.code); - sendNotificationForError(error); - deferred.reject(error); - } - ) - .finally(() => { - NotificationConsoleUtils.clearInProgressMessageWithId(id); - }); - - return deferred.promise; -} - export function deleteDatabase(database: ViewModels.Database, options: any = {}): Q.Promise { var deferred = Q.defer(); diff --git a/src/Common/MongoProxyClient.ts b/src/Common/MongoProxyClient.ts index 0491c7ef0..0a6fa2ce2 100644 --- a/src/Common/MongoProxyClient.ts +++ b/src/Common/MongoProxyClient.ts @@ -13,7 +13,7 @@ import { Constants as CosmosSDKConstants } from "@azure/cosmos"; import { CosmosClient } from "./CosmosClient"; import { sendMessage } from "./MessageHandler"; import { MessageTypes } from "../Contracts/ExplorerContracts"; -import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils"; import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient"; import { MinimalQueryIterator } from "./IteratorUtilities"; import DocumentId from "../Explorer/Tree/DocumentId"; diff --git a/src/Common/QueriesClient.ts b/src/Common/QueriesClient.ts index 73610e092..ebf903833 100644 --- a/src/Common/QueriesClient.ts +++ b/src/Common/QueriesClient.ts @@ -8,7 +8,7 @@ import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/Notificat import { CosmosClient } from "./CosmosClient"; import { ItemDefinition, QueryIterator, Resource } from "@azure/cosmos"; import * as Logger from "./Logger"; -import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils"; import { QueryUtils } from "../Utils/QueryUtils"; import Explorer from "../Explorer/Explorer"; import { diff --git a/src/Common/dataAccess/deleteCollection.test.ts b/src/Common/dataAccess/deleteCollection.test.ts new file mode 100644 index 000000000..7bb5d3ec5 --- /dev/null +++ b/src/Common/dataAccess/deleteCollection.test.ts @@ -0,0 +1,13 @@ +jest.mock("../../Utils/arm/request"); +import { deleteCollection } from "./deleteCollection"; +import { armRequest } from "../../Utils/arm/request"; +import { AuthType } from "../../AuthType"; + +describe("deleteCollection", () => { + it("should call ARM if logged in with AAD", async () => { + window.authType = AuthType.AAD; + await deleteCollection("database", "collection"); + expect(armRequest).toHaveBeenCalled(); + }); + // TODO: Test non-AAD case +}); diff --git a/src/Common/dataAccess/deleteCollection.ts b/src/Common/dataAccess/deleteCollection.ts new file mode 100644 index 000000000..96bd42630 --- /dev/null +++ b/src/Common/dataAccess/deleteCollection.ts @@ -0,0 +1,31 @@ +import { CosmosClient } from "../CosmosClient"; +import { refreshCachedResources } from "../DataAccessUtilityBase"; +import { logConsoleProgress, logConsoleInfo, logConsoleError } from "../../Utils/NotificationConsoleUtils"; +import { AuthType } from "../../AuthType"; +import { deleteSqlContainer } from "../../Utils/arm/generatedClients/2020-04-01/sqlResources"; + +export async function deleteCollection(databaseId: string, collectionId: string): Promise { + const clearMessage = logConsoleProgress(`Deleting container ${collectionId}`); + try { + if (window.authType === AuthType.AAD) { + await deleteSqlContainer( + CosmosClient.subscriptionId(), + CosmosClient.resourceGroup(), + CosmosClient.databaseAccount().name, + databaseId, + collectionId + ); + } else { + await CosmosClient.client() + .database(databaseId) + .container(collectionId) + .delete(); + } + } catch (error) { + logConsoleError(`Error while deleting container ${collectionId}:\n ${JSON.stringify(error)}`); + throw error; + } + logConsoleInfo(`Successfully deleted container ${collectionId}`); + clearMessage(); + await refreshCachedResources(); +} diff --git a/src/Explorer/Controls/Notebook/NotebookTerminalComponent.tsx b/src/Explorer/Controls/Notebook/NotebookTerminalComponent.tsx index 5ff1d9b33..63c6f0768 100644 --- a/src/Explorer/Controls/Notebook/NotebookTerminalComponent.tsx +++ b/src/Explorer/Controls/Notebook/NotebookTerminalComponent.tsx @@ -5,7 +5,7 @@ import * as React from "react"; import * as DataModels from "../../../Contracts/DataModels"; import * as Logger from "../../../Common/Logger"; -import { NotificationConsoleUtils } from "../../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils"; import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent"; import { StringUtils } from "../../../Utils/StringUtils"; diff --git a/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx b/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx index 6ca1c4fd8..34758dc1d 100644 --- a/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx +++ b/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx @@ -17,7 +17,7 @@ import * as React from "react"; import * as Logger from "../../../Common/Logger"; import { IGalleryItem, JunoClient } from "../../../Juno/JunoClient"; import * as GalleryUtils from "../../../Utils/GalleryUtils"; -import { NotificationConsoleUtils } from "../../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils"; import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent"; import { DialogComponent, DialogProps } from "../DialogReactComponent/DialogComponent"; import { GalleryCardComponent, GalleryCardComponentProps } from "./Cards/GalleryCardComponent"; diff --git a/src/Explorer/Controls/NotebookViewer/NotebookViewerComponent.tsx b/src/Explorer/Controls/NotebookViewer/NotebookViewerComponent.tsx index 024d3c90e..e1c461961 100644 --- a/src/Explorer/Controls/NotebookViewer/NotebookViewerComponent.tsx +++ b/src/Explorer/Controls/NotebookViewer/NotebookViewerComponent.tsx @@ -10,7 +10,7 @@ import * as Logger from "../../../Common/Logger"; import * as ViewModels from "../../../Contracts/ViewModels"; import { IGalleryItem, JunoClient } from "../../../Juno/JunoClient"; import * as GalleryUtils from "../../../Utils/GalleryUtils"; -import { NotificationConsoleUtils } from "../../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils"; import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent"; import { NotebookClientV2 } from "../../Notebook/NotebookClientV2"; import { NotebookComponentBootstrapper } from "../../Notebook/NotebookComponent/NotebookComponentBootstrapper"; diff --git a/src/Explorer/DataSamples/ContainerSampleGenerator.ts b/src/Explorer/DataSamples/ContainerSampleGenerator.ts index 1a5bf40a0..37d89fbca 100644 --- a/src/Explorer/DataSamples/ContainerSampleGenerator.ts +++ b/src/Explorer/DataSamples/ContainerSampleGenerator.ts @@ -5,7 +5,7 @@ import GraphTab from ".././Tabs/GraphTab"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; import { CosmosClient } from "../../Common/CosmosClient"; import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import Explorer from "../Explorer"; import { createDocument, getOrCreateDatabaseAndCollection } from "../../Common/DocumentClientUtilityBase"; diff --git a/src/Explorer/DataSamples/DataSamplesUtil.ts b/src/Explorer/DataSamples/DataSamplesUtil.ts index 78c2bc14d..dcf62498e 100644 --- a/src/Explorer/DataSamples/DataSamplesUtil.ts +++ b/src/Explorer/DataSamples/DataSamplesUtil.ts @@ -1,6 +1,6 @@ import * as ViewModels from "../../Contracts/ViewModels"; import { ContainerSampleGenerator } from "./ContainerSampleGenerator"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; import Explorer from "../Explorer"; diff --git a/src/Explorer/Explorer.ts b/src/Explorer/Explorer.ts index e6d28dbb5..2365fbc04 100644 --- a/src/Explorer/Explorer.ts +++ b/src/Explorer/Explorer.ts @@ -56,7 +56,7 @@ import { NotebookContentItem, NotebookContentItemType } from "./Notebook/Noteboo import { NotebookUtil } from "./Notebook/NotebookUtil"; import { NotebookWorkspaceManager } from "../NotebookWorkspaceManager/NotebookWorkspaceManager"; import { NotificationConsoleComponentAdapter } from "./Menus/NotificationConsole/NotificationConsoleComponentAdapter"; -import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils"; import { PlatformType } from "../PlatformType"; import { QueriesClient } from "../Common/QueriesClient"; import { QuerySelectPane } from "./Panes/Tables/QuerySelectPane"; diff --git a/src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.ts b/src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.ts index 4c61e0f27..b66807286 100644 --- a/src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.ts +++ b/src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.ts @@ -15,7 +15,7 @@ import { GraphData, D3Node, D3Link } from "./GraphData"; import { HashMap } from "../../../Common/HashMap"; import { BaseType } from "d3"; import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent"; -import { NotificationConsoleUtils } from "../../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils"; import { GraphConfig } from "../../Tabs/GraphTab"; import { GraphExplorer } from "./GraphExplorer"; import * as Constants from "../../../Common/Constants"; diff --git a/src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.tsx b/src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.tsx index b4b11e082..cd4a3e58d 100644 --- a/src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.tsx +++ b/src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.tsx @@ -8,7 +8,7 @@ import * as D3ForceGraph from "./D3ForceGraph"; import { GraphVizComponentProps } from "./GraphVizComponent"; import * as GraphData from "./GraphData"; import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent"; -import { NotificationConsoleUtils } from "../../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils"; import { GraphUtil } from "./GraphUtil"; import * as DataModels from "../../../Contracts/DataModels"; import * as ViewModels from "../../../Contracts/ViewModels"; diff --git a/src/Explorer/Graph/GraphExplorerComponent/GremlinClient.test.ts b/src/Explorer/Graph/GraphExplorerComponent/GremlinClient.test.ts index 0be25205a..f5256b9d5 100644 --- a/src/Explorer/Graph/GraphExplorerComponent/GremlinClient.test.ts +++ b/src/Explorer/Graph/GraphExplorerComponent/GremlinClient.test.ts @@ -1,6 +1,6 @@ import * as sinon from "sinon"; import { GremlinClient, GremlinClientParameters } from "./GremlinClient"; -import { NotificationConsoleUtils } from "../../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils"; import * as Logger from "../../../Common/Logger"; describe("Gremlin Client", () => { diff --git a/src/Explorer/Graph/GraphExplorerComponent/GremlinClient.ts b/src/Explorer/Graph/GraphExplorerComponent/GremlinClient.ts index df87c9966..ec1de5a0c 100644 --- a/src/Explorer/Graph/GraphExplorerComponent/GremlinClient.ts +++ b/src/Explorer/Graph/GraphExplorerComponent/GremlinClient.ts @@ -4,7 +4,7 @@ import * as Q from "q"; import { GremlinSimpleClient, Result } from "./GremlinSimpleClient"; -import { NotificationConsoleUtils } from "../../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils"; import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent"; import { HashMap } from "../../../Common/HashMap"; import * as Logger from "../../../Common/Logger"; diff --git a/src/Explorer/Notebook/NotebookComponent/epics.ts b/src/Explorer/Notebook/NotebookComponent/epics.ts index bea320a33..84b5a78dc 100644 --- a/src/Explorer/Notebook/NotebookComponent/epics.ts +++ b/src/Explorer/Notebook/NotebookComponent/epics.ts @@ -34,7 +34,7 @@ import { sessions, kernels } from "rx-jupyter"; import { RecordOf } from "immutable"; import * as Constants from "../../../Common/Constants"; -import { NotificationConsoleUtils } from "../../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils"; import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent"; import * as CdbActions from "./actions"; import TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor"; diff --git a/src/Explorer/Notebook/NotebookContainerClient.ts b/src/Explorer/Notebook/NotebookContainerClient.ts index e0ede4109..78cfa0fa3 100644 --- a/src/Explorer/Notebook/NotebookContainerClient.ts +++ b/src/Explorer/Notebook/NotebookContainerClient.ts @@ -4,7 +4,7 @@ import * as DataModels from "../../Contracts/DataModels"; import * as Constants from "../../Common/Constants"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import * as Logger from "../../Common/Logger"; export class NotebookContainerClient { diff --git a/src/Explorer/Panes/DeleteCollectionConfirmationPane.test.ts b/src/Explorer/Panes/DeleteCollectionConfirmationPane.test.ts index 305c96655..abb1c41fe 100644 --- a/src/Explorer/Panes/DeleteCollectionConfirmationPane.test.ts +++ b/src/Explorer/Panes/DeleteCollectionConfirmationPane.test.ts @@ -1,4 +1,4 @@ -jest.mock("../../Common/DocumentClientUtilityBase"); +jest.mock("../../Common/dataAccess/deleteCollection"); import * as ko from "knockout"; import * as sinon from "sinon"; import Q from "q"; @@ -7,10 +7,10 @@ import * as ViewModels from "../../Contracts/ViewModels"; import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants"; import DeleteCollectionConfirmationPane from "./DeleteCollectionConfirmationPane"; import DeleteFeedback from "../../Common/DeleteFeedback"; -import { deleteCollection } from "../../Common/DocumentClientUtilityBase"; import Explorer from "../Explorer"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import { TreeNode } from "../../Contracts/ViewModels"; +import { deleteCollection } from "../../Common/dataAccess/deleteCollection"; describe("Delete Collection Confirmation Pane", () => { describe("Explorer.isLastCollection()", () => { @@ -84,6 +84,7 @@ describe("Delete Collection Confirmation Pane", () => { let telemetryProcessorSpy: sinon.SinonSpy; beforeEach(() => { + (deleteCollection as jest.Mock).mockResolvedValue(undefined); telemetryProcessorSpy = sinon.spy(TelemetryProcessor, "trace"); }); @@ -93,7 +94,6 @@ describe("Delete Collection Confirmation Pane", () => { it("it should log feedback if last collection and database is not shared", () => { let selectedCollectionId = "testCol"; - (deleteCollection as jest.Mock).mockResolvedValue(null); let fakeExplorer = {} as Explorer; fakeExplorer.findSelectedCollection = () => { return { diff --git a/src/Explorer/Panes/DeleteCollectionConfirmationPane.ts b/src/Explorer/Panes/DeleteCollectionConfirmationPane.ts index c02b675b0..f148ce6c6 100644 --- a/src/Explorer/Panes/DeleteCollectionConfirmationPane.ts +++ b/src/Explorer/Panes/DeleteCollectionConfirmationPane.ts @@ -9,9 +9,9 @@ import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsol import { ContextualPaneBase } from "./ContextualPaneBase"; import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility"; import DeleteFeedback from "../../Common/DeleteFeedback"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; -import { deleteCollection } from "../../Common/DocumentClientUtilityBase"; +import { deleteCollection } from "../../Common/dataAccess/deleteCollection"; export default class DeleteCollectionConfirmationPane extends ContextualPaneBase { public collectionIdConfirmationText: ko.Observable; @@ -29,7 +29,7 @@ export default class DeleteCollectionConfirmationPane extends ContextualPaneBase this.resetData(); } - public submit(): Q.Promise { + public submit(): Promise { if (!this._isValid()) { const selectedCollection: ViewModels.Collection = this.container.findSelectedCollection(); this.formErrors("Input collection name does not match the selected collection"); @@ -37,7 +37,7 @@ export default class DeleteCollectionConfirmationPane extends ContextualPaneBase ConsoleDataType.Error, `Error while deleting collection ${selectedCollection && selectedCollection.id()}: ${this.formErrors()}` ); - return Q.resolve(); + return Promise.resolve(); } this.formErrors(""); @@ -50,16 +50,16 @@ export default class DeleteCollectionConfirmationPane extends ContextualPaneBase dataExplorerArea: Constants.Areas.ContextualPane, paneTitle: this.title() }); - let promise: Q.Promise; + let promise: Promise; if (this.container.isPreferredApiCassandra()) { - promise = (this.container.tableDataClient).deleteTableOrKeyspace( + promise = ((this.container.tableDataClient).deleteTableOrKeyspace( this.container.databaseAccount().properties.cassandraEndpoint, this.container.databaseAccount().id, `DROP TABLE ${selectedCollection.databaseId}.${selectedCollection.id()};`, this.container - ); + ) as unknown) as Promise; } else { - promise = deleteCollection(selectedCollection); + promise = deleteCollection(selectedCollection.databaseId, selectedCollection.id()); } return promise.then( () => { diff --git a/src/Explorer/Panes/DeleteDatabaseConfirmationPane.ts b/src/Explorer/Panes/DeleteDatabaseConfirmationPane.ts index 5f055fd40..2db69256f 100644 --- a/src/Explorer/Panes/DeleteDatabaseConfirmationPane.ts +++ b/src/Explorer/Panes/DeleteDatabaseConfirmationPane.ts @@ -10,7 +10,7 @@ import { ContextualPaneBase } from "./ContextualPaneBase"; import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility"; import DeleteFeedback from "../../Common/DeleteFeedback"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import { deleteDatabase } from "../../Common/DocumentClientUtilityBase"; diff --git a/src/Explorer/Panes/GitHubReposPane.ts b/src/Explorer/Panes/GitHubReposPane.ts index 8f6fbe3a7..fb81e36ce 100644 --- a/src/Explorer/Panes/GitHubReposPane.ts +++ b/src/Explorer/Panes/GitHubReposPane.ts @@ -8,7 +8,7 @@ import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstan import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import * as GitHubUtils from "../../Utils/GitHubUtils"; import { JunoUtils } from "../../Utils/JunoUtils"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import { AuthorizeAccessComponent } from "../Controls/GitHub/AuthorizeAccessComponent"; import { GitHubReposComponent, GitHubReposComponentProps, RepoListItem } from "../Controls/GitHub/GitHubReposComponent"; import { GitHubReposComponentAdapter } from "../Controls/GitHub/GitHubReposComponentAdapter"; diff --git a/src/Explorer/Panes/LoadQueryPane.ts b/src/Explorer/Panes/LoadQueryPane.ts index c5e21e632..8ac434edd 100644 --- a/src/Explorer/Panes/LoadQueryPane.ts +++ b/src/Explorer/Panes/LoadQueryPane.ts @@ -5,7 +5,7 @@ import * as ViewModels from "../../Contracts/ViewModels"; import { ContextualPaneBase } from "./ContextualPaneBase"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; import * as Logger from "../../Common/Logger"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import QueryTab from "../Tabs/QueryTab"; export class LoadQueryPane extends ContextualPaneBase { diff --git a/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx b/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx index 6c20dcb48..c6ef6a7b5 100644 --- a/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx +++ b/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx @@ -4,7 +4,7 @@ import { ReactAdapter } from "../../Bindings/ReactBindingHandler"; import * as Logger from "../../Common/Logger"; import Explorer from "../Explorer"; import { JunoClient } from "../../Juno/JunoClient"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; import { GenericRightPaneComponent, GenericRightPaneProps } from "./GenericRightPaneComponent"; import { PublishNotebookPaneComponent, PublishNotebookPaneProps } from "./PublishNotebookPaneComponent"; diff --git a/src/Explorer/Panes/RenewAdHocAccessPane.ts b/src/Explorer/Panes/RenewAdHocAccessPane.ts index 8d79ad36e..eeb1eb6f6 100644 --- a/src/Explorer/Panes/RenewAdHocAccessPane.ts +++ b/src/Explorer/Panes/RenewAdHocAccessPane.ts @@ -6,7 +6,7 @@ import { ConnectionStringParser } from "../../Platform/Hosted/Helpers/Connection import { ContextualPaneBase } from "./ContextualPaneBase"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; export class RenewAdHocAccessPane extends ContextualPaneBase { public accessKey: ko.Observable; diff --git a/src/Explorer/Panes/SaveQueryPane.ts b/src/Explorer/Panes/SaveQueryPane.ts index a64070ef8..652defc5a 100644 --- a/src/Explorer/Panes/SaveQueryPane.ts +++ b/src/Explorer/Panes/SaveQueryPane.ts @@ -5,7 +5,7 @@ import * as ViewModels from "../../Contracts/ViewModels"; import { Action } from "../../Shared/Telemetry/TelemetryConstants"; import { ContextualPaneBase } from "./ContextualPaneBase"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import QueryTab from "../Tabs/QueryTab"; diff --git a/src/Explorer/Panes/SettingsPane.ts b/src/Explorer/Panes/SettingsPane.ts index d6af0b338..8cd3a08fd 100644 --- a/src/Explorer/Panes/SettingsPane.ts +++ b/src/Explorer/Panes/SettingsPane.ts @@ -4,7 +4,7 @@ import * as ViewModels from "../../Contracts/ViewModels"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; import { ContextualPaneBase } from "./ContextualPaneBase"; import { LocalStorageUtility, StorageKey } from "../../Shared/StorageUtility"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import { StringUtility } from "../../Shared/StringUtility"; import { config } from "../../Config"; diff --git a/src/Explorer/Panes/SetupNotebooksPane.ts b/src/Explorer/Panes/SetupNotebooksPane.ts index ec3592ea6..1492b7529 100644 --- a/src/Explorer/Panes/SetupNotebooksPane.ts +++ b/src/Explorer/Panes/SetupNotebooksPane.ts @@ -3,7 +3,7 @@ import { Action } from "../../Shared/Telemetry/TelemetryConstants"; import { Areas, KeyCodes } from "../../Common/Constants"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; import { ContextualPaneBase } from "./ContextualPaneBase"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import * as ko from "knockout"; diff --git a/src/Explorer/Panes/StringInputPane.ts b/src/Explorer/Panes/StringInputPane.ts index 56b6c0463..1a8e7130f 100644 --- a/src/Explorer/Panes/StringInputPane.ts +++ b/src/Explorer/Panes/StringInputPane.ts @@ -3,7 +3,7 @@ import Q from "q"; import * as ViewModels from "../../Contracts/ViewModels"; import { ContextualPaneBase } from "./ContextualPaneBase"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; export interface StringInputPaneOpenOptions { paneTitle: string; diff --git a/src/Explorer/Panes/UploadFilePane.ts b/src/Explorer/Panes/UploadFilePane.ts index 60dfeb796..56ec52ca5 100644 --- a/src/Explorer/Panes/UploadFilePane.ts +++ b/src/Explorer/Panes/UploadFilePane.ts @@ -3,7 +3,7 @@ import * as Constants from "../../Common/Constants"; import * as ViewModels from "../../Contracts/ViewModels"; import { ContextualPaneBase } from "./ContextualPaneBase"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; export interface UploadFilePaneOpenOptions { paneTitle: string; diff --git a/src/Explorer/Panes/UploadItemsPane.ts b/src/Explorer/Panes/UploadItemsPane.ts index db986c7a7..7b1f227a9 100644 --- a/src/Explorer/Panes/UploadItemsPane.ts +++ b/src/Explorer/Panes/UploadItemsPane.ts @@ -3,7 +3,7 @@ import * as Constants from "../../Common/Constants"; import * as ViewModels from "../../Contracts/ViewModels"; import { ContextualPaneBase } from "./ContextualPaneBase"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import * as ErrorParserUtility from "../../Common/ErrorParserUtility"; import { UploadDetailsRecord, UploadDetails } from "../../workers/upload/definitions"; diff --git a/src/Explorer/Panes/UploadItemsPaneAdapter.tsx b/src/Explorer/Panes/UploadItemsPaneAdapter.tsx index fd63e1a73..6858a8ed2 100644 --- a/src/Explorer/Panes/UploadItemsPaneAdapter.tsx +++ b/src/Explorer/Panes/UploadItemsPaneAdapter.tsx @@ -6,7 +6,7 @@ import * as ViewModels from "../../Contracts/ViewModels"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; import { IconButton } from "office-ui-fabric-react/lib/Button"; import { GenericRightPaneComponent, GenericRightPaneProps } from "./GenericRightPaneComponent"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import { ReactAdapter } from "../../Bindings/ReactBindingHandler"; import { UploadDetailsRecord, UploadDetails } from "../../workers/upload/definitions"; import InfoBubbleIcon from "../../../images/info-bubble.svg"; diff --git a/src/Explorer/Tables/TableDataClient.ts b/src/Explorer/Tables/TableDataClient.ts index 0c34f02e6..5474ba7be 100644 --- a/src/Explorer/Tables/TableDataClient.ts +++ b/src/Explorer/Tables/TableDataClient.ts @@ -9,7 +9,7 @@ import * as Entities from "./Entities"; import EnvironmentUtility from "../../Common/EnvironmentUtility"; import * as HeadersUtility from "../../Common/HeadersUtility"; import * as Logger from "../../Common/Logger"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import * as TableConstants from "./Constants"; import * as TableEntityProcessor from "./TableEntityProcessor"; import * as ViewModels from "../../Contracts/ViewModels"; diff --git a/src/Explorer/Tabs/DocumentsTab.ts b/src/Explorer/Tabs/DocumentsTab.ts index b055a24a0..4b852bb3d 100644 --- a/src/Explorer/Tabs/DocumentsTab.ts +++ b/src/Explorer/Tabs/DocumentsTab.ts @@ -22,7 +22,7 @@ import DeleteDocumentIcon from "../../../images/DeleteDocument.svg"; import UploadIcon from "../../../images/Upload_16x16.svg"; import { extractPartitionKey, PartitionKeyDefinition, QueryIterator, ItemDefinition, Resource } from "@azure/cosmos"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import Explorer from "../Explorer"; import { readDocument, diff --git a/src/Explorer/Tabs/MongoShellTab.ts b/src/Explorer/Tabs/MongoShellTab.ts index 058eebd64..be5afb2c0 100644 --- a/src/Explorer/Tabs/MongoShellTab.ts +++ b/src/Explorer/Tabs/MongoShellTab.ts @@ -11,7 +11,7 @@ import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstan import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; import { CosmosClient } from "../../Common/CosmosClient"; import { HashMap } from "../../Common/HashMap"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import { PlatformType } from "../../PlatformType"; import Explorer from "../Explorer"; diff --git a/src/Explorer/Tabs/NotebookV2Tab.ts b/src/Explorer/Tabs/NotebookV2Tab.ts index cbcf4ddf4..5717c2e70 100644 --- a/src/Explorer/Tabs/NotebookV2Tab.ts +++ b/src/Explorer/Tabs/NotebookV2Tab.ts @@ -22,7 +22,7 @@ import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstan import { Areas, ArmApiVersions } from "../../Common/Constants"; import { CommandBarComponentButtonFactory } from "../Menus/CommandBar/CommandBarComponentButtonFactory"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import { NotebookComponentAdapter } from "../Notebook/NotebookComponent/NotebookComponentAdapter"; import { NotebookConfigurationUtils } from "../../Utils/NotebookConfigurationUtils"; import { KernelSpecsDisplay, NotebookClientV2 } from "../Notebook/NotebookClientV2"; diff --git a/src/Explorer/Tree/Collection.ts b/src/Explorer/Tree/Collection.ts index 54a2db164..8c6a5e214 100644 --- a/src/Explorer/Tree/Collection.ts +++ b/src/Explorer/Tree/Collection.ts @@ -11,7 +11,7 @@ import * as ViewModels from "../../Contracts/ViewModels"; import { PlatformType } from "../../PlatformType"; import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import { OfferUtils } from "../../Utils/OfferUtils"; import { StartUploadMessageParams, UploadDetails, UploadDetailsRecord } from "../../workers/upload/definitions"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; diff --git a/src/Explorer/Tree/Database.ts b/src/Explorer/Tree/Database.ts index 6b1ae0120..c4e1782a7 100644 --- a/src/Explorer/Tree/Database.ts +++ b/src/Explorer/Tree/Database.ts @@ -8,7 +8,7 @@ import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstan import DatabaseSettingsTab from "../Tabs/DatabaseSettingsTab"; import Collection from "./Collection"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; import * as Logger from "../../Common/Logger"; import Explorer from "../Explorer"; diff --git a/src/GitHub/GitHubOAuthService.ts b/src/GitHub/GitHubOAuthService.ts index 680d33e67..846f06228 100644 --- a/src/GitHub/GitHubOAuthService.ts +++ b/src/GitHub/GitHubOAuthService.ts @@ -6,7 +6,7 @@ import { AuthorizeAccessComponent } from "../Explorer/Controls/GitHub/AuthorizeA import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent"; import { JunoClient } from "../Juno/JunoClient"; import { isInvalidParentFrameOrigin } from "../Utils/MessageValidation"; -import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils"; import { GitHubConnectorMsgType, IGitHubConnectorParams } from "./GitHubConnector"; window.addEventListener("message", (event: MessageEvent) => { diff --git a/src/Platform/Hosted/Authorization.ts b/src/Platform/Hosted/Authorization.ts index 01c6cd566..de0cd6cd0 100644 --- a/src/Platform/Hosted/Authorization.ts +++ b/src/Platform/Hosted/Authorization.ts @@ -5,7 +5,7 @@ import * as Constants from "../../Common/Constants"; import * as DataModels from "../../Contracts/DataModels"; import * as ViewModels from "../../Contracts/ViewModels"; import { AuthType } from "../../AuthType"; -import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import { ConsoleDataType } from "../../Explorer/Menus/NotificationConsole/NotificationConsoleComponent"; import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility"; import { CosmosClient } from "../../Common/CosmosClient"; diff --git a/src/Shared/AddCollectionUtility.ts b/src/Shared/AddCollectionUtility.ts index a926c448f..e2476f3f0 100644 --- a/src/Shared/AddCollectionUtility.ts +++ b/src/Shared/AddCollectionUtility.ts @@ -9,7 +9,7 @@ import { CosmosClient } from "../Common/CosmosClient"; import { HttpStatusCodes } from "../Common/Constants"; import { sendMessage } from "../Common/MessageHandler"; import { MessageTypes } from "../Contracts/ExplorerContracts"; -import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils"; import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient"; import Explorer from "../Explorer/Explorer"; diff --git a/src/Shared/AddDatabaseUtility.ts b/src/Shared/AddDatabaseUtility.ts index 4a78dba5b..116ed75ef 100644 --- a/src/Shared/AddDatabaseUtility.ts +++ b/src/Shared/AddDatabaseUtility.ts @@ -6,7 +6,7 @@ import { CosmosClient } from "../Common/CosmosClient"; import { HttpStatusCodes } from "../Common/Constants"; import { sendMessage } from "../Common/MessageHandler"; import { MessageTypes } from "../Contracts/ExplorerContracts"; -import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils"; import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient"; export class AddDbUtilities { diff --git a/src/Utils/GalleryUtils.ts b/src/Utils/GalleryUtils.ts index b170f20d4..5767b793a 100644 --- a/src/Utils/GalleryUtils.ts +++ b/src/Utils/GalleryUtils.ts @@ -1,5 +1,5 @@ import { IGalleryItem, JunoClient } from "../Juno/JunoClient"; -import { NotificationConsoleUtils } from "./NotificationConsoleUtils"; +import * as NotificationConsoleUtils from "./NotificationConsoleUtils"; import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent"; import * as Logger from "../Common/Logger"; import { diff --git a/src/Utils/NotificationConsoleUtils.ts b/src/Utils/NotificationConsoleUtils.ts index 4bde9c0c9..86daeca5a 100644 --- a/src/Utils/NotificationConsoleUtils.ts +++ b/src/Utils/NotificationConsoleUtils.ts @@ -3,26 +3,77 @@ import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/Notificat const _global = typeof self === "undefined" ? window : self; -export class NotificationConsoleUtils { - public static logConsoleMessage(type: ConsoleDataType, message: string, id?: string): string { - const dataExplorer = _global.dataExplorer; - if (dataExplorer != null) { - const date = new Date(); - const formattedDate: string = new Intl.DateTimeFormat("en-EN", { - hour12: true, - hour: "numeric", - minute: "numeric" - }).format(date); - if (!id) { - id = _.uniqueId(); - } - dataExplorer.logConsoleData({ type: type, date: formattedDate, message: message, id: id }); +// DEPRECATED: Use logConsoleInfo, logConsoleError, logConsoleProgress instead +export function logConsoleMessage(type: ConsoleDataType, message: string, id?: string): string { + const dataExplorer = _global.dataExplorer; + if (dataExplorer) { + const date = new Date(); + const formattedDate: string = new Intl.DateTimeFormat("en-EN", { + hour12: true, + hour: "numeric", + minute: "numeric" + }).format(date); + if (!id) { + id = _.uniqueId(); } - return id; + dataExplorer.logConsoleData({ type: type, date: formattedDate, message: message, id: id }); } + return id; +} - public static clearInProgressMessageWithId(id: string) { - const dataExplorer = _global.dataExplorer; - dataExplorer && (dataExplorer as any).deleteInProgressConsoleDataWithId(id); +export function clearInProgressMessageWithId(id: string): void { + const dataExplorer = _global.dataExplorer; + dataExplorer && dataExplorer.deleteInProgressConsoleDataWithId(id); +} + +export function logConsoleProgress(message: string): () => void { + const type = ConsoleDataType.InProgress; + const dataExplorer = _global.dataExplorer; + if (dataExplorer) { + const id = _.uniqueId(); + const date = new Date(); + const formattedDate: string = new Intl.DateTimeFormat("en-EN", { + hour12: true, + hour: "numeric", + minute: "numeric" + }).format(date); + dataExplorer.logConsoleData({ type, date: formattedDate, message, id }); + return () => { + dataExplorer.deleteInProgressConsoleDataWithId(id); + }; + } else { + return () => { + return; + }; + } +} + +export function logConsoleError(message: string): void { + const type = ConsoleDataType.Error; + const dataExplorer = _global.dataExplorer; + if (dataExplorer) { + const id = _.uniqueId(); + const date = new Date(); + const formattedDate: string = new Intl.DateTimeFormat("en-EN", { + hour12: true, + hour: "numeric", + minute: "numeric" + }).format(date); + dataExplorer.logConsoleData({ type, date: formattedDate, message, id }); + } +} + +export function logConsoleInfo(message: string): void { + const type = ConsoleDataType.Info; + const dataExplorer = _global.dataExplorer; + if (dataExplorer) { + const id = _.uniqueId(); + const date = new Date(); + const formattedDate: string = new Intl.DateTimeFormat("en-EN", { + hour12: true, + hour: "numeric", + minute: "numeric" + }).format(date); + dataExplorer.logConsoleData({ type, date: formattedDate, message, id }); } } diff --git a/src/Utils/arm/generatedClients/2020-04-01/cassandraResources.ts b/src/Utils/arm/generatedClients/2020-04-01/cassandraResources.ts new file mode 100644 index 000000000..864fa29ab --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/cassandraResources.ts @@ -0,0 +1,196 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* Lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. */ +export async function listCassandraKeyspaces( + subscriptionId: string, + resourceGroupName: string, + accountName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Deletes an existing Azure Cosmos DB Cassandra keyspace. */ +export async function deleteCassandraKeyspace( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + keyspaceName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Migrate an Azure Cosmos DB Cassandra Keyspace from manual throughput to autoscale */ +export async function migrateCassandraKeyspaceToAutoscale( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + keyspaceName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default/migrateToAutoscale`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* Migrate an Azure Cosmos DB Cassandra Keyspace from autoscale to manual throughput */ +export async function migrateCassandraKeyspaceToManualThroughput( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + keyspaceName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default/migrateToManualThroughput`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Deletes an existing Azure Cosmos DB Cassandra table. */ +export async function deleteCassandraTable( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + keyspaceName: string, + tableName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale */ +export async function migrateCassandraTableToAutoscale( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + keyspaceName: string, + tableName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default/migrateToAutoscale`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* Migrate an Azure Cosmos DB Cassandra table from autoscale to manual throughput */ +export async function migrateCassandraTableToManualThroughput( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + keyspaceName: string, + tableName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default/migrateToManualThroughput`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/collection.ts b/src/Utils/arm/generatedClients/2020-04-01/collection.ts new file mode 100644 index 000000000..ffae3e9cf --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/collection.ts @@ -0,0 +1,46 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/metrics`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/usages`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* Retrieves metric definitions for the given collection. */ +export async function listMetricDefinitions( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseRid: string, + collectionRid: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/metricDefinitions`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/collectionPartition.ts b/src/Utils/arm/generatedClients/2020-04-01/collectionPartition.ts new file mode 100644 index 000000000..30984317b --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/collectionPartition.ts @@ -0,0 +1,34 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/partitions/metrics`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/partitions/usages`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/collectionPartitionRegion.ts b/src/Utils/arm/generatedClients/2020-04-01/collectionPartitionRegion.ts new file mode 100644 index 000000000..70268066c --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/collectionPartitionRegion.ts @@ -0,0 +1,23 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/databases/${databaseRid}/collections/${collectionRid}/partitions/metrics`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/collectionRegion.ts b/src/Utils/arm/generatedClients/2020-04-01/collectionRegion.ts new file mode 100644 index 000000000..5fb04a052 --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/collectionRegion.ts @@ -0,0 +1,23 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/databases/${databaseRid}/collections/${collectionRid}/metrics`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/database.ts b/src/Utils/arm/generatedClients/2020-04-01/database.ts new file mode 100644 index 000000000..44bbd1a82 --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/database.ts @@ -0,0 +1,43 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/metrics`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* Retrieves the usages (most recent data) for the given database. */ +export async function listUsages( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseRid: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/usages`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* Retrieves metric definitions for the given database. */ +export async function listMetricDefinitions( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseRid: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/metricDefinitions`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/databaseAccountRegion.ts b/src/Utils/arm/generatedClients/2020-04-01/databaseAccountRegion.ts new file mode 100644 index 000000000..1e8634502 --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/databaseAccountRegion.ts @@ -0,0 +1,21 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/metrics`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/databaseAccounts.ts b/src/Utils/arm/generatedClients/2020-04-01/databaseAccounts.ts new file mode 100644 index 000000000..65c5c2929 --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/databaseAccounts.ts @@ -0,0 +1,183 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* Retrieves the properties of an existing Azure Cosmos DB database account. */ +export async function get( + subscriptionId: string, + resourceGroupName: string, + accountName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PATCH", apiVersion, body: JSON.stringify(body) }); +} + +/* Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account. */ +export async function createOrUpdate( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + body: Types.DatabaseAccountCreateUpdateParameters +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Deletes an existing Azure Cosmos DB database account. */ +export async function destroy(subscriptionId: string, resourceGroupName: string, accountName: string): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/failoverPriorityChange`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) }); +} + +/* Lists all the Azure Cosmos DB database accounts available under the subscription. */ +export async function list(subscriptionId: string): Promise { + const path = `/subscriptions/${subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* Lists all the Azure Cosmos DB database accounts available under the given resource group. */ +export async function listByResourceGroup( + subscriptionId: string, + resourceGroupName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* Lists the access keys for the specified Azure Cosmos DB database account. */ +export async function listKeys( + subscriptionId: string, + resourceGroupName: string, + accountName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/listKeys`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* Lists the connection strings for the specified Azure Cosmos DB database account. */ +export async function listConnectionStrings( + subscriptionId: string, + resourceGroupName: string, + accountName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/listConnectionStrings`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/offlineRegion`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/onlineRegion`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/readonlykeys`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/readonlykeys`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/regenerateKey`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) }); +} + +/* Checks that the Azure Cosmos DB account name already exists. A valid account name may contain only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters. */ +export async function checkNameExists(accountName: string): Promise { + const path = `/providers/Microsoft.DocumentDB/databaseAccountNames/${accountName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "HEAD", apiVersion }); +} + +/* Retrieves the metrics determined by the given filter for the given database account. */ +export async function listMetrics( + subscriptionId: string, + resourceGroupName: string, + accountName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/metrics`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* Retrieves the usages (most recent data) for the given database account. */ +export async function listUsages( + subscriptionId: string, + resourceGroupName: string, + accountName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/usages`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* Retrieves metric definitions for the given database account. */ +export async function listMetricDefinitions( + subscriptionId: string, + resourceGroupName: string, + accountName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/metricDefinitions`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/gremlinResources.ts b/src/Utils/arm/generatedClients/2020-04-01/gremlinResources.ts new file mode 100644 index 000000000..94afd77cc --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/gremlinResources.ts @@ -0,0 +1,196 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* Lists the Gremlin databases under an existing Azure Cosmos DB database account. */ +export async function listGremlinDatabases( + subscriptionId: string, + resourceGroupName: string, + accountName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Deletes an existing Azure Cosmos DB Gremlin database. */ +export async function deleteGremlinDatabase( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale */ +export async function migrateGremlinDatabaseToAutoscale( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default/migrateToAutoscale`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* Migrate an Azure Cosmos DB Gremlin database from autoscale to manual throughput */ +export async function migrateGremlinDatabaseToManualThroughput( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default/migrateToManualThroughput`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Deletes an existing Azure Cosmos DB Gremlin graph. */ +export async function deleteGremlinGraph( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string, + graphName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Migrate an Azure Cosmos DB Gremlin graph from manual throughput to autoscale */ +export async function migrateGremlinGraphToAutoscale( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string, + graphName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default/migrateToAutoscale`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* Migrate an Azure Cosmos DB Gremlin graph from autoscale to manual throughput */ +export async function migrateGremlinGraphToManualThroughput( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string, + graphName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default/migrateToManualThroughput`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/mongoDBResources.ts b/src/Utils/arm/generatedClients/2020-04-01/mongoDBResources.ts new file mode 100644 index 000000000..3501358ac --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/mongoDBResources.ts @@ -0,0 +1,196 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* Lists the MongoDB databases under an existing Azure Cosmos DB database account. */ +export async function listMongoDBDatabases( + subscriptionId: string, + resourceGroupName: string, + accountName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* Create or updates Azure Cosmos DB MongoDB database */ +export async function createUpdateMongoDBDatabase( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string, + body: Types.MongoDBDatabaseCreateUpdateParameters +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Deletes an existing Azure Cosmos DB MongoDB database. */ +export async function deleteMongoDBDatabase( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale */ +export async function migrateMongoDBDatabaseToAutoscale( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default/migrateToAutoscale`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* Migrate an Azure Cosmos DB MongoDB database from autoscale to manual throughput */ +export async function migrateMongoDBDatabaseToManualThroughput( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default/migrateToManualThroughput`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Deletes an existing Azure Cosmos DB MongoDB Collection. */ +export async function deleteMongoDBCollection( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string, + collectionName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Migrate an Azure Cosmos DB MongoDB collection from manual throughput to autoscale */ +export async function migrateMongoDBCollectionToAutoscale( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string, + collectionName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default/migrateToAutoscale`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* Migrate an Azure Cosmos DB MongoDB collection from autoscale to manual throughput */ +export async function migrateMongoDBCollectionToManualThroughput( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string, + collectionName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default/migrateToManualThroughput`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/operations.ts b/src/Utils/arm/generatedClients/2020-04-01/operations.ts new file mode 100644 index 000000000..58dc86c82 --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/operations.ts @@ -0,0 +1,16 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* Lists all of the available Cosmos DB Resource Provider operations. */ +export async function list(): Promise { + const path = `/providers/Microsoft.DocumentDB/operations`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/partitionKeyRangeId.ts b/src/Utils/arm/generatedClients/2020-04-01/partitionKeyRangeId.ts new file mode 100644 index 000000000..89605b35a --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/partitionKeyRangeId.ts @@ -0,0 +1,23 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/partitionKeyRangeId/${partitionKeyRangeId}/metrics`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/partitionKeyRangeIdRegion.ts b/src/Utils/arm/generatedClients/2020-04-01/partitionKeyRangeIdRegion.ts new file mode 100644 index 000000000..0197ed16d --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/partitionKeyRangeIdRegion.ts @@ -0,0 +1,24 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/databases/${databaseRid}/collections/${collectionRid}/partitionKeyRangeId/${partitionKeyRangeId}/metrics`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/percentile.ts b/src/Utils/arm/generatedClients/2020-04-01/percentile.ts new file mode 100644 index 000000000..483d02aa8 --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/percentile.ts @@ -0,0 +1,20 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/percentile/metrics`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/percentileSourceTarget.ts b/src/Utils/arm/generatedClients/2020-04-01/percentileSourceTarget.ts new file mode 100644 index 000000000..51678e34f --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/percentileSourceTarget.ts @@ -0,0 +1,22 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sourceRegion/${sourceRegion}/targetRegion/${targetRegion}/percentile/metrics`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/percentileTarget.ts b/src/Utils/arm/generatedClients/2020-04-01/percentileTarget.ts new file mode 100644 index 000000000..ac84ed930 --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/percentileTarget.ts @@ -0,0 +1,21 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/targetRegion/${targetRegion}/percentile/metrics`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/sqlResources.ts b/src/Utils/arm/generatedClients/2020-04-01/sqlResources.ts new file mode 100644 index 000000000..0435c6a34 --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/sqlResources.ts @@ -0,0 +1,352 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* Lists the SQL databases under an existing Azure Cosmos DB database account. */ +export async function listSqlDatabases( + subscriptionId: string, + resourceGroupName: string, + accountName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Deletes an existing Azure Cosmos DB SQL database. */ +export async function deleteSqlDatabase( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Migrate an Azure Cosmos DB SQL database from manual throughput to autoscale */ +export async function migrateSqlDatabaseToAutoscale( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default/migrateToAutoscale`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* Migrate an Azure Cosmos DB SQL database from autoscale to manual throughput */ +export async function migrateSqlDatabaseToManualThroughput( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default/migrateToManualThroughput`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Deletes an existing Azure Cosmos DB SQL container. */ +export async function deleteSqlContainer( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string, + containerName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Migrate an Azure Cosmos DB SQL container from manual throughput to autoscale */ +export async function migrateSqlContainerToAutoscale( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string, + containerName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default/migrateToAutoscale`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* Migrate an Azure Cosmos DB SQL container from autoscale to manual throughput */ +export async function migrateSqlContainerToManualThroughput( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + databaseName: string, + containerName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default/migrateToManualThroughput`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/tableResources.ts b/src/Utils/arm/generatedClients/2020-04-01/tableResources.ts new file mode 100644 index 000000000..2499eb158 --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/tableResources.ts @@ -0,0 +1,99 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +import { armRequest } from "../../request"; +import * as Types from "./types"; +import { config } from "../../../../Config"; +const apiVersion = "2020-04-01"; + +/* Lists the Tables under an existing Azure Cosmos DB database account. */ +export async function listTables( + subscriptionId: string, + resourceGroupName: string, + accountName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* Create or update an Azure Cosmos DB Table */ +export async function createUpdateTable( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + tableName: string, + body: Types.TableCreateUpdateParameters +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Deletes an existing Azure Cosmos DB Table. */ +export async function deleteTable( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + tableName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion }); +} + +/* 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 { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) }); +} + +/* Migrate an Azure Cosmos DB Table from manual throughput to autoscale */ +export async function migrateTableToAutoscale( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + tableName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default/migrateToAutoscale`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} + +/* Migrate an Azure Cosmos DB Table from autoscale to manual throughput */ +export async function migrateTableToManualThroughput( + subscriptionId: string, + resourceGroupName: string, + accountName: string, + tableName: string +): Promise { + const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default/migrateToManualThroughput`; + return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion }); +} diff --git a/src/Utils/arm/generatedClients/2020-04-01/types.ts b/src/Utils/arm/generatedClients/2020-04-01/types.ts new file mode 100644 index 000000000..88f0f1daa --- /dev/null +++ b/src/Utils/arm/generatedClients/2020-04-01/types.ts @@ -0,0 +1,1213 @@ +/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/ + +export interface DatabaseAccountsListResult { + /* List of database account and their properties. */ + readonly value: DatabaseAccountGetResults[]; +} + +export interface SqlDatabaseListResult { + /* List of SQL databases and their properties. */ + readonly value: SqlDatabaseGetResults[]; +} + +export interface SqlContainerListResult { + /* List of containers and their properties. */ + readonly value: SqlContainerGetResults[]; +} + +export interface SqlStoredProcedureListResult { + /* List of storedProcedures and their properties. */ + readonly value: SqlStoredProcedureGetResults[]; +} + +export interface SqlUserDefinedFunctionListResult { + /* List of userDefinedFunctions and their properties. */ + readonly value: SqlUserDefinedFunctionGetResults[]; +} + +export interface SqlTriggerListResult { + /* List of triggers and their properties. */ + readonly value: SqlTriggerGetResults[]; +} + +export interface MongoDBDatabaseListResult { + /* List of MongoDB databases and their properties. */ + readonly value: MongoDBDatabaseGetResults[]; +} + +export interface MongoDBCollectionListResult { + /* List of MongoDB collections and their properties. */ + readonly value: MongoDBCollectionGetResults[]; +} + +export interface TableListResult { + /* List of Table and their properties. */ + readonly value: TableGetResults[]; +} + +export interface CassandraKeyspaceListResult { + /* List of Cassandra keyspaces and their properties. */ + readonly value: CassandraKeyspaceGetResults[]; +} + +export interface CassandraTableListResult { + /* List of Cassandra tables and their properties. */ + readonly value: CassandraTableGetResults[]; +} + +export interface GremlinDatabaseListResult { + /* List of Gremlin databases and their properties. */ + readonly value: GremlinDatabaseGetResults[]; +} + +export interface GremlinGraphListResult { + /* 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; +} + +export interface FailoverPolicies { + /* 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; +} + +export interface RegionForOnlineOffline { + /* 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; +} + +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; +} + +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; +} + +export type DatabaseAccountGetResults = ARMResourceProperties & { + /* Indicates the type of database account. This can only be set at database account creation. */ + kind: string; + /* undefined */ + properties: DatabaseAccountGetProperties; +}; + +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; +} + +export type ThroughputSettingsGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB resource throughput */ + properties: ThroughputSettingsGetProperties; +}; + +export interface ThroughputSettingsGetProperties { + /* undefined */ + resource: undefined; +} + +export type SqlDatabaseGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB SQL database */ + properties: SqlDatabaseGetProperties; +}; + +export interface SqlDatabaseGetProperties { + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} + +export type SqlContainerGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB container */ + properties: SqlContainerGetProperties; +}; + +export interface SqlContainerGetProperties { + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} + +export type SqlStoredProcedureGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB storedProcedure */ + properties: SqlStoredProcedureGetProperties; +}; + +export interface SqlStoredProcedureGetProperties { + /* undefined */ + resource: undefined; +} + +export type SqlUserDefinedFunctionGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB userDefinedFunction */ + properties: SqlUserDefinedFunctionGetProperties; +}; + +export interface SqlUserDefinedFunctionGetProperties { + /* undefined */ + resource: undefined; +} + +export type SqlTriggerGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB trigger */ + properties: SqlTriggerGetProperties; +}; + +export interface SqlTriggerGetProperties { + /* undefined */ + resource: undefined; +} + +export type MongoDBDatabaseGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB MongoDB database */ + properties: MongoDBDatabaseGetProperties; +}; + +export interface MongoDBDatabaseGetProperties { + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} + +export type MongoDBCollectionGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB MongoDB collection */ + properties: MongoDBCollectionGetProperties; +}; + +export interface MongoDBCollectionGetProperties { + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} + +export type TableGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB Table */ + properties: TableGetProperties; +}; + +export interface TableGetProperties { + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} + +export type CassandraKeyspaceGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB Cassandra keyspace */ + properties: CassandraKeyspaceGetProperties; +}; + +export interface CassandraKeyspaceGetProperties { + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} + +export type CassandraTableGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB Cassandra table */ + properties: CassandraTableGetProperties; +}; + +export interface CassandraTableGetProperties { + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} + +export type GremlinDatabaseGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB SQL database */ + properties: GremlinDatabaseGetProperties; +}; + +export interface GremlinDatabaseGetProperties { + /* undefined */ + resource: undefined; + /* undefined */ + options: undefined; +} + +export type GremlinGraphGetResults = ARMResourceProperties & { + /* The properties of an Azure Cosmos DB Gremlin graph */ + properties: GremlinGraphGetProperties; +}; + +export interface GremlinGraphGetProperties { + /* 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; +} + +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; +} + +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; +} + +export type DatabaseAccountCreateUpdateParameters = ARMResourceProperties & { + /* 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; +} + +export interface DatabaseAccountUpdateParameters { + /* 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; +} + +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; +}; + +export interface DatabaseAccountConnectionString { + /* 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[]; +} + +export interface DatabaseAccountRegenerateKeyParameters { + /* The access key to regenerate. */ + keyKind: string; +} + +/* 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; +}; + +export interface ThroughputSettingsUpdateProperties { + /* 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; +}; + +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; +} + +export type SqlContainerCreateUpdateParameters = ARMResourceProperties & { + /* 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; +} + +export type SqlStoredProcedureCreateUpdateParameters = ARMResourceProperties & { + /* 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; +} + +export type SqlUserDefinedFunctionCreateUpdateParameters = ARMResourceProperties & { + /* 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; +} + +export type SqlTriggerCreateUpdateParameters = ARMResourceProperties & { + /* 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; +} + +export type MongoDBDatabaseCreateUpdateParameters = ARMResourceProperties & { + /* 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; +} + +export type MongoDBCollectionCreateUpdateParameters = ARMResourceProperties & { + /* 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; +} + +export type TableCreateUpdateParameters = ARMResourceProperties & { + /* 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; +} + +export type CassandraKeyspaceCreateUpdateParameters = ARMResourceProperties & { + /* 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; +} + +export type CassandraTableCreateUpdateParameters = ARMResourceProperties & { + /* 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; +} + +export type GremlinDatabaseCreateUpdateParameters = ARMResourceProperties & { + /* 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; +} + +export type GremlinGraphCreateUpdateParameters = ARMResourceProperties & { + /* 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; +} + +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; +} + +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; +} + +export interface AutoUpgradePolicyResource { + /* 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; +} + +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; +} + +export interface SqlDatabaseResource { + /* 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; +} + +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[]; +} + +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; +} + +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[]; +} + +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; +} + +/* 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[]; +} + +/* 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; +} + +/* 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[]; +} + +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; +} + +export interface SqlStoredProcedureResource { + /* 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; +} + +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; +} + +export interface MongoDBDatabaseResource { + /* 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; +} + +/* 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[]; +} + +/* 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; +} + +export interface CassandraKeyspaceResource { + /* 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; +} + +export interface CassandraSchema { + /* 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; +} + +export interface CassandraPartitionKey { + /* 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; +} + +export interface GremlinDatabaseResource { + /* 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; +} + +export interface CreateUpdateOptions { + /* 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; +} + +export interface Capability { + /* 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 }; + +/* 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; +} + +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; +} + +export type PrivateEndpointConnection = unknown & { + /* 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; +} + +export interface PrivateEndpointProperty { + /* 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; +} + +export interface Operation { + /* 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; +} + +export interface UsagesResult { + /* 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; +} + +export interface PartitionUsagesResult { + /* 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; +}; + +export interface MetricDefinitionsListResult { + /* 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; +} + +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; +} + +export interface MetricListResult { + /* 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[]; +} + +export interface MetricName { + /* 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; +} + +export interface PercentileMetricListResult { + /* 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[]; +} + +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; +}; + +export interface PartitionMetricListResult { + /* 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 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"; + +/* 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; +} diff --git a/src/Utils/arm/request.test.ts b/src/Utils/arm/request.test.ts new file mode 100644 index 000000000..e0ba3120d --- /dev/null +++ b/src/Utils/arm/request.test.ts @@ -0,0 +1,44 @@ +import { armRequest } from "./request"; + +describe("ARM request", () => { + it("should call window.fetch", async () => { + window.fetch = jest.fn().mockResolvedValue({ + ok: true, + json: async () => { + return {}; + } + }); + await armRequest({ apiVersion: "2001-01-01", host: "https://foo.com", path: "foo", method: "GET" }); + expect(window.fetch).toHaveBeenCalled(); + }); + + it("should poll for async operations", async () => { + const headers = new Headers(); + headers.set("azure-asyncoperation", "https://foo.com/operationStatus"); + window.fetch = jest.fn().mockResolvedValue({ + ok: true, + headers, + json: async () => { + return { status: "Succeeded" }; + } + }); + await armRequest({ apiVersion: "2001-01-01", host: "https://foo.com", path: "foo", method: "GET" }); + expect(window.fetch).toHaveBeenCalledTimes(2); + }); + + it("should throw for failed async operations", async () => { + const headers = new Headers(); + headers.set("azure-asyncoperation", "https://foo.com/operationStatus"); + window.fetch = jest.fn().mockResolvedValue({ + ok: true, + headers, + json: async () => { + return { status: "Failed" }; + } + }); + await expect(() => + armRequest({ apiVersion: "2001-01-01", host: "https://foo.com", path: "foo", method: "GET" }) + ).rejects.toThrow(); + expect(window.fetch).toHaveBeenCalledTimes(2); + }); +}); diff --git a/src/Utils/arm/request.ts b/src/Utils/arm/request.ts new file mode 100644 index 000000000..9adaf15f1 --- /dev/null +++ b/src/Utils/arm/request.ts @@ -0,0 +1,102 @@ +/* + +A general purpose fetch function for ARM resources. Not designed to be used directly +Instead, generate ARM clients that consume this function with stricter typing. + +*/ + +import { CosmosClient } from "../../Common/CosmosClient"; +import promiseRetry, { AbortError } from "p-retry"; + +interface ErrorResponse { + error: { + code: string; + message: string; + }; +} + +interface ARMError extends Error { + code: string; +} + +interface Options { + host: string; + path: string; + apiVersion: string; + method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD"; + body?: unknown; +} + +// TODO: This is very similar to what is happening in ResourceProviderClient.ts. Should probably merge them. +export async function armRequest({ host, path, apiVersion, method, body: requestBody }: Options): Promise { + const url = new URL(path, host); + url.searchParams.append("api-version", apiVersion); + const response = await window.fetch(url.href, { + method, + headers: { + Authorization: CosmosClient.authorizationToken() + }, + body: requestBody ? JSON.stringify(requestBody) : undefined + }); + if (!response.ok) { + const errorResponse = (await response.json()) as ErrorResponse; + const error = new Error(errorResponse.error?.message) as ARMError; + error.code = errorResponse.error.code; + throw error; + } + + const operationStatusUrl = response.headers && response.headers.get("azure-asyncoperation"); + if (operationStatusUrl) { + await promiseRetry(() => getOperationStatus(operationStatusUrl)); + // TODO: ARM is supposed to return a resourceLocation property, but it does not https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#target-resource-location + // When Cosmos RP adds resourceLocation, we should use it instead + // For now manually execute a GET if the operation was a mutation and not a deletion + if (method === "POST" || method === "PATCH" || method === "PUT") { + return armRequest({ + host, + path, + apiVersion, + method: "GET" + }); + } + } + + const responseBody = (await response.json()) as T; + return responseBody; +} + +const SUCCEEDED = "Succeeded" as const; +const FAILED = "Failed" as const; +const CANCELED = "Canceled" as const; + +type Status = typeof SUCCEEDED | typeof FAILED | typeof CANCELED; + +interface OperationResponse { + status: Status; + error: unknown; +} + +async function getOperationStatus(operationStatusUrl: string) { + const response = await window.fetch(operationStatusUrl, { + headers: { + Authorization: CosmosClient.authorizationToken() + } + }); + if (!response.ok) { + const errorResponse = (await response.json()) as ErrorResponse; + const error = new Error(errorResponse.error?.message) as ARMError; + error.code = errorResponse.error.code; + throw new AbortError(error); + } + const body = (await response.json()) as OperationResponse; + const status = body.status; + if (status === SUCCEEDED) { + return; + } + if (status === CANCELED || status === FAILED) { + const errorMessage = body.error ? JSON.stringify(body.error) : "Operation could not be completed"; + const error = new Error(errorMessage); + throw new AbortError(error); + } + throw new Error(`Operation Response: ${JSON.stringify(body)}. Retrying.`); +} diff --git a/tsconfig.strict.json b/tsconfig.strict.json index a7efd2996..7cef53e56 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -68,6 +68,7 @@ "./src/Utils/MessageValidation.ts", "./src/Utils/OfferUtils.ts", "./src/Utils/StringUtils.ts", + "./src/Utils/arm/generatedClients/2020-04-01/types.ts", "./src/quickstart.ts", "./src/setupTests.ts", "./src/workers/upload/definitions.ts" diff --git a/utils/armClientGenerator/generator.ts b/utils/armClientGenerator/generator.ts new file mode 100644 index 000000000..e7bdbe3e6 --- /dev/null +++ b/utils/armClientGenerator/generator.ts @@ -0,0 +1,246 @@ +/// +import { writeFileSync } from "fs"; +import mkdirp from "mkdirp"; +import fetch from "node-fetch"; +import * as path from "path"; + +/* +Open API TypeScript Client Generator + +This is a bespoke Open API client generator not intended for general public use. +It is not designed to handle the full OpenAPI spec. +Many other more general purpose generators exist, but their output is very verbose and overly complex for our use case. +But it does work well enough to generate a fully typed tree-shakeable client for the Cosmos resource provider. +Results of this file should be checked into the repo. +*/ + +// Array of strings to use for eventual output +const outputTypes: string[] = [""]; +const version = "2020-04-01"; +const schemaURL = `https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/${version}/cosmos-db.json`; + +const outputDir = path.join(__dirname, `../../src/Utils/arm/generatedClients/${version}`); +mkdirp.sync(outputDir); + +// Buckets for grouping operations based on their name +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 } = { + integer: "number" +}; + +// Converts a Open API reference: "#/definitions/Foo" to a type name: Foo +function refToType(path: string | undefined, namespace?: string) { + // References must be in the same file. Bail to `unknown` types for remote references + if (path && path.startsWith("#")) { + const type = path.split("/").pop(); + return namespace ? `${namespace}.${type}` : type; + } + return "unknown"; +} + +// Converts "Something_Foo" -> "somethingFoo" +function camelize(str: string) { + return str + .replace(/(?:^\w|[A-Z]|\b\w)/g, (word: string, index: number) => { + return index === 0 ? word.toLowerCase() : word.toUpperCase(); + }) + .replace(/\s+/g, ""); +} + +// Converts a body paramter to the equivalent typescript function parameter type +function bodyParam(parameter: { schema: { $ref: string } }, namespace: string) { + if (!parameter) { + return ""; + } + return `,body: ${refToType(parameter.schema.$ref, namespace)}`; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +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]); +} + +type Operation = { responses: { [key: string]: { schema: { $ref: string } } } }; + +// Converts OpenAPI response definition to TypeScript return type. Uses unions if possible. Bails to unknown +function responseType(operation: Operation, namespace: string) { + if (operation.responses) { + return Object.keys(operation.responses) + .map((responseCode: string) => { + if (!operation.responses[responseCode].schema) { + return "void"; + } + return refToType(operation.responses[responseCode].schema.$ref, namespace); + }) + .filter((value, index, array) => array.indexOf(value) === index) + .join(" | "); + } + return "unknown"; +} + +async function main() { + const response = await fetch(schemaURL); + const schema = await response.json(); + + // STEP 1: Convert all definitions to TypeScript types and interfaces + for (const definition in schema.definitions) { + const properties = schema.definitions[definition].properties; + if (properties) { + if (schema.definitions[definition].allOf) { + const baseTypes = schema.definitions[definition].allOf + .map((allof: { $ref: string }) => refToType(allof.$ref)) + .join(" & "); + outputTypes.push(`export type ${definition} = ${baseTypes} & {`); + } else { + outputTypes.push(`export interface ${definition} {`); + } + for (const prop in schema.definitions[definition].properties) { + const property = schema.definitions[definition].properties[prop]; + if (property) { + if (property.$ref) { + const type = refToType(property.$ref); + outputTypes.push(` + /* ${property.description} */ + ${property.readOnly ? "readonly " : ""}${prop}: ${type} + `); + } else if (property.type === "array") { + const type = refToType(property.items.$ref); + outputTypes.push(` + /* ${property.description} */ + ${property.readOnly ? "readonly " : ""}${prop}: ${type}[] + `); + } else if (property.type === "object") { + const type = refToType(property.$ref); + outputTypes.push(` + /* ${property.description} */ + ${property.readOnly ? "readonly " : ""}${prop}: ${type} + `); + } else { + outputTypes.push(` + /* ${property.description} */ + ${property.readOnly ? "readonly " : ""}${prop}: ${ + propertyMap[property.type] ? propertyMap[property.type] : property.type + }`); + } + } + } + outputTypes.push(`}`); + outputTypes.push("\n\n"); + } else { + const def = schema.definitions[definition]; + if (def.enum) { + outputTypes.push(` + /* ${def.description} */ + export type ${definition} = ${def.enum.map((v: string) => `"${v}"`).join(" | ")}`); + outputTypes.push("\n"); + } else if (def.type === "string") { + outputTypes.push(` + /* ${def.description} */ + export type ${definition} = string + `); + } else if (def.type === "array") { + const type = refToType(def.items.$ref); + outputTypes.push(` + /* ${def.description} */ + export type ${definition} = ${type}[] + `); + } else if (def.type === "object" && def.additionalProperties) { + outputTypes.push(` + /* ${def.description} */ + export type ${definition} = { [key: string]: ${def.additionalProperties.type}} + `); + } else if (def.type === "object" && def.allOf) { + const type = refToType(def.allOf[0].$ref); + outputTypes.push(` + /* ${def.description} */ + export type ${definition} = ${type} + `); + } else { + console.log("UNHANDLED MODEL:", def, schema.definitions[def]); + } + } + } + + // 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 [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); + } + } + } + + // Write all grouped fetch functions to objects + for (const clientName in clients) { + const outputClient: string[] = [""]; + outputClient.push(`import { armRequest } from "../../request"\n`); + outputClient.push(`import * as Types from "./types"\n`); + outputClient.push(`import { config } from "../../../../Config";\n`); + outputClient.push(`const apiVersion = "${version}"\n\n`); + for (const path of clients[clientName].paths) { + for (const method in schema.paths[path]) { + const operation = schema.paths[path][method]; + console.log(operation["x-ms-long-running-operation"]); + const [, methodName] = operation.operationId.split("_"); + const bodyParameter = operation.parameters.find( + (parameter: { in: string; required: boolean }) => parameter.in === "body" && parameter.required === true + ); + outputClient.push(` + /* ${operation.description} */ + export async function ${sanitize(camelize(methodName))} ( + ${parametersFromPath(path) + .map(p => `${p}: string`) + .join(",\n")} + ${bodyParam(bodyParameter, "Types")} + ) : Promise<${responseType(operation, "Types")}> { + const path = \`${path.replace(/{/g, "${")}\` + return armRequest({ host: config.ARM_ENDPOINT, path, method: "${method.toLocaleUpperCase()}", apiVersion, ${ + bodyParameter ? "body: JSON.stringify(body)" : "" + } }) + } + `); + } + } + writeOutputFile(`./${camelize(clientName)}.ts`, outputClient); + } + + writeOutputFile("./types.ts", outputTypes); +} + +function sanitize(name: string) { + if (name === "delete") { + return "destroy"; + } + return name; +} + +function writeOutputFile(outputPath: string, components: string[]) { + components.unshift(`/* + AUTOGENERATED FILE + Do not manually edit + Run "npm run generateARMClients" to regenerate +*/\n\n`); + writeFileSync(path.join(outputDir, outputPath), components.join("")); +} + +main().catch(e => { + console.error(e); + process.exit(1); +});