Skip to content

Commit

Permalink
Merge pull request #1962 from docohe/Kusto/auto-generate
Browse files Browse the repository at this point in the history
Kusto: Onboard to auto generate
  • Loading branch information
anthony-c-martin authored Oct 25, 2021
2 parents b001714 + 9cd0021 commit b997d0c
Show file tree
Hide file tree
Showing 26 changed files with 10,668 additions and 5,111 deletions.
11 changes: 6 additions & 5 deletions generator/autogenlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ScopeType, AutoGenConfig } from './models';
import { postProcessor as insightsApplicationPostProcessor } from './processors/Microsoft.Insights.Application';
import { postProcessor as resourcesPostProcessor } from './processors/Microsoft.Resources';
import { postProcessor as machineLearningPostProcessor } from './processors/Microsoft.MachineLearning';
import { postProcessor as kustoPostProcessor } from './processors/Microsoft.Kusto';
import { postProcessor as machineLearningServicesPostProcessor } from './processors/Microsoft.MachineLearningServices';
import { postProcessor as storageProcessor } from './processors/Microsoft.Storage';
import { postProcessor as computeProcessor } from './processors/Microsoft.Compute';
Expand All @@ -18,11 +19,6 @@ const disabledProviders: AutoGenConfig[] = [
namespace: 'Microsoft.Advisor',
disabledForAutogen: true,
},
{
basePath: 'azure-kusto/resource-manager',
namespace: 'Microsoft.Kusto',
disabledForAutogen: true,
},
{
basePath: 'cloudshell/resource-manager',
namespace: 'Microsoft.Portal',
Expand Down Expand Up @@ -470,6 +466,11 @@ const autoGenList: AutoGenConfig[] = [
namespace: 'Microsoft.MachineLearning',
postProcessor: machineLearningPostProcessor,
},
{
basePath: 'azure-kusto/resource-manager',
namespace: 'Microsoft.Kusto',
postProcessor: kustoPostProcessor,
},
{
basePath: 'machinelearningservices/resource-manager',
namespace: 'Microsoft.MachineLearningServices',
Expand Down
160 changes: 160 additions & 0 deletions generator/processors/Microsoft.Kusto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import { SchemaPostProcessor } from '../models';
import { apiVersionCompare } from '../utils';

const clusterDataConnections = (apiVersion: string) => ({
type: 'object',
oneOf: [
{
$ref: '#/definitions/GenevaDataConnection'
},
{
$ref: '#/definitions/GenevaLegacyDataConnection'
}
],
properties: {
name: {
type: 'string',
description: 'The data connection name'
},
type: {
enum: [
'Microsoft.Kusto/clusters/dataConnections'
]
},
apiVersion: {
type: 'string',
enum: [
apiVersion
]
}
},
required: [
'apiVersion',
'properties',
'type'
],
description: 'Microsoft.Kusto/clusters/dataConnections'
});

const genevaDataConnectionProperties = () => ({
type: 'object',
properties: {
genevaEnvironment: {
type: 'string',
'description': 'The Geneva environment of the geneva data connection.'
}
},
required: [
'genevaEnvironment'
],
description: 'Class representing the Kusto Geneva (GDS) connection properties.'
});

const genevaDataConnection = () => ({
type: 'object',
properties: {
properties: {
oneOf: [
{
$ref: '#/definitions/GenevaDataConnectionProperties'
},
{
$ref: 'https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression'
}
],
description: 'Geneva (DGS) data connection properties'
},
kind: {
type: 'string',
enum: [
'Geneva'
]
}
},
required: [
'kind'
],
description: 'Information about the Geneva (GDS) data connection'
});

const genevaLegacyDataConnectionProperties = () => ({
type: 'object',
properties: {
genevaEnvironment: {
type: 'string',
description: 'The Geneva environment of the geneva data connection.'
},
mdsAccounts: {
type: 'array',
description: 'The list of mds accounts of the geneva data connection.'
},
isScrubbed: {
type: 'boolean',
description: 'Indicates whether the data is scrubbed.'
}
},
required: [
'genevaEnvironment',
'mdsAccounts',
'isScrubbed'
],
'description': 'Class representing the Kusto Geneva legacy connection properties.'
});

const genevaLegacyDataConnection = () => ({
type: 'object',
properties: {
properties: {
oneOf: [
{
$ref: '#/definitions/GenevaLegacyDataConnectionProperties'
},
{
$ref: 'https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression'
}
],
description: 'Geneva legacy data connection properties.'
},
kind: {
type: 'string',
enum: [
'GenevaLegacy'
]
}
},
required: [
'kind'
],
description: 'Information about the Geneva legacy data connection.'
});

const clusterDataConnections_childResource = () => ({
$ref: '#/definitions/clusters_dataConnections_childResource'
});

export const postProcessor: SchemaPostProcessor = async (namespace: string, apiVersion: string, schema: any) => {
// Handle cluster data connection
if (apiVersionCompare(apiVersion, '2019-11-09') > -1) {
const clusterSubResources = schema.resourceDefinitions.clusters.properties.resources.items.oneOf;
clusterSubResources.push(clusterDataConnections_childResource());
schema.resourceDefinitions.clusters.properties.resources.items.oneOf = clusterSubResources;
const clusterDataConnectionObject = clusterDataConnections(apiVersion);
schema['resourceDefinitions']['clusters_dataConnections'] = clusterDataConnectionObject;
clusterDataConnectionObject.properties.type.enum = ["Microsoft.Kusto/clusters/dataconnections"];
schema.definitions.clusters_dataConnections_childResource = clusterDataConnectionObject;
schema.definitions.GenevaDataConnectionProperties = genevaDataConnectionProperties();
schema.definitions.GenevaDataConnection = genevaDataConnection();
schema.definitions.GenevaLegacyDataConnectionProperties = genevaLegacyDataConnectionProperties();
schema.definitions.GenevaLegacyDataConnection = genevaLegacyDataConnection();
}
// Handle read only following database

// TODO: Remove this workaround once https://github.com/Azure/autorest.azureresourceschema/pull/74 is merged
const requiredArray = schema['resourceDefinitions']['clusters'].required
if (requiredArray && Array.isArray(requiredArray)) {
const index = requiredArray.indexOf('properties')
if (index !== -1) {
requiredArray.splice(index, 1)
}
}
}
1 change: 1 addition & 0 deletions generator/processors/Microsoft.Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const postProcessor: SchemaPostProcessor = async (namespace: string, apiV
'extension_resourceDefinitions'
].filter(scope => schema[scope])

// TODO: Remove this workaround once https://github.com/Azure/autorest.azureresourceschema/pull/74 is merged
scopes.forEach(scope => {
for (let key in schema[scope]) {
const requiredArray = schema[scope][key].required
Expand Down
38 changes: 19 additions & 19 deletions schemas/2014-04-01-preview/deploymentTemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@
"$ref": "https://schema.management.azure.com/schemas/2019-01-21/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases"
},
{
"$ref": "https://schema.management.azure.com/schemas/2019-01-21/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataconnections"
"$ref": "https://schema.management.azure.com/schemas/2019-01-21/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataConnections"
},
{
"$ref": "https://schema.management.azure.com/schemas/2019-05-15/Microsoft.Kusto.json#/resourceDefinitions/clusters"
Expand All @@ -645,7 +645,7 @@
"$ref": "https://schema.management.azure.com/schemas/2019-05-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases"
},
{
"$ref": "https://schema.management.azure.com/schemas/2019-05-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataconnections"
"$ref": "https://schema.management.azure.com/schemas/2019-05-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataConnections"
},
{
"$ref": "https://schema.management.azure.com/schemas/2019-09-07/Microsoft.Kusto.json#/resourceDefinitions/clusters"
Expand All @@ -654,10 +654,10 @@
"$ref": "https://schema.management.azure.com/schemas/2019-09-07/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases"
},
{
"$ref": "https://schema.management.azure.com/schemas/2019-09-07/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataconnections"
"$ref": "https://schema.management.azure.com/schemas/2019-09-07/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataConnections"
},
{
"$ref": "https://schema.management.azure.com/schemas/2019-09-07/Microsoft.Kusto.json#/resourceDefinitions/clusters_attacheddatabaseconfigurations"
"$ref": "https://schema.management.azure.com/schemas/2019-09-07/Microsoft.Kusto.json#/resourceDefinitions/clusters_attachedDatabaseConfigurations"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters"
Expand All @@ -666,19 +666,19 @@
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataconnections"
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataConnections"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_attacheddatabaseconfigurations"
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_attachedDatabaseConfigurations"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_dataconnections"
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_dataConnections"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_principalassignments"
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_principalAssignments"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_principalassignments"
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_principalAssignments"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters"
Expand All @@ -687,19 +687,19 @@
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataconnections"
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataConnections"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_attacheddatabaseconfigurations"
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_attachedDatabaseConfigurations"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_dataconnections"
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_dataConnections"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_principalassignments"
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_principalAssignments"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_principalassignments"
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_principalAssignments"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters"
Expand All @@ -708,19 +708,19 @@
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataconnections"
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataConnections"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_attacheddatabaseconfigurations"
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_attachedDatabaseConfigurations"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_dataconnections"
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_dataConnections"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_principalassignments"
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_principalAssignments"
},
{
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_principalassignments"
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_principalAssignments"
},
{
"$ref": "https://schema.management.azure.com/schemas/2014-04-01-preview/Microsoft.Cache.json#/resourceDefinitions/Redis"
Expand Down
Loading

0 comments on commit b997d0c

Please sign in to comment.