@@ -2,152 +2,159 @@ import { SchemaPostProcessor } from '../models';
22import { apiVersionCompare } from '../utils' ;
33
44const 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- }
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+ ]
3023 } ,
31- required : [
32- 'apiVersion' ,
33- 'properties' ,
34- 'type'
35- ] ,
36- description : 'Microsoft.Kusto/clusters/dataConnections'
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'
3737} ) ;
3838
3939const 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.'
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.'
5151} ) ;
5252
5353const genevaDataConnection = ( ) => ( {
54- type : 'object' ,
54+ type : 'object' ,
55+ properties : {
5556 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- }
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'
7366 } ,
74- required : [
75- 'kind'
76- ] ,
77- description : 'Information about the Geneva (GDS) data connection'
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'
7878} ) ;
7979
8080const 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.'
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.'
102102} ) ;
103103
104104const 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.'
105+ type : 'object' ,
106+ properties : {
107+ properties : {
108+ oneOf : [
109+ {
110+ $ref : '#/definitions/GenevaLegacyDataConnectionProperties'
117111 } ,
118- kind : {
119- type : 'string' ,
120- enum : [
121- 'GenevaLegacy'
122- ]
112+ {
113+ $ref : 'https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression'
123114 }
124- } ,
125- required : [
126- 'kind'
127115 ] ,
128- description : 'Information about the Geneva legacy data connection.'
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.'
129129} ) ;
130130
131131const clusterDataConnections_childResource = ( ) => ( {
132- $ref : '#/definitions/clusters_dataConnections_childResource'
132+ $ref : '#/definitions/clusters_dataConnections_childResource'
133133} ) ;
134134
135135export 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-
151- // Handle read only following database
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
152151
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+ }
153160}
0 commit comments