internal static DiagnosticDetectorResponse DeserializeDiagnosticDetectorResponse(JsonElement element)
        {
            Optional <string>                              kind                = default;
            ResourceIdentifier                             id                  = default;
            string                                         name                = default;
            ResourceType                                   type                = default;
            SystemData                                     systemData          = default;
            Optional <DateTimeOffset>                      startTime           = default;
            Optional <DateTimeOffset>                      endTime             = default;
            Optional <bool>                                issueDetected       = default;
            Optional <DetectorDefinition>                  detectorDefinition  = default;
            Optional <IList <DiagnosticMetricSet> >        metrics             = default;
            Optional <IList <DetectorAbnormalTimePeriod> > abnormalTimePeriods = default;
            Optional <IList <IList <NameValuePair> > >     data                = default;
            Optional <ResponseMetaData>                    responseMetaData    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("startTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            startTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("endTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            endTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("issueDetected"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            issueDetected = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("detectorDefinition"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            detectorDefinition = DetectorDefinition.DeserializeDetectorDefinition(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("metrics"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <DiagnosticMetricSet> array = new List <DiagnosticMetricSet>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(DiagnosticMetricSet.DeserializeDiagnosticMetricSet(item));
                            }
                            metrics = array;
                            continue;
                        }
                        if (property0.NameEquals("abnormalTimePeriods"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <DetectorAbnormalTimePeriod> array = new List <DetectorAbnormalTimePeriod>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(DetectorAbnormalTimePeriod.DeserializeDetectorAbnormalTimePeriod(item));
                            }
                            abnormalTimePeriods = array;
                            continue;
                        }
                        if (property0.NameEquals("data"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <IList <NameValuePair> > array = new List <IList <NameValuePair> >();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                List <NameValuePair> array0 = new List <NameValuePair>();
                                foreach (var item0 in item.EnumerateArray())
                                {
                                    array0.Add(NameValuePair.DeserializeNameValuePair(item0));
                                }
                                array.Add(array0);
                            }
                            data = array;
                            continue;
                        }
                        if (property0.NameEquals("responseMetaData"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            responseMetaData = ResponseMetaData.DeserializeResponseMetaData(property0.Value);
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new DiagnosticDetectorResponse(id, name, type, systemData, kind.Value, Optional.ToNullable(startTime), Optional.ToNullable(endTime), Optional.ToNullable(issueDetected), detectorDefinition.Value, Optional.ToList(metrics), Optional.ToList(abnormalTimePeriods), Optional.ToList(data), responseMetaData.Value));
        }
        internal static AbnormalTimePeriod DeserializeAbnormalTimePeriod(JsonElement element)
        {
            Optional <DateTimeOffset> startTime = default;
            Optional <DateTimeOffset> endTime   = default;
            Optional <IList <DetectorAbnormalTimePeriod> > events = default;
            Optional <IList <Solution> > solutions = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("startTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    startTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    endTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("events"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DetectorAbnormalTimePeriod> array = new List <DetectorAbnormalTimePeriod>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DetectorAbnormalTimePeriod.DeserializeDetectorAbnormalTimePeriod(item));
                    }
                    events = array;
                    continue;
                }
                if (property.NameEquals("solutions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <Solution> array = new List <Solution>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Solution.DeserializeSolution(item));
                    }
                    solutions = array;
                    continue;
                }
            }
            return(new AbnormalTimePeriod(Optional.ToNullable(startTime), Optional.ToNullable(endTime), Optional.ToList(events), Optional.ToList(solutions)));
        }