UpdateAttributes implements EntityRegistry.
(ctx context.Context, ids *ttnpb.GatewayIdentifiers, current, new map[string]string)
| 140 | |
| 141 | // UpdateAttributes implements EntityRegistry. |
| 142 | func (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. |
| 174 | func (is IS) ValidateGatewayID(ctx context.Context, ids *ttnpb.GatewayIdentifiers) error { |
nothing calls this directly
no test coverage detected