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

Method GetBrand

pkg/devicerepository/grpc.go:96–117  ·  view source on GitHub ↗

GetBrand implements the ttnpb.DeviceRepositoryServer interface.

(
	ctx context.Context,
	req *ttnpb.GetEndDeviceBrandRequest,
)

Source from the content-addressed store, hash-verified

94
95// GetBrand implements the ttnpb.DeviceRepositoryServer interface.
96func (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.
120func (dr *DeviceRepository) ListModels(

Callers

nothing calls this directly

Calls 5

assetURLMethod · 0.95
RequireAuthenticatedFunction · 0.92
withDefaultBrandFieldsFunction · 0.85
GetBrandsMethod · 0.65
WithAttributesMethod · 0.45

Tested by

no test coverage detected