// Assign new device letter
172951
func (s *SingleLetter) Assign() (string, error) {
	s.Lock()
	defer s.Unlock()
	if len(s.devices) == 0 {
		return "", fmt.Errorf("No free device IDs")
	}
	device := s.devPrefix + s.devices[:1]
	s.devices = s.devices[1:]
	return device, nil
}
325761
func (u *Unit) AssignToNewMachine() (err error) {
	defer assignContextf(&err, u.Name(), "new machine")
	return u.assignToNewMachine("")
}
447546
func (s *Device) SetDeviceName(v string) *Device {
	s.DeviceName = &v
	return s
}
784161
func (s *ListDeviceEventsInput) SetDeviceId(v string) *ListDeviceEventsInput {
	s.DeviceId = &v
	return s
}
977128
func (r *Robot) AddDevice(d Device) Device {
	*r.devices = append(*r.Devices(), d)
	return d
}
1352653
func (n *BuilderNode) Assign(replica, partition int) {
	n.builder.Assign(replica, partition, n)
}
1160038
func (g *Generation) AssignUnit(unitName string) error {
	appName, err := names.UnitApplication(unitName)
	if err != nil {
		return errors.Trace(err)
	}

	buildTxn := func(attempt int) ([]txn.Op, error) {
		if attempt > 0 {
			if err := g.Refresh(); err != nil {
				return nil, errors.Trace(err)
			}
		}
		if err := g.CheckNotComplete(); err != nil {
			return nil, errors.Trace(err)
		}
		if set.NewStrings(g.doc.AssignedUnits[appName]...).Contains(unitName) {
			return nil, jujutxn.ErrNoOperations
		}
		unit, err := g.st.Unit(unitName)
		if err != nil {
			return nil, errors.Trace(err)
		}
		return assignGenerationUnitTxnOps(g.doc.DocId, appName, unit), nil
	}

	return errors.Trace(g.st.db().Run(buildTxn))
}
304203
func (w *wrapper) Device(id protocol.DeviceID) (DeviceConfiguration, bool) {
	w.mut.Lock()
	defer w.mut.Unlock()
	for _, device := range w.cfg.Devices {
		if device.DeviceID == id {
			return device.Copy(), true
		}
	}
	return DeviceConfiguration{}, false
}
1371375
func (vmap *masterVNIDMap) assignVNID(networkClient networkclient.Interface, nsName string) error {
	vmap.lock.Lock()
	defer vmap.lock.Unlock()

	netid, exists, err := vmap.allocateNetID(nsName)
	if err != nil {
		return err
	}

	if !exists {
		// Create NetNamespace Object and update vnid map
		netns := &networkv1.NetNamespace{
			TypeMeta:   metav1.TypeMeta{Kind: "NetNamespace"},
			ObjectMeta: metav1.ObjectMeta{Name: nsName},
			NetName:    nsName,
			NetID:      netid,
		}
		if _, err := networkClient.NetworkV1().NetNamespaces().Create(netns); err != nil {
			if er := vmap.releaseNetID(nsName); er != nil {
				utilruntime.HandleError(er)
			}
			return err
		}
	}
	return nil
}
525178
func (s *EbsVolume) SetDevice(v string) *EbsVolume {
	s.Device = &v
	return s
}
588652
func (d *Driver) Create(id, parent, mountLabel string) error {
	if err := d.DeviceSet.AddDevice(id, parent); err != nil {
		return err
	}

	return nil
}
959806
func (s *RedisDeviceStore) Set(new *Device, properties ...string) (err error) {
	// If this is an update, check if AppEUI, DevEUI and DevAddr are still the same
	old := new.old
	var addrChanged bool
	if old != nil {
		addrChanged = new.DevAddr != old.DevAddr || new.DevEUI != old.DevEUI || new.AppEUI != old.AppEUI
		if addrChanged {
			if err := s.devAddrIndex.Remove(old.DevAddr.String(), s.key(old.AppEUI, old.DevEUI)); err != nil {
				return err
			}
		}
	}

	now := time.Now()
	new.UpdatedAt = now
	key := s.key(new.AppEUI, new.DevEUI)
	if new.old == nil {
		new.CreatedAt = now
	}
	err = s.store.Set(key, *new, properties...)
	if err != nil {
		return
	}

	if (new.old == nil || addrChanged) && !new.DevAddr.IsEmpty() {
		if err := s.devAddrIndex.Add(new.DevAddr.String(), key); err != nil {
			return err
		}
	}

	return nil
}
173797
func (u *UserConfig) SetDevice(d keybase1.DeviceID) {
	u.importedDeviceID = d
	var s *string
	if d.Exists() {
		tmp := d.String()
		s = &tmp
	}
	u.Device = s
	return
}
552001
func NewDeviceApprovalsChangeDesktopPolicyType(Description string) *DeviceApprovalsChangeDesktopPolicyType {
	s := new(DeviceApprovalsChangeDesktopPolicyType)
	s.Description = Description
	return s
}
633516
func (a *ActiveDevice) setSigningKey(g *GlobalContext, uv keybase1.UserVersion, deviceID keybase1.DeviceID,
	sigKey GenericKey, deviceName string) error {
	a.Lock()
	defer a.Unlock()

	if err := a.internalUpdateUserVersionDeviceID(uv, deviceID); err != nil {
		return err
	}

	a.signingKey = sigKey
	if len(deviceName) > 0 {
		a.deviceName = deviceName
	}
	a.nistFactory = NewNISTFactory(g, uv.Uid, deviceID, sigKey)
	return nil
}
1297982
func (s *UpdateStreamInput) SetDeviceName(v string) *UpdateStreamInput {
	s.DeviceName = &v
	return s
}
805062
func (s *AdminForgetDeviceInput) SetDeviceKey(v string) *AdminForgetDeviceInput {
	s.DeviceKey = &v
	return s
}