Files
csharp/gen/KubernetesGenerator/Model.cs.template

98 lines
2.9 KiB
Plaintext
Raw Normal View History

// <auto-generated>
// Code generated by https://github.com/kubernetes-client/csharp/tree/master/gen/KubernetesGenerator
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace k8s.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
/// <summary>
/// {{ToXmlDoc def.description}}
/// </summary>
public partial class {{clz}}
{
/// <summary>
/// Initializes a new instance of the {{GetClassName def}} class.
/// </summary>
public {{clz}}()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the {{GetClassName def}} class.
/// </summary>
{{#properties}}
{{#isRequired}}
/// <param name="{{GetDotNetName name "fieldctor"}}">
/// {{ToXmlDoc description}}
/// </param>
{{/isRequired}}
{{/properties}}
{{#properties}}
{{^isRequired}}
/// <param name="{{GetDotNetName name "fieldctor"}}">
/// {{ToXmlDoc description}}
/// </param>
{{/isRequired}}
{{/properties}}
public {{clz}}({{GetModelCtorParam def}})
{
{{#properties}}
{{GetDotNetName name "field"}} = {{GetDotNetName name "fieldctor"}};
{{/properties}}
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
{{#properties}}
/// <summary>
/// {{ToXmlDoc description}}
/// </summary>
[JsonProperty(PropertyName = "{{name}}")]
public {{GetDotNetType .}} {{GetDotNetName name "field"}} { get; set; }
{{/properties}}
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
{{#properties}}
{{#IfType . "object"}}
{{#isRequired}}
if ({{GetDotNetName name "field"}} == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "{{GetDotNetName name "field"}}");
}
{{/isRequired}}
{{/IfType . "object"}}
{{/properties}}
{{#properties}}
{{#IfType . "object"}}
{{GetDotNetName name "field"}}?.Validate();
{{/IfType . "object"}}
{{#IfType . "objectarray"}}
foreach(var obj in {{GetDotNetName name "field"}})
{
obj.Validate();
}
{{/IfType . "objectarray"}}
{{/properties}}
}
}
}