| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Collections.Generic; |
| | 10 | | using System.Text.Json; |
| | 11 | | using Azure.Core; |
| | 12 | |
|
| | 13 | | namespace Azure.Search.Documents.Indexes.Models |
| | 14 | | { |
| | 15 | | public partial class WebApiSkill : IUtf8JsonSerializable |
| | 16 | | { |
| | 17 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 18 | | { |
| 0 | 19 | | writer.WriteStartObject(); |
| 0 | 20 | | writer.WritePropertyName("uri"); |
| 0 | 21 | | writer.WriteStringValue(Uri); |
| 0 | 22 | | if (Optional.IsCollectionDefined(HttpHeaders)) |
| | 23 | | { |
| 0 | 24 | | writer.WritePropertyName("httpHeaders"); |
| 0 | 25 | | writer.WriteStartObject(); |
| 0 | 26 | | foreach (var item in HttpHeaders) |
| | 27 | | { |
| 0 | 28 | | writer.WritePropertyName(item.Key); |
| 0 | 29 | | writer.WriteStringValue(item.Value); |
| | 30 | | } |
| 0 | 31 | | writer.WriteEndObject(); |
| | 32 | | } |
| 0 | 33 | | if (Optional.IsDefined(HttpMethod)) |
| | 34 | | { |
| 0 | 35 | | writer.WritePropertyName("httpMethod"); |
| 0 | 36 | | writer.WriteStringValue(HttpMethod); |
| | 37 | | } |
| 0 | 38 | | if (Optional.IsDefined(Timeout)) |
| | 39 | | { |
| 0 | 40 | | writer.WritePropertyName("timeout"); |
| 0 | 41 | | writer.WriteStringValue(Timeout.Value, "P"); |
| | 42 | | } |
| 0 | 43 | | if (Optional.IsDefined(BatchSize)) |
| | 44 | | { |
| 0 | 45 | | if (BatchSize != null) |
| | 46 | | { |
| 0 | 47 | | writer.WritePropertyName("batchSize"); |
| 0 | 48 | | writer.WriteNumberValue(BatchSize.Value); |
| | 49 | | } |
| | 50 | | else |
| | 51 | | { |
| 0 | 52 | | writer.WriteNull("batchSize"); |
| | 53 | | } |
| | 54 | | } |
| 0 | 55 | | if (Optional.IsDefined(DegreeOfParallelism)) |
| | 56 | | { |
| 0 | 57 | | if (DegreeOfParallelism != null) |
| | 58 | | { |
| 0 | 59 | | writer.WritePropertyName("degreeOfParallelism"); |
| 0 | 60 | | writer.WriteNumberValue(DegreeOfParallelism.Value); |
| | 61 | | } |
| | 62 | | else |
| | 63 | | { |
| 0 | 64 | | writer.WriteNull("degreeOfParallelism"); |
| | 65 | | } |
| | 66 | | } |
| 0 | 67 | | writer.WritePropertyName("@odata.type"); |
| 0 | 68 | | writer.WriteStringValue(ODataType); |
| 0 | 69 | | if (Optional.IsDefined(Name)) |
| | 70 | | { |
| 0 | 71 | | writer.WritePropertyName("name"); |
| 0 | 72 | | writer.WriteStringValue(Name); |
| | 73 | | } |
| 0 | 74 | | if (Optional.IsDefined(Description)) |
| | 75 | | { |
| 0 | 76 | | writer.WritePropertyName("description"); |
| 0 | 77 | | writer.WriteStringValue(Description); |
| | 78 | | } |
| 0 | 79 | | if (Optional.IsDefined(Context)) |
| | 80 | | { |
| 0 | 81 | | writer.WritePropertyName("context"); |
| 0 | 82 | | writer.WriteStringValue(Context); |
| | 83 | | } |
| 0 | 84 | | writer.WritePropertyName("inputs"); |
| 0 | 85 | | writer.WriteStartArray(); |
| 0 | 86 | | foreach (var item in Inputs) |
| | 87 | | { |
| 0 | 88 | | writer.WriteObjectValue(item); |
| | 89 | | } |
| 0 | 90 | | writer.WriteEndArray(); |
| 0 | 91 | | writer.WritePropertyName("outputs"); |
| 0 | 92 | | writer.WriteStartArray(); |
| 0 | 93 | | foreach (var item in Outputs) |
| | 94 | | { |
| 0 | 95 | | writer.WriteObjectValue(item); |
| | 96 | | } |
| 0 | 97 | | writer.WriteEndArray(); |
| 0 | 98 | | writer.WriteEndObject(); |
| 0 | 99 | | } |
| | 100 | |
|
| | 101 | | internal static WebApiSkill DeserializeWebApiSkill(JsonElement element) |
| | 102 | | { |
| 0 | 103 | | string uri = default; |
| 0 | 104 | | Optional<IDictionary<string, string>> httpHeaders = default; |
| 0 | 105 | | Optional<string> httpMethod = default; |
| 0 | 106 | | Optional<TimeSpan> timeout = default; |
| 0 | 107 | | Optional<int?> batchSize = default; |
| 0 | 108 | | Optional<int?> degreeOfParallelism = default; |
| 0 | 109 | | string odataType = default; |
| 0 | 110 | | Optional<string> name = default; |
| 0 | 111 | | Optional<string> description = default; |
| 0 | 112 | | Optional<string> context = default; |
| 0 | 113 | | IList<InputFieldMappingEntry> inputs = default; |
| 0 | 114 | | IList<OutputFieldMappingEntry> outputs = default; |
| 0 | 115 | | foreach (var property in element.EnumerateObject()) |
| | 116 | | { |
| 0 | 117 | | if (property.NameEquals("uri")) |
| | 118 | | { |
| 0 | 119 | | uri = property.Value.GetString(); |
| 0 | 120 | | continue; |
| | 121 | | } |
| 0 | 122 | | if (property.NameEquals("httpHeaders")) |
| | 123 | | { |
| 0 | 124 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 125 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 126 | | { |
| 0 | 127 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 128 | | } |
| 0 | 129 | | httpHeaders = dictionary; |
| 0 | 130 | | continue; |
| | 131 | | } |
| 0 | 132 | | if (property.NameEquals("httpMethod")) |
| | 133 | | { |
| 0 | 134 | | httpMethod = property.Value.GetString(); |
| 0 | 135 | | continue; |
| | 136 | | } |
| 0 | 137 | | if (property.NameEquals("timeout")) |
| | 138 | | { |
| 0 | 139 | | timeout = property.Value.GetTimeSpan("P"); |
| 0 | 140 | | continue; |
| | 141 | | } |
| 0 | 142 | | if (property.NameEquals("batchSize")) |
| | 143 | | { |
| 0 | 144 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 145 | | { |
| 0 | 146 | | batchSize = null; |
| 0 | 147 | | continue; |
| | 148 | | } |
| 0 | 149 | | batchSize = property.Value.GetInt32(); |
| 0 | 150 | | continue; |
| | 151 | | } |
| 0 | 152 | | if (property.NameEquals("degreeOfParallelism")) |
| | 153 | | { |
| 0 | 154 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 155 | | { |
| 0 | 156 | | degreeOfParallelism = null; |
| 0 | 157 | | continue; |
| | 158 | | } |
| 0 | 159 | | degreeOfParallelism = property.Value.GetInt32(); |
| 0 | 160 | | continue; |
| | 161 | | } |
| 0 | 162 | | if (property.NameEquals("@odata.type")) |
| | 163 | | { |
| 0 | 164 | | odataType = property.Value.GetString(); |
| 0 | 165 | | continue; |
| | 166 | | } |
| 0 | 167 | | if (property.NameEquals("name")) |
| | 168 | | { |
| 0 | 169 | | name = property.Value.GetString(); |
| 0 | 170 | | continue; |
| | 171 | | } |
| 0 | 172 | | if (property.NameEquals("description")) |
| | 173 | | { |
| 0 | 174 | | description = property.Value.GetString(); |
| 0 | 175 | | continue; |
| | 176 | | } |
| 0 | 177 | | if (property.NameEquals("context")) |
| | 178 | | { |
| 0 | 179 | | context = property.Value.GetString(); |
| 0 | 180 | | continue; |
| | 181 | | } |
| 0 | 182 | | if (property.NameEquals("inputs")) |
| | 183 | | { |
| 0 | 184 | | List<InputFieldMappingEntry> array = new List<InputFieldMappingEntry>(); |
| 0 | 185 | | foreach (var item in property.Value.EnumerateArray()) |
| | 186 | | { |
| 0 | 187 | | array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); |
| | 188 | | } |
| 0 | 189 | | inputs = array; |
| 0 | 190 | | continue; |
| | 191 | | } |
| 0 | 192 | | if (property.NameEquals("outputs")) |
| | 193 | | { |
| 0 | 194 | | List<OutputFieldMappingEntry> array = new List<OutputFieldMappingEntry>(); |
| 0 | 195 | | foreach (var item in property.Value.EnumerateArray()) |
| | 196 | | { |
| 0 | 197 | | array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); |
| | 198 | | } |
| 0 | 199 | | outputs = array; |
| | 200 | | continue; |
| | 201 | | } |
| | 202 | | } |
| 0 | 203 | | return new WebApiSkill(odataType, name.Value, description.Value, context.Value, inputs, outputs, uri, Option |
| | 204 | | } |
| | 205 | | } |
| | 206 | | } |