using System.Collections.Generic; using System.Linq; using Microsoft.Rest; using Newtonsoft.Json; namespace k8s.Models { public class KubernetesList : IMetadata, IItems where T : IKubernetesObject { public KubernetesList(IList items, string apiVersion = default(string), string kind = default(string), V1ListMeta metadata = default(V1ListMeta)) { ApiVersion = apiVersion; Items = items; Kind = kind; Metadata = metadata; } /// /// Gets or sets aPIVersion defines the versioned schema of this /// representation of an object. Servers should convert recognized /// schemas to the latest internal value, and may reject unrecognized /// values. More info: /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources /// [JsonProperty(PropertyName = "apiVersion")] public string ApiVersion { get; set; } [JsonProperty(PropertyName = "items")] public IList Items { get; set; } /// /// Gets or sets kind is a string value representing the REST resource /// this object represents. Servers may infer this from the endpoint /// the client submits requests to. Cannot be updated. In CamelCase. /// More info: /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds /// [JsonProperty(PropertyName = "kind")] public string Kind { get; set; } /// /// Gets or sets standard object's metadata. /// [JsonProperty(PropertyName = "metadata")] public V1ListMeta Metadata { get; set; } /// /// Validate the object. /// /// /// Thrown if validation fails /// public void Validate() { if (Items == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Items"); } if (Items != null) { foreach (var element in Items.OfType()) { element.Validate(); } } } } }