Git Product home page Git Product logo

Comments (3)

stephenpope avatar stephenpope commented on July 17, 2024 1

This is fantastic. Thank you very much :)

from dotnet-kube-client.

tintoy avatar tintoy commented on July 17, 2024

Hi - this is fairly easy to do if you've already defined your resource type. There's an additional package called KubeClient.Extensions.CustomResources that defines a base class for your resource type.

Once you have defined your specification model (the bit that goes under spec in the JSON), you can define your resource model:

public enum ThingState
{
  Draft,
  Final
}

public class MyResourceSpecV1
{
  [JsonProperty("thingState")]
  [YamlMember(Name="thingState")]
  public ThingState ThingState { get; set; }

  [YamlMember(Name="thingSizes")]
  [JsonProperty("thingSizes", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
  public List<string> ThingSizes { get; set; }
}

[KubeObject("Pod", "things.example.com/v1")]
public class MyResourceV1
  : KubeCustomResourceV1<MyResourceSpecV1>
{
}

You can then follow the steps under Extensibility to create a client for working with your resources.

Note that your code can live in its own library - the client is designed so you can layer additional models and clients on top of the existing ones regardless of where they live.

from dotnet-kube-client.

tintoy avatar tintoy commented on July 17, 2024

Oh, and the DefaultValueHandling stuff is mainly to do with whether or not you want to send default (usually null) values when calling your API. If you use DefaultValueHandling.IgnoreAndPopulate, then the field is omitted from the JSON when serialising. If you use DefaultValueHandling.Include, then the field is included in the JSON with a null value.

from dotnet-kube-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.