/*
* InfluxDB OSS API Service
*
* The InfluxDB v2 API provides a programmatic interface for all interactions with InfluxDB. Access the InfluxDB API using the `/api/v2/` endpoint.
*
* OpenAPI spec version: 2.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using OpenAPIDateConverter = InfluxDB.Client.Api.Client.OpenAPIDateConverter;
namespace InfluxDB.Client.Api.Domain
{
///
/// TemplateChart
///
[DataContract]
public partial class TemplateChart : IEquatable
{
///
/// Initializes a new instance of the class.
///
/// xPos.
/// yPos.
/// height.
/// width.
/// properties.
public TemplateChart(int? xPos = default, int? yPos = default, int? height = default, int? width = default,
ViewProperties properties = default)
{
XPos = xPos;
YPos = yPos;
Height = height;
Width = width;
Properties = properties;
}
///
/// Gets or Sets XPos
///
[DataMember(Name = "xPos", EmitDefaultValue = false)]
public int? XPos { get; set; }
///
/// Gets or Sets YPos
///
[DataMember(Name = "yPos", EmitDefaultValue = false)]
public int? YPos { get; set; }
///
/// Gets or Sets Height
///
[DataMember(Name = "height", EmitDefaultValue = false)]
public int? Height { get; set; }
///
/// Gets or Sets Width
///
[DataMember(Name = "width", EmitDefaultValue = false)]
public int? Width { get; set; }
///
/// Gets or Sets Properties
///
[DataMember(Name = "properties", EmitDefaultValue = false)]
[JsonConverter(typeof(TemplateChartPropertiesAdapter))]
public ViewProperties Properties { get; set; }
///
/// Returns the string presentation of the object
///
/// String presentation of the object
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class TemplateChart {\n");
sb.Append(" XPos: ").Append(XPos).Append("\n");
sb.Append(" YPos: ").Append(YPos).Append("\n");
sb.Append(" Height: ").Append(Height).Append("\n");
sb.Append(" Width: ").Append(Width).Append("\n");
sb.Append(" Properties: ").Append(Properties).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
///
/// Returns the JSON string presentation of the object
///
/// JSON string presentation of the object
public virtual string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
///
/// Returns true if objects are equal
///
/// Object to be compared
/// Boolean
public override bool Equals(object input)
{
return Equals(input as TemplateChart);
}
///
/// Returns true if TemplateChart instances are equal
///
/// Instance of TemplateChart to be compared
/// Boolean
public bool Equals(TemplateChart input)
{
if (input == null)
{
return false;
}
return
(
XPos == input.XPos ||
XPos != null && XPos.Equals(input.XPos)
) &&
(
YPos == input.YPos ||
YPos != null && YPos.Equals(input.YPos)
) &&
(
Height == input.Height ||
Height != null && Height.Equals(input.Height)
) &&
(
Width == input.Width ||
Width != null && Width.Equals(input.Width)
) && Properties != null && Properties.Equals(input.Properties);
}
///
/// Gets the hash code
///
/// Hash code
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
var hashCode = 41;
if (XPos != null)
{
hashCode = hashCode * 59 + XPos.GetHashCode();
}
if (YPos != null)
{
hashCode = hashCode * 59 + YPos.GetHashCode();
}
if (Height != null)
{
hashCode = hashCode * 59 + Height.GetHashCode();
}
if (Width != null)
{
hashCode = hashCode * 59 + Width.GetHashCode();
}
if (Properties != null)
{
hashCode = hashCode * 59 + Properties.GetHashCode();
}
return hashCode;
}
}
public class TemplateChartPropertiesAdapter : JsonConverter
{
private static readonly Dictionary Types =
new Dictionary(new Client.DiscriminatorComparer())
{
{
new[] { "LinePlusSingleStatProperties", "line-plus-single-stat", "chronograf-v2" },
typeof(LinePlusSingleStatProperties)
},
{ new[] { "XYViewProperties", "xy", "chronograf-v2" }, typeof(XYViewProperties) },
{ new[] { "single-stat", "chronograf-v2" }, typeof(SingleStatViewProperties) },
{ new[] { "histogram", "chronograf-v2" }, typeof(HistogramViewProperties) },
{ new[] { "gauge", "chronograf-v2" }, typeof(GaugeViewProperties) },
{ new[] { "table", "chronograf-v2" }, typeof(TableViewProperties) },
{ new[] { "simple-table", "chronograf-v2" }, typeof(SimpleTableViewProperties) },
{ new[] { "markdown", "chronograf-v2" }, typeof(MarkdownViewProperties) },
{ new[] { "check", "chronograf-v2" }, typeof(CheckViewProperties) },
{ new[] { "ScatterViewProperties", "scatter", "chronograf-v2" }, typeof(ScatterViewProperties) },
{ new[] { "HeatmapViewProperties", "heatmap", "chronograf-v2" }, typeof(HeatmapViewProperties) },
{ new[] { "MosaicViewProperties", "mosaic", "chronograf-v2" }, typeof(MosaicViewProperties) },
{ new[] { "BandViewProperties", "band", "chronograf-v2" }, typeof(BandViewProperties) }
};
public override bool CanConvert(Type objectType)
{
return false;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
serializer.Serialize(writer, value);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
JsonSerializer serializer)
{
return Deserialize(reader, objectType, serializer);
}
private object Deserialize(JsonReader reader, Type objectType, JsonSerializer serializer)
{
switch (reader.TokenType)
{
case JsonToken.StartObject:
var jObject = Newtonsoft.Json.Linq.JObject.Load(reader);
var discriminator = new[] { "timeFormat", "type", "shape" }
.Select(key => jObject[key].ToString()).ToArray();
Types.TryGetValue(discriminator, out var type);
return serializer.Deserialize(jObject.CreateReader(), type);
case JsonToken.StartArray:
return DeserializeArray(reader, objectType, serializer);
default:
return serializer.Deserialize(reader, objectType);
}
}
private IList DeserializeArray(JsonReader reader, Type targetType, JsonSerializer serializer)
{
var elementType = targetType.GenericTypeArguments.FirstOrDefault();
var list = (IList)Activator.CreateInstance(targetType);
while (reader.Read() && reader.TokenType != JsonToken.EndArray)
list.Add(Deserialize(reader, elementType, serializer));
return list;
}
}
}
}