From 828d76b88150867e9dfc55a28fccf22a4baf5107 Mon Sep 17 00:00:00 2001 From: bwjuniper Date: Tue, 22 Oct 2024 11:42:36 -0700 Subject: [PATCH] update link and integration test --- apstra/freeform_link.go | 22 +++++++------- apstra/freeform_link_integration_test.go | 38 ++++++++++++------------ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/apstra/freeform_link.go b/apstra/freeform_link.go index dae2943..7664135 100644 --- a/apstra/freeform_link.go +++ b/apstra/freeform_link.go @@ -55,14 +55,14 @@ func (o *FreeformLink) UnmarshalJSON(bytes []byte) error { o.Data.Speed = raw.Speed o.Data.Label = raw.Label o.Data.AggregateLinkId = raw.AggregateLinkId - o.Data.Endpoints[0] = FreeformEndpoint{ + o.Data.Endpoints[0] = FreeformEthernetEndpoint{ SystemId: raw.Endpoints[0].System.Id, Interface: FreeformInterface{ Id: raw.Endpoints[0].Interface.Id, Data: raw.Endpoints[0].Interface.Data, }, } - o.Data.Endpoints[1] = FreeformEndpoint{ + o.Data.Endpoints[1] = FreeformEthernetEndpoint{ SystemId: raw.Endpoints[1].System.Id, Interface: FreeformInterface{ Id: raw.Endpoints[1].Interface.Id, @@ -79,7 +79,7 @@ type FreeformLinkData struct { Label string Speed LogicalDevicePortSpeed Tags []string - Endpoints [2]FreeformEndpoint + Endpoints [2]FreeformEthernetEndpoint } var _ json.Marshaler = new(FreeformInterfaceData) @@ -193,16 +193,16 @@ func (o *FreeformInterface) UnmarshalJSON(bytes []byte) error { } var ( - _ json.Marshaler = new(FreeformEndpoint) - _ json.Unmarshaler = new(FreeformEndpoint) + _ json.Marshaler = new(FreeformEthernetEndpoint) + _ json.Unmarshaler = new(FreeformEthernetEndpoint) ) -type FreeformEndpoint struct { +type FreeformEthernetEndpoint struct { SystemId ObjectId Interface FreeformInterface } -func (o *FreeformEndpoint) UnmarshalJSON(bytes []byte) error { +func (o *FreeformEthernetEndpoint) UnmarshalJSON(bytes []byte) error { var raw struct { System struct { Id ObjectId `json:"id"` @@ -216,7 +216,7 @@ func (o *FreeformEndpoint) UnmarshalJSON(bytes []byte) error { return json.Unmarshal(bytes, &raw) } -func (o FreeformEndpoint) MarshalJSON() ([]byte, error) { +func (o FreeformEthernetEndpoint) MarshalJSON() ([]byte, error) { var raw struct { System *struct { Id ObjectId `json:"id"` @@ -251,9 +251,9 @@ func (o FreeformEndpoint) MarshalJSON() ([]byte, error) { } type FreeformLinkRequest struct { - Label string `json:"label"` - Tags []string `json:"tags"` - Endpoints [2]FreeformEndpoint `json:"endpoints"` + Label string `json:"label"` + Tags []string `json:"tags"` + Endpoints [2]FreeformEthernetEndpoint `json:"endpoints"` } func (o *FreeformClient) CreateLink(ctx context.Context, in *FreeformLinkRequest) (ObjectId, error) { diff --git a/apstra/freeform_link_integration_test.go b/apstra/freeform_link_integration_test.go index 5237109..2ab7863 100644 --- a/apstra/freeform_link_integration_test.go +++ b/apstra/freeform_link_integration_test.go @@ -22,7 +22,7 @@ func TestCRUDFFLink(t *testing.T) { clients, err := getTestClients(ctx, t) require.NoError(t, err) - compareEndPoint := func(t testing.TB, req, resp *FreeformEndpoint) { + compareEndPoint := func(t testing.TB, req, resp *FreeformEthernetEndpoint) { t.Helper() require.Equal(t, req.SystemId, resp.SystemId, "system id ") @@ -75,7 +75,7 @@ func TestCRUDFFLink(t *testing.T) { steps: []FreeformLinkRequest{ { Label: randString(6, "hex"), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ IfName: toPtr("ge-0/0/0"), TransformationId: toPtr(1), @@ -89,7 +89,7 @@ func TestCRUDFFLink(t *testing.T) { { Label: randString(6, "hex"), Tags: randStrings(rand.Intn(3)+2, 6), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ IfName: toPtr("ge-0/0/1"), TransformationId: toPtr(2), @@ -108,7 +108,7 @@ func TestCRUDFFLink(t *testing.T) { }, { Label: randString(6, "hex"), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ IfName: toPtr("ge-0/0/2"), TransformationId: toPtr(1), @@ -126,7 +126,7 @@ func TestCRUDFFLink(t *testing.T) { { Label: randString(6, "hex"), Tags: randStrings(rand.Intn(3)+2, 6), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ IfName: toPtr("ge-0/0/3"), TransformationId: toPtr(2), @@ -145,7 +145,7 @@ func TestCRUDFFLink(t *testing.T) { }, { Label: randString(6, "hex"), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ IfName: toPtr("ge-0/0/4"), TransformationId: toPtr(1), @@ -159,7 +159,7 @@ func TestCRUDFFLink(t *testing.T) { { Label: randString(6, "hex"), Tags: randStrings(rand.Intn(3)+2, 6), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ IfName: toPtr("ge-0/0/5"), TransformationId: toPtr(2), @@ -182,7 +182,7 @@ func TestCRUDFFLink(t *testing.T) { steps: []FreeformLinkRequest{ { Label: randString(6, "hex"), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ IfName: toPtr("ge-0/0/6"), TransformationId: toPtr(1), @@ -193,7 +193,7 @@ func TestCRUDFFLink(t *testing.T) { { Label: randString(6, "hex"), Tags: randStrings(rand.Intn(3)+2, 6), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ IfName: toPtr("ge-0/0/7"), TransformationId: toPtr(2), @@ -210,7 +210,7 @@ func TestCRUDFFLink(t *testing.T) { }, { Label: randString(6, "hex"), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ IfName: toPtr("ge-0/0/8"), TransformationId: toPtr(1), @@ -225,7 +225,7 @@ func TestCRUDFFLink(t *testing.T) { { Label: randString(6, "hex"), Tags: randStrings(rand.Intn(3)+2, 6), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ IfName: toPtr("ge-0/0/9"), TransformationId: toPtr(2), @@ -242,7 +242,7 @@ func TestCRUDFFLink(t *testing.T) { }, { Label: randString(6, "hex"), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ IfName: toPtr("ge-0/0/10"), TransformationId: toPtr(1), @@ -253,7 +253,7 @@ func TestCRUDFFLink(t *testing.T) { { Label: randString(6, "hex"), Tags: randStrings(rand.Intn(3)+2, 6), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ IfName: toPtr("ge-0/0/11"), TransformationId: toPtr(2), @@ -274,7 +274,7 @@ func TestCRUDFFLink(t *testing.T) { steps: []FreeformLinkRequest{ { Label: randString(6, "hex"), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: extSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{}}}, {SystemId: extSysIds[1], Interface: FreeformInterface{Data: &FreeformInterfaceData{}}}, }, @@ -282,7 +282,7 @@ func TestCRUDFFLink(t *testing.T) { { Label: randString(6, "hex"), Tags: randStrings(rand.Intn(3)+2, 6), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: extSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ Ipv4Address: &net.IPNet{IP: net.ParseIP("10.0.0.3"), Mask: net.CIDRMask(24, 32)}, Ipv6Address: &net.IPNet{IP: net.ParseIP("2001:db8::3"), Mask: net.CIDRMask(64, 128)}, @@ -297,7 +297,7 @@ func TestCRUDFFLink(t *testing.T) { }, { Label: randString(6, "hex"), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: extSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{}}}, {SystemId: extSysIds[1], Interface: FreeformInterface{Data: &FreeformInterfaceData{}}}, }, @@ -309,7 +309,7 @@ func TestCRUDFFLink(t *testing.T) { { Label: randString(6, "hex"), Tags: randStrings(rand.Intn(3)+2, 6), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: extSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ Ipv4Address: &net.IPNet{IP: net.ParseIP("10.1.0.1"), Mask: net.CIDRMask(24, 32)}, Ipv6Address: &net.IPNet{IP: net.ParseIP("2001:db8:1::1"), Mask: net.CIDRMask(64, 128)}, @@ -324,7 +324,7 @@ func TestCRUDFFLink(t *testing.T) { }, { Label: randString(6, "hex"), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: extSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{}}}, {SystemId: extSysIds[1], Interface: FreeformInterface{Data: &FreeformInterfaceData{}}}, }, @@ -332,7 +332,7 @@ func TestCRUDFFLink(t *testing.T) { { Label: randString(6, "hex"), Tags: randStrings(rand.Intn(3)+2, 6), - Endpoints: [2]FreeformEndpoint{ + Endpoints: [2]FreeformEthernetEndpoint{ {SystemId: extSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{ Ipv4Address: &net.IPNet{IP: net.ParseIP("10.1.0.2"), Mask: net.CIDRMask(24, 32)}, Ipv6Address: &net.IPNet{IP: net.ParseIP("2001:db8:1::2"), Mask: net.CIDRMask(64, 128)},