Exemplo n.º 1
0
        internal static LogsBatchQueryResult DeserializeLogsBatchQueryResult(JsonElement element)
        {
            Optional <IReadOnlyList <LogQueryResponse> > responses = default;
            Optional <BatchResponseError> error = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("responses"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <LogQueryResponse> array = new List <LogQueryResponse>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(LogQueryResponse.DeserializeLogQueryResponse(item));
                    }
                    responses = array;
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = BatchResponseError.DeserializeBatchResponseError(property.Value);
                    continue;
                }
            }
            return(new LogsBatchQueryResult(Optional.ToList(responses), error.Value));
        }
 internal LogsBatchQueryResult(IReadOnlyList <LogQueryResponse> responses, BatchResponseError error)
 {
     Responses = responses;
     Error     = error;
 }