2020-03-23 00:22:45 -04:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Microsoft.Rest;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
namespace k8s.Models
|
|
|
|
|
{
|
2020-11-01 12:24:51 -08:00
|
|
|
public class KubernetesList<T> : IMetadata<V1ListMeta>, IItems<T>
|
|
|
|
|
where T : IKubernetesObject
|
2020-03-23 00:22:45 -04:00
|
|
|
{
|
2020-11-22 14:52:09 -08:00
|
|
|
public KubernetesList(IList<T> items, string apiVersion = default, string kind = default,
|
|
|
|
|
V1ListMeta metadata = default)
|
2020-03-23 00:22:45 -04:00
|
|
|
{
|
|
|
|
|
ApiVersion = apiVersion;
|
|
|
|
|
Items = items;
|
|
|
|
|
Kind = kind;
|
|
|
|
|
Metadata = metadata;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 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
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty(PropertyName = "apiVersion")]
|
|
|
|
|
public string ApiVersion { get; set; }
|
|
|
|
|
|
2020-11-01 12:24:51 -08:00
|
|
|
[JsonProperty(PropertyName = "items")]
|
|
|
|
|
public IList<T> Items { get; set; }
|
2020-03-23 00:22:45 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 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
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty(PropertyName = "kind")]
|
|
|
|
|
public string Kind { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets standard object's metadata.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty(PropertyName = "metadata")]
|
|
|
|
|
public V1ListMeta Metadata { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Validate the object.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <exception cref="ValidationException">
|
|
|
|
|
/// Thrown if validation fails
|
|
|
|
|
/// </exception>
|
|
|
|
|
public void Validate()
|
|
|
|
|
{
|
|
|
|
|
if (Items == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ValidationException(ValidationRules.CannotBeNull, "Items");
|
|
|
|
|
}
|
2020-04-23 11:40:06 -07:00
|
|
|
|
2020-03-23 00:22:45 -04:00
|
|
|
if (Items != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var element in Items.OfType<IValidate>())
|
|
|
|
|
{
|
|
|
|
|
element.Validate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|