/* * 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 { /// /// View /// [DataContract] public partial class View : IEquatable { /// /// Initializes a new instance of the class. /// [JsonConstructorAttribute] protected View() { } /// /// Initializes a new instance of the class. /// /// links. /// name (required). /// properties (required). public View(ViewLinks links = default, string name = default, ViewProperties properties = default) { // to ensure "name" is required (not null) if (name == null) { throw new InvalidDataException("name is a required property for View and cannot be null"); } Name = name; // to ensure "properties" is required (not null) if (properties == null) { throw new InvalidDataException("properties is a required property for View and cannot be null"); } Properties = properties; Links = links; } /// /// Gets or Sets Links /// [DataMember(Name = "links", EmitDefaultValue = false)] public ViewLinks Links { get; set; } /// /// Gets or Sets Id /// [DataMember(Name = "id", EmitDefaultValue = false)] public string Id { get; private set; } /// /// Gets or Sets Name /// [DataMember(Name = "name", EmitDefaultValue = false)] public string Name { get; set; } /// /// Gets or Sets Properties /// [DataMember(Name = "properties", EmitDefaultValue = false)] [JsonConverter(typeof(ViewPropertiesAdapter))] 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 View {\n"); sb.Append(" Links: ").Append(Links).Append("\n"); sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" Name: ").Append(Name).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 View); } /// /// Returns true if View instances are equal /// /// Instance of View to be compared /// Boolean public bool Equals(View input) { if (input == null) { return false; } return Links != null && Links.Equals(input.Links) && ( Id == input.Id || Id != null && Id.Equals(input.Id) ) && ( Name == input.Name || Name != null && Name.Equals(input.Name) ) && 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 (Links != null) { hashCode = hashCode * 59 + Links.GetHashCode(); } if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (Properties != null) { hashCode = hashCode * 59 + Properties.GetHashCode(); } return hashCode; } } public class ViewPropertiesAdapter : 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; } } } }