| | 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.Text.Json; |
| | 9 | | using Azure.Core; |
| | 10 | |
|
| | 11 | | namespace Azure.Search.Documents.Indexes.Models |
| | 12 | | { |
| | 13 | | public partial class SearchIndexerDataSourceConnection : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 7 | 17 | | writer.WriteStartObject(); |
| 7 | 18 | | writer.WritePropertyName("name"); |
| 7 | 19 | | writer.WriteStringValue(Name); |
| 7 | 20 | | if (Optional.IsDefined(Description)) |
| | 21 | | { |
| 2 | 22 | | writer.WritePropertyName("description"); |
| 2 | 23 | | writer.WriteStringValue(Description); |
| | 24 | | } |
| 7 | 25 | | writer.WritePropertyName("type"); |
| 7 | 26 | | writer.WriteStringValue(Type.ToString()); |
| 7 | 27 | | writer.WritePropertyName("credentials"); |
| 7 | 28 | | writer.WriteObjectValue(CredentialsInternal); |
| 7 | 29 | | writer.WritePropertyName("container"); |
| 7 | 30 | | writer.WriteObjectValue(Container); |
| 7 | 31 | | if (Optional.IsDefined(DataChangeDetectionPolicy)) |
| | 32 | | { |
| 0 | 33 | | if (DataChangeDetectionPolicy != null) |
| | 34 | | { |
| 0 | 35 | | writer.WritePropertyName("dataChangeDetectionPolicy"); |
| 0 | 36 | | writer.WriteObjectValue(DataChangeDetectionPolicy); |
| | 37 | | } |
| | 38 | | else |
| | 39 | | { |
| 0 | 40 | | writer.WriteNull("dataChangeDetectionPolicy"); |
| | 41 | | } |
| | 42 | | } |
| 7 | 43 | | if (Optional.IsDefined(DataDeletionDetectionPolicy)) |
| | 44 | | { |
| 0 | 45 | | if (DataDeletionDetectionPolicy != null) |
| | 46 | | { |
| 0 | 47 | | writer.WritePropertyName("dataDeletionDetectionPolicy"); |
| 0 | 48 | | writer.WriteObjectValue(DataDeletionDetectionPolicy); |
| | 49 | | } |
| | 50 | | else |
| | 51 | | { |
| 0 | 52 | | writer.WriteNull("dataDeletionDetectionPolicy"); |
| | 53 | | } |
| | 54 | | } |
| 7 | 55 | | if (Optional.IsDefined(_etag)) |
| | 56 | | { |
| 2 | 57 | | writer.WritePropertyName("@odata.etag"); |
| 2 | 58 | | writer.WriteStringValue(_etag); |
| | 59 | | } |
| 7 | 60 | | writer.WriteEndObject(); |
| 7 | 61 | | } |
| | 62 | |
|
| | 63 | | internal static SearchIndexerDataSourceConnection DeserializeSearchIndexerDataSourceConnection(JsonElement eleme |
| | 64 | | { |
| 12 | 65 | | string name = default; |
| 12 | 66 | | Optional<string> description = default; |
| 12 | 67 | | SearchIndexerDataSourceType type = default; |
| 12 | 68 | | DataSourceCredentials credentials = default; |
| 12 | 69 | | SearchIndexerDataContainer container = default; |
| 12 | 70 | | Optional<DataChangeDetectionPolicy> dataChangeDetectionPolicy = default; |
| 12 | 71 | | Optional<DataDeletionDetectionPolicy> dataDeletionDetectionPolicy = default; |
| 12 | 72 | | Optional<string> odataEtag = default; |
| 228 | 73 | | foreach (var property in element.EnumerateObject()) |
| | 74 | | { |
| 102 | 75 | | if (property.NameEquals("name")) |
| | 76 | | { |
| 12 | 77 | | name = property.Value.GetString(); |
| 12 | 78 | | continue; |
| | 79 | | } |
| 90 | 80 | | if (property.NameEquals("description")) |
| | 81 | | { |
| 9 | 82 | | description = property.Value.GetString(); |
| 9 | 83 | | continue; |
| | 84 | | } |
| 81 | 85 | | if (property.NameEquals("type")) |
| | 86 | | { |
| 9 | 87 | | type = new SearchIndexerDataSourceType(property.Value.GetString()); |
| 9 | 88 | | continue; |
| | 89 | | } |
| 72 | 90 | | if (property.NameEquals("credentials")) |
| | 91 | | { |
| 9 | 92 | | credentials = DataSourceCredentials.DeserializeDataSourceCredentials(property.Value); |
| 9 | 93 | | continue; |
| | 94 | | } |
| 63 | 95 | | if (property.NameEquals("container")) |
| | 96 | | { |
| 9 | 97 | | container = SearchIndexerDataContainer.DeserializeSearchIndexerDataContainer(property.Value); |
| 9 | 98 | | continue; |
| | 99 | | } |
| 54 | 100 | | if (property.NameEquals("dataChangeDetectionPolicy")) |
| | 101 | | { |
| 9 | 102 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 103 | | { |
| 9 | 104 | | dataChangeDetectionPolicy = null; |
| 9 | 105 | | continue; |
| | 106 | | } |
| 0 | 107 | | dataChangeDetectionPolicy = DataChangeDetectionPolicy.DeserializeDataChangeDetectionPolicy(property. |
| 0 | 108 | | continue; |
| | 109 | | } |
| 45 | 110 | | if (property.NameEquals("dataDeletionDetectionPolicy")) |
| | 111 | | { |
| 9 | 112 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 113 | | { |
| 9 | 114 | | dataDeletionDetectionPolicy = null; |
| 9 | 115 | | continue; |
| | 116 | | } |
| 0 | 117 | | dataDeletionDetectionPolicy = DataDeletionDetectionPolicy.DeserializeDataDeletionDetectionPolicy(pro |
| 0 | 118 | | continue; |
| | 119 | | } |
| 36 | 120 | | if (property.NameEquals("@odata.etag")) |
| | 121 | | { |
| 9 | 122 | | odataEtag = property.Value.GetString(); |
| | 123 | | continue; |
| | 124 | | } |
| | 125 | | } |
| 12 | 126 | | return new SearchIndexerDataSourceConnection(name, description.Value, type, credentials, container, dataChan |
| | 127 | | } |
| | 128 | | } |
| | 129 | | } |