GetModel implements the ttnpb.DeviceRepositoryServer interface.
( ctx context.Context, req *ttnpb.GetEndDeviceModelRequest, )
| 149 | |
| 150 | // GetModel implements the ttnpb.DeviceRepositoryServer interface. |
| 151 | func (dr *DeviceRepository) GetModel( |
| 152 | ctx context.Context, |
| 153 | req *ttnpb.GetEndDeviceModelRequest, |
| 154 | ) (*ttnpb.EndDeviceModel, error) { |
| 155 | if err := rights.RequireAuthenticated(ctx); err != nil { |
| 156 | return nil, err |
| 157 | } |
| 158 | response, err := dr.store.GetModels(store.GetModelsRequest{ |
| 159 | BrandID: req.BrandId, |
| 160 | ModelID: req.ModelId, |
| 161 | Limit: 1, |
| 162 | Paths: withDefaultModelFields(req.FieldMask.GetPaths()), |
| 163 | }) |
| 164 | if err != nil { |
| 165 | return nil, err |
| 166 | } |
| 167 | if len(response.Models) == 0 { |
| 168 | return nil, errModelNotFound.WithAttributes("brand_id", req.BrandId, "model_id", req.ModelId) |
| 169 | } |
| 170 | dr.ensureBaseAssetURLs(response.Models) |
| 171 | |
| 172 | return response.Models[0], nil |
| 173 | } |
| 174 | |
| 175 | // GetTemplate implements the ttnpb.DeviceRepositoryServer interface. |
| 176 | func (dr *DeviceRepository) GetTemplate( |
nothing calls this directly
no test coverage detected