Reduce API response size by using node ID references

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ian Gulliver
2026-01-30 09:35:42 -08:00
parent d970d1db86
commit ef01aaa5c9
3 changed files with 61 additions and 23 deletions

14
link.go
View File

@@ -15,18 +15,18 @@ type Link struct {
func (l *Link) MarshalJSON() ([]byte, error) {
type linkJSON struct {
ID string `json:"id"`
NodeA interface{} `json:"node_a"`
InterfaceA string `json:"interface_a,omitempty"`
NodeB interface{} `json:"node_b"`
InterfaceB string `json:"interface_b,omitempty"`
ID string `json:"id"`
NodeAID string `json:"node_a_id"`
InterfaceA string `json:"interface_a,omitempty"`
NodeBID string `json:"node_b_id"`
InterfaceB string `json:"interface_b,omitempty"`
}
return json.Marshal(linkJSON{
ID: l.ID,
NodeA: l.NodeA.WithInterface(l.InterfaceA),
NodeAID: l.NodeA.ID,
InterfaceA: l.InterfaceA,
NodeB: l.NodeB.WithInterface(l.InterfaceB),
NodeBID: l.NodeB.ID,
InterfaceB: l.InterfaceB,
})
}