// GetAllDeviceProfiles provides a mock function with given fields:
774958
func (_m *DBClient) GetAllDeviceProfiles() ([]models.DeviceProfile, error) {
	ret := _m.Called()

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

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

	return r0, r1
}
614008
func getDevices(pool, block, metadatadev string) (map[int]*DeviceBlockStats, error) {
	cmd := exec.Command("thin_dump", "-f", "xml", metadatadev, "-m", block)
	stdout, err := cmd.StdoutPipe()
	cmd.Stderr = os.Stderr
	if err != nil {
		return nil, err
	}
	if err := cmd.Start(); err != nil {
		return nil, err
	}
	devices, err := parseMetadata(stdout)
	if err != nil {
		return nil, err
	}
	if err := cmd.Wait(); err != nil {
		return nil, err
	}
	return devices, nil
}
202030
func (o *Me) InfrastructureGatewayProfiles(info *bambou.FetchingInfo) (InfrastructureGatewayProfilesList, *bambou.Error) {

	var list InfrastructureGatewayProfilesList
	err := bambou.CurrentSession().FetchChildren(o, InfrastructureGatewayProfileIdentity, &list, info)
	return list, err
}
752672
func (m *Machine) CharmProfiles() []string {
	m.mu.Lock()
	defer m.mu.Unlock()
	return m.details.CharmProfiles
}
535527
func (_m *DBClient) GetAllDevices() ([]models.Device, error) {
	ret := _m.Called()

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

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

	return r0, r1
}
142759
func (mc MongoClient) GetDeviceProfilesByCommandId(id string) ([]contract.DeviceProfile, error) {
	command, err := mc.getCommandById(id)
	if err != nil {
		return []contract.DeviceProfile{}, err
	}

	dps, err := mc.getDeviceProfiles(bson.M{"commands.$id": command.Id})
	if err != nil {
		return []contract.DeviceProfile{}, err
	}
	return dps, nil
}
1244220
func (mc MongoClient) GetAllDeviceReports() ([]contract.DeviceReport, error) {
	return mc.getDeviceReports(bson.M{})
}
575793
func updateDeviceFields(from models.Device, to *models.Device) error {

	if (from.Service.String() != models.DeviceService{}.String()) {
		// Check if the new service exists
		// Try ID first
		ds, err := dbClient.GetDeviceServiceById(from.Service.Id)
		if err != nil {
			// Then try name
			ds, err = dbClient.GetDeviceServiceByName(from.Service.Name)
			if err != nil {
				return errors.New("Device service not found for updated device")
			}
		}

		to.Service = ds
	}
	if (from.Profile.String() != models.DeviceProfile{}.String()) {
		// Check if the new profile exists
		// Try ID first
		dp, err := dbClient.GetDeviceProfileById(from.Profile.Id)
		if err != nil {
			// Then try Name
			dp, err = dbClient.GetDeviceProfileByName(from.Profile.Name)
			if err != nil {
				return errors.New("Device profile not found for updated device")
			}
		}

		to.Profile = dp
	}
	if len(from.Protocols) > 0 {
		to.Protocols = from.Protocols
	}
	if len(from.AutoEvents) > 0 {
		to.AutoEvents = from.AutoEvents
	}
	if from.AdminState != "" {
		to.AdminState = from.AdminState
	}
	if from.Description != "" {
		to.Description = from.Description
	}
	if from.Labels != nil {
		to.Labels = from.Labels
	}
	if from.LastConnected != 0 {
		to.LastConnected = from.LastConnected
	}
	if from.LastReported != 0 {
		to.LastReported = from.LastReported
	}
	if from.Location != nil {
		to.Location = from.Location
	}
	if from.OperatingState != models.OperatingState("") {
		to.OperatingState = from.OperatingState
	}
	if from.Origin != 0 {
		to.Origin = from.Origin
	}
	if from.Name != "" {
		to.Name = from.Name

		// Check if the name is unique
		checkD, err := dbClient.GetDeviceByName(from.Name)
		if err != nil {
			// A problem occurred accessing database
			if err != db.ErrNotFound {
				LoggingClient.Error(err.Error())
				return err
			}
		}

		// Found a device, make sure its the one we're trying to update
		if err != db.ErrNotFound {
			// Different IDs -> Name is not unique
			if checkD.Id != to.Id {
				err = errors.New("Duplicate name for Device")
				LoggingClient.Error(err.Error())
				return err
			}
		}
	}

	return nil
}
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
}
785856
func (_m *DBClient) GetDevicesByProfileId(pid string) ([]models.Device, error) {
	ret := _m.Called(pid)

	var r0 []models.Device
	if rf, ok := ret.Get(0).(func(string) []models.Device); ok {
		r0 = rf(pid)
	} 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(pid)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
256541
func (plugin *vsphereVolumePlugin) GetDeviceMountRefs(deviceMountPath string) ([]string, error) {
	mounter := plugin.host.GetMounter(plugin.GetPluginName())
	return mounter.GetMountRefs(deviceMountPath)
}
515495
func (p *V2) GetDevices() ([]common.Device, error) {
	p.RLock()
	defer p.RUnlock()
	if len(p.devices) == 0 {
		return nil, common.ErrNotFound
	}
	devices := make([]common.Device, len(p.devices))
	i := 0
	for _, device := range p.devices {
		devices[i] = device
		i++
	}

	return devices, nil
}
806020
func (n *NetworkServerAPI) GetGatewayProfile(ctx context.Context, req *ns.GetGatewayProfileRequest) (*ns.GetGatewayProfileResponse, error) {
	var gpID uuid.UUID
	copy(gpID[:], req.Id)

	gc, err := storage.GetGatewayProfile(storage.DB(), gpID)
	if err != nil {
		return nil, errToRPCError(err)
	}

	out := ns.GetGatewayProfileResponse{
		GatewayProfile: &ns.GatewayProfile{
			Id: gc.ID.Bytes(),
		},
	}

	out.CreatedAt, err = ptypes.TimestampProto(gc.CreatedAt)
	if err != nil {
		return nil, errToRPCError(err)
	}

	out.UpdatedAt, err = ptypes.TimestampProto(gc.UpdatedAt)
	if err != nil {
		return nil, errToRPCError(err)
	}

	for _, c := range gc.Channels {
		out.GatewayProfile.Channels = append(out.GatewayProfile.Channels, uint32(c))
	}

	for _, ec := range gc.ExtraChannels {
		c := ns.GatewayProfileExtraChannel{
			Frequency: uint32(ec.Frequency),
			Bandwidth: uint32(ec.Bandwidth),
			Bitrate:   uint32(ec.Bitrate),
		}

		switch ec.Modulation {
		case storage.ModulationFSK:
			c.Modulation = common.Modulation_FSK
		default:
			c.Modulation = common.Modulation_LORA
		}

		for _, sf := range ec.SpreadingFactors {
			c.SpreadingFactors = append(c.SpreadingFactors, uint32(sf))
		}

		out.GatewayProfile.ExtraChannels = append(out.GatewayProfile.ExtraChannels, &c)
	}

	return &out, nil
}
1331659
func (surface *Surface) GetDeviceScale() (float64, float64) {
	var xScale C.double
	var yScale C.double

	C.cairo_surface_get_device_scale(surface.Ptr, &xScale, &yScale)
	if err := surface.status(); err != nil {
		panic(err)
	}
	return float64(xScale), float64(yScale)
}
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
}
962631
func (c *Client) GetDeviceProfileById(id string) (contract.DeviceProfile, error) {
	conn := c.Pool.Get()
	defer conn.Close()

	var d contract.DeviceProfile
	err := getObjectById(conn, id, unmarshalDeviceProfile, &d)
	return d, err
}
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
}