foltik / vyos-client-go

VyOS Router HTTP API Client in Go (WIP)
MIT License
4 stars 6 forks source link

Add Types for configuration #12

Open jtcarnes opened 1 year ago

jtcarnes commented 1 year ago

As a developer, it would make integration easier by creating types that represent the Vyos configuration types. This would add simplicity of integration and type safety.

I would think it best to add one at a time the different resources as structs initially. Then, eventually creating a common interface for the structs to implement (CRUD or something similar) that could translate from something common to the proper vyos way.

An example would be something like:

type VPN struct {
  IPSec IPsec
...
}

func (v *VPN) Create() {
  op := "set"
  path :=  ["vpn"]
...
}

Each subtype would implement the path returning up which could then be joined so that you dont have to create crazy logic to understand the path.

I have talked about writing code back before, sorry for the absence, there were some health issues. I'm back and happy to start contributing if you're still maintaining.

foltik commented 1 year ago

@jtcarnes no worries at all, hope everything is okay. Health comes first!

I'm all for this proposal, this sounds super useful. I'm thinking we can layer more fine-grained services on top of the base ConfigService, kind of like what @ammmze did with ContainerImageService, but for individual config objects. We could probably reuse the ConfigService under the hood.

In the mean time, I'll reorganize some things so it's easier to add new services.