From 2790e568d4d3b033411bdbe3f13dfe2085b265db Mon Sep 17 00:00:00 2001 From: Lei Ni Date: Wed, 29 Sep 2021 10:53:26 +0800 Subject: [PATCH 1/2] Fix schemas readme files --- scripts/multiapi.ts | 108 +++++++++++ .../readme.azureresourceschema.md | 173 ------------------ .../readme.azureresourceschema.md | 24 --- .../cosmos-db/resource-manager/readme.md | 40 ---- .../readme.azureresourceschema.md | 172 ----------------- .../datadog/resource-manager/readme.md | 24 --- .../dataprotection/resource-manager/readme.md | 24 --- .../datashare/resource-manager/readme.md | 27 --- .../resource-manager/readme.md | 33 ---- .../postgresql/resource-manager/readme.md | 44 ----- .../readme.azureresourceschema.md | 44 ----- .../quota/resource-manager/readme.md | 23 --- .../resource-manager/readme.md | 24 --- 13 files changed, 108 insertions(+), 652 deletions(-) create mode 100644 scripts/multiapi.ts delete mode 100644 specification/applicationinsights/resource-manager/readme.azureresourceschema.md delete mode 100644 specification/azurearcdata/resource-manager/readme.azureresourceschema.md delete mode 100644 specification/cost-management/resource-manager/readme.azureresourceschema.md delete mode 100644 specification/quota/resource-manager/readme.azureresourceschema.md diff --git a/scripts/multiapi.ts b/scripts/multiapi.ts new file mode 100644 index 000000000000..b72b0bb6a914 --- /dev/null +++ b/scripts/multiapi.ts @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +import * as fs from "@ts-common/fs" +import * as process from "process" +import * as path from "path" +import * as cm from "@ts-common/commonmark-to-markdown" +import * as it from "@ts-common/iterator" +import * as yaml from "js-yaml" + +type Code = { + readonly "input-file"?: ReadonlyArray|string +} +const magic = `yaml $(tag) == 'all-api-versions' /* autogenerated */`; +const pathRegex = /microsoft\.(\w+)[\\\/]\S*[\\\/](\d{4}-\d{2}-\d{2}(|-preview))[\\\/]/i; + +const main = async (specificationDir: string) => { + try { + const list = fs.recursiveReaddir(specificationDir) + for await (const file of list) { + const f = path.parse(file) + if (f.base === "readme.md" && f.dir.endsWith('resource-manager')) { + const original_content = (await fs.readFile(file)).toString() + let content = original_content; + const readMe = cm.parse(content) + const set = new Set() + for (const c of cm.iterate(readMe.markDown)) { + if ( + c.type === "code_block" && + c.info !== null && + (c.info.startsWith("yaml") && !c.info.startsWith(magic)) && + c.literal !== null + ) { + const DOC = (yaml.load(c.literal) as Code); + if (DOC ) { + const y = DOC['input-file'] + if (typeof y === "string") { + set.add(y) + } else if (it.isArray(y)) { + for (const i of y) { + set.add(i) + } + } + } + } + } + let map = new Map(); + for (let input of set) { + let match = pathRegex.exec(input); + if (!!match) { + let tagName = `schema-${match[1].toLowerCase()}-${match[2]}`; + if (!map.has(tagName)) { + map.set(tagName, []); + } + let array = map.get(tagName); + if (!!array) { + array.push(input); + } + } + } + map = new Map(Array.from(map.entries()).sort().reverse()); + let schemaReadmeContent = +`## AzureResourceSchema + +These settings apply only when \`--azureresourceschema\` is specified on the command line. + +### AzureResourceSchema multi-api + +\`\`\` yaml $(azureresourceschema) && $(multiapi) +${yaml.dump({ 'batch': it.toArray(it.map(map.keys(), (tagName) => ({'tag': tagName})))}, { lineWidth: 1000})} +\`\`\` + +Please also specify \`--azureresourceschema-folder=\`. +` + map.forEach((inputList, tagName) => { + schemaReadmeContent += +` +### Tag: ${tagName} and azureresourceschema + +\`\`\` yaml $(tag) == '${tagName}' && $(azureresourceschema) +output-folder: $(azureresourceschema-folder)/schemas + +# all the input files in this apiVersion +${yaml.dump({ 'input-file': it.toArray(inputList)}, { lineWidth: 1000})} +\`\`\` +` + }); + + content = content.replace( /``` yaml \$\(tag\) == 'all-api-versions' \/\* autogenerated \*\/[\S\s]*?```/g, '') + content = content.replace( /``` yaml \$\(tag\) == 'all-api-versions'[\S\s]*?```/g, '') + content = content.replace( /## Multi-API\/Profile support for AutoRest v3 generators[\S\s]*/g, '') + + if(original_content !== content ){ + console.log(`Updating: ${file}`); + fs.writeFile(path.join(f.dir, "readme.md"), content) + } + + console.log(`Rewriting: ${f.dir}/readme.azureresourceschema.md\n contentLength: ${schemaReadmeContent.length}`); + // fs.writeFile(path.join(f.dir, "readme.azureresourceschema.md"), schemaReadmeContent); + + } + } + } catch (e) { + console.error(e) + } +} + +main(path.join(process.cwd(), "specification")) \ No newline at end of file diff --git a/specification/applicationinsights/resource-manager/readme.azureresourceschema.md b/specification/applicationinsights/resource-manager/readme.azureresourceschema.md deleted file mode 100644 index 15fdfa11ba7a..000000000000 --- a/specification/applicationinsights/resource-manager/readme.azureresourceschema.md +++ /dev/null @@ -1,173 +0,0 @@ -## AzureResourceSchema - -These settings apply only when `--azureresourceschema` is specified on the command line. - -### AzureResourceSchema multi-api - -``` yaml $(azureresourceschema) && $(multiapi) -batch: - - tag: schema-insights-2020-11-20 - - tag: schema-insights-2020-10-20 - - tag: schema-insights-2020-10-05-preview - - tag: schema-insights-2020-06-02-preview - - tag: schema-insights-2020-03-01-preview - - tag: schema-insights-2020-02-10-preview - - tag: schema-insights-2020-02-02-preview - - tag: schema-insights-2019-10-17-preview - - tag: schema-insights-2018-06-17-preview - - tag: schema-insights-2018-05-01-preview - - tag: schema-insights-2017-10-01 - - tag: schema-insights-2015-05-01 - -``` - -Please also specify `--azureresourceschema-folder=`. - -### Tag: schema-insights-2020-11-20 and azureresourceschema - -``` yaml $(tag) == 'schema-insights-2020-11-20' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Insights/stable/2020-11-20/workbookTemplates_API.json - -``` - -### Tag: schema-insights-2020-10-20 and azureresourceschema - -``` yaml $(tag) == 'schema-insights-2020-10-20' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Insights/stable/2020-10-20/myworkbooks_API.json - - Microsoft.Insights/stable/2020-10-20/workbooks_API.json - - Microsoft.Insights/stable/2020-10-20/workbookOperations_API.json - -``` - -### Tag: schema-insights-2020-10-05-preview and azureresourceschema - -``` yaml $(tag) == 'schema-insights-2020-10-05-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Insights/preview/2020-10-05-preview/webTests_API.json - -``` - -### Tag: schema-insights-2020-06-02-preview and azureresourceschema - -``` yaml $(tag) == 'schema-insights-2020-06-02-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Insights/preview/2020-06-02-preview/livetoken_API.json - -``` - -### Tag: schema-insights-2020-03-01-preview and azureresourceschema - -``` yaml $(tag) == 'schema-insights-2020-03-01-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Insights/preview/2020-03-01-preview/componentLinkedStorageAccounts_API.json - -``` - -### Tag: schema-insights-2020-02-10-preview and azureresourceschema - -``` yaml $(tag) == 'schema-insights-2020-02-10-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Insights/preview/2020-02-10-preview/WebTestResults_API.json - -``` - -### Tag: schema-insights-2020-02-02-preview and azureresourceschema - -``` yaml $(tag) == 'schema-insights-2020-02-02-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Insights/preview/2020-02-02-preview/components_API.json - -``` - -### Tag: schema-insights-2019-10-17-preview and azureresourceschema - -``` yaml $(tag) == 'schema-insights-2019-10-17-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Insights/preview/2019-10-17-preview/workbookTemplates_API.json - -``` - -### Tag: schema-insights-2018-06-17-preview and azureresourceschema - -``` yaml $(tag) == 'schema-insights-2018-06-17-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Insights/preview/2018-06-17-preview/workbooks_API.json - -``` - -### Tag: schema-insights-2018-05-01-preview and azureresourceschema - -``` yaml $(tag) == 'schema-insights-2018-05-01-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Insights/preview/2018-05-01-preview/components_API.json - - Microsoft.Insights/preview/2018-05-01-preview/componentProactiveDetection_API.json - -``` - -### Tag: schema-insights-2017-10-01 and azureresourceschema - -``` yaml $(tag) == 'schema-insights-2017-10-01' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Insights/preview/2017-10-01/eaSubscriptionMigration_API.json - - Microsoft.Insights/preview/2017-10-01/componentFeaturesAndPricing_API.json - -``` - -### Tag: schema-insights-2015-05-01 and azureresourceschema - -``` yaml $(tag) == 'schema-insights-2015-05-01' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Insights/stable/2015-05-01/analyticsItems_API.json - - Microsoft.Insights/stable/2015-05-01/componentAnnotations_API.json - - Microsoft.Insights/stable/2015-05-01/componentApiKeys_API.json - - Microsoft.Insights/stable/2015-05-01/componentContinuousExport_API.json - - Microsoft.Insights/stable/2015-05-01/componentFeaturesAndPricing_API.json - - Microsoft.Insights/stable/2015-05-01/componentProactiveDetection_API.json - - Microsoft.Insights/stable/2015-05-01/components_API.json - - Microsoft.Insights/stable/2015-05-01/componentWorkItemConfigs_API.json - - Microsoft.Insights/stable/2015-05-01/favorites_API.json - - Microsoft.Insights/stable/2015-05-01/webTestLocations_API.json - - Microsoft.Insights/stable/2015-05-01/webTests_API.json - - Microsoft.Insights/stable/2015-05-01/aiOperations_API.json - - Microsoft.Insights/stable/2015-05-01/workbooks_API.json - - Microsoft.Insights/stable/2015-05-01/myworkbooks_API.json - -``` diff --git a/specification/azurearcdata/resource-manager/readme.azureresourceschema.md b/specification/azurearcdata/resource-manager/readme.azureresourceschema.md deleted file mode 100644 index 8a5870cc234b..000000000000 --- a/specification/azurearcdata/resource-manager/readme.azureresourceschema.md +++ /dev/null @@ -1,24 +0,0 @@ -## AzureResourceSchema - -These settings apply only when `--azureresourceschema` is specified on the command line. - -### AzureResourceSchema multi-api - -``` yaml $(azureresourceschema) && $(multiapi) -batch: - - tag: schema-azurearcdata-2021-08-01 - -``` - -Please also specify `--azureresourceschema-folder=`. - -### Tag: schema-azurearcdata-2021-08-01 and azureresourceschema - -``` yaml $(tag) == 'schema-azurearcdata-2021-08-01' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.AzureArcData/stable/2021-08-01/azurearcdata.json - -``` diff --git a/specification/cosmos-db/resource-manager/readme.md b/specification/cosmos-db/resource-manager/readme.md index c830ba4ecc63..143767c91ef5 100644 --- a/specification/cosmos-db/resource-manager/readme.md +++ b/specification/cosmos-db/resource-manager/readme.md @@ -452,43 +452,3 @@ See configuration in [readme.go.md](./readme.go.md) See configuration in [readme.java.md](./readme.java.md) -## Multi-API/Profile support for AutoRest v3 generators - -AutoRest V3 generators require the use of `--tag=all-api-versions` to select api files. - -This block is updated by an automatic script. Edits may be lost! - -``` yaml $(tag) == 'all-api-versions' /* autogenerated */ -# include the azure profile definitions from the standard location -require: $(this-folder)/../../../profiles/readme.md - -# all the input files across all versions -input-file: - - $(this-folder)/Microsoft.DocumentDB/preview/2020-06-01-preview/cosmos-db.json - - $(this-folder)/Microsoft.DocumentDB/preview/2020-06-01-preview/notebook.json - - $(this-folder)/Microsoft.DocumentDB/preview/2020-06-01-preview/rbac.json - - $(this-folder)/Microsoft.DocumentDB/preview/2019-08-01-preview/privateLinkResources.json - - $(this-folder)/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json - - $(this-folder)/Microsoft.DocumentDB/stable/2020-04-01/cosmos-db.json - - $(this-folder)/Microsoft.DocumentDB/stable/2020-04-01/notebook.json - - $(this-folder)/Microsoft.DocumentDB/stable/2020-03-01/cosmos-db.json - - $(this-folder)/Microsoft.DocumentDB/stable/2020-03-01/notebook.json - - $(this-folder)/Microsoft.DocumentDB/stable/2019-12-12/cosmos-db.json - - $(this-folder)/Microsoft.DocumentDB/stable/2019-12-12/notebook.json - - $(this-folder)/Microsoft.DocumentDB/stable/2019-08-01/cosmos-db.json - - $(this-folder)/Microsoft.DocumentDB/stable/2019-08-01/notebook.json - - $(this-folder)/Microsoft.DocumentDB/stable/2015-04-08/cosmos-db.json - - $(this-folder)/Microsoft.DocumentDB/stable/2014-04-01/cosmos-db.json - - $(this-folder)/Microsoft.DocumentDB/stable/2015-11-06/cosmos-db.json - - $(this-folder)/Microsoft.DocumentDB/stable/2016-03-19/cosmos-db.json - - $(this-folder)/Microsoft.DocumentDB/stable/2016-03-31/cosmos-db.json - -``` - -If there are files that should not be in the `all-api-versions` set, -uncomment the `exclude-file` section below and add the file paths. - -``` yaml $(tag) == 'all-api-versions' -#exclude-file: -# - $(this-folder)/Microsoft.Example/stable/2010-01-01/somefile.json -``` diff --git a/specification/cost-management/resource-manager/readme.azureresourceschema.md b/specification/cost-management/resource-manager/readme.azureresourceschema.md deleted file mode 100644 index ca57f5675564..000000000000 --- a/specification/cost-management/resource-manager/readme.azureresourceschema.md +++ /dev/null @@ -1,172 +0,0 @@ -## AzureResourceSchema - -These settings apply only when `--azureresourceschema` is specified on the command line. - -### AzureResourceSchema multi-api - -``` yaml $(azureresourceschema) && $(multiapi) -batch: - - tag: schema-costmanagement-2020-12-01-preview - - tag: schema-costmanagement-2020-06-01 - - tag: schema-costmanagement-2020-03-01-preview - - tag: schema-costmanagement-2019-11-01 - - tag: schema-costmanagement-2019-10-01 - - tag: schema-costmanagement-2019-09-01 - - tag: schema-costmanagement-2019-04-01-preview - - tag: schema-costmanagement-2019-03-01-preview - - tag: schema-costmanagement-2019-01-01 - - tag: schema-costmanagement-2018-12-01-preview - - tag: schema-costmanagement-2018-08-01-preview - - tag: schema-costmanagement-2018-05-31 - -``` - -Please also specify `--azureresourceschema-folder=`. - -### Tag: schema-costmanagement-2021-01-01 and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2021-01-01' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/stable/2021-01-01/costmanagement.exports.json - - Microsoft.CostManagement/stable/2021-01-01/costmanagement.generatedetailedcostreport.json - - Microsoft.CostManagement/stable/2020-06-01/costmanagement.json - -``` - -### Tag: schema-costmanagement-2020-12-01-preview and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2020-12-01-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/preview/2020-12-01-preview/costmanagement.exports.json - - Microsoft.CostManagement/preview/2020-12-01-preview/costmanagement.generatedetailedcostreport.json - -``` - -### Tag: schema-costmanagement-2020-06-01 and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2020-06-01' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/stable/2020-06-01/costmanagement.json - - Microsoft.CostManagement/stable/2020-06-01/costmanagement.exports.json - -``` - -### Tag: schema-costmanagement-2020-03-01-preview and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2020-03-01-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/preview/2020-03-01-preview/costallocation.json - -``` - -### Tag: schema-costmanagement-2019-11-01 and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2019-11-01' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/stable/2019-11-01/costmanagement.json - - Microsoft.CostManagement/stable/2019-11-01/costmanagement.exports.json - -``` - -### Tag: schema-costmanagement-2019-10-01 and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2019-10-01' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/stable/2019-10-01/costmanagement.json - -``` - -### Tag: schema-costmanagement-2019-09-01 and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2019-09-01' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/stable/2019-09-01/costmanagement.json - -``` - -### Tag: schema-costmanagement-2019-04-01-preview and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2019-04-01-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/preview/2019-04-01-preview/costmanagement.json - -``` - -### Tag: schema-costmanagement-2019-03-01-preview and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2019-03-01-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/preview/2019-03-01-preview/costmanagement.json - -``` - -### Tag: schema-costmanagement-2019-01-01 and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2019-01-01' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/stable/2019-01-01/costmanagement.json - -``` - -### Tag: schema-costmanagement-2018-12-01-preview and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2018-12-01-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/preview/2018-12-01-preview/costmanagement.json - -``` - -### Tag: schema-costmanagement-2018-08-01-preview and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2018-08-01-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/preview/2018-08-01-preview/costmanagement.json - -``` - -### Tag: schema-costmanagement-2018-05-31 and azureresourceschema - -``` yaml $(tag) == 'schema-costmanagement-2018-05-31' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.CostManagement/stable/2018-05-31/costmanagement.json - -``` diff --git a/specification/datadog/resource-manager/readme.md b/specification/datadog/resource-manager/readme.md index 08c2573523b0..a5717a6d4a1c 100644 --- a/specification/datadog/resource-manager/readme.md +++ b/specification/datadog/resource-manager/readme.md @@ -100,27 +100,3 @@ See configuration in [readme.typescript.md](./readme.typescript.md) -## Multi-API/Profile support for AutoRest v3 generators - -AutoRest V3 generators require the use of `--tag=all-api-versions` to select api files. - -This block is updated by an automatic script. Edits may be lost! - -``` yaml $(tag) == 'all-api-versions' /* autogenerated */ -# include the azure profile definitions from the standard location -require: $(this-folder)/../../../profiles/readme.md - -# all the input files across all versions -input-file: - - $(this-folder)/Microsoft.Datadog/stable/2021-03-01/datadog.json - - $(this-folder)/Microsoft.Datadog/preview/2020-02-01-preview/datadog.json - -``` - -If there are files that should not be in the `all-api-versions` set, -uncomment the `exclude-file` section below and add the file paths. - -``` yaml $(tag) == 'all-api-versions' -#exclude-file: -# - $(this-folder)/Microsoft.Example/stable/2010-01-01/somefile.json -``` diff --git a/specification/dataprotection/resource-manager/readme.md b/specification/dataprotection/resource-manager/readme.md index 5ee7f5607149..06d5c2ae3bfb 100644 --- a/specification/dataprotection/resource-manager/readme.md +++ b/specification/dataprotection/resource-manager/readme.md @@ -136,27 +136,3 @@ See configuration in [readme.go.md](./readme.go.md) See configuration in [readme.java.md](./readme.java.md) -## Multi-API/Profile support for AutoRest v3 generators - -AutoRest V3 generators require the use of `--tag=all-api-versions` to select api files. - -This block is updated by an automatic script. Edits may be lost! - -``` yaml $(tag) == 'all-api-versions' /* autogenerated */ -# include the azure profile definitions from the standard location -require: $(this-folder)/../../../profiles/readme.md - -# all the input files across all versions -input-file: - - Microsoft.DataProtection/stable/2021-01-01/dataprotection.json - - Microsoft.DataProtection/preview/2021-02-01-preview/dataprotection.json - - Microsoft.DataProtection/preview/2021-06-01-preview/dataprotection.json -``` - -If there are files that should not be in the `all-api-versions` set, -uncomment the `exclude-file` section below and add the file paths. - -``` yaml $(tag) == 'all-api-versions' -#exclude-file: -# - $(this-folder)/Microsoft.Example/2010-01-01/somefile.json -``` diff --git a/specification/datashare/resource-manager/readme.md b/specification/datashare/resource-manager/readme.md index fc4537f05508..f2a798002cae 100644 --- a/specification/datashare/resource-manager/readme.md +++ b/specification/datashare/resource-manager/readme.md @@ -115,30 +115,3 @@ See configuration in [readme.python.md](./readme.python.md) See configuration in [readme.go.md](./readme.go.md) -## Multi-API/Profile support for AutoRest v3 generators - -AutoRest V3 generators require the use of `--tag=all-api-versions` to select api files. - -This block is updated by an automatic script. Edits may be lost! - -``` yaml $(tag) == 'all-api-versions' /* autogenerated */ -# include the azure profile definitions from the standard location -require: $(this-folder)/../../../profiles/readme.md - -# all the input files across all versions -input-file: - - $(this-folder)/Microsoft.DataShare/preview/2018-11-01-preview/DataShare.json - - $(this-folder)/Microsoft.DataShare/stable/2019-11-01/DataShare.json - - $(this-folder)/Microsoft.DataShare/stable/2020-09-01/DataShare.json - - $(this-folder)/Microsoft.DataShare/preview/2020-10-01-preview/DataShare.json - - $(this-folder)/Microsoft.DataShare/stable/2021-08-01/DataShare.json - -``` - -If there are files that should not be in the `all-api-versions` set, -uncomment the `exclude-file` section below and add the file paths. - -``` yaml $(tag) == 'all-api-versions' -#exclude-file: -# - $(this-folder)/Microsoft.Example/stable/2010-01-01/somefile.json -``` \ No newline at end of file diff --git a/specification/desktopvirtualization/resource-manager/readme.md b/specification/desktopvirtualization/resource-manager/readme.md index dc825b87e53e..fba7e680a56a 100644 --- a/specification/desktopvirtualization/resource-manager/readme.md +++ b/specification/desktopvirtualization/resource-manager/readme.md @@ -189,36 +189,3 @@ See configuration in [readme.node.md](./readme.node.md) See configuration in [readme.ruby.md](./readme.ruby.md) -## Multi-API/Profile support for AutoRest v3 generators - -AutoRest V3 generators require the use of `--tag=all-api-versions` to select api files. - -This block is updated by an automatic script. Edits may be lost! - -``` yaml $(tag) == 'all-api-versions' /* autogenerated */ -# include the azure profile definitions from the standard location -require: $(this-folder)/../../../profiles/readme.md - -# all the input files across all versions -input-file: - - $(this-folder)/Microsoft.DesktopVirtualization/preview/2019-01-23-preview/desktopvirtualization.json - - $(this-folder)/Microsoft.DesktopVirtualization/preview/2019-09-24-preview/desktopvirtualization.json - - $(this-folder)/Microsoft.DesktopVirtualization/preview/2019-12-10-preview/desktopvirtualization.json - - $(this-folder)/Microsoft.DesktopVirtualization/preview/2020-09-21-preview/desktopvirtualization.json - - $(this-folder)/Microsoft.DesktopVirtualization/preview/2020-10-19-preview/desktopvirtualization.json - - $(this-folder)/Microsoft.DesktopVirtualization/preview/2020-11-02-preview/desktopvirtualization.json - - $(this-folder)/Microsoft.DesktopVirtualization/preview/2020-11-10-preview/desktopvirtualization.json - - $(this-folder)/Microsoft.DesktopVirtualization/preview/2021-01-14-preview/desktopvirtualization.json - - $(this-folder)/Microsoft.DesktopVirtualization/preview/2021-02-01-preview/desktopvirtualization.json - - $(this-folder)/Microsoft.DesktopVirtualization/preview/2021-03-09-preview/desktopvirtualization.json - - $(this-folder)/Microsoft.DesktopVirtualization/preview/2021-04-01-preview/desktopvirtualization.json - -``` - -If there are files that should not be in the `all-api-versions` set, -uncomment the `exclude-file` section below and add the file paths. - -``` yaml $(tag) == 'all-api-versions' -#exclude-file: -# - $(this-folder)/Microsoft.Example/stable/2010-01-01/somefile.json -``` diff --git a/specification/postgresql/resource-manager/readme.md b/specification/postgresql/resource-manager/readme.md index 9207cc353c16..974284768f89 100644 --- a/specification/postgresql/resource-manager/readme.md +++ b/specification/postgresql/resource-manager/readme.md @@ -262,47 +262,3 @@ See configuration in [readme.typescript.md](./readme.typescript.md) -## Multi-API/Profile support for AutoRest v3 generators - -AutoRest V3 generators require the use of `--tag=all-api-versions` to select api files. - -This block is updated by an automatic script. Edits may be lost! - -``` yaml $(tag) == 'all-api-versions' /* autogenerated */ -# include the azure profile definitions from the standard location -require: $(this-folder)/../../../profiles/readme.md - -# all the input files across all versions -input-file: - - $(this-folder)/Microsoft.DBforPostgreSQL/preview/2020-11-05-preview/Databases.json - - $(this-folder)/Microsoft.DBforPostgreSQL/preview/2020-02-14-preview/postgresql.json - - $(this-folder)/Microsoft.DBforPostgreSQL/preview/2020-02-14-privatepreview/postgresql.json - - $(this-folder)/Microsoft.DBforPostgreSQL/preview/2021-04-10-privatepreview/postgresql.json - - $(this-folder)/Microsoft.DBforPostgreSQL/preview/2020-01-01-privatepreview/DataEncryptionKeys.json - - $(this-folder)/Microsoft.DBforPostgreSQL/preview/2021-03-31-privatepreview/PrivateDnsZone.json - - $(this-folder)/Microsoft.DBforPostgreSQL/preview/2021-06-01-preview/postgresql.json - - $(this-folder)/Microsoft.DBforPostgreSQL/preview/2021-06-01-preview/IntelligentPerformance.json - - $(this-folder)/Microsoft.DBforPostgreSQL/preview/2021-06-01-preview/QueryPerformanceInsights.json - - $(this-folder)/Microsoft.DBforPostgreSQL/stable/2017-12-01/postgresql.json - - $(this-folder)/Microsoft.DBforPostgreSQL/stable/2017-12-01/ServerSecurityAlertPolicies.json - - $(this-folder)/Microsoft.DBforPostgreSQL/stable/2018-06-01/PrivateEndpointConnections.json - - $(this-folder)/Microsoft.DBforPostgreSQL/stable/2018-06-01/PrivateLinkResources.json - - $(this-folder)/Microsoft.DBforPostgreSQL/stable/2018-06-01/QueryPerformanceInsights.json - - $(this-folder)/Microsoft.DBforPostgreSQL/stable/2018-06-01/PerformanceRecommendations.json - - $(this-folder)/Microsoft.DBforPostgreSQL/stable/2020-01-01/DataEncryptionKeys.json - - $(this-folder)/Microsoft.DBforPostgreSQL/stable/2021-06-01/postgresql.json - - $(this-folder)/Microsoft.DBforPostgreSQL/stable/2021-06-01/Databases.json - - $(this-folder)/Microsoft.DBforPostgreSQL/stable/2021-06-01/PrivateDnsZone.json - - $(this-folder)/Microsoft.DBforPostgreSQL/preview/2018-06-01-privatepreview/PrivateEndpointConnections.json - - $(this-folder)/Microsoft.DBforPostgreSQL/preview/2018-06-01-privatepreview/PrivateLinkResources.json - - $(this-folder)/Microsoft.DBforPostgreSQL/preview/2017-12-01-preview/postgresql.json - -``` - -If there are files that should not be in the `all-api-versions` set, -uncomment the `exclude-file` section below and add the file paths. - -``` yaml $(tag) == 'all-api-versions' -#exclude-file: -# - $(this-folder)/Microsoft.Example/stable/2010-01-01/somefile.json -``` diff --git a/specification/quota/resource-manager/readme.azureresourceschema.md b/specification/quota/resource-manager/readme.azureresourceschema.md deleted file mode 100644 index b4bf5795d0f5..000000000000 --- a/specification/quota/resource-manager/readme.azureresourceschema.md +++ /dev/null @@ -1,44 +0,0 @@ -## AzureResourceSchema - -These settings apply only when `--azureresourceschema` is specified on the command line. - -### AzureResourceSchema multi-api - -``` yaml $(azureresourceschema) && $(multiapi) -batch: - - tag: schema-quota-2021-03-15 -``` - -Please also specify `--azureresourceschema-folder=`. - -### Tag: schema-quota-2021-03-15 and azureresourceschema - -``` yaml $(tag) == 'schema-quota-2021-03-15' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Quota/stable/2021-03-15/quota.json - -``` - -# all the input files in this apiVersion -input-file: - - Microsoft.Quota/stable/2021-03-15/quota.json -``` - -### Tag: schema-quota-2021-03-15-preview and azureresourceschema - -``` yaml $(tag) == 'schema-quota-2021-03-15-preview' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -input-file: - - Microsoft.Quota/review/2021-03-15-preview/quota.json - -``` - -# all the input files in this apiVersion -input-file: - - Microsoft.Quota/preview/2021-03-15-preview/quota.json -``` \ No newline at end of file diff --git a/specification/quota/resource-manager/readme.md b/specification/quota/resource-manager/readme.md index bae51c5d4d6d..c4a30aee870a 100644 --- a/specification/quota/resource-manager/readme.md +++ b/specification/quota/resource-manager/readme.md @@ -124,26 +124,3 @@ See configuration in [readme.java.md](./readme.java.md) See configuration in [readme.ruby.md](./readme.ruby.md) -## Multi-API/Profile support for AutoRest v3 generators - -AutoRest V3 generators require the use of `--tag=all-api-versions` to select api files. - -This block is updated by an automatic script. Edits may be lost! - -``` yaml $(tag) == 'all-api-versions' /* autogenerated */ -# include the azure profile definitions from the standard location -require: $(this-folder)/../../../profiles/readme.md - -# all the input files across all versions -input-file: - - $(this-folder)/Microsoft.Quota/preview/2021-03-15-preview/quota.json - -``` - -If there are files that should not be in the `all-api-versions` set, -uncomment the `exclude-file` section below and add the file paths. - -``` yaml $(tag) == 'all-api-versions' -#exclude-file: -# - $(this-folder)/Microsoft.Example/stable/2010-01-01/somefile.json -``` diff --git a/specification/workloadmonitor/resource-manager/readme.md b/specification/workloadmonitor/resource-manager/readme.md index c47da59665ed..c6bda6acece2 100644 --- a/specification/workloadmonitor/resource-manager/readme.md +++ b/specification/workloadmonitor/resource-manager/readme.md @@ -160,27 +160,3 @@ generate-interface: true -## Multi-API/Profile support for AutoRest v3 generators - -AutoRest V3 generators require the use of `--tag=all-api-versions` to select api files. - -This block is updated by an automatic script. Edits may be lost! - -``` yaml $(tag) == 'all-api-versions' /* autogenerated */ -# include the azure profile definitions from the standard location -require: $(this-folder)/../../../profiles/readme.md - -# all the input files across all versions -input-file: - - $(this-folder)/Microsoft.WorkloadMonitor/preview/2018-08-31-preview/Microsoft.WorkloadMonitor.json - - $(this-folder)/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/Microsoft.WorkloadMonitor.json - -``` - -If there are files that should not be in the `all-api-versions` set, -uncomment the `exclude-file` section below and add the file paths. - -``` yaml $(tag) == 'all-api-versions' -#exclude-file: -# - $(this-folder)/Microsoft.Example/stable/2010-01-01/somefile.json -``` From b1a793fd9dd9b427efd4297ff926c7a0cc9c3a53 Mon Sep 17 00:00:00 2001 From: Lei Ni Date: Wed, 29 Sep 2021 11:00:52 +0800 Subject: [PATCH 2/2] fix ref --- scripts/multiapi.ts | 108 ------------------ .../azurearcdata/resource-manager/readme.md | 6 - .../quota/resource-manager/readme.md | 6 - 3 files changed, 120 deletions(-) delete mode 100644 scripts/multiapi.ts diff --git a/scripts/multiapi.ts b/scripts/multiapi.ts deleted file mode 100644 index b72b0bb6a914..000000000000 --- a/scripts/multiapi.ts +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -import * as fs from "@ts-common/fs" -import * as process from "process" -import * as path from "path" -import * as cm from "@ts-common/commonmark-to-markdown" -import * as it from "@ts-common/iterator" -import * as yaml from "js-yaml" - -type Code = { - readonly "input-file"?: ReadonlyArray|string -} -const magic = `yaml $(tag) == 'all-api-versions' /* autogenerated */`; -const pathRegex = /microsoft\.(\w+)[\\\/]\S*[\\\/](\d{4}-\d{2}-\d{2}(|-preview))[\\\/]/i; - -const main = async (specificationDir: string) => { - try { - const list = fs.recursiveReaddir(specificationDir) - for await (const file of list) { - const f = path.parse(file) - if (f.base === "readme.md" && f.dir.endsWith('resource-manager')) { - const original_content = (await fs.readFile(file)).toString() - let content = original_content; - const readMe = cm.parse(content) - const set = new Set() - for (const c of cm.iterate(readMe.markDown)) { - if ( - c.type === "code_block" && - c.info !== null && - (c.info.startsWith("yaml") && !c.info.startsWith(magic)) && - c.literal !== null - ) { - const DOC = (yaml.load(c.literal) as Code); - if (DOC ) { - const y = DOC['input-file'] - if (typeof y === "string") { - set.add(y) - } else if (it.isArray(y)) { - for (const i of y) { - set.add(i) - } - } - } - } - } - let map = new Map(); - for (let input of set) { - let match = pathRegex.exec(input); - if (!!match) { - let tagName = `schema-${match[1].toLowerCase()}-${match[2]}`; - if (!map.has(tagName)) { - map.set(tagName, []); - } - let array = map.get(tagName); - if (!!array) { - array.push(input); - } - } - } - map = new Map(Array.from(map.entries()).sort().reverse()); - let schemaReadmeContent = -`## AzureResourceSchema - -These settings apply only when \`--azureresourceschema\` is specified on the command line. - -### AzureResourceSchema multi-api - -\`\`\` yaml $(azureresourceschema) && $(multiapi) -${yaml.dump({ 'batch': it.toArray(it.map(map.keys(), (tagName) => ({'tag': tagName})))}, { lineWidth: 1000})} -\`\`\` - -Please also specify \`--azureresourceschema-folder=\`. -` - map.forEach((inputList, tagName) => { - schemaReadmeContent += -` -### Tag: ${tagName} and azureresourceschema - -\`\`\` yaml $(tag) == '${tagName}' && $(azureresourceschema) -output-folder: $(azureresourceschema-folder)/schemas - -# all the input files in this apiVersion -${yaml.dump({ 'input-file': it.toArray(inputList)}, { lineWidth: 1000})} -\`\`\` -` - }); - - content = content.replace( /``` yaml \$\(tag\) == 'all-api-versions' \/\* autogenerated \*\/[\S\s]*?```/g, '') - content = content.replace( /``` yaml \$\(tag\) == 'all-api-versions'[\S\s]*?```/g, '') - content = content.replace( /## Multi-API\/Profile support for AutoRest v3 generators[\S\s]*/g, '') - - if(original_content !== content ){ - console.log(`Updating: ${file}`); - fs.writeFile(path.join(f.dir, "readme.md"), content) - } - - console.log(`Rewriting: ${f.dir}/readme.azureresourceschema.md\n contentLength: ${schemaReadmeContent.length}`); - // fs.writeFile(path.join(f.dir, "readme.azureresourceschema.md"), schemaReadmeContent); - - } - } - } catch (e) { - console.error(e) - } -} - -main(path.join(process.cwd(), "specification")) \ No newline at end of file diff --git a/specification/azurearcdata/resource-manager/readme.md b/specification/azurearcdata/resource-manager/readme.md index 4ca5a9eb2e78..f1045a2c204b 100644 --- a/specification/azurearcdata/resource-manager/readme.md +++ b/specification/azurearcdata/resource-manager/readme.md @@ -77,8 +77,6 @@ swagger-to-sdk: after_scripts: - bundle install && rake arm:regen_all_profiles['azure_mgmt_azurearcdata'] - repo: azure-resource-manager-schemas - after_scripts: - - node sdkauto_afterscript.js azurearcdata/resource-manager ``` ## Go @@ -100,7 +98,3 @@ See configuration in [readme.typescript.md](./readme.typescript.md) ## CSharp See configuration in [readme.csharp.md](./readme.csharp.md) - -## AzureResourceSchema - -See configuration in [readme.azureresourceschema.md](./readme.azureresourceschema.md) diff --git a/specification/quota/resource-manager/readme.md b/specification/quota/resource-manager/readme.md index c4a30aee870a..45ebe980a4cb 100644 --- a/specification/quota/resource-manager/readme.md +++ b/specification/quota/resource-manager/readme.md @@ -77,8 +77,6 @@ swagger-to-sdk: - repo: azure-cli-extensions - repo: azure-sdk-for-ruby - repo: azure-resource-manager-schemas - after_scripts: - - node sdkauto_afterscript.js quota/resource-manager ``` ## C# @@ -112,10 +110,6 @@ See configuration in [readme.cli.md](./readme.cli.md) See configuration in [readme.go.md](./readme.go.md) -## AzureResourceSchema - -See configuration in [readme.azureresourceschema.md](./readme.azureresourceschema.md) - ## Java See configuration in [readme.java.md](./readme.java.md)