| | 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.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.Search.Documents.Indexes.Models |
| | 13 | | { |
| | 14 | | public partial class IndexingSchedule : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | writer.WritePropertyName("interval"); |
| 0 | 20 | | writer.WriteStringValue(Interval, "P"); |
| 0 | 21 | | if (Optional.IsDefined(StartTime)) |
| | 22 | | { |
| 0 | 23 | | writer.WritePropertyName("startTime"); |
| 0 | 24 | | writer.WriteStringValue(StartTime.Value, "O"); |
| | 25 | | } |
| 0 | 26 | | writer.WriteEndObject(); |
| 0 | 27 | | } |
| | 28 | |
|
| | 29 | | internal static IndexingSchedule DeserializeIndexingSchedule(JsonElement element) |
| | 30 | | { |
| 0 | 31 | | TimeSpan interval = default; |
| 0 | 32 | | Optional<DateTimeOffset> startTime = default; |
| 0 | 33 | | foreach (var property in element.EnumerateObject()) |
| | 34 | | { |
| 0 | 35 | | if (property.NameEquals("interval")) |
| | 36 | | { |
| 0 | 37 | | interval = property.Value.GetTimeSpan("P"); |
| 0 | 38 | | continue; |
| | 39 | | } |
| 0 | 40 | | if (property.NameEquals("startTime")) |
| | 41 | | { |
| 0 | 42 | | startTime = property.Value.GetDateTimeOffset("O"); |
| | 43 | | continue; |
| | 44 | | } |
| | 45 | | } |
| 0 | 46 | | return new IndexingSchedule(interval, Optional.ToNullable(startTime)); |
| | 47 | | } |
| | 48 | | } |
| | 49 | | } |