GetBrand implements the ttnpb.DeviceRepositoryServer interface.
( ctx context.Context, req *ttnpb.GetEndDeviceBrandRequest, )
| 94 | |
| 95 | // GetBrand implements the ttnpb.DeviceRepositoryServer interface. |
| 96 | func (dr *DeviceRepository) GetBrand( |
| 97 | ctx context.Context, |
| 98 | req *ttnpb.GetEndDeviceBrandRequest, |
| 99 | ) (*ttnpb.EndDeviceBrand, error) { |
| 100 | if err := rights.RequireAuthenticated(ctx); err != nil { |
| 101 | return nil, err |
| 102 | } |
| 103 | response, err := dr.store.GetBrands(store.GetBrandsRequest{ |
| 104 | BrandID: req.BrandId, |
| 105 | Paths: withDefaultBrandFields(req.FieldMask.GetPaths()), |
| 106 | Limit: 1, |
| 107 | }) |
| 108 | if err != nil { |
| 109 | return nil, err |
| 110 | } |
| 111 | if len(response.Brands) == 0 { |
| 112 | return nil, errBrandNotFound.WithAttributes("brand_id", req.BrandId) |
| 113 | } |
| 114 | brand := response.Brands[0] |
| 115 | brand.Logo = dr.assetURL(brand.BrandId, brand.Logo) |
| 116 | return brand, nil |
| 117 | } |
| 118 | |
| 119 | // ListModels implements the ttnpb.DeviceRepositoryServer interface. |
| 120 | func (dr *DeviceRepository) ListModels( |
nothing calls this directly
no test coverage detected