Is your feature request related to a use case? Please describe.
For code snippet below, error won't be reported if user happened to accidentally pass ps to both the calls or modified ps twice (with different choices).
api := gosnappi.NewApi()
c := api.NewConfig()
// set config
api.SetConfig(c)
// By design, pass parent object consisting of choices during API call
// set protocol state
ps := gosnappi.NewControlState()
ps.Protocol().SetState(gosnappi.ProtocolStateState.START)
// set transmit state
ts := gosnappi.NewControlState()
ts.FlowTransmit().SetState(gosnappi.TransmitStateState.START)
// call APIs
api.SetControlState(ps)
api.SetControlState(ts)
Describe the solution you'd like
Discussed following two approaches which potentially provide more guard rails.
Approach 1: Pass choice objects instead of the parent request object during API call
// set protocol state
ps := gosnappi.NewControlState().Protocol()
ps.SetState(gosnappi.ProtocolStateState.START)
// set transmit state
ts := gosnappi.NewControlState().FlowTransmit()
ts.SetState(gosnappi.TransmitStateState.START)
// call APIs
api.SetControlState(ps)
api.SetControlState(ts)
Approach 2: Per-choice request object and func call, namespaced by an additional method
// set protocol state
ps := gosnappi.ControlState().NewProtocolState()
ps.SetState(gosnappi.ProtocolStateState.START)
// set transmit state
ts := gosnappi.ControlState().NewFlowTransmitState()
ts.SetState(gosnappi.TransmitStateState.START)
// call APIs
api.ControlState().SetProtocolState(ps)
api.ControlState().SetTransmitState(ts)
Is your feature request related to a use case? Please describe. For code snippet below, error won't be reported if user happened to accidentally pass
ps
to both the calls or modifiedps
twice (with different choices).Describe the solution you'd like
Discussed following two approaches which potentially provide more guard rails.
Approach 1: Pass choice objects instead of the parent request object during API call
Approach 2: Per-choice request object and func call, namespaced by an additional method