diff --git a/client/client.go b/client/client.go index d11ea9a..5ba0d6b 100644 --- a/client/client.go +++ b/client/client.go @@ -415,7 +415,9 @@ func (c *client) Logout(ctx context.Context) error { // GetValue - port of python's get_value_by_xpath // Retrieve raw value from router using XPath. func (c *client) GetValue(ctx context.Context, xpath string) (*ValueResponse, error) { - ctx, span := tracer.Start(ctx, "SagemcomClient.GetValue") + ctx, span := tracer.Start(ctx, "SagemcomClient.GetValue", trace.WithAttributes( + attribute.String("xpath", xpath), + )) defer span.End() actions := []action{ diff --git a/client/types.go b/client/types.go index 9fa8720..81ed075 100644 --- a/client/types.go +++ b/client/types.go @@ -9,20 +9,32 @@ import ( "time" ) +// requestBody - represents the body of a request to the API +// +// note: order of fields is significant - the API will reject requests if the +// order is not maintained +// +//nolint:govet type requestBody struct { - AuthKey string `json:"auth-key"` - Actions []action `json:"actions"` ID int `json:"id"` SessionID int `json:"session-id"` - Cnonce int `json:"cnonce"` Priority bool `json:"priority"` + Actions []action `json:"actions"` + Cnonce int `json:"cnonce"` + AuthKey string `json:"auth-key"` } +// action - represents a single action to be performed +// +// note: order of fields is significant - the API will reject requests if the +// order is not maintained +// +//nolint:govet type action struct { - Parameters map[string]any `json:"parameters,omitempty"` + ID int `json:"id"` Method string `json:"method"` + Parameters map[string]any `json:"parameters,omitempty"` XPath string `json:"xpath,omitempty"` - ID int `json:"id,omitempty"` } type sessionOptions struct { diff --git a/go.mod b/go.mod index 10c6381..af0c100 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,7 @@ require ( go.opentelemetry.io/otel/sdk/log v0.9.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.33.0 // indirect go.opentelemetry.io/proto/otlp v1.4.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect diff --git a/go.sum b/go.sum index a5482b2..831d747 100644 --- a/go.sum +++ b/go.sum @@ -89,8 +89,8 @@ go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1 go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=