예제 #1
0
 internal LogQueryResponse(string id, int?status, LogsBatchQueryResultInternal body, IReadOnlyDictionary <string, string> headers)
 {
     Id      = id;
     Status  = status;
     Body    = body;
     Headers = headers;
 }
        internal static LogQueryResponse DeserializeLogQueryResponse(JsonElement element)
        {
            Optional <string> id     = default;
            Optional <int>    status = default;
            Optional <LogsBatchQueryResultInternal>          body    = default;
            Optional <IReadOnlyDictionary <string, string> > headers = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    status = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("body"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    body = LogsBatchQueryResultInternal.DeserializeLogsBatchQueryResultInternal(property.Value);
                    continue;
                }
                if (property.NameEquals("headers"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    headers = dictionary;
                    continue;
                }
            }
            return(new LogQueryResponse(id.Value, Optional.ToNullable(status), body.Value, Optional.ToDictionary(headers)));
        }