|
| 1 | +/* |
| 2 | + * pollination-server |
| 3 | + * |
| 4 | + * Pollination Server OpenAPI Definition |
| 5 | + * |
| 6 | + |
| 7 | + * Generated by: https://github.com/openapitools/openapi-generator.git |
| 8 | + */ |
| 9 | + |
| 10 | +using System; |
| 11 | +using System.Linq; |
| 12 | +using System.IO; |
| 13 | +using System.Text; |
| 14 | +using System.Text.RegularExpressions; |
| 15 | +using System.Collections; |
| 16 | +using System.Collections.Generic; |
| 17 | +using System.Collections.ObjectModel; |
| 18 | +using System.Runtime.Serialization; |
| 19 | +using Newtonsoft.Json; |
| 20 | +using Newtonsoft.Json.Converters; |
| 21 | +using System.ComponentModel.DataAnnotations; |
| 22 | + |
| 23 | + |
| 24 | +namespace PollinationSDK |
| 25 | +{ |
| 26 | + /// <summary> |
| 27 | + /// Metadata |
| 28 | + /// </summary> |
| 29 | + [DataContract(Name = "Metadata")] |
| 30 | + public partial class LicenseMetadata : CryptlexBase, IEquatable<LicenseMetadata>, IValidatableObject |
| 31 | + { |
| 32 | + /// <summary> |
| 33 | + /// Initializes a new instance of the <see cref="Metadata" /> class. |
| 34 | + /// </summary> |
| 35 | + [JsonConstructorAttribute] |
| 36 | + protected LicenseMetadata() |
| 37 | + { |
| 38 | + // Set non-required readonly properties with defaultValue |
| 39 | + this.Type = "Metadata"; |
| 40 | + } |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Initializes a new instance of the <see cref="Metadata" /> class. |
| 44 | + /// </summary> |
| 45 | + /// <param name="key">key (required).</param> |
| 46 | + /// <param name="value">value (required).</param> |
| 47 | + /// <param name="id">id.</param> |
| 48 | + /// <param name="visible">visible (default to false).</param> |
| 49 | + public LicenseMetadata |
| 50 | + ( |
| 51 | + string key, string value, // Required parameters |
| 52 | + string id= default, bool visible = false // Optional parameters |
| 53 | + ) : base()// BaseClass |
| 54 | + { |
| 55 | + // to ensure "key" is required (not null) |
| 56 | + this.Key = key ?? throw new ArgumentNullException("key is a required property for Metadata and cannot be null"); |
| 57 | + // to ensure "value" is required (not null) |
| 58 | + this.Value = value ?? throw new ArgumentNullException("value is a required property for Metadata and cannot be null"); |
| 59 | + this.Id = id; |
| 60 | + this.Visible = visible; |
| 61 | + |
| 62 | + // Set non-required readonly properties with defaultValue |
| 63 | + this.Type = "Metadata"; |
| 64 | + } |
| 65 | + |
| 66 | + //============================================== is ReadOnly |
| 67 | + /// <summary> |
| 68 | + /// Gets or Sets Type |
| 69 | + /// </summary> |
| 70 | + [DataMember(Name = "type", EmitDefaultValue = true)] |
| 71 | + public string Type { get; protected internal set; } = "Metadata"; |
| 72 | + |
| 73 | + /// <summary> |
| 74 | + /// Gets or Sets Key |
| 75 | + /// </summary> |
| 76 | + [DataMember(Name = "key", IsRequired = true, EmitDefaultValue = false)] |
| 77 | + public string Key { get; set; } |
| 78 | + /// <summary> |
| 79 | + /// Gets or Sets Value |
| 80 | + /// </summary> |
| 81 | + [DataMember(Name = "value", IsRequired = true, EmitDefaultValue = false)] |
| 82 | + public string Value { get; set; } |
| 83 | + /// <summary> |
| 84 | + /// Gets or Sets Id |
| 85 | + /// </summary> |
| 86 | + [DataMember(Name = "id", EmitDefaultValue = false)] |
| 87 | + public string Id { get; set; } |
| 88 | + /// <summary> |
| 89 | + /// Gets or Sets Visible |
| 90 | + /// </summary> |
| 91 | + [DataMember(Name = "visible", EmitDefaultValue = true)] |
| 92 | + public bool Visible { get; set; } = false; |
| 93 | + |
| 94 | + /// <summary> |
| 95 | + /// Returns the string presentation of the object |
| 96 | + /// </summary> |
| 97 | + /// <returns>String presentation of the object</returns> |
| 98 | + public override string ToString() |
| 99 | + { |
| 100 | + return "Metadata"; |
| 101 | + } |
| 102 | + |
| 103 | + /// <summary> |
| 104 | + /// Returns the string presentation of the object |
| 105 | + /// </summary> |
| 106 | + /// <returns>String presentation of the object</returns> |
| 107 | + public override string ToString(bool detailed) |
| 108 | + { |
| 109 | + if (!detailed) |
| 110 | + return this.ToString(); |
| 111 | + |
| 112 | + var sb = new StringBuilder(); |
| 113 | + sb.Append("Metadata:\n"); |
| 114 | + sb.Append(" Type: ").Append(Type).Append("\n"); |
| 115 | + sb.Append(" Key: ").Append(Key).Append("\n"); |
| 116 | + sb.Append(" Value: ").Append(Value).Append("\n"); |
| 117 | + sb.Append(" Id: ").Append(Id).Append("\n"); |
| 118 | + sb.Append(" Visible: ").Append(Visible).Append("\n"); |
| 119 | + return sb.ToString(); |
| 120 | + } |
| 121 | + |
| 122 | + /// <summary> |
| 123 | + /// Returns the object from JSON string |
| 124 | + /// </summary> |
| 125 | + /// <returns>Metadata object</returns> |
| 126 | + public static LicenseMetadata FromJson(string json) |
| 127 | + { |
| 128 | + var obj = JsonConvert.DeserializeObject<LicenseMetadata>(json, JsonSetting.AnyOfConvertSetting); |
| 129 | + if (obj == null) |
| 130 | + return null; |
| 131 | + return obj.Type.ToLower() == obj.GetType().Name.ToLower() ? obj : null; |
| 132 | + } |
| 133 | + |
| 134 | + /// <summary> |
| 135 | + /// Creates a new instance with the same properties. |
| 136 | + /// </summary> |
| 137 | + /// <returns>Metadata object</returns> |
| 138 | + public virtual LicenseMetadata DuplicateMetadata() |
| 139 | + { |
| 140 | + return FromJson(this.ToJson()); |
| 141 | + } |
| 142 | + |
| 143 | + /// <summary> |
| 144 | + /// Creates a new instance with the same properties. |
| 145 | + /// </summary> |
| 146 | + /// <returns>OpenAPIGenBaseModel</returns> |
| 147 | + public override OpenAPIGenBaseModel Duplicate() |
| 148 | + { |
| 149 | + return DuplicateMetadata(); |
| 150 | + } |
| 151 | + |
| 152 | + /// <summary> |
| 153 | + /// Creates a new instance with the same properties. |
| 154 | + /// </summary> |
| 155 | + /// <returns>OpenAPIGenBaseModel</returns> |
| 156 | + public override CryptlexBase DuplicateCryptlexBase() |
| 157 | + { |
| 158 | + return DuplicateMetadata(); |
| 159 | + } |
| 160 | + |
| 161 | + /// <summary> |
| 162 | + /// Returns true if objects are equal |
| 163 | + /// </summary> |
| 164 | + /// <param name="input">Object to be compared</param> |
| 165 | + /// <returns>Boolean</returns> |
| 166 | + public override bool Equals(object input) |
| 167 | + { |
| 168 | + input = input is AnyOf anyOf ? anyOf.Obj : input; |
| 169 | + return this.Equals(input as LicenseMetadata); |
| 170 | + } |
| 171 | + |
| 172 | + /// <summary> |
| 173 | + /// Returns true if Metadata instances are equal |
| 174 | + /// </summary> |
| 175 | + /// <param name="input">Instance of Metadata to be compared</param> |
| 176 | + /// <returns>Boolean</returns> |
| 177 | + public bool Equals(LicenseMetadata input) |
| 178 | + { |
| 179 | + if (input == null) |
| 180 | + return false; |
| 181 | + return base.Equals(input) && |
| 182 | + ( |
| 183 | + this.Key == input.Key || |
| 184 | + (this.Key != null && |
| 185 | + this.Key.Equals(input.Key)) |
| 186 | + ) && base.Equals(input) && |
| 187 | + ( |
| 188 | + this.Value == input.Value || |
| 189 | + (this.Value != null && |
| 190 | + this.Value.Equals(input.Value)) |
| 191 | + ) && base.Equals(input) && |
| 192 | + ( |
| 193 | + this.Id == input.Id || |
| 194 | + (this.Id != null && |
| 195 | + this.Id.Equals(input.Id)) |
| 196 | + ) && base.Equals(input) && |
| 197 | + ( |
| 198 | + this.Visible == input.Visible || |
| 199 | + (this.Visible != null && |
| 200 | + this.Visible.Equals(input.Visible)) |
| 201 | + ) && base.Equals(input) && |
| 202 | + ( |
| 203 | + this.Type == input.Type || |
| 204 | + (this.Type != null && |
| 205 | + this.Type.Equals(input.Type)) |
| 206 | + ); |
| 207 | + } |
| 208 | + |
| 209 | + /// <summary> |
| 210 | + /// Gets the hash code |
| 211 | + /// </summary> |
| 212 | + /// <returns>Hash code</returns> |
| 213 | + public override int GetHashCode() |
| 214 | + { |
| 215 | + unchecked // Overflow is fine, just wrap |
| 216 | + { |
| 217 | + int hashCode = base.GetHashCode(); |
| 218 | + if (this.Key != null) |
| 219 | + hashCode = hashCode * 59 + this.Key.GetHashCode(); |
| 220 | + if (this.Value != null) |
| 221 | + hashCode = hashCode * 59 + this.Value.GetHashCode(); |
| 222 | + if (this.Id != null) |
| 223 | + hashCode = hashCode * 59 + this.Id.GetHashCode(); |
| 224 | + if (this.Visible != null) |
| 225 | + hashCode = hashCode * 59 + this.Visible.GetHashCode(); |
| 226 | + if (this.Type != null) |
| 227 | + hashCode = hashCode * 59 + this.Type.GetHashCode(); |
| 228 | + return hashCode; |
| 229 | + } |
| 230 | + } |
| 231 | + |
| 232 | + /// <summary> |
| 233 | + /// To validate all properties of the instance |
| 234 | + /// </summary> |
| 235 | + /// <param name="validationContext">Validation context</param> |
| 236 | + /// <returns>Validation Result</returns> |
| 237 | + IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext) |
| 238 | + { |
| 239 | + foreach(var x in base.BaseValidate(validationContext)) yield return x; |
| 240 | + |
| 241 | + |
| 242 | + // Type (string) pattern |
| 243 | + Regex regexType = new Regex(@"^Metadata$", RegexOptions.CultureInvariant); |
| 244 | + if (false == regexType.Match(this.Type).Success) |
| 245 | + { |
| 246 | + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Type, must match a pattern of " + regexType, new [] { "Type" }); |
| 247 | + } |
| 248 | + |
| 249 | + yield break; |
| 250 | + } |
| 251 | + } |
| 252 | +} |
0 commit comments