-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
JsonDataset.cs
205 lines (200 loc) · 11.3 KB
/
JsonDataset.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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#nullable disable
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text.Json;
using Azure.Core;
using Azure.Core.Expressions.DataFactory;
namespace Azure.ResourceManager.DataFactory.Models
{
/// <summary> Json dataset. </summary>
[CodeGenSuppress(nameof(JsonDataset), typeof(string), typeof(string), typeof(DataFactoryElement<IList<DatasetDataElement>>),
typeof(DataFactoryElement<BinaryData>), typeof(Core.Expressions.DataFactory.DataFactoryLinkedServiceReference), typeof(IDictionary<string, EntityParameterSpecification>),
typeof(IList<BinaryData>), typeof(string), typeof(IDictionary<string, BinaryData>), typeof(DatasetLocation), typeof(DataFactoryElement<string>), typeof(DatasetCompression))]
public partial class JsonDataset : DataFactoryDatasetProperties
{
/// <summary> Initializes a new instance of <see cref="JsonDataset"/>. </summary>
/// <param name="datasetType"> Type of dataset. </param>
/// <param name="description"> Dataset description. </param>
/// <param name="structure"> Columns that define the structure of the dataset. Type: array (or Expression with resultType array), itemType: DatasetDataElement. </param>
/// <param name="schema"> Columns that define the physical type schema of the dataset. Type: array (or Expression with resultType array), itemType: DatasetSchemaDataElement. </param>
/// <param name="linkedServiceName"> Linked service reference. </param>
/// <param name="parameters"> Parameters for dataset. </param>
/// <param name="annotations"> List of tags that can be used for describing the Dataset. </param>
/// <param name="folder"> The folder that this Dataset is in. If not specified, Dataset will appear at the root level. </param>
/// <param name="additionalProperties"> Additional Properties. </param>
/// <param name="dataLocation">
/// The location of the json data storage.
/// Please note <see cref="DatasetLocation"/> is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
/// The available derived classes include <see cref="AmazonS3CompatibleLocation"/>, <see cref="AmazonS3Location"/>, <see cref="AzureBlobFSLocation"/>, <see cref="AzureBlobStorageLocation"/>, <see cref="AzureDataLakeStoreLocation"/>, <see cref="AzureFileStorageLocation"/>, <see cref="FileServerLocation"/>, <see cref="FtpServerLocation"/>, <see cref="GoogleCloudStorageLocation"/>, <see cref="HdfsLocation"/>, <see cref="HttpServerLocation"/>, <see cref="LakeHouseLocation"/>, <see cref="OracleCloudStorageLocation"/> and <see cref="SftpLocation"/>.
/// </param>
/// <param name="encodingName"> The code page name of the preferred encoding. If not specified, the default value is UTF-8, unless BOM denotes another Unicode encoding. Refer to the name column of the table in the following link to set supported values: https://msdn.microsoft.com/library/system.text.encoding.aspx. Type: string (or Expression with resultType string). </param>
/// <param name="compression"> The data compression method used for the json dataset. </param>
internal JsonDataset(string datasetType, string description, DataFactoryElement<IList<DatasetDataElement>> structure, DataFactoryElement<BinaryData> schema, Core.Expressions.DataFactory.DataFactoryLinkedServiceReference linkedServiceName, IDictionary<string, EntityParameterSpecification> parameters, IList<BinaryData> annotations, DatasetFolder folder, IDictionary<string, BinaryData> additionalProperties, DatasetLocation dataLocation, DataFactoryElement<string> encodingName, DatasetCompression compression) : base(datasetType, description, structure, null, linkedServiceName, parameters, annotations, folder, additionalProperties)
{
DataLocation = dataLocation;
EncodingName = encodingName;
Compression = compression;
Schema = schema;
DatasetType = datasetType ?? "Json";
}
/// <summary> Columns that define the physical type schema of the dataset. Type: array (or Expression with resultType array), itemType: DatasetSchemaDataElement. </summary>
public new DataFactoryElement<BinaryData> Schema { get; set; }
internal static JsonDataset DeserializeJsonDataset(JsonElement element)
{
if (element.ValueKind == JsonValueKind.Null)
{
return null;
}
string type = default;
string description = default;
DataFactoryElement<IList<DatasetDataElement>> structure = default;
DataFactoryElement<BinaryData> schema = default;
Core.Expressions.DataFactory.DataFactoryLinkedServiceReference linkedServiceName = default;
IDictionary<string, EntityParameterSpecification> parameters = default;
IList<BinaryData> annotations = default;
DatasetFolder folder = default;
DatasetLocation location = default;
DataFactoryElement<string> encodingName = default;
DatasetCompression compression = default;
IDictionary<string, BinaryData> additionalProperties = default;
Dictionary<string, BinaryData> additionalPropertiesDictionary = new Dictionary<string, BinaryData>();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("type"u8))
{
type = property.Value.GetString();
continue;
}
if (property.NameEquals("description"u8))
{
description = property.Value.GetString();
continue;
}
if (property.NameEquals("structure"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
structure = JsonSerializer.Deserialize<DataFactoryElement<IList<DatasetDataElement>>>(property.Value.GetRawText());
continue;
}
if (property.NameEquals("schema"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
schema = JsonSerializer.Deserialize<DataFactoryElement<BinaryData>>(property.Value.GetRawText());
continue;
}
if (property.NameEquals("linkedServiceName"u8))
{
linkedServiceName = JsonSerializer.Deserialize<Core.Expressions.DataFactory.DataFactoryLinkedServiceReference>(property.Value.GetRawText());
continue;
}
if (property.NameEquals("parameters"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
Dictionary<string, EntityParameterSpecification> dictionary = new Dictionary<string, EntityParameterSpecification>();
foreach (var property0 in property.Value.EnumerateObject())
{
dictionary.Add(property0.Name, EntityParameterSpecification.DeserializeEntityParameterSpecification(property0.Value));
}
parameters = dictionary;
continue;
}
if (property.NameEquals("annotations"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
List<BinaryData> array = new List<BinaryData>();
foreach (var item in property.Value.EnumerateArray())
{
if (item.ValueKind == JsonValueKind.Null)
{
array.Add(null);
}
else
{
array.Add(BinaryData.FromString(item.GetRawText()));
}
}
annotations = array;
continue;
}
if (property.NameEquals("folder"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
folder = DatasetFolder.DeserializeDatasetFolder(property.Value);
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("location"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
location = DatasetLocation.DeserializeDatasetLocation(property0.Value);
continue;
}
if (property0.NameEquals("encodingName"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
encodingName = JsonSerializer.Deserialize<DataFactoryElement<string>>(property0.Value.GetRawText());
continue;
}
if (property0.NameEquals("compression"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
compression = DatasetCompression.DeserializeDatasetCompression(property0.Value);
continue;
}
}
continue;
}
additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
}
additionalProperties = additionalPropertiesDictionary;
return new JsonDataset(
type,
description,
structure,
schema,
linkedServiceName,
parameters ?? new ChangeTrackingDictionary<string, EntityParameterSpecification>(),
annotations ?? new ChangeTrackingList<BinaryData>(),
folder,
additionalProperties,
location,
encodingName,
compression);
}
}
}