internal AnalysisData(string source, DetectorDefinition detectorDefinition, IList <DiagnosticMetricSet> metrics, IList <IList <NameValuePair> > data, ResponseMetaData detectorMetaData)
 {
     Source             = source;
     DetectorDefinition = detectorDefinition;
     Metrics            = metrics;
     Data             = data;
     DetectorMetaData = detectorMetaData;
 }
 internal DiagnosticDetectorResponse(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string kind, DateTimeOffset?startOn, DateTimeOffset?endOn, bool?issueDetected, DetectorDefinition detectorDefinition, IList <DiagnosticMetricSet> metrics, IList <DetectorAbnormalTimePeriod> abnormalTimePeriods, IList <IList <NameValuePair> > data, ResponseMetaData responseMetaData) : base(id, name, resourceType, systemData, kind)
 {
     StartOn             = startOn;
     EndOn               = endOn;
     IssueDetected       = issueDetected;
     DetectorDefinition  = detectorDefinition;
     Metrics             = metrics;
     AbnormalTimePeriods = abnormalTimePeriods;
     Data             = data;
     ResponseMetaData = responseMetaData;
 }
        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));
        }
Esempio n. 4
0
        internal static DiagnosticAnalysis DeserializeDiagnosticAnalysis(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 <IList <AbnormalTimePeriod> > abnormalTimePeriods    = default;
            Optional <IList <AnalysisData> >       payload                = default;
            Optional <IList <DetectorDefinition> > nonCorrelatedDetectors = 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 = new ResourceType(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("abnormalTimePeriods"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <AbnormalTimePeriod> array = new List <AbnormalTimePeriod>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(AbnormalTimePeriod.DeserializeAbnormalTimePeriod(item));
                            }
                            abnormalTimePeriods = array;
                            continue;
                        }
                        if (property0.NameEquals("payload"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <AnalysisData> array = new List <AnalysisData>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(AnalysisData.DeserializeAnalysisData(item));
                            }
                            payload = array;
                            continue;
                        }
                        if (property0.NameEquals("nonCorrelatedDetectors"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <DetectorDefinition> array = new List <DetectorDefinition>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(DetectorDefinition.DeserializeDetectorDefinition(item));
                            }
                            nonCorrelatedDetectors = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new DiagnosticAnalysis(id, name, type, systemData, kind.Value, Optional.ToNullable(startTime), Optional.ToNullable(endTime), Optional.ToList(abnormalTimePeriods), Optional.ToList(payload), Optional.ToList(nonCorrelatedDetectors)));
        }
Esempio n. 5
0
        internal static AnalysisData DeserializeAnalysisData(JsonElement element)
        {
            Optional <string>                          source             = default;
            Optional <DetectorDefinition>              detectorDefinition = default;
            Optional <IList <DiagnosticMetricSet> >    metrics            = default;
            Optional <IList <IList <NameValuePair> > > data             = default;
            Optional <ResponseMetaData>                detectorMetaData = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("source"))
                {
                    source = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("detectorDefinition"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    detectorDefinition = DetectorDefinition.DeserializeDetectorDefinition(property.Value);
                    continue;
                }
                if (property.NameEquals("metrics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DiagnosticMetricSet> array = new List <DiagnosticMetricSet>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DiagnosticMetricSet.DeserializeDiagnosticMetricSet(item));
                    }
                    metrics = array;
                    continue;
                }
                if (property.NameEquals("data"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <IList <NameValuePair> > array = new List <IList <NameValuePair> >();
                    foreach (var item in property.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 (property.NameEquals("detectorMetaData"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    detectorMetaData = ResponseMetaData.DeserializeResponseMetaData(property.Value);
                    continue;
                }
            }
            return(new AnalysisData(source.Value, detectorDefinition.Value, Optional.ToList(metrics), Optional.ToList(data), detectorMetaData.Value));
        }