|
| 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 = (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 |
| 152 | + |
| 153 | +} |
0 commit comments