feat(modem): method to configure APN/authentication
This commit is contained in:
@ -162,3 +162,13 @@ func (o *Operations) GetConfiguration(ctx context.Context) (*model.Configuration
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
func (o *Operations) PostModem(ctx context.Context, config *model.ModemAuthentication) (*model.ModemAuthentication, error) {
|
||||
var updated model.ModemAuthentication
|
||||
|
||||
if err := o.PostJSON("/modem/1/settings", config, &updated); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return &updated, nil
|
||||
}
|
||||
|
12
reach/client/protocol/v2/model/modem.go
Normal file
12
reach/client/protocol/v2/model/modem.go
Normal file
@ -0,0 +1,12 @@
|
||||
package model
|
||||
|
||||
// type : null, pap_chap, pap, chap
|
||||
// if type selected, username and password are mandatory
|
||||
type ModemAuthentication struct {
|
||||
Authentication struct {
|
||||
Apn string `json:"apn"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
} `json:"authentication"`
|
||||
}
|
@ -362,4 +362,31 @@ func (o *Operations) SetBaseCorrections(ctx context.Context, funcs ...protocol.S
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetModem implements protocol.Operations.
|
||||
func (o *Operations) SetModem(ctx context.Context, funcs ...protocol.SetModemOptionsFunc) error {
|
||||
opts := protocol.NewSetModemOptions(funcs...)
|
||||
modem := &model.ModemAuthentication{}
|
||||
if opts.Apn != nil {
|
||||
modem.Authentication.Apn = *opts.Apn
|
||||
}
|
||||
|
||||
if opts.Type != nil {
|
||||
modem.Authentication.Type = *opts.Type
|
||||
}
|
||||
|
||||
if opts.Password != nil {
|
||||
modem.Authentication.Password = *opts.Password
|
||||
}
|
||||
|
||||
if opts.Username != nil {
|
||||
modem.Authentication.Username = *opts.Username
|
||||
}
|
||||
|
||||
if _, err := o.PostModem(ctx, modem); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ protocol.Operations = &Operations{}
|
||||
|
Reference in New Issue
Block a user