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

Method getByID

pkg/frequencyplans/frequencyplans.go:655–690  ·  view source on GitHub ↗
(id string)

Source from the content-addressed store, hash-verified

653)
654
655func (s *Store) getByID(id string) (*FrequencyPlan, error) {
656 descriptions, err := s.descriptions()
657 if err != nil {
658 return nil, errReadList.WithCause(err)
659 }
660 description, ok := descriptions.get(id)
661 if !ok {
662 return nil, errNotFound.WithAttributes("id", id)
663 }
664 proto, err := description.proto(s.Fetcher)
665 if err != nil {
666 return nil, errRead.WithCause(err).WithAttributes("id", id)
667 }
668 if description.BaseID != "" {
669 base, ok := descriptions.get(description.BaseID)
670 if !ok {
671 return nil, errReadBase.WithCause(errNotFound.WithAttributes("id", description.BaseID)).WithAttributes(
672 "id", description.ID,
673 "base_id", description.BaseID,
674 )
675 }
676 var baseProto FrequencyPlan
677 baseProto, err = base.proto(s.Fetcher)
678 if err != nil {
679 return nil, errReadBase.WithCause(err).WithAttributes(
680 "id", description.ID,
681 "base_id", description.BaseID,
682 )
683 }
684 proto = baseProto.Extend(proto)
685 }
686 if err := proto.Validate(); err != nil {
687 return nil, errInvalid.WithCause(err)
688 }
689 return &proto, nil
690}
691
692// GetByID retrieves the frequency plan that has the given ID.
693func (s *Store) GetByID(id string) (*FrequencyPlan, error) {

Callers 1

GetByIDMethod · 0.95

Calls 7

descriptionsMethod · 0.95
ExtendMethod · 0.95
protoMethod · 0.80
ValidateMethod · 0.65
WithCauseMethod · 0.45
getMethod · 0.45
WithAttributesMethod · 0.45

Tested by

no test coverage detected