MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / UpdateAttributes

Method UpdateAttributes

pkg/gatewayserver/is.go:142–171  ·  view source on GitHub ↗

UpdateAttributes implements EntityRegistry.

(ctx context.Context, ids *ttnpb.GatewayIdentifiers, current, new map[string]string)

Source from the content-addressed store, hash-verified

140
141// UpdateAttributes implements EntityRegistry.
142func (is IS) UpdateAttributes(ctx context.Context, ids *ttnpb.GatewayIdentifiers, current, new map[string]string) error {
143 ctx, err := getAuthenticatedContext(ctx)
144 if err != nil {
145 return err
146 }
147 callOpt, err := rpcmetadata.WithForwardedAuth(ctx, is.AllowInsecureForCredentials())
148 if err != nil {
149 return err
150 }
151
152 registry, err := is.newRegistryClient(ctx, ids)
153 if err != nil {
154 return err
155 }
156
157 // Take the union of keys with new values overwriting existing entries.
158 merged := make(map[string]string)
159 maps.Copy(merged, current)
160 maps.Copy(merged, new)
161
162 req := &ttnpb.UpdateGatewayRequest{
163 Gateway: &ttnpb.Gateway{
164 Ids: ids,
165 Attributes: merged,
166 },
167 FieldMask: ttnpb.FieldMask("attributes"),
168 }
169 _, err = registry.Update(ctx, req, callOpt)
170 return err
171}
172
173// ValidateGatewayID implements EntityRegistry.
174func (is IS) ValidateGatewayID(ctx context.Context, ids *ttnpb.GatewayIdentifiers) error {

Callers

nothing calls this directly

Calls 7

newRegistryClientMethod · 0.95
WithForwardedAuthFunction · 0.92
FieldMaskFunction · 0.92
getAuthenticatedContextFunction · 0.85
UpdateMethod · 0.65
CopyMethod · 0.45

Tested by

no test coverage detected