From 429244a10cca6d034e2bae6e70128bf50f47de02 Mon Sep 17 00:00:00 2001 From: apattar Date: Sat, 21 Dec 2024 15:50:53 +0530 Subject: [PATCH] add auth_zones in return_fields and UnmarshalJson for LBDN --- object_manager_dtc_lbdn.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/object_manager_dtc_lbdn.go b/object_manager_dtc_lbdn.go index c51a0fd..800f3d0 100644 --- a/object_manager_dtc_lbdn.go +++ b/object_manager_dtc_lbdn.go @@ -51,6 +51,24 @@ func (d *DtcLbdn) MarshalJSON() ([]byte, error) { return json.Marshal(aux) } +func (d *DtcLbdn) UnmarshalJSON(data []byte) error { + type Alias DtcLbdn + aux := &struct { + AuthZones []string `json:"auth_zones"` + *Alias + }{ + Alias: (*Alias)(d), + } + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + d.AuthZones = make([]*ZoneAuth, len(aux.AuthZones)) + for i, zone := range aux.AuthZones { + d.AuthZones[i] = &ZoneAuth{Ref: zone} + } + return nil +} + func (objMgr *ObjectManager) CreateDtcLbdn(name string, authZones []string, comment string, disable bool, autoConsolidatedMonitors bool, ea EA, lbMethod string, patterns []string, persistence uint32, pools []*DtcPoolLink, priority uint32, topology string, types []string, ttl uint32, usettl bool) (*DtcLbdn, error) { @@ -187,7 +205,7 @@ func NewDtcLbdn(ref string, name string, authZones []*ZoneAuth, comment string, func NewEmptyDtcLbdn() *DtcLbdn { dtcLbdn := &DtcLbdn{} - dtcLbdn.SetReturnFields(append(dtcLbdn.ReturnFields(), "extattrs", "disable", "auto_consolidated_monitors", "lb_method", "patterns", "persistence", "pools", "priority", "topology", "types", "health", "ttl", "use_ttl")) + dtcLbdn.SetReturnFields(append(dtcLbdn.ReturnFields(), "extattrs", "disable", "auth_zones", "auto_consolidated_monitors", "lb_method", "patterns", "persistence", "pools", "priority", "topology", "types", "health", "ttl", "use_ttl")) return dtcLbdn }