internal static TimeSeriesHierarchyOrError DeserializeTimeSeriesHierarchyOrError(JsonElement element)
        {
            Optional <TimeSeriesHierarchy> hierarchy = default;
            Optional <TsiErrorBody>        error     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("hierarchy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    hierarchy = TimeSeriesHierarchy.DeserializeTimeSeriesHierarchy(property.Value);
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = TsiErrorBody.DeserializeTsiErrorBody(property.Value);
                    continue;
                }
            }
            return(new TimeSeriesHierarchyOrError(hierarchy.Value, error.Value));
        }
Exemplo n.º 2
0
        internal static InstanceOrError DeserializeInstanceOrError(JsonElement element)
        {
            Optional <TimeSeriesInstance> instance = default;
            Optional <TsiErrorBody>       error    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("instance"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    instance = TimeSeriesInstance.DeserializeTimeSeriesInstance(property.Value);
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = TsiErrorBody.DeserializeTsiErrorBody(property.Value);
                    continue;
                }
            }
            return(new InstanceOrError(instance.Value, error.Value));
        }
Exemplo n.º 3
0
 internal TsiErrorBody(string code, string message, string target, TsiErrorBody innerError, IReadOnlyList <TsiErrorDetails> details, IReadOnlyDictionary <string, object> additionalProperties)
 {
     Code                 = code;
     Message              = message;
     Target               = target;
     InnerError           = innerError;
     Details              = details;
     AdditionalProperties = additionalProperties;
 }
        internal static HierarchiesBatchResponse DeserializeHierarchiesBatchResponse(JsonElement element)
        {
            Optional <IReadOnlyList <TimeSeriesHierarchyOrError> > @get = default;
            Optional <IReadOnlyList <TimeSeriesHierarchyOrError> > put  = default;
            Optional <IReadOnlyList <TsiErrorBody> > delete             = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("get"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TimeSeriesHierarchyOrError> array = new List <TimeSeriesHierarchyOrError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TimeSeriesHierarchyOrError.DeserializeTimeSeriesHierarchyOrError(item));
                    }
                    @get = array;
                    continue;
                }
                if (property.NameEquals("put"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TimeSeriesHierarchyOrError> array = new List <TimeSeriesHierarchyOrError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TimeSeriesHierarchyOrError.DeserializeTimeSeriesHierarchyOrError(item));
                    }
                    put = array;
                    continue;
                }
                if (property.NameEquals("delete"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TsiErrorBody> array = new List <TsiErrorBody>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TsiErrorBody.DeserializeTsiErrorBody(item));
                    }
                    delete = array;
                    continue;
                }
            }
            return(new HierarchiesBatchResponse(Optional.ToList(@get), Optional.ToList(put), Optional.ToList(delete)));
        }