Skip to content

Commit b997d0c

Browse files
Merge pull request #1962 from docohe/Kusto/auto-generate
Kusto: Onboard to auto generate
2 parents b001714 + 9cd0021 commit b997d0c

26 files changed

+10668
-5111
lines changed

generator/autogenlist.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ScopeType, AutoGenConfig } from './models';
22
import { postProcessor as insightsApplicationPostProcessor } from './processors/Microsoft.Insights.Application';
33
import { postProcessor as resourcesPostProcessor } from './processors/Microsoft.Resources';
44
import { postProcessor as machineLearningPostProcessor } from './processors/Microsoft.MachineLearning';
5+
import { postProcessor as kustoPostProcessor } from './processors/Microsoft.Kusto';
56
import { postProcessor as machineLearningServicesPostProcessor } from './processors/Microsoft.MachineLearningServices';
67
import { postProcessor as storageProcessor } from './processors/Microsoft.Storage';
78
import { postProcessor as computeProcessor } from './processors/Microsoft.Compute';
@@ -18,11 +19,6 @@ const disabledProviders: AutoGenConfig[] = [
1819
namespace: 'Microsoft.Advisor',
1920
disabledForAutogen: true,
2021
},
21-
{
22-
basePath: 'azure-kusto/resource-manager',
23-
namespace: 'Microsoft.Kusto',
24-
disabledForAutogen: true,
25-
},
2622
{
2723
basePath: 'cloudshell/resource-manager',
2824
namespace: 'Microsoft.Portal',
@@ -470,6 +466,11 @@ const autoGenList: AutoGenConfig[] = [
470466
namespace: 'Microsoft.MachineLearning',
471467
postProcessor: machineLearningPostProcessor,
472468
},
469+
{
470+
basePath: 'azure-kusto/resource-manager',
471+
namespace: 'Microsoft.Kusto',
472+
postProcessor: kustoPostProcessor,
473+
},
473474
{
474475
basePath: 'machinelearningservices/resource-manager',
475476
namespace: 'Microsoft.MachineLearningServices',
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import { SchemaPostProcessor } from '../models';
2+
import { apiVersionCompare } from '../utils';
3+
4+
const clusterDataConnections = (apiVersion: string) => ({
5+
type: 'object',
6+
oneOf: [
7+
{
8+
$ref: '#/definitions/GenevaDataConnection'
9+
},
10+
{
11+
$ref: '#/definitions/GenevaLegacyDataConnection'
12+
}
13+
],
14+
properties: {
15+
name: {
16+
type: 'string',
17+
description: 'The data connection name'
18+
},
19+
type: {
20+
enum: [
21+
'Microsoft.Kusto/clusters/dataConnections'
22+
]
23+
},
24+
apiVersion: {
25+
type: 'string',
26+
enum: [
27+
apiVersion
28+
]
29+
}
30+
},
31+
required: [
32+
'apiVersion',
33+
'properties',
34+
'type'
35+
],
36+
description: 'Microsoft.Kusto/clusters/dataConnections'
37+
});
38+
39+
const genevaDataConnectionProperties = () => ({
40+
type: 'object',
41+
properties: {
42+
genevaEnvironment: {
43+
type: 'string',
44+
'description': 'The Geneva environment of the geneva data connection.'
45+
}
46+
},
47+
required: [
48+
'genevaEnvironment'
49+
],
50+
description: 'Class representing the Kusto Geneva (GDS) connection properties.'
51+
});
52+
53+
const genevaDataConnection = () => ({
54+
type: 'object',
55+
properties: {
56+
properties: {
57+
oneOf: [
58+
{
59+
$ref: '#/definitions/GenevaDataConnectionProperties'
60+
},
61+
{
62+
$ref: 'https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression'
63+
}
64+
],
65+
description: 'Geneva (DGS) data connection properties'
66+
},
67+
kind: {
68+
type: 'string',
69+
enum: [
70+
'Geneva'
71+
]
72+
}
73+
},
74+
required: [
75+
'kind'
76+
],
77+
description: 'Information about the Geneva (GDS) data connection'
78+
});
79+
80+
const genevaLegacyDataConnectionProperties = () => ({
81+
type: 'object',
82+
properties: {
83+
genevaEnvironment: {
84+
type: 'string',
85+
description: 'The Geneva environment of the geneva data connection.'
86+
},
87+
mdsAccounts: {
88+
type: 'array',
89+
description: 'The list of mds accounts of the geneva data connection.'
90+
},
91+
isScrubbed: {
92+
type: 'boolean',
93+
description: 'Indicates whether the data is scrubbed.'
94+
}
95+
},
96+
required: [
97+
'genevaEnvironment',
98+
'mdsAccounts',
99+
'isScrubbed'
100+
],
101+
'description': 'Class representing the Kusto Geneva legacy connection properties.'
102+
});
103+
104+
const genevaLegacyDataConnection = () => ({
105+
type: 'object',
106+
properties: {
107+
properties: {
108+
oneOf: [
109+
{
110+
$ref: '#/definitions/GenevaLegacyDataConnectionProperties'
111+
},
112+
{
113+
$ref: 'https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression'
114+
}
115+
],
116+
description: 'Geneva legacy data connection properties.'
117+
},
118+
kind: {
119+
type: 'string',
120+
enum: [
121+
'GenevaLegacy'
122+
]
123+
}
124+
},
125+
required: [
126+
'kind'
127+
],
128+
description: 'Information about the Geneva legacy data connection.'
129+
});
130+
131+
const clusterDataConnections_childResource = () => ({
132+
$ref: '#/definitions/clusters_dataConnections_childResource'
133+
});
134+
135+
export const postProcessor: SchemaPostProcessor = async (namespace: string, apiVersion: string, schema: any) => {
136+
// Handle cluster data connection
137+
if (apiVersionCompare(apiVersion, '2019-11-09') > -1) {
138+
const clusterSubResources = schema.resourceDefinitions.clusters.properties.resources.items.oneOf;
139+
clusterSubResources.push(clusterDataConnections_childResource());
140+
schema.resourceDefinitions.clusters.properties.resources.items.oneOf = clusterSubResources;
141+
const clusterDataConnectionObject = clusterDataConnections(apiVersion);
142+
schema['resourceDefinitions']['clusters_dataConnections'] = clusterDataConnectionObject;
143+
clusterDataConnectionObject.properties.type.enum = ["Microsoft.Kusto/clusters/dataconnections"];
144+
schema.definitions.clusters_dataConnections_childResource = clusterDataConnectionObject;
145+
schema.definitions.GenevaDataConnectionProperties = genevaDataConnectionProperties();
146+
schema.definitions.GenevaDataConnection = genevaDataConnection();
147+
schema.definitions.GenevaLegacyDataConnectionProperties = genevaLegacyDataConnectionProperties();
148+
schema.definitions.GenevaLegacyDataConnection = genevaLegacyDataConnection();
149+
}
150+
// Handle read only following database
151+
152+
// TODO: Remove this workaround once https://github.com/Azure/autorest.azureresourceschema/pull/74 is merged
153+
const requiredArray = schema['resourceDefinitions']['clusters'].required
154+
if (requiredArray && Array.isArray(requiredArray)) {
155+
const index = requiredArray.indexOf('properties')
156+
if (index !== -1) {
157+
requiredArray.splice(index, 1)
158+
}
159+
}
160+
}

generator/processors/Microsoft.Storage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const postProcessor: SchemaPostProcessor = async (namespace: string, apiV
99
'extension_resourceDefinitions'
1010
].filter(scope => schema[scope])
1111

12+
// TODO: Remove this workaround once https://github.com/Azure/autorest.azureresourceschema/pull/74 is merged
1213
scopes.forEach(scope => {
1314
for (let key in schema[scope]) {
1415
const requiredArray = schema[scope][key].required

schemas/2014-04-01-preview/deploymentTemplate.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@
636636
"$ref": "https://schema.management.azure.com/schemas/2019-01-21/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases"
637637
},
638638
{
639-
"$ref": "https://schema.management.azure.com/schemas/2019-01-21/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataconnections"
639+
"$ref": "https://schema.management.azure.com/schemas/2019-01-21/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataConnections"
640640
},
641641
{
642642
"$ref": "https://schema.management.azure.com/schemas/2019-05-15/Microsoft.Kusto.json#/resourceDefinitions/clusters"
@@ -645,7 +645,7 @@
645645
"$ref": "https://schema.management.azure.com/schemas/2019-05-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases"
646646
},
647647
{
648-
"$ref": "https://schema.management.azure.com/schemas/2019-05-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataconnections"
648+
"$ref": "https://schema.management.azure.com/schemas/2019-05-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataConnections"
649649
},
650650
{
651651
"$ref": "https://schema.management.azure.com/schemas/2019-09-07/Microsoft.Kusto.json#/resourceDefinitions/clusters"
@@ -654,10 +654,10 @@
654654
"$ref": "https://schema.management.azure.com/schemas/2019-09-07/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases"
655655
},
656656
{
657-
"$ref": "https://schema.management.azure.com/schemas/2019-09-07/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataconnections"
657+
"$ref": "https://schema.management.azure.com/schemas/2019-09-07/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataConnections"
658658
},
659659
{
660-
"$ref": "https://schema.management.azure.com/schemas/2019-09-07/Microsoft.Kusto.json#/resourceDefinitions/clusters_attacheddatabaseconfigurations"
660+
"$ref": "https://schema.management.azure.com/schemas/2019-09-07/Microsoft.Kusto.json#/resourceDefinitions/clusters_attachedDatabaseConfigurations"
661661
},
662662
{
663663
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters"
@@ -666,19 +666,19 @@
666666
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases"
667667
},
668668
{
669-
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataconnections"
669+
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataConnections"
670670
},
671671
{
672-
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_attacheddatabaseconfigurations"
672+
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_attachedDatabaseConfigurations"
673673
},
674674
{
675-
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_dataconnections"
675+
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_dataConnections"
676676
},
677677
{
678-
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_principalassignments"
678+
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_principalAssignments"
679679
},
680680
{
681-
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_principalassignments"
681+
"$ref": "https://schema.management.azure.com/schemas/2020-02-15/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_principalAssignments"
682682
},
683683
{
684684
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters"
@@ -687,19 +687,19 @@
687687
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases"
688688
},
689689
{
690-
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataconnections"
690+
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataConnections"
691691
},
692692
{
693-
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_attacheddatabaseconfigurations"
693+
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_attachedDatabaseConfigurations"
694694
},
695695
{
696-
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_dataconnections"
696+
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_dataConnections"
697697
},
698698
{
699-
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_principalassignments"
699+
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_principalAssignments"
700700
},
701701
{
702-
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_principalassignments"
702+
"$ref": "https://schema.management.azure.com/schemas/2020-06-14/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_principalAssignments"
703703
},
704704
{
705705
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters"
@@ -708,19 +708,19 @@
708708
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases"
709709
},
710710
{
711-
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataconnections"
711+
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_dataConnections"
712712
},
713713
{
714-
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_attacheddatabaseconfigurations"
714+
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_attachedDatabaseConfigurations"
715715
},
716716
{
717-
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_dataconnections"
717+
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_dataConnections"
718718
},
719719
{
720-
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_principalassignments"
720+
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_principalAssignments"
721721
},
722722
{
723-
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_principalassignments"
723+
"$ref": "https://schema.management.azure.com/schemas/2020-09-18/Microsoft.Kusto.json#/resourceDefinitions/clusters_databases_principalAssignments"
724724
},
725725
{
726726
"$ref": "https://schema.management.azure.com/schemas/2014-04-01-preview/Microsoft.Cache.json#/resourceDefinitions/Redis"

0 commit comments

Comments
 (0)