Example #1
0
 internal BatchQueryResponse(string id, int?status, LogsBatchQueryResult body, IReadOnlyDictionary <string, string> headers)
 {
     Id      = id;
     Status  = status;
     _body   = body;
     Headers = headers;
 }
        internal static BatchQueryResponse DeserializeBatchQueryResponse(JsonElement element)
        {
            Optional <string> id                 = default;
            Optional <int>    status             = default;
            Optional <LogsBatchQueryResult> 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 = LogsBatchQueryResult.DeserializeLogsBatchQueryResult(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 BatchQueryResponse(id.Value, Optional.ToNullable(status), body.Value, Optional.ToDictionary(headers)));
        }