/
polymorphic_helpers.go
200 lines (190 loc) · 5.34 KB
/
polymorphic_helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
//go:build go1.18
// +build go1.18
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
package armstreamanalytics
import "encoding/json"
func unmarshalFunctionBindingClassification(rawMsg json.RawMessage) (FunctionBindingClassification, error) {
if rawMsg == nil {
return nil, nil
}
var m map[string]any
if err := json.Unmarshal(rawMsg, &m); err != nil {
return nil, err
}
var b FunctionBindingClassification
switch m["type"] {
case "Microsoft.MachineLearning/WebService":
b = &AzureMachineLearningWebServiceFunctionBinding{}
case "Microsoft.StreamAnalytics/JavascriptUdf":
b = &JavaScriptFunctionBinding{}
default:
b = &FunctionBinding{}
}
if err := json.Unmarshal(rawMsg, b); err != nil {
return nil, err
}
return b, nil
}
func unmarshalFunctionPropertiesClassification(rawMsg json.RawMessage) (FunctionPropertiesClassification, error) {
if rawMsg == nil {
return nil, nil
}
var m map[string]any
if err := json.Unmarshal(rawMsg, &m); err != nil {
return nil, err
}
var b FunctionPropertiesClassification
switch m["type"] {
case "Aggregate":
b = &AggregateFunctionProperties{}
case "Scalar":
b = &ScalarFunctionProperties{}
default:
b = &FunctionProperties{}
}
if err := json.Unmarshal(rawMsg, b); err != nil {
return nil, err
}
return b, nil
}
func unmarshalInputPropertiesClassification(rawMsg json.RawMessage) (InputPropertiesClassification, error) {
if rawMsg == nil {
return nil, nil
}
var m map[string]any
if err := json.Unmarshal(rawMsg, &m); err != nil {
return nil, err
}
var b InputPropertiesClassification
switch m["type"] {
case "Reference":
b = &ReferenceInputProperties{}
case "Stream":
b = &StreamInputProperties{}
default:
b = &InputProperties{}
}
if err := json.Unmarshal(rawMsg, b); err != nil {
return nil, err
}
return b, nil
}
func unmarshalOutputDataSourceClassification(rawMsg json.RawMessage) (OutputDataSourceClassification, error) {
if rawMsg == nil {
return nil, nil
}
var m map[string]any
if err := json.Unmarshal(rawMsg, &m); err != nil {
return nil, err
}
var b OutputDataSourceClassification
switch m["type"] {
case "Microsoft.AzureFunction":
b = &AzureFunctionOutputDataSource{}
case "Microsoft.DataLake/Accounts":
b = &AzureDataLakeStoreOutputDataSource{}
case "Microsoft.EventHub/EventHub":
b = &EventHubV2OutputDataSource{}
case "Microsoft.ServiceBus/EventHub":
b = &EventHubOutputDataSource{}
case "Microsoft.ServiceBus/Queue":
b = &ServiceBusQueueOutputDataSource{}
case "Microsoft.ServiceBus/Topic":
b = &ServiceBusTopicOutputDataSource{}
case "Microsoft.Sql/Server/DataWarehouse":
b = &AzureSynapseOutputDataSource{}
case "Microsoft.Sql/Server/Database":
b = &AzureSQLDatabaseOutputDataSource{}
case "Microsoft.Storage/Blob":
b = &BlobOutputDataSource{}
case "Microsoft.Storage/DocumentDB":
b = &DocumentDbOutputDataSource{}
case "Microsoft.Storage/Table":
b = &AzureTableOutputDataSource{}
case "PowerBI":
b = &PowerBIOutputDataSource{}
default:
b = &OutputDataSource{}
}
if err := json.Unmarshal(rawMsg, b); err != nil {
return nil, err
}
return b, nil
}
func unmarshalReferenceInputDataSourceClassification(rawMsg json.RawMessage) (ReferenceInputDataSourceClassification, error) {
if rawMsg == nil {
return nil, nil
}
var m map[string]any
if err := json.Unmarshal(rawMsg, &m); err != nil {
return nil, err
}
var b ReferenceInputDataSourceClassification
switch m["type"] {
case "Microsoft.Sql/Server/Database":
b = &AzureSQLReferenceInputDataSource{}
case "Microsoft.Storage/Blob":
b = &BlobReferenceInputDataSource{}
default:
b = &ReferenceInputDataSource{}
}
if err := json.Unmarshal(rawMsg, b); err != nil {
return nil, err
}
return b, nil
}
func unmarshalSerializationClassification(rawMsg json.RawMessage) (SerializationClassification, error) {
if rawMsg == nil {
return nil, nil
}
var m map[string]any
if err := json.Unmarshal(rawMsg, &m); err != nil {
return nil, err
}
var b SerializationClassification
switch m["type"] {
case string(EventSerializationTypeAvro):
b = &AvroSerialization{}
case string(EventSerializationTypeCSV):
b = &CSVSerialization{}
case string(EventSerializationTypeJSON):
b = &JSONSerialization{}
case string(EventSerializationTypeParquet):
b = &ParquetSerialization{}
default:
b = &Serialization{}
}
if err := json.Unmarshal(rawMsg, b); err != nil {
return nil, err
}
return b, nil
}
func unmarshalStreamInputDataSourceClassification(rawMsg json.RawMessage) (StreamInputDataSourceClassification, error) {
if rawMsg == nil {
return nil, nil
}
var m map[string]any
if err := json.Unmarshal(rawMsg, &m); err != nil {
return nil, err
}
var b StreamInputDataSourceClassification
switch m["type"] {
case "Microsoft.Devices/IotHubs":
b = &IoTHubStreamInputDataSource{}
case "Microsoft.EventHub/EventHub":
b = &EventHubV2StreamInputDataSource{}
case "Microsoft.ServiceBus/EventHub":
b = &EventHubStreamInputDataSource{}
case "Microsoft.Storage/Blob":
b = &BlobStreamInputDataSource{}
default:
b = &StreamInputDataSource{}
}
if err := json.Unmarshal(rawMsg, b); err != nil {
return nil, err
}
return b, nil
}