Juniper / apstra-go-sdk

Go SDK for Apstra
Apache License 2.0
5 stars 1 forks source link

Convert LogicalDevicePortRole from iota to enum #425

Closed chrismarget-j closed 1 month ago

chrismarget-j commented 1 month ago

This:

    _                  enum = new(PortRole)
    PortRoleAccess          = PortRole{Value: "access"}
    PortRoleGeneric         = PortRole{Value: "generic"}
    PortRoleLeaf            = PortRole{Value: "leaf"}
    PortRolePeer            = PortRole{Value: "peer"}
    PortRoleSpine           = PortRole{Value: "spine"}
    PortRoleSuperspine      = PortRole{Value: "superspine"}
    PortRoleUnused          = PortRole{Value: "unused"}
    PortRoles               = oenum.New(
        PortRoleAccess,
        PortRoleGeneric,
        PortRoleLeaf,
        PortRolePeer,
        PortRoleSpine,
        PortRoleSuperspine,
        PortRoleUnused,
    )

type PortRole oenum.Member[string]

func (o PortRole) String() string {
    return o.Value
}

func (o *PortRole) FromString(s string) error {
    t := PortRoles.Parse(s)
    if t == nil {
        return newEnumParseError(o, s)
    }
    o.Value = t.Value
    return nil