Skip to content

Commit da92c1d

Browse files
feat(vpc): add support for RouteType (scaleway#2831)
Co-authored-by: Rémy Léone <[email protected]>
1 parent 77904f8 commit da92c1d

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

api/vpc/v2/vpc_sdk.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,51 @@ func (enum *ListVPCsRequestOrderBy) UnmarshalJSON(data []byte) error {
283283
return nil
284284
}
285285

286+
type RouteType string
287+
288+
const (
289+
RouteTypeUnknownRouteType = RouteType("unknown_route_type")
290+
RouteTypeSubnet = RouteType("subnet")
291+
RouteTypeDefault = RouteType("default")
292+
RouteTypeCustom = RouteType("custom")
293+
RouteTypeInterlink = RouteType("interlink")
294+
RouteTypeS2sVpn = RouteType("s2s_vpn")
295+
)
296+
297+
func (enum RouteType) String() string {
298+
if enum == "" {
299+
// return default value if empty
300+
return string(RouteTypeUnknownRouteType)
301+
}
302+
return string(enum)
303+
}
304+
305+
func (enum RouteType) Values() []RouteType {
306+
return []RouteType{
307+
"unknown_route_type",
308+
"subnet",
309+
"default",
310+
"custom",
311+
"interlink",
312+
"s2s_vpn",
313+
}
314+
}
315+
316+
func (enum RouteType) MarshalJSON() ([]byte, error) {
317+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
318+
}
319+
320+
func (enum *RouteType) UnmarshalJSON(data []byte) error {
321+
tmp := ""
322+
323+
if err := json.Unmarshal(data, &tmp); err != nil {
324+
return err
325+
}
326+
327+
*enum = RouteType(RouteType(tmp).String())
328+
return nil
329+
}
330+
286331
type RouteWithNexthopResourceType string
287332

288333
const (
@@ -421,6 +466,10 @@ type Route struct {
421466
// IsReadOnly: defines whether the route can be modified or deleted by the user.
422467
IsReadOnly bool `json:"is_read_only"`
423468

469+
// Type: type of the Route.
470+
// Default value: unknown_route_type
471+
Type *RouteType `json:"type"`
472+
424473
// Region: region of the Route.
425474
Region scw.Region `json:"region"`
426475
}

0 commit comments

Comments
 (0)