diff --git a/CHANGELOG.md b/CHANGELOG.md index f00d9df2..373fb27d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] +### Added + +- router: add `type` field to static routes + ## [8.6.2] ### Added diff --git a/upcloud/network.go b/upcloud/network.go index eb3cdd62..6f4ff6c8 100644 --- a/upcloud/network.go +++ b/upcloud/network.go @@ -2,11 +2,15 @@ package upcloud import "encoding/json" -// Constants +type RouterStaticRouteType string + const ( NetworkTypePrivate = "private" NetworkTypePublic = "public" NetworkTypeUtility = "utility" + + RouterStaticRouteTypeService RouterStaticRouteType = "service" + RouterStaticRouteTypeUser RouterStaticRouteType = "user" ) // ServerInterface represent a network interface on the server @@ -298,9 +302,10 @@ type Router struct { // StaticRoute represents a Static route type StaticRoute struct { - Name string `json:"name,omitempty"` - Route string `json:"route"` - Nexthop string `json:"nexthop"` + Name string `json:"name,omitempty"` + Route string `json:"route"` + Nexthop string `json:"nexthop"` + Type RouterStaticRouteType `json:"type,omitempty"` } // UnmarshalJSON is a custom unmarshaller that deals with diff --git a/upcloud/network_test.go b/upcloud/network_test.go index eec802f2..0f7994df 100644 --- a/upcloud/network_test.go +++ b/upcloud/network_test.go @@ -448,10 +448,17 @@ func TestUnmarshalRouters(t *testing.T) { }, "name": "Example router", "static_routes": [ + { + "name": "ngw-ID-default", + "nexthop": "169.254.16.2", + "route": "0.0.0.0/0", + "type": "service" + }, { "route": "0.0.0.0/0", "nexthop": "10.0.0.100", - "name": "static_route_0" + "name": "static_route_0", + "type": "user" } ], "type": "normal", @@ -481,10 +488,17 @@ func TestUnmarshalRouters(t *testing.T) { Name: "Example router", Type: "normal", StaticRoutes: []StaticRoute{ + { + Name: "ngw-ID-default", + Route: "0.0.0.0/0", + Nexthop: "169.254.16.2", + Type: RouterStaticRouteTypeService, + }, { Name: "static_route_0", Route: "0.0.0.0/0", Nexthop: "10.0.0.100", + Type: RouterStaticRouteTypeUser, }, }, UUID: "04c0df35-2658-4b0c-8ac7-962090f4e92a",