From 420453449cbc5d8388fd6d7d0255330c70072ccf Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Mon, 12 Sep 2022 11:15:45 -0700 Subject: [PATCH 1/2] Add broader set of fields for ZoneAuth resource --- object_manager.go | 34 +------------------------ object_manager_test.go | 19 ++++++++++---- object_manager_zone_auth.go | 50 +++++++++++++++++++++++++++++++++++++ objects.go | 24 +++++++++++++----- objects_test.go | 34 ++++++++++++++++++++++--- 5 files changed, 114 insertions(+), 47 deletions(-) create mode 100644 object_manager_zone_auth.go diff --git a/object_manager.go b/object_manager.go index ee09709a..490579e6 100644 --- a/object_manager.go +++ b/object_manager.go @@ -15,7 +15,7 @@ type IBObjectManager interface { AllocateNetworkContainer(netview string, cidr string, isIPv6 bool, prefixLen uint, comment string, eas EA) (netContainer *NetworkContainer, err error) CreateARecord(netView string, dnsView string, name string, cidr string, ipAddr string, ttl uint32, useTTL bool, comment string, ea EA) (*RecordA, error) CreateAAAARecord(netView string, dnsView string, recordName string, cidr string, ipAddr string, useTtl bool, ttl uint32, comment string, eas EA) (*RecordAAAA, error) - CreateZoneAuth(fqdn string, ea EA) (*ZoneAuth, error) + CreateZoneAuth(fqdn string, nsGroup string, restartIfNeeded bool, comment string, SoaDefaultTtl int, SoaExpire int, SoaNegativeTtl int, SoaRefresh int, SoaRetry int, ea EA) (*ZoneAuth, error) CreateCNAMERecord(dnsview string, canonical string, recordname string, useTtl bool, ttl uint32, comment string, eas EA) (*RecordCNAME, error) CreateDefaultNetviews(globalNetview string, localNetview string) (globalNetviewRef string, localNetviewRef string, err error) CreateEADefinition(eadef EADefinition) (*EADefinition, error) @@ -194,38 +194,6 @@ func (objMgr *ObjectManager) GetGridInfo() ([]Grid, error) { return res, err } -// CreateZoneAuth creates zones and subs by passing fqdn -func (objMgr *ObjectManager) CreateZoneAuth( - fqdn string, - eas EA) (*ZoneAuth, error) { - - zoneAuth := NewZoneAuth(ZoneAuth{ - Fqdn: fqdn, - Ea: eas}) - - ref, err := objMgr.connector.CreateObject(zoneAuth) - zoneAuth.Ref = ref - return zoneAuth, err -} - -// Retreive a authortative zone by ref -func (objMgr *ObjectManager) GetZoneAuthByRef(ref string) (*ZoneAuth, error) { - res := NewZoneAuth(ZoneAuth{}) - - if ref == "" { - return nil, fmt.Errorf("empty reference to an object is not allowed") - } - - err := objMgr.connector.GetObject( - res, ref, NewQueryParams(false, nil), res) - return res, err -} - -// DeleteZoneAuth deletes an auth zone -func (objMgr *ObjectManager) DeleteZoneAuth(ref string) (string, error) { - return objMgr.connector.DeleteObject(ref) -} - // GetZoneAuth returns the authoritatives zones func (objMgr *ObjectManager) GetZoneAuth() ([]ZoneAuth, error) { var res []ZoneAuth diff --git a/object_manager_test.go b/object_manager_test.go index 92ee6ac0..37e583f9 100644 --- a/object_manager_test.go +++ b/object_manager_test.go @@ -310,12 +310,22 @@ var _ = Describe("Object Manager", func() { Describe("Create Zone Auth", func() { cmpType := "Docker" tenantID := "01234567890abcdef01234567890abcdef" + nsGroup := "mynameservers" + restartIfNeeded := true fqdn := "azone.example.com" + comment := "test comment" + soaDefaultTtl := 3600 + soaExpire := 2419200 + soaNegativeTtl := 900 + soaRefresh := 10800 + soaRetry := 3600 fakeRefReturn := "zone_auth/ZG5zLnpvbmUkLl9kZWZhdWx0LnphLmNvLmFic2EuY2Fhcy5vaG15Z2xiLmdzbGJpYmNsaWVudA:dzone.example.com/default" zaFakeConnector := &fakeConnector{ - createObjectObj: NewZoneAuth(ZoneAuth{Fqdn: fqdn}), - resultObject: NewZoneAuth(ZoneAuth{Fqdn: fqdn, Ref: fakeRefReturn}), - fakeRefReturn: fakeRefReturn, + createObjectObj: NewZoneAuth(ZoneAuth{Fqdn: fqdn, NsGroup: nsGroup, RestartIfNeeded: restartIfNeeded, Comment: comment, + SoaDefaultTtl: soaDefaultTtl, SoaExpire: soaExpire, SoaNegativeTtl: soaNegativeTtl, SoaRefresh: soaRefresh, SoaRetry: soaRetry}), + resultObject: NewZoneAuth(ZoneAuth{Fqdn: fqdn, NsGroup: nsGroup, RestartIfNeeded: restartIfNeeded, Comment: comment, + SoaDefaultTtl: soaDefaultTtl, SoaExpire: soaExpire, SoaNegativeTtl: soaNegativeTtl, SoaRefresh: soaRefresh, SoaRetry: soaRetry, Ref: fakeRefReturn}), + fakeRefReturn: fakeRefReturn, } objMgr := NewObjectManager(zaFakeConnector, cmpType, tenantID) @@ -333,7 +343,7 @@ var _ = Describe("Object Manager", func() { var actualZoneAuth *ZoneAuth var err error It("should pass expected ZoneAuth Object to CreateObject", func() { - actualZoneAuth, err = objMgr.CreateZoneAuth(fqdn, ea) + actualZoneAuth, err = objMgr.CreateZoneAuth(fqdn, nsGroup, restartIfNeeded, comment, soaDefaultTtl, soaExpire, soaNegativeTtl, soaRefresh, soaRetry, ea) }) It("should return expected ZoneAuth Object", func() { Expect(actualZoneAuth).To(Equal(zaFakeConnector.resultObject)) @@ -361,7 +371,6 @@ var _ = Describe("Object Manager", func() { It("should pass expected ZoneAuth Object to GetObject", func() { actualZoneAuth, err = objMgr.GetZoneAuthByRef(fakeRefReturn) }) - fmt.Printf("doodo %s", actualZoneAuth) It("should return expected ZoneAuth Object", func() { Expect(actualZoneAuth).To(Equal(zdFakeConnector.resultObject)) Expect(err).To(BeNil()) diff --git a/object_manager_zone_auth.go b/object_manager_zone_auth.go new file mode 100644 index 00000000..bb8b42b5 --- /dev/null +++ b/object_manager_zone_auth.go @@ -0,0 +1,50 @@ +package ibclient + +import "fmt" + +func (objMgr *ObjectManager) CreateZoneAuth( + fqdn string, + nsGroup string, + restartIfNeeded bool, + comment string, + soaDefaultTtl int, + soaExpire int, + soaNegativeTtl int, + soaRefresh int, + soaRetry int, + eas EA) (*ZoneAuth, error) { + + zoneAuth := NewZoneAuth(ZoneAuth{ + Fqdn: fqdn, + NsGroup: nsGroup, + RestartIfNeeded: restartIfNeeded, + Comment: comment, + SoaDefaultTtl: soaDefaultTtl, + SoaExpire: soaExpire, + SoaNegativeTtl: soaNegativeTtl, + SoaRefresh: soaRefresh, + SoaRetry: soaRetry, + Ea: eas}) + + ref, err := objMgr.connector.CreateObject(zoneAuth) + zoneAuth.Ref = ref + return zoneAuth, err +} + +// Retreive a authortative zone by ref +func (objMgr *ObjectManager) GetZoneAuthByRef(ref string) (*ZoneAuth, error) { + res := NewZoneAuth(ZoneAuth{}) + + if ref == "" { + return nil, fmt.Errorf("empty reference to an object is not allowed") + } + + err := objMgr.connector.GetObject( + res, ref, NewQueryParams(false, nil), res) + return res, err +} + +// DeleteZoneAuth deletes an auth zone +func (objMgr *ObjectManager) DeleteZoneAuth(ref string) (string, error) { + return objMgr.connector.DeleteObject(ref) +} diff --git a/objects.go b/objects.go index f0310870..c218bfc2 100644 --- a/objects.go +++ b/objects.go @@ -824,17 +824,29 @@ func NewRecordTXT( } type ZoneAuth struct { - IBBase `json:"-"` - Ref string `json:"_ref,omitempty"` - Fqdn string `json:"fqdn,omitempty"` - View string `json:"view,omitempty"` - Ea EA `json:"extattrs"` + IBBase `json:"-"` + Ref string `json:"_ref,omitempty"` + Fqdn string `json:"fqdn,omitempty"` + View string `json:"view,omitempty"` + NsGroup string `json:"ns_group,omitempty"` + RestartIfNeeded bool `json:"restart_if_needed"` + Comment string `json:"comment"` + SoaDefaultTtl int `json:"soa_default_ttl"` + SoaExpire int `json:"soa_expire"` + SoaNegativeTtl int `json:"soa_negative_ttl"` + SoaRefresh int `json:"soa_refresh"` + SoaRetry int `json:"soa_retry"` + Ea EA `json:"extattrs"` } func NewZoneAuth(za ZoneAuth) *ZoneAuth { res := za res.objectType = "zone_auth" - res.returnFields = []string{"extattrs", "fqdn", "view"} + // restart_if_needed not included here because it is not readable + res.returnFields = []string{ + "extattrs", "fqdn", "view", "ns_group", "comment", + "soa_default_ttl", "soa_expire", "soa_negative_ttl", "soa_refresh", "soa_retry", + } return &res } diff --git a/objects_test.go b/objects_test.go index eeb645a2..4ed2406e 100644 --- a/objects_test.go +++ b/objects_test.go @@ -2,6 +2,7 @@ package ibclient import ( "encoding/json" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -628,20 +629,47 @@ var _ = Describe("Objects", func() { Context("ZoneAuth object", func() { fqdn := "domain.com" + ns_group := "mynameservers" + restart_if_needed := true + comment := "test comment" + soa_default_ttl := 3600 + soa_expire := 2419200 + soa_negative_ttl := 900 + soa_refresh := 10800 + soa_retry := 3600 view := "default" za := NewZoneAuth(ZoneAuth{ - Fqdn: fqdn, - View: view}) + Fqdn: fqdn, + NsGroup: ns_group, + RestartIfNeeded: restart_if_needed, + Comment: comment, + SoaDefaultTtl: soa_default_ttl, + SoaExpire: soa_expire, + SoaNegativeTtl: soa_negative_ttl, + SoaRefresh: soa_refresh, + SoaRetry: soa_retry, + View: view}) It("should set fields correctly", func() { Expect(za.Fqdn).To(Equal(fqdn)) + Expect(za.NsGroup).To(Equal(ns_group)) + Expect(za.RestartIfNeeded).To(Equal(restart_if_needed)) + Expect(za.Comment).To(Equal(comment)) + Expect(za.SoaDefaultTtl).To(Equal(soa_default_ttl)) + Expect(za.SoaExpire).To(Equal(soa_expire)) + Expect(za.SoaNegativeTtl).To(Equal(soa_negative_ttl)) + Expect(za.SoaRefresh).To(Equal(soa_refresh)) + Expect(za.SoaRetry).To(Equal(soa_retry)) Expect(za.View).To(Equal(view)) }) It("should set base fields correctly", func() { Expect(za.ObjectType()).To(Equal("zone_auth")) - Expect(za.ReturnFields()).To(ConsistOf("extattrs", "fqdn", "view")) + Expect(za.ReturnFields()).To(ConsistOf( + "extattrs", "fqdn", "view", "ns_group", "comment", + "soa_default_ttl", "soa_expire", "soa_negative_ttl", "soa_refresh", "soa_retry", + )) }) }) From df51f5aa3a16f1cca55738e57853c8844c8db1ef Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Thu, 9 Feb 2023 16:00:13 -0800 Subject: [PATCH 2/2] Add requested fields and UpdateZoneAuth function --- object_manager.go | 3 ++- object_manager_test.go | 54 ++++++++++++++++++++++++++++++++----- object_manager_zone_auth.go | 52 ++++++++++++++++++++++++++++++++--- objects.go | 6 +++-- objects_test.go | 6 ++++- 5 files changed, 107 insertions(+), 14 deletions(-) diff --git a/object_manager.go b/object_manager.go index 490579e6..977390f4 100644 --- a/object_manager.go +++ b/object_manager.go @@ -15,7 +15,7 @@ type IBObjectManager interface { AllocateNetworkContainer(netview string, cidr string, isIPv6 bool, prefixLen uint, comment string, eas EA) (netContainer *NetworkContainer, err error) CreateARecord(netView string, dnsView string, name string, cidr string, ipAddr string, ttl uint32, useTTL bool, comment string, ea EA) (*RecordA, error) CreateAAAARecord(netView string, dnsView string, recordName string, cidr string, ipAddr string, useTtl bool, ttl uint32, comment string, eas EA) (*RecordAAAA, error) - CreateZoneAuth(fqdn string, nsGroup string, restartIfNeeded bool, comment string, SoaDefaultTtl int, SoaExpire int, SoaNegativeTtl int, SoaRefresh int, SoaRetry int, ea EA) (*ZoneAuth, error) + CreateZoneAuth(dnsview string, fqdn string, nsGroup string, restartIfNeeded bool, comment string, soaDefaultTtl int, soaExpire int, soaNegativeTtl int, soaRefresh int, soaRetry int, zoneFormat string, ea EA) (*ZoneAuth, error) CreateCNAMERecord(dnsview string, canonical string, recordname string, useTtl bool, ttl uint32, comment string, eas EA) (*RecordCNAME, error) CreateDefaultNetviews(globalNetview string, localNetview string) (globalNetviewRef string, localNetviewRef string, err error) CreateEADefinition(eadef EADefinition) (*EADefinition, error) @@ -79,6 +79,7 @@ type IBObjectManager interface { UpdatePTRRecord(ref string, netview string, ptrdname string, name string, cidr string, ipAddr string, useTtl bool, ttl uint32, comment string, setEas EA) (*RecordPTR, error) UpdateTXTRecord(ref string, recordName string, text string, ttl uint32, useTtl bool, comment string, eas EA) (*RecordTXT, error) UpdateARecord(ref string, name string, ipAddr string, cidr string, netview string, ttl uint32, useTTL bool, comment string, eas EA) (*RecordA, error) + UpdateZoneAuth(ref string, dnsview string, nsGroup string, restartIfNeeded bool, comment string, soaDefaultTtl int, soaExpire int, soaNegativeTtl int, soaRefresh int, soaRetry int, ea EA) (*ZoneAuth, error) UpdateZoneDelegated(ref string, delegate_to []NameServer) (*ZoneDelegated, error) } diff --git a/object_manager_test.go b/object_manager_test.go index 37e583f9..ef146032 100644 --- a/object_manager_test.go +++ b/object_manager_test.go @@ -310,6 +310,7 @@ var _ = Describe("Object Manager", func() { Describe("Create Zone Auth", func() { cmpType := "Docker" tenantID := "01234567890abcdef01234567890abcdef" + dnsview := "default" nsGroup := "mynameservers" restartIfNeeded := true fqdn := "azone.example.com" @@ -319,12 +320,13 @@ var _ = Describe("Object Manager", func() { soaNegativeTtl := 900 soaRefresh := 10800 soaRetry := 3600 + zoneFormat := "FORWARD" fakeRefReturn := "zone_auth/ZG5zLnpvbmUkLl9kZWZhdWx0LnphLmNvLmFic2EuY2Fhcy5vaG15Z2xiLmdzbGJpYmNsaWVudA:dzone.example.com/default" zaFakeConnector := &fakeConnector{ - createObjectObj: NewZoneAuth(ZoneAuth{Fqdn: fqdn, NsGroup: nsGroup, RestartIfNeeded: restartIfNeeded, Comment: comment, - SoaDefaultTtl: soaDefaultTtl, SoaExpire: soaExpire, SoaNegativeTtl: soaNegativeTtl, SoaRefresh: soaRefresh, SoaRetry: soaRetry}), - resultObject: NewZoneAuth(ZoneAuth{Fqdn: fqdn, NsGroup: nsGroup, RestartIfNeeded: restartIfNeeded, Comment: comment, - SoaDefaultTtl: soaDefaultTtl, SoaExpire: soaExpire, SoaNegativeTtl: soaNegativeTtl, SoaRefresh: soaRefresh, SoaRetry: soaRetry, Ref: fakeRefReturn}), + createObjectObj: NewZoneAuth(ZoneAuth{View: dnsview, Fqdn: fqdn, NsGroup: nsGroup, RestartIfNeeded: restartIfNeeded, Comment: comment, + SoaDefaultTtl: soaDefaultTtl, SoaExpire: soaExpire, SoaNegativeTtl: soaNegativeTtl, SoaRefresh: soaRefresh, SoaRetry: soaRetry, ZoneFormat: zoneFormat}), + resultObject: NewZoneAuth(ZoneAuth{View: dnsview, Fqdn: fqdn, NsGroup: nsGroup, RestartIfNeeded: restartIfNeeded, Comment: comment, + SoaDefaultTtl: soaDefaultTtl, SoaExpire: soaExpire, SoaNegativeTtl: soaNegativeTtl, SoaRefresh: soaRefresh, SoaRetry: soaRetry, ZoneFormat: zoneFormat, Ref: fakeRefReturn}), fakeRefReturn: fakeRefReturn, } @@ -343,7 +345,7 @@ var _ = Describe("Object Manager", func() { var actualZoneAuth *ZoneAuth var err error It("should pass expected ZoneAuth Object to CreateObject", func() { - actualZoneAuth, err = objMgr.CreateZoneAuth(fqdn, nsGroup, restartIfNeeded, comment, soaDefaultTtl, soaExpire, soaNegativeTtl, soaRefresh, soaRetry, ea) + actualZoneAuth, err = objMgr.CreateZoneAuth(dnsview, fqdn, nsGroup, restartIfNeeded, comment, soaDefaultTtl, soaExpire, soaNegativeTtl, soaRefresh, soaRetry, zoneFormat, ea) }) It("should return expected ZoneAuth Object", func() { Expect(actualZoneAuth).To(Equal(zaFakeConnector.resultObject)) @@ -354,13 +356,14 @@ var _ = Describe("Object Manager", func() { Describe("Get AuthZone by ref", func() { cmpType := "Docker" tenantID := "01234567890abcdef01234567890abcdef" + dnsview := "default" fqdn := "azone.example.com" fakeRefReturn := "zone_delegated/ZG5zLnpvbmUkLl9kZWZhdWx0LnphLmNvLmFic2EuY2Fhcy5vaG15Z2xiLmdzbGJpYmNsaWVudA:azone.example.com/default" zdFakeConnector := &fakeConnector{ getObjectObj: NewZoneAuth(ZoneAuth{}), getObjectRef: fakeRefReturn, getObjectQueryParams: NewQueryParams(false, nil), - resultObject: NewZoneAuth(ZoneAuth{Fqdn: fqdn}), + resultObject: NewZoneAuth(ZoneAuth{View: dnsview, Fqdn: fqdn}), } objMgr := NewObjectManager(zdFakeConnector, cmpType, tenantID) @@ -384,6 +387,45 @@ var _ = Describe("Object Manager", func() { }) }) + Describe("Update ZoneAuth", func() { + cmpType := "Docker" + tenantID := "01234567890abcdef01234567890abcdef" + dnsview := "default" + // fqdn := "azone.example.com" + nsGroup := "mynameservers" + restartIfNeeded := true + comment := "test comment" + soaDefaultTtl := 3600 + soaExpire := 2419200 + soaNegativeTtl := 900 + soaRefresh := 10800 + soaRetry := 3600 + // zoneFormat := "FORWARD" + ea := make(EA) + + fakeRefReturn := "zone_auth/ZG5zLnpvbmUkLl9kZWZhdWx0LnphLmNvLmFic2EuY2Fhcy5vaG15Z2xiLmdzbGJpYmNsaWVudA:dzone.example.com/default" + + zaFakeConnector := &fakeConnector{ + updateObjectObj: NewZoneAuth(ZoneAuth{Ref: fakeRefReturn, View: dnsview, NsGroup: nsGroup, RestartIfNeeded: restartIfNeeded, Comment: comment, + SoaDefaultTtl: soaDefaultTtl, SoaExpire: soaExpire, SoaNegativeTtl: soaNegativeTtl, SoaRefresh: soaRefresh, SoaRetry: soaRetry, Ea: ea}), + updateObjectRef: fakeRefReturn, + resultObject: NewZoneAuth(ZoneAuth{Ref: fakeRefReturn, View: dnsview, NsGroup: nsGroup, RestartIfNeeded: restartIfNeeded, Comment: comment, + SoaDefaultTtl: soaDefaultTtl, SoaExpire: soaExpire, SoaNegativeTtl: soaNegativeTtl, SoaRefresh: soaRefresh, SoaRetry: soaRetry, Ea: ea}), + fakeRefReturn: fakeRefReturn, + } + + objMgr := NewObjectManager(zaFakeConnector, cmpType, tenantID) + + var actualZoneAuth *ZoneAuth + var err error + It("should pass expected ZoneAuth fields to UpdateObject and receive updated ZoneAuth Object", func() { + actualZoneAuth, err = objMgr.UpdateZoneAuth(fakeRefReturn, dnsview, nsGroup, restartIfNeeded, comment, + soaDefaultTtl, soaExpire, soaNegativeTtl, soaRefresh, soaRetry, ea) + Expect(err).To(BeNil()) + Expect(actualZoneAuth).To(Equal(zaFakeConnector.resultObject)) + }) + }) + Describe("Delete ZoneAuth", func() { cmpType := "Docker" tenantID := "01234567890abcdef01234567890abcdef" diff --git a/object_manager_zone_auth.go b/object_manager_zone_auth.go index bb8b42b5..b789d451 100644 --- a/object_manager_zone_auth.go +++ b/object_manager_zone_auth.go @@ -1,8 +1,11 @@ package ibclient -import "fmt" +import ( + "fmt" +) func (objMgr *ObjectManager) CreateZoneAuth( + dnsview string, fqdn string, nsGroup string, restartIfNeeded bool, @@ -12,9 +15,11 @@ func (objMgr *ObjectManager) CreateZoneAuth( soaNegativeTtl int, soaRefresh int, soaRetry int, - eas EA) (*ZoneAuth, error) { + zoneFormat string, + ea EA) (*ZoneAuth, error) { zoneAuth := NewZoneAuth(ZoneAuth{ + View: dnsview, Fqdn: fqdn, NsGroup: nsGroup, RestartIfNeeded: restartIfNeeded, @@ -24,14 +29,15 @@ func (objMgr *ObjectManager) CreateZoneAuth( SoaNegativeTtl: soaNegativeTtl, SoaRefresh: soaRefresh, SoaRetry: soaRetry, - Ea: eas}) + ZoneFormat: zoneFormat, + Ea: ea}) ref, err := objMgr.connector.CreateObject(zoneAuth) zoneAuth.Ref = ref return zoneAuth, err } -// Retreive a authortative zone by ref +// Retrieve a authoritative zone by ref func (objMgr *ObjectManager) GetZoneAuthByRef(ref string) (*ZoneAuth, error) { res := NewZoneAuth(ZoneAuth{}) @@ -44,6 +50,44 @@ func (objMgr *ObjectManager) GetZoneAuthByRef(ref string) (*ZoneAuth, error) { return res, err } +// UpdateZoneAuth updates an auth zone, except fields that can't be updated +func (objMgr *ObjectManager) UpdateZoneAuth( + ref string, + dnsview string, + // fqdn string, CANNOT BE UPDATED IN WAPI + nsGroup string, + restartIfNeeded bool, + comment string, + soaDefaultTtl int, + soaExpire int, + soaNegativeTtl int, + soaRefresh int, + soaRetry int, + // zoneFormat string, CANNOT BE UPDATED IN WAPI + ea EA) (*ZoneAuth, error) { + + inputZoneAuth := NewZoneAuth(ZoneAuth{ + Ref: ref, + View: dnsview, + NsGroup: nsGroup, + RestartIfNeeded: restartIfNeeded, + Comment: comment, + SoaDefaultTtl: soaDefaultTtl, + SoaExpire: soaExpire, + SoaNegativeTtl: soaNegativeTtl, + SoaRefresh: soaRefresh, + SoaRetry: soaRetry, + Ea: ea}) + + updatedRef, err := objMgr.connector.UpdateObject(inputZoneAuth, ref) + if err != nil { + fmt.Printf("failed to update object with this ref '%s': %s", updatedRef, err) + return nil, err + } + inputZoneAuth.Ref = updatedRef + return inputZoneAuth, err +} + // DeleteZoneAuth deletes an auth zone func (objMgr *ObjectManager) DeleteZoneAuth(ref string) (string, error) { return objMgr.connector.DeleteObject(ref) diff --git a/objects.go b/objects.go index c218bfc2..f956b411 100644 --- a/objects.go +++ b/objects.go @@ -827,7 +827,7 @@ type ZoneAuth struct { IBBase `json:"-"` Ref string `json:"_ref,omitempty"` Fqdn string `json:"fqdn,omitempty"` - View string `json:"view,omitempty"` + View string `json:"view"` NsGroup string `json:"ns_group,omitempty"` RestartIfNeeded bool `json:"restart_if_needed"` Comment string `json:"comment"` @@ -836,6 +836,7 @@ type ZoneAuth struct { SoaNegativeTtl int `json:"soa_negative_ttl"` SoaRefresh int `json:"soa_refresh"` SoaRetry int `json:"soa_retry"` + ZoneFormat string `json:"zone_format,omitempty"` Ea EA `json:"extattrs"` } @@ -844,8 +845,9 @@ func NewZoneAuth(za ZoneAuth) *ZoneAuth { res.objectType = "zone_auth" // restart_if_needed not included here because it is not readable res.returnFields = []string{ - "extattrs", "fqdn", "view", "ns_group", "comment", + "view", "fqdn", "ns_group", "comment", "soa_default_ttl", "soa_expire", "soa_negative_ttl", "soa_refresh", "soa_retry", + "zone_format", "extattrs", } return &res diff --git a/objects_test.go b/objects_test.go index 4ed2406e..64cce92e 100644 --- a/objects_test.go +++ b/objects_test.go @@ -637,6 +637,7 @@ var _ = Describe("Objects", func() { soa_negative_ttl := 900 soa_refresh := 10800 soa_retry := 3600 + zone_format := "FORWARD" view := "default" za := NewZoneAuth(ZoneAuth{ @@ -649,9 +650,11 @@ var _ = Describe("Objects", func() { SoaNegativeTtl: soa_negative_ttl, SoaRefresh: soa_refresh, SoaRetry: soa_retry, + ZoneFormat: zone_format, View: view}) It("should set fields correctly", func() { + Expect(za.View).To(Equal(view)) Expect(za.Fqdn).To(Equal(fqdn)) Expect(za.NsGroup).To(Equal(ns_group)) Expect(za.RestartIfNeeded).To(Equal(restart_if_needed)) @@ -661,6 +664,7 @@ var _ = Describe("Objects", func() { Expect(za.SoaNegativeTtl).To(Equal(soa_negative_ttl)) Expect(za.SoaRefresh).To(Equal(soa_refresh)) Expect(za.SoaRetry).To(Equal(soa_retry)) + Expect(za.ZoneFormat).To(Equal(zone_format)) Expect(za.View).To(Equal(view)) }) @@ -668,7 +672,7 @@ var _ = Describe("Objects", func() { Expect(za.ObjectType()).To(Equal("zone_auth")) Expect(za.ReturnFields()).To(ConsistOf( "extattrs", "fqdn", "view", "ns_group", "comment", - "soa_default_ttl", "soa_expire", "soa_negative_ttl", "soa_refresh", "soa_retry", + "soa_default_ttl", "soa_expire", "soa_negative_ttl", "soa_refresh", "soa_retry", "zone_format", )) }) })