Skip to content

Commit

Permalink
Merge pull request #1162 from Azure/multiapi-work
Browse files Browse the repository at this point in the history
use multiapi instead of all-api-versions
  • Loading branch information
anthony-c-martin committed Sep 6, 2020
2 parents 7a2cb3e + 4c6fd1f commit 7d93d9c
Show file tree
Hide file tree
Showing 48 changed files with 5,982 additions and 1,078 deletions.
36 changes: 16 additions & 20 deletions generator/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ScopeType, AutogenlistConfig } from './models';
import { resetFile } from './git';
import { get, set, flatten, uniq, concat, Dictionary, groupBy, keys, difference, pickBy, flatMap, values, uniqBy } from 'lodash';

const autorestBinary = os.platform() === 'win32' ? 'autorest-beta.cmd' : 'autorest-beta';
const autorestBinary = os.platform() === 'win32' ? 'autorest.cmd' : 'autorest';
const apiVersionRegex = /^\d{4}-\d{2}-\d{2}(|-preview)$/;

export interface SchemaConfiguration {
Expand Down Expand Up @@ -50,31 +50,28 @@ export async function generateSchemas(readme: string, autogenlistConfig?: Autoge
await getApiVersionsByNamespace(readme),
(_, key) => !autogenlistConfig || lowerCaseEquals(key, autogenlistConfig.namespace));

const apiVersions = uniqBy(flatMap(values(apiVersionsByNamespace)), s => s.toLowerCase());
const namespaces = keys(apiVersionsByNamespace);

const schemaConfigs: SchemaConfiguration[] = [];
for (const apiVersion of apiVersions) {
const tmpFolder = path.join(os.tmpdir(), Math.random().toString(36).substr(2));
const tmpFolder = path.join(os.tmpdir(), Math.random().toString(36).substr(2));

try {
const generatedSchemas = await generateSchema(readme, tmpFolder, apiVersion);
try {
const generatedSchemas = await generateSchema(readme, tmpFolder);

for (const schemaPath of generatedSchemas) {
const namespace = path.basename(schemaPath.substring(0, schemaPath.lastIndexOf(path.extname(schemaPath))));
if (!lowerCaseContains(namespaces, namespace)) {
continue;
}
for (const schemaPath of generatedSchemas) {
const namespace = path.basename(schemaPath.substring(0, schemaPath.lastIndexOf(path.extname(schemaPath))));
if (!lowerCaseContains(namespaces, namespace)) {
continue;
}

const generatedSchemaConfig = await handleGeneratedSchema(readme, schemaPath, autogenlistConfig);
const generatedSchemaConfig = await handleGeneratedSchema(readme, schemaPath, autogenlistConfig);

schemaConfigs.push(generatedSchemaConfig);
}
}
finally {
await rmdirRecursive(tmpFolder);
schemaConfigs.push(generatedSchemaConfig);
}
}
finally {
await rmdirRecursive(tmpFolder);
}

return schemaConfigs;
}
Expand Down Expand Up @@ -134,14 +131,13 @@ async function execAutoRest(tmpFolder: string, params: string[]) {
return await findRecursive(tmpFolder, p => path.extname(p) === '.json');
}

async function generateSchema(readme: string, tmpFolder: string, apiVersion: string) {
async function generateSchema(readme: string, tmpFolder: string) {
const autoRestParams = [
`--version=${constants.autorestCoreVersion}`,
`--use=@autorest/azureresourceschema@${constants.azureresourceschemaVersion}`,
'--azureresourceschema',
`--output-folder=${tmpFolder}`,
`--tag=all-api-versions`,
`--api-version=${apiVersion}`,
`--multiapi`,
'--title=none',
'--pass-thru:subset-reducer',
readme,
Expand Down
12 changes: 6 additions & 6 deletions generator/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"postprocessor": "ts-node cmd/postprocessor"
},
"devDependencies": {
"@autorest/autorest": "^3.0.6187",
"autorest": "^3.0.6187",
"@autorest/azureresourceschema": "^3.0.79",
"@autorest/core": "^3.0.6257",
"@types/async": "^3.2.0",
Expand Down
33 changes: 33 additions & 0 deletions generator/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -791,9 +791,15 @@
"2018-03-01",
"2019-07-01"
],
"Microsoft.Capacity/autoQuotaIncrease": [
"2019-07-19-preview"
],
"Microsoft.Capacity/reservationOrders": [
"2019-04-01"
],
"Microsoft.Capacity/resourceProviders/locations/serviceLimits": [
"2019-07-19-preview"
],
"Microsoft.Cdn/CdnWebApplicationFirewallPolicies": [
"2019-06-15",
"2019-06-15-preview",
Expand Down Expand Up @@ -1099,6 +1105,7 @@
"Microsoft.ContainerService/openShiftManagedClusters": [
"2018-09-30-preview",
"2019-04-30",
"2019-09-30-preview",
"2019-10-27-preview"
],
"Microsoft.CustomProviders/resourceProviders": [
Expand Down Expand Up @@ -1577,6 +1584,7 @@
"2020-03-01-preview"
],
"Microsoft.DocumentDB/databaseAccounts": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
Expand All @@ -1588,84 +1596,98 @@
"2020-06-01-preview"
],
"Microsoft.DocumentDB/databaseAccounts/apis/databases": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/databases/collections": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/databases/collections/settings": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/databases/containers": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/databases/containers/settings": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/databases/graphs": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/databases/graphs/settings": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/databases/settings": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/keyspaces": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/keyspaces/settings": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/keyspaces/tables": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/keyspaces/tables/settings": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/tables": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
"2016-03-31"
],
"Microsoft.DocumentDB/databaseAccounts/apis/tables/settings": [
"2015-04-01",
"2015-04-08",
"2015-11-06",
"2016-03-19",
Expand Down Expand Up @@ -1834,6 +1856,12 @@
"Microsoft.DomainRegistration/domains/domainOwnershipIdentifiers": [
"2015-04-01"
],
"Microsoft.EngagementFabric/Accounts": [
"2018-09-01-preview"
],
"Microsoft.EngagementFabric/Accounts/Channels": [
"2018-09-01-preview"
],
"Microsoft.EnterpriseKnowledgeGraph/services": [
"2018-12-03"
],
Expand Down Expand Up @@ -1979,12 +2007,15 @@
"2019-09-16"
],
"Microsoft.HybridCompute/machines": [
"2019-03-18-preview",
"2019-08-02-preview",
"2019-12-12",
"2020-07-30-preview",
"2020-08-02",
"2020-08-15-preview"
],
"Microsoft.HybridCompute/machines/extensions": [
"2019-08-02-preview",
"2019-12-12",
"2020-07-30-preview",
"2020-08-02",
Expand Down Expand Up @@ -2494,6 +2525,7 @@
"2020-05-01"
],
"Microsoft.Network/FrontDoorWebApplicationFirewallPolicies": [
"2018-08-01",
"2019-03-01",
"2019-10-01",
"2020-04-01"
Expand Down Expand Up @@ -2899,6 +2931,7 @@
"2020-04-01"
],
"Microsoft.Network/frontDoors": [
"2018-08-01",
"2019-04-01",
"2019-05-01",
"2020-01-01",
Expand Down
Loading

0 comments on commit 7d93d9c

Please sign in to comment.