// Get device profiles with the passed query
3739
func (mc MongoClient) getDeviceProfiles(q bson.M) ([]contract.DeviceProfile, error) {
	s := mc.session.Copy()
	defer s.Close()

	var dps []models.DeviceProfile
	err := s.DB(mc.database.Name).C(db.DeviceProfile).Find(q).Sort("queryts").All(&dps)
	if err != nil {
		return []contract.DeviceProfile{}, errorMap(err)
	}

	cdps := make([]contract.DeviceProfile, 0)
	for _, dp := range dps {
		c, err := dp.ToContract(mc)
		if err != nil {
			return []contract.DeviceProfile{}, err
		}
		cdps = append(cdps, c)
	}
	return cdps, nil
}
159078
func (_m *DBClient) GetDeviceProfileByName(n string) (models.DeviceProfile, error) {
	ret := _m.Called(n)

	var r0 models.DeviceProfile
	if rf, ok := ret.Get(0).(func(string) models.DeviceProfile); ok {
		r0 = rf(n)
	} else {
		r0 = ret.Get(0).(models.DeviceProfile)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string) error); ok {
		r1 = rf(n)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1286135
func (os *OpenStack) GetDevicePath(volumeID string) string {
	devicePath := os.GetDevicePathBySerialID(volumeID)

	if devicePath == "" {
		devicePath = os.getDevicePathFromInstanceMetadata(volumeID)
	}

	if devicePath == "" {
		klog.Warningf("Failed to find device for the volumeID: %q", volumeID)
	}

	return devicePath
}
1168359
func (_m *DBClient) UpdateDeviceProfile(dp models.DeviceProfile) error {
	ret := _m.Called(dp)

	var r0 error
	if rf, ok := ret.Get(0).(func(models.DeviceProfile) error); ok {
		r0 = rf(dp)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
1082136
func (devices *DeviceSet) exportDeviceMetadata(hash string) (*deviceMetadata, error) {
	info, err := devices.lookupDeviceWithLock(hash)
	if err != nil {
		return nil, err
	}

	info.lock.Lock()
	defer info.lock.Unlock()

	metadata := &deviceMetadata{info.DeviceID, info.Size, info.Name()}
	return metadata, nil
}
566051
func (p Profile) ValidateConfigDevices() error {
	for _, val := range p.Devices {
		goodDevs := set.NewStrings("unix-char", "unix-block", "gpu", "usb")
		if devType, ok := val["type"]; ok {
			if !goodDevs.Contains(devType) {
				return fmt.Errorf("invalid lxd-profile: contains device type %q", devType)
			}
		}
	}
	for key := range p.Config {
		if strings.HasPrefix(key, "boot") ||
			strings.HasPrefix(key, "limits") ||
			strings.HasPrefix(key, "migration") {
			return fmt.Errorf("invalid lxd-profile: contains config value %q", key)
		}
	}
	return nil
}
1206104
func getProfileNICs(profile *api.Profile) map[string]device {
	nics := make(map[string]device, len(profile.Devices))
	for k, v := range profile.Devices {
		if v["type"] == nic {
			nics[k] = v
		}
	}
	return nics
}
1027296
func (_m *DBClient) GetDeviceServiceByName(n string) (models.DeviceService, error) {
	ret := _m.Called(n)

	var r0 models.DeviceService
	if rf, ok := ret.Get(0).(func(string) models.DeviceService); ok {
		r0 = rf(n)
	} else {
		r0 = ret.Get(0).(models.DeviceService)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string) error); ok {
		r1 = rf(n)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
737872
func (o *Enterprise) IKEEncryptionprofiles(info *bambou.FetchingInfo) (IKEEncryptionprofilesList, *bambou.Error) {

	var list IKEEncryptionprofilesList
	err := bambou.CurrentSession().FetchChildren(o, IKEEncryptionprofileIdentity, &list, info)
	return list, err
}
98415
func (md *RootMetadataV2) GetUserDevicePublicKeys(_ ExtraMetadata) (
	writerDeviceKeys, readerDeviceKeys UserDevicePublicKeys, err error) {
	if md.TlfID().Type() != tlf.Private {
		return nil, nil, InvalidNonPrivateTLFOperation{
			md.TlfID(), "GetUserDevicePublicKeys", md.Version()}
	}

	if len(md.WKeys) == 0 || len(md.RKeys) == 0 {
		return nil, nil, errors.New(
			"GetUserDevicePublicKeys called with no key generations (V2)")
	}

	wUDKIM := md.WKeys[len(md.WKeys)-1]
	rUDKIM := md.RKeys[len(md.RKeys)-1]

	return wUDKIM.WKeys.ToPublicKeys(), rUDKIM.RKeys.ToPublicKeys(), nil
}
1006824
func (_m *DBClient) GetDevicesWithLabel(l string) ([]models.Device, error) {
	ret := _m.Called(l)

	var r0 []models.Device
	if rf, ok := ret.Get(0).(func(string) []models.Device); ok {
		r0 = rf(l)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]models.Device)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string) error); ok {
		r1 = rf(l)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
329301
func deleteDeviceProfile(dp models.DeviceProfile, w http.ResponseWriter) error {
	// Check if the device profile is still in use by devices
	d, err := dbClient.GetDevicesByProfileId(dp.Id)

	// XXX ErrNotFound should always be returned but this is not consistent in the implementations
	if err == db.ErrNotFound {
		err = nil
		d = []models.Device{}
	} else if err != nil {
		http.Error(w, err.Error(), http.StatusServiceUnavailable)
		return err
	}
	if len(d) > 0 {
		err = errors.New("Can't delete device profile, the profile is still in use by a device")
		http.Error(w, err.Error(), http.StatusConflict)
		return err
	}

	// Check if the device profile is still in use by provision watchers
	pw, err := dbClient.GetProvisionWatchersByProfileId(dp.Id)
	if err != nil {
		http.Error(w, err.Error(), http.StatusServiceUnavailable)
		return err
	}
	if len(pw) > 0 {
		err = errors.New("Cant delete device profile, the profile is still in use by a provision watcher")
		http.Error(w, err.Error(), http.StatusConflict)
		return err
	}

	// Delete the profile
	if err := dbClient.DeleteDeviceProfileById(dp.Id); err != nil {
		http.Error(w, err.Error(), http.StatusServiceUnavailable)
		return err
	}

	return nil
}
611414
func (d *domainClient) GetSearchResults(ctx context.Context, args *GetSearchResultsArgs) (reply *GetSearchResultsReply, err error) {
	reply = new(GetSearchResultsReply)
	if args != nil {
		err = rpcc.Invoke(ctx, "DOM.getSearchResults", args, reply, d.conn)
	} else {
		err = rpcc.Invoke(ctx, "DOM.getSearchResults", nil, reply, d.conn)
	}
	if err != nil {
		err = &internal.OpError{Domain: "DOM", Op: "GetSearchResults", Err: err}
	}
	return
}
522348
func (d *domainClient) GetMediaQueries(ctx context.Context) (reply *GetMediaQueriesReply, err error) {
	reply = new(GetMediaQueriesReply)
	err = rpcc.Invoke(ctx, "CSS.getMediaQueries", nil, reply, d.conn)
	if err != nil {
		err = &internal.OpError{Domain: "CSS", Op: "GetMediaQueries", Err: err}
	}
	return
}
1348610
func (pb *Pushbullet) GetDevices() ([]*responses.Device, error) {
	req, err := http.NewRequest("GET", ENDPOINT_DEVICES, nil)
	if err != nil {
		return nil, err
	}

	req.SetBasicAuth(pb.token, "")

	res, err := pb.client.Do(req)
	if err != nil {
		return nil, err
	}

	// TODO: Return an error value with human friendly message.
	if res.StatusCode != 200 {
		return nil, errors.New(res.Status)
	}

	var devices *devicesResponse

	decoder := json.NewDecoder(res.Body)
	if err := decoder.Decode(&devices); err != nil {
		return nil, err
	}

	return devices.Devices, nil
}
899406
func (r *rest) Get(c *gin.Context) {
	if resDTO, err := r.service.Retrieve(c.Param("profileId")); err != nil {
		c.JSON(apihelper.BuildResponseError(err))
	} else {
		c.JSON(http.StatusOK, resDTO)
	}
}
528610
func (r Layout_Profile_Containers) GetLayoutProfile() (resp datatypes.Layout_Profile, err error) {
	err = r.Session.DoRequest("SoftLayer_Layout_Profile_Containers", "getLayoutProfile", nil, &r.Options, &resp)
	return
}