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

Method GetModel

pkg/devicerepository/grpc.go:151–173  ·  view source on GitHub ↗

GetModel implements the ttnpb.DeviceRepositoryServer interface.

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

Source from the content-addressed store, hash-verified

149
150// GetModel implements the ttnpb.DeviceRepositoryServer interface.
151func (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.
176func (dr *DeviceRepository) GetTemplate(

Callers

nothing calls this directly

Calls 5

ensureBaseAssetURLsMethod · 0.95
RequireAuthenticatedFunction · 0.92
withDefaultModelFieldsFunction · 0.85
GetModelsMethod · 0.65
WithAttributesMethod · 0.45

Tested by

no test coverage detected