// ItemByID by returns the file's Item of a given ID.
// If the ID is known, the returned error is ErrUnknownItem.
614
func (f *File) ItemByID(id uint32) (*Item, error) {
	meta, err := f.getMeta()
	if err != nil {
		return nil, err
	}
	it := &Item{
		f:  f,
		ID: id,
	}
	if meta.ItemLocation != nil {
		for _, ilbe := range meta.ItemLocation.Items {
			if uint32(ilbe.ItemID) == id {
				shallowCopy := ilbe
				it.Location = &shallowCopy
			}
		}
	}
	if meta.ItemInfo != nil {
		for _, iie := range meta.ItemInfo.ItemInfos {
			if uint32(iie.ItemID) == id {
				it.Info = iie
			}
		}
	}
	if it.Info == nil {
		return nil, ErrUnknownItem
	}
	if meta.Properties != nil {
		allProps := meta.Properties.PropertyContainer.Properties
		for _, ipa := range meta.Properties.Associations {
			// TODO: I've never seen a file with more than
			// top-level ItemPropertyAssociation box, but
			// apparently they can exist with different
			// versions/flags. For now we just merge them
			// all together, but that's not really right.
			// So for now, just bail once a previous loop
			// found anything.
			if len(it.Properties) > 0 {
				break
			}

			for _, ipai := range ipa.Entries {
				if ipai.ItemID != id {
					continue
				}
				for _, ass := range ipai.Associations {
					if ass.Index != 0 && int(ass.Index) <= len(allProps) {
						box := allProps[ass.Index-1]
						boxp, err := box.Parse()
						if err == nil {
							box = boxp
						}
						it.Properties = append(it.Properties, box)
					}
				}
			}
		}
	}
	return it, nil
}
1208918
func GetReleaseByID(id int64) (*Release, error) {
	r := new(Release)
	has, err := x.Id(id).Get(r)
	if err != nil {
		return nil, err
	} else if !has {
		return nil, ErrReleaseNotExist{id, ""}
	}

	return r, r.LoadAttributes()
}
1332166
func (info Info) GetIMByID(imID string) *IM {
	for _, im := range info.IMs {
		if im.ID == imID {
			return &im
		}
	}
	return nil
}
1370151
func FindById(i interface{}, id string) error {
	return Find(i, bson.M{"_id": bson.ObjectIdHex(id)})
}
1121919
func getByID(c context.Context, id string) (*instances.Instance, error) {
	if vmtoken.Has(c) {
		return nil, status.Errorf(codes.PermissionDenied, "unauthorized user")
	}
	vm := &model.VM{
		ID: id,
	}
	switch err := datastore.Get(c, vm); {
	case err == datastore.ErrNoSuchEntity:
		return nil, status.Errorf(codes.NotFound, "no VM found with ID %q", id)
	case err != nil:
		return nil, errors.Annotate(err, "failed to fetch VM").Err()
	default:
		return toInstance(vm), nil
	}
}
125151
func ElementByIdReady(tab *Tab, elementAttributeId string) ConditionalFunc {
	return func(tab *Tab) bool {
		element, _, _ := tab.GetElementById(elementAttributeId)
		return (element != nil) && (element.IsReady())
	}
}
584813
func (s *StateStore) JobByID(ws memdb.WatchSet, namespace, id string) (*structs.Job, error) {
	txn := s.db.Txn(false)
	return s.JobByIDTxn(ws, namespace, id, txn)
}
1057827
func (pis PeerIdentitySet) ByID() map[string]PeerIdentityInfo {
	m := make(map[string]PeerIdentityInfo)
	for _, id := range pis {
		m[string(id.PKIId)] = id
	}
	return m
}
866930
func (mc MongoClient) ValueDescriptorById(id string) (contract.ValueDescriptor, error) {
	query, err := idToBsonM(id)
	if err != nil {
		return contract.ValueDescriptor{}, err
	}

	mvd, err := mc.getValueDescriptor(query)
	if err != nil {
		return contract.ValueDescriptor{}, err
	}
	return mvd.ToContract(), nil
}
379873
func (c *RegionCache) ClearStoreByID(id uint64) {
	c.storeMu.Lock()
	defer c.storeMu.Unlock()
	delete(c.storeMu.stores, id)
}
457555
func (s *invocationIDSet) ItemToInvID(i *dsset.Item) int64 {
	id, _ := strconv.ParseInt(i.ID, 10, 64)
	return id
}
332352
func (mc MongoClient) RegistrationById(id string) (contract.Registration, error) {
	reg, err := mc.registrationById(id)
	if err != nil {
		return contract.Registration{}, err
	}
	return reg.ToContract(), nil
}
570125
func (c *Client) GetGifsById(ids ...string) ([]*Gif, error) {

	// check that a query string was actually passed in
	if len(ids) > 100 {
		err := errors.New("Cannot fetch more than 100 GIFs at a time.")
		return nil, err
	}

	// build query string that will be appended to url
	qs := &url.Values{}
	qs.Set("ids", strings.Join(ids, ","))

	// construct and execute the HTTP request
	pr := &paginatedResults{}
	if err := c.makeRequest("gifs", qs, pr); err != nil {
		return nil, err
	}

	return pr.Data, nil
}
1061749
func (api *OmdbApi) MovieByImdbID(id string) (*MovieResult, error) {
	resp, err := api.requestAPI("id", id)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	r := new(MovieResult)
	err = json.NewDecoder(resp.Body).Decode(r)

	if err != nil {
		return nil, err
	}
	if r.Response == "False" {
		return r, errors.New(r.Error)
	}
	return r, nil
}
78763
func (auto *AutoGcd) tabById(id string) (*Tab, error) {
	auto.tabLock.RLock()
	tab := auto.tabs[id]
	auto.tabLock.RUnlock()
	if tab == nil {
		return nil, &InvalidTabErr{"unknown tab id " + id}
	}
	return tab, nil
}
213407
func (comments *Comments) DelByID(id string) error {
	return comments.Del(&Comment{idstr: id})
}
637514
func (info Info) GetChannelByID(channelID string) *Channel {
	for _, channel := range info.Channels {
		if channel.ID == channelID {
			return &channel
		}
	}
	return nil
}