* fix SA1505 and SA1508 * fix SA1116 * fix SA1009 * fix SA1019 * fix SA1127 * fix SA1128 * fix SA1134 * fix indent * allow CA2227 * fix CA1810 * using clean up * fix naming * fix CA1806 * fix await * Revert "fix CA1806" This reverts commit a3b465087fdaf26ec461272373ee9810a90de2cc. * fix dotnet format * allow SA1009
72 lines
2.4 KiB
C#
72 lines
2.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Microsoft.Rest;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace k8s.Models
|
|
{
|
|
public class KubernetesList<T> : IMetadata<V1ListMeta>, IItems<T>
|
|
where T : IKubernetesObject
|
|
{
|
|
public KubernetesList(IList<T> items, string apiVersion = default(string), string kind = default(string),
|
|
V1ListMeta metadata = default(V1ListMeta))
|
|
{
|
|
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; }
|
|
|
|
[JsonProperty(PropertyName = "items")]
|
|
public IList<T> Items { get; set; }
|
|
|
|
/// <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");
|
|
}
|
|
|
|
if (Items != null)
|
|
{
|
|
foreach (var element in Items.OfType<IValidate>())
|
|
{
|
|
element.Validate();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|