-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
HDInsightHiveActivity.Serialization.cs
495 lines (480 loc) · 21.3 KB
/
HDInsightHiveActivity.Serialization.cs
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.ClientModel.Primitives;
using System.Collections.Generic;
using System.Text.Json;
using Azure.Core;
using Azure.Core.Expressions.DataFactory;
namespace Azure.ResourceManager.DataFactory.Models
{
public partial class HDInsightHiveActivity : IUtf8JsonSerializable, IJsonModel<HDInsightHiveActivity>
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel<HDInsightHiveActivity>)this).Write(writer, ModelSerializationExtensions.WireOptions);
void IJsonModel<HDInsightHiveActivity>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
{
var format = options.Format == "W" ? ((IPersistableModel<HDInsightHiveActivity>)this).GetFormatFromOptions(options) : options.Format;
if (format != "J")
{
throw new FormatException($"The model {nameof(HDInsightHiveActivity)} does not support writing '{format}' format.");
}
writer.WriteStartObject();
if (Optional.IsDefined(LinkedServiceName))
{
writer.WritePropertyName("linkedServiceName"u8);
JsonSerializer.Serialize(writer, LinkedServiceName);
}
if (Optional.IsDefined(Policy))
{
writer.WritePropertyName("policy"u8);
writer.WriteObjectValue(Policy, options);
}
writer.WritePropertyName("name"u8);
writer.WriteStringValue(Name);
writer.WritePropertyName("type"u8);
writer.WriteStringValue(ActivityType);
if (Optional.IsDefined(Description))
{
writer.WritePropertyName("description"u8);
writer.WriteStringValue(Description);
}
if (Optional.IsDefined(State))
{
writer.WritePropertyName("state"u8);
writer.WriteStringValue(State.Value.ToString());
}
if (Optional.IsDefined(OnInactiveMarkAs))
{
writer.WritePropertyName("onInactiveMarkAs"u8);
writer.WriteStringValue(OnInactiveMarkAs.Value.ToString());
}
if (Optional.IsCollectionDefined(DependsOn))
{
writer.WritePropertyName("dependsOn"u8);
writer.WriteStartArray();
foreach (var item in DependsOn)
{
writer.WriteObjectValue(item, options);
}
writer.WriteEndArray();
}
if (Optional.IsCollectionDefined(UserProperties))
{
writer.WritePropertyName("userProperties"u8);
writer.WriteStartArray();
foreach (var item in UserProperties)
{
writer.WriteObjectValue(item, options);
}
writer.WriteEndArray();
}
writer.WritePropertyName("typeProperties"u8);
writer.WriteStartObject();
if (Optional.IsCollectionDefined(StorageLinkedServices))
{
writer.WritePropertyName("storageLinkedServices"u8);
writer.WriteStartArray();
foreach (var item in StorageLinkedServices)
{
JsonSerializer.Serialize(writer, item);
}
writer.WriteEndArray();
}
if (Optional.IsCollectionDefined(Arguments))
{
writer.WritePropertyName("arguments"u8);
writer.WriteStartArray();
foreach (var item in Arguments)
{
if (item == null)
{
writer.WriteNullValue();
continue;
}
#if NET6_0_OR_GREATER
writer.WriteRawValue(item);
#else
using (JsonDocument document = JsonDocument.Parse(item))
{
JsonSerializer.Serialize(writer, document.RootElement);
}
#endif
}
writer.WriteEndArray();
}
if (Optional.IsDefined(GetDebugInfo))
{
writer.WritePropertyName("getDebugInfo"u8);
writer.WriteStringValue(GetDebugInfo.Value.ToString());
}
if (Optional.IsDefined(ScriptPath))
{
writer.WritePropertyName("scriptPath"u8);
JsonSerializer.Serialize(writer, ScriptPath);
}
if (Optional.IsDefined(ScriptLinkedService))
{
writer.WritePropertyName("scriptLinkedService"u8);
JsonSerializer.Serialize(writer, ScriptLinkedService);
}
if (Optional.IsCollectionDefined(Defines))
{
writer.WritePropertyName("defines"u8);
writer.WriteStartObject();
foreach (var item in Defines)
{
writer.WritePropertyName(item.Key);
if (item.Value == null)
{
writer.WriteNullValue();
continue;
}
#if NET6_0_OR_GREATER
writer.WriteRawValue(item.Value);
#else
using (JsonDocument document = JsonDocument.Parse(item.Value))
{
JsonSerializer.Serialize(writer, document.RootElement);
}
#endif
}
writer.WriteEndObject();
}
if (Optional.IsCollectionDefined(Variables))
{
writer.WritePropertyName("variables"u8);
writer.WriteStartObject();
foreach (var item in Variables)
{
writer.WritePropertyName(item.Key);
if (item.Value == null)
{
writer.WriteNullValue();
continue;
}
#if NET6_0_OR_GREATER
writer.WriteRawValue(item.Value);
#else
using (JsonDocument document = JsonDocument.Parse(item.Value))
{
JsonSerializer.Serialize(writer, document.RootElement);
}
#endif
}
writer.WriteEndObject();
}
if (Optional.IsDefined(QueryTimeout))
{
writer.WritePropertyName("queryTimeout"u8);
writer.WriteNumberValue(QueryTimeout.Value);
}
writer.WriteEndObject();
foreach (var item in AdditionalProperties)
{
writer.WritePropertyName(item.Key);
#if NET6_0_OR_GREATER
writer.WriteRawValue(item.Value);
#else
using (JsonDocument document = JsonDocument.Parse(item.Value))
{
JsonSerializer.Serialize(writer, document.RootElement);
}
#endif
}
writer.WriteEndObject();
}
HDInsightHiveActivity IJsonModel<HDInsightHiveActivity>.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
{
var format = options.Format == "W" ? ((IPersistableModel<HDInsightHiveActivity>)this).GetFormatFromOptions(options) : options.Format;
if (format != "J")
{
throw new FormatException($"The model {nameof(HDInsightHiveActivity)} does not support reading '{format}' format.");
}
using JsonDocument document = JsonDocument.ParseValue(ref reader);
return DeserializeHDInsightHiveActivity(document.RootElement, options);
}
internal static HDInsightHiveActivity DeserializeHDInsightHiveActivity(JsonElement element, ModelReaderWriterOptions options = null)
{
options ??= ModelSerializationExtensions.WireOptions;
if (element.ValueKind == JsonValueKind.Null)
{
return null;
}
DataFactoryLinkedServiceReference linkedServiceName = default;
PipelineActivityPolicy policy = default;
string name = default;
string type = default;
string description = default;
PipelineActivityState? state = default;
ActivityOnInactiveMarkAs? onInactiveMarkAs = default;
IList<PipelineActivityDependency> dependsOn = default;
IList<PipelineActivityUserProperty> userProperties = default;
IList<DataFactoryLinkedServiceReference> storageLinkedServices = default;
IList<BinaryData> arguments = default;
HDInsightActivityDebugInfoOptionSetting? getDebugInfo = default;
DataFactoryElement<string> scriptPath = default;
DataFactoryLinkedServiceReference scriptLinkedService = default;
IDictionary<string, BinaryData> defines = default;
IDictionary<string, BinaryData> variables = default;
int? queryTimeout = default;
IDictionary<string, BinaryData> additionalProperties = default;
Dictionary<string, BinaryData> additionalPropertiesDictionary = new Dictionary<string, BinaryData>();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("linkedServiceName"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
linkedServiceName = JsonSerializer.Deserialize<DataFactoryLinkedServiceReference>(property.Value.GetRawText());
continue;
}
if (property.NameEquals("policy"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
policy = PipelineActivityPolicy.DeserializePipelineActivityPolicy(property.Value, options);
continue;
}
if (property.NameEquals("name"u8))
{
name = property.Value.GetString();
continue;
}
if (property.NameEquals("type"u8))
{
type = property.Value.GetString();
continue;
}
if (property.NameEquals("description"u8))
{
description = property.Value.GetString();
continue;
}
if (property.NameEquals("state"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
state = new PipelineActivityState(property.Value.GetString());
continue;
}
if (property.NameEquals("onInactiveMarkAs"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
onInactiveMarkAs = new ActivityOnInactiveMarkAs(property.Value.GetString());
continue;
}
if (property.NameEquals("dependsOn"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
List<PipelineActivityDependency> array = new List<PipelineActivityDependency>();
foreach (var item in property.Value.EnumerateArray())
{
array.Add(PipelineActivityDependency.DeserializePipelineActivityDependency(item, options));
}
dependsOn = array;
continue;
}
if (property.NameEquals("userProperties"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
List<PipelineActivityUserProperty> array = new List<PipelineActivityUserProperty>();
foreach (var item in property.Value.EnumerateArray())
{
array.Add(PipelineActivityUserProperty.DeserializePipelineActivityUserProperty(item, options));
}
userProperties = array;
continue;
}
if (property.NameEquals("typeProperties"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
property.ThrowNonNullablePropertyIsNull();
continue;
}
foreach (var property0 in property.Value.EnumerateObject())
{
if (property0.NameEquals("storageLinkedServices"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
List<DataFactoryLinkedServiceReference> array = new List<DataFactoryLinkedServiceReference>();
foreach (var item in property0.Value.EnumerateArray())
{
array.Add(JsonSerializer.Deserialize<DataFactoryLinkedServiceReference>(item.GetRawText()));
}
storageLinkedServices = array;
continue;
}
if (property0.NameEquals("arguments"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
List<BinaryData> array = new List<BinaryData>();
foreach (var item in property0.Value.EnumerateArray())
{
if (item.ValueKind == JsonValueKind.Null)
{
array.Add(null);
}
else
{
array.Add(BinaryData.FromString(item.GetRawText()));
}
}
arguments = array;
continue;
}
if (property0.NameEquals("getDebugInfo"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
getDebugInfo = new HDInsightActivityDebugInfoOptionSetting(property0.Value.GetString());
continue;
}
if (property0.NameEquals("scriptPath"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
scriptPath = JsonSerializer.Deserialize<DataFactoryElement<string>>(property0.Value.GetRawText());
continue;
}
if (property0.NameEquals("scriptLinkedService"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
scriptLinkedService = JsonSerializer.Deserialize<DataFactoryLinkedServiceReference>(property0.Value.GetRawText());
continue;
}
if (property0.NameEquals("defines"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
Dictionary<string, BinaryData> dictionary = new Dictionary<string, BinaryData>();
foreach (var property1 in property0.Value.EnumerateObject())
{
if (property1.Value.ValueKind == JsonValueKind.Null)
{
dictionary.Add(property1.Name, null);
}
else
{
dictionary.Add(property1.Name, BinaryData.FromString(property1.Value.GetRawText()));
}
}
defines = dictionary;
continue;
}
if (property0.NameEquals("variables"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
Dictionary<string, BinaryData> dictionary = new Dictionary<string, BinaryData>();
foreach (var property1 in property0.Value.EnumerateObject())
{
if (property1.Value.ValueKind == JsonValueKind.Null)
{
dictionary.Add(property1.Name, null);
}
else
{
dictionary.Add(property1.Name, BinaryData.FromString(property1.Value.GetRawText()));
}
}
variables = dictionary;
continue;
}
if (property0.NameEquals("queryTimeout"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
queryTimeout = property0.Value.GetInt32();
continue;
}
}
continue;
}
additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
}
additionalProperties = additionalPropertiesDictionary;
return new HDInsightHiveActivity(
name,
type,
description,
state,
onInactiveMarkAs,
dependsOn ?? new ChangeTrackingList<PipelineActivityDependency>(),
userProperties ?? new ChangeTrackingList<PipelineActivityUserProperty>(),
additionalProperties,
linkedServiceName,
policy,
storageLinkedServices ?? new ChangeTrackingList<DataFactoryLinkedServiceReference>(),
arguments ?? new ChangeTrackingList<BinaryData>(),
getDebugInfo,
scriptPath,
scriptLinkedService,
defines ?? new ChangeTrackingDictionary<string, BinaryData>(),
variables ?? new ChangeTrackingDictionary<string, BinaryData>(),
queryTimeout);
}
BinaryData IPersistableModel<HDInsightHiveActivity>.Write(ModelReaderWriterOptions options)
{
var format = options.Format == "W" ? ((IPersistableModel<HDInsightHiveActivity>)this).GetFormatFromOptions(options) : options.Format;
switch (format)
{
case "J":
return ModelReaderWriter.Write(this, options);
default:
throw new FormatException($"The model {nameof(HDInsightHiveActivity)} does not support writing '{options.Format}' format.");
}
}
HDInsightHiveActivity IPersistableModel<HDInsightHiveActivity>.Create(BinaryData data, ModelReaderWriterOptions options)
{
var format = options.Format == "W" ? ((IPersistableModel<HDInsightHiveActivity>)this).GetFormatFromOptions(options) : options.Format;
switch (format)
{
case "J":
{
using JsonDocument document = JsonDocument.Parse(data);
return DeserializeHDInsightHiveActivity(document.RootElement, options);
}
default:
throw new FormatException($"The model {nameof(HDInsightHiveActivity)} does not support reading '{options.Format}' format.");
}
}
string IPersistableModel<HDInsightHiveActivity>.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
}
}