// ImageByID returns the specified image within the named Docker image repository
505313
func (c *connection) ImageByID(namespace, name, imageID string) (*Image, error) {
	if len(namespace) == 0 && reference.IsRegistryDockerHub(c.url.Host) {
		namespace = "library"
	}
	if len(name) == 0 {
		return nil, fmt.Errorf("image name must be specified")
	}

	repo, err := c.getCachedRepository(fmt.Sprintf("%s/%s", namespace, name))
	if err != nil {
		return nil, err
	}

	image, _, err := repo.getImage(c, imageID, "")
	return image, err
}
387508
func (c *Client) DeleteRegistrationById(id string) error {
	conn := c.Pool.Get()
	defer conn.Close()

	return deleteRegistration(conn, id)
}
869953
func (mc MongoClient) EventById(id string) (contract.Event, error) {
	s := mc.getSessionCopy()
	defer s.Close()

	query, err := idToBsonM(id)
	if err != nil {
		return contract.Event{}, err
	}

	var evt models.Event
	if err := s.DB(mc.database.Name).C(db.EventsCollection).Find(query).One(&evt); err != nil {
		return contract.Event{}, errorMap(err)
	}
	return evt.ToContract(mc)
}
723266
func (p *propIcon) SetIconByID(id int64) {
	p.Icon = &Icon{Resource: NewResource(id)}
}
1154209
func (q *Queue) PeekByID(id uint64) (*Item, error) {
	q.RLock()
	defer q.RUnlock()

	// Check if queue is closed.
	if !q.isOpen {
		return nil, ErrDBClosed
	}

	return q.getItemByID(id)
}
1214108
func (s *userService) DeleteByID(id int64) bool {
	return s.repo.Delete(func(m datamodels.User) bool {
		return m.ID == id
	}, 1)
}
4192
func (el EntityList) KeysById(id uint64) (keys []Key) {
	for _, e := range el {
		if e.PrimaryKey.KeyId == id {
			var selfSig *packet.Signature
			for _, ident := range e.Identities {
				if selfSig == nil {
					selfSig = ident.SelfSignature
				} else if ident.SelfSignature.IsPrimaryId != nil && *ident.SelfSignature.IsPrimaryId {
					selfSig = ident.SelfSignature
					break
				}
			}
			keys = append(keys, Key{e, e.PrimaryKey, e.PrivateKey, selfSig})
		}

		for _, subKey := range e.Subkeys {
			if subKey.PublicKey.KeyId == id {
				keys = append(keys, Key{e, subKey.PublicKey, subKey.PrivateKey, subKey.Sig})
			}
		}
	}
	return
}
493670
func (st *State) RelationById(id int) (*Relation, error) {
	var results params.RelationResults
	args := params.RelationIds{
		RelationIds: []int{id},
	}
	err := st.facade.FacadeCall("RelationById", args, &results)
	if err != nil {
		return nil, err
	}
	if len(results.Results) != 1 {
		return nil, fmt.Errorf("expected 1 result, got %d", len(results.Results))
	}
	result := results.Results[0]
	if err := result.Error; err != nil {
		return nil, err
	}
	relationTag := names.NewRelationTag(result.Key)
	return &Relation{
		id:        result.Id,
		tag:       relationTag,
		life:      result.Life,
		suspended: result.Suspended,
		st:        st,
		otherApp:  result.OtherApplication,
	}, nil
}
1257099
func (repo *repo) FindByID(id uint) (user service.Entity, err error) {
	if err = dbconn.DB.Where("id = ?", id).First(&user).Error; err != nil {
		return service.Entity{}, err
	}
	return user, nil
}
274091
func (c *Client) GetLightByID(id uint64) (light common.Light, err error) {
	dev, err := c.GetDeviceByID(id)
	if err != nil {
		return nil, err
	}

	light, ok := dev.(common.Light)
	if !ok {
		return nil, common.ErrDeviceInvalidType
	}

	return light, 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
}
722206
func findImageIDByName(client *gophercloud.ServiceClient, imageName string) (string, error) {
	if imageName == "" {
		return "", fmt.Errorf("empty image name")
	}

	// We have the option of filtering the image list. If we want the full
	// collection, leave it as an empty struct
	opts := images.ListOpts{Name: imageName}

	// Retrieve image list
	page, err := images.ListDetail(client, opts).AllPages()
	if err != nil {
		return "", fmt.Errorf("error on retrieving image pages: %s", err)
	}

	imageList, err := images.ExtractImages(page)
	if err != nil {
		return "", fmt.Errorf("error on extracting image list: %s", err)
	}

	if len(imageList) == 0 {
		return "", nil
	}

	if len(imageList) > 1 {
		return "", fmt.Errorf("there exists more than one image with the same name")
	}

	return imageList[0].ID, err
}
235237
func (s *ScanKeys) KeysById(id uint64, fp []byte) []openpgp.Key {
	m := s.M()
	primaries := s.unlockByID(m, id)
	memres := primaries.KeysById(id, fp)
	m.Debug("ScanKeys:KeysById(%016x) => %d keys match in memory", id, len(memres))
	if len(memres) > 0 {
		m.Debug("ScanKeys:KeysById(%016x) => owner == me (%s)", id, s.me.GetName())
		s.Lock()
		s.keyOwners[id] = s.me
		s.Unlock()
		return memres
	}

	// KeysById is only used for decryption, so getting public keys from
	// API server via s.scan(id) is pointless, so just returning nil.
	return nil
}
714638
func amiRootSnapshotId(image *ec2.Image) string {
	if image.RootDeviceName == nil {
		return ""
	}
	for _, bdm := range image.BlockDeviceMappings {
		if bdm.DeviceName == nil || *bdm.DeviceName != *image.RootDeviceName {
			continue
		}
		if bdm.Ebs != nil && bdm.Ebs.SnapshotId != nil {
			return *bdm.Ebs.SnapshotId
		}
	}
	return ""
}
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
}
777502
func AuthGroupByID(db XODB, id int) (*AuthGroup, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`id, name ` +
		`FROM django.auth_group ` +
		`WHERE id = ?`

	// run query
	XOLog(sqlstr, id)
	ag := AuthGroup{
		_exists: true,
	}

	err = db.QueryRow(sqlstr, id).Scan(&ag.ID, &ag.Name)
	if err != nil {
		return nil, err
	}

	return &ag, nil
}
926993
func (s *WorkspaceImage) SetImageId(v string) *WorkspaceImage {
	s.ImageId = &v
	return s
}