Esempio n. 1
0
 internal AutoHealTriggers(RequestsBasedTrigger requests, int?privateBytesInKB, IList <StatusCodesBasedTrigger> statusCodes, SlowRequestsBasedTrigger slowRequests, IList <SlowRequestsBasedTrigger> slowRequestsWithPath, IList <StatusCodesRangeBasedTrigger> statusCodesRange)
 {
     Requests             = requests;
     PrivateBytesInKB     = privateBytesInKB;
     StatusCodes          = statusCodes;
     SlowRequests         = slowRequests;
     SlowRequestsWithPath = slowRequestsWithPath;
     StatusCodesRange     = statusCodesRange;
 }
        internal static AutoHealTriggers DeserializeAutoHealTriggers(JsonElement element)
        {
            Optional <RequestsBasedTrigger> requests = default;
            Optional <int> privateBytesInKB          = default;
            Optional <IList <StatusCodesBasedTrigger> >      statusCodes          = default;
            Optional <SlowRequestsBasedTrigger>              slowRequests         = default;
            Optional <IList <SlowRequestsBasedTrigger> >     slowRequestsWithPath = default;
            Optional <IList <StatusCodesRangeBasedTrigger> > statusCodesRange     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("requests"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    requests = RequestsBasedTrigger.DeserializeRequestsBasedTrigger(property.Value);
                    continue;
                }
                if (property.NameEquals("privateBytesInKB"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    privateBytesInKB = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("statusCodes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <StatusCodesBasedTrigger> array = new List <StatusCodesBasedTrigger>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(StatusCodesBasedTrigger.DeserializeStatusCodesBasedTrigger(item));
                    }
                    statusCodes = array;
                    continue;
                }
                if (property.NameEquals("slowRequests"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    slowRequests = SlowRequestsBasedTrigger.DeserializeSlowRequestsBasedTrigger(property.Value);
                    continue;
                }
                if (property.NameEquals("slowRequestsWithPath"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SlowRequestsBasedTrigger> array = new List <SlowRequestsBasedTrigger>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SlowRequestsBasedTrigger.DeserializeSlowRequestsBasedTrigger(item));
                    }
                    slowRequestsWithPath = array;
                    continue;
                }
                if (property.NameEquals("statusCodesRange"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <StatusCodesRangeBasedTrigger> array = new List <StatusCodesRangeBasedTrigger>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(StatusCodesRangeBasedTrigger.DeserializeStatusCodesRangeBasedTrigger(item));
                    }
                    statusCodesRange = array;
                    continue;
                }
            }
            return(new AutoHealTriggers(requests.Value, Optional.ToNullable(privateBytesInKB), Optional.ToList(statusCodes), slowRequests.Value, Optional.ToList(slowRequestsWithPath), Optional.ToList(statusCodesRange)));
        }