// Update the device
// Use ID to identify device first, then name
// Can't create new Device Services/Profiles with a PUT, but you can reference another one
779381
func restUpdateDevice(w http.ResponseWriter, r *http.Request) {
	defer r.Body.Close()
	var rd models.Device
	err := json.NewDecoder(r.Body).Decode(&rd)
	if err != nil {
		LoggingClient.Error(err.Error())
		http.Error(w, err.Error(), http.StatusServiceUnavailable)
		return
	}

	// Check if the device exists
	// First try ID
	oldDevice, err := dbClient.GetDeviceById(rd.Id)
	if err != nil {
		// Then try name
		oldDevice, err = dbClient.GetDeviceByName(rd.Name)
		if err != nil {
			LoggingClient.Error(err.Error())
			http.Error(w, err.Error(), http.StatusNotFound)
			return
		}
	}

	if err = updateDeviceFields(rd, &oldDevice); err != nil {
		LoggingClient.Error(err.Error())
		http.Error(w, err.Error(), http.StatusServiceUnavailable)
		return
	}

	if err = dbClient.UpdateDevice(oldDevice); err != nil {
		LoggingClient.Error(err.Error())
		http.Error(w, err.Error(), http.StatusServiceUnavailable)
		return
	}

	ctx := r.Context()
	// Notify
	notifyDeviceAssociates(oldDevice, http.MethodPut, ctx)

	w.WriteHeader(http.StatusOK)
	w.Write([]byte("true"))
}
228295
func (c *UserServiceController) Update(ctx *app.UpdateUserServiceContext) error {
	c.UpdateTenant(ctx)
	return ctx.OK([]byte{})
}
110870
func (f *FakeServiceUpdater) Update(srv *v1.Service) (*v1.Service, error) {
	return f.RetSvc, f.Err
}
88390
func (d *Daemon) UpdateIdentities(added, deleted cache.IdentityCache) {
	policy.UpdateIdentities(added, deleted)
	d.TriggerPolicyUpdates(true, "one or more identities created or deleted")
}
778918
func (s *UsergroupsUsersService) Update(usergroup string, users string) *UsergroupsUsersUpdateCall {
	var call UsergroupsUsersUpdateCall
	call.service = s
	call.usergroup = usergroup
	call.users = users
	return &call
}
942335
func (part *Partition) Update(id int, data []byte) (err error) {
	physID := part.lookup.Get(id, 1)
	if len(physID) == 0 {
		return dberr.New(dberr.ErrorNoDoc, id)
	}
	newID, err := part.col.Update(physID[0], data)
	if err != nil {
		return
	}
	if newID != physID[0] {
		part.lookup.Remove(id, physID[0])
		part.lookup.Put(id, newID)
	}
	return
}
1092362
func updateDeviceServiceLastReportedConnected(device string) {
	if !Configuration.Writable.ServiceUpdateLastConnected {
		LoggingClient.Debug("Skipping update of device service connected/reported times for:  " + device)
		return
	}

	t := db.MakeTimestamp()

	// Get the device
	d, err := mdc.CheckForDevice(device, context.Background())
	if err != nil {
		LoggingClient.Error("Error getting device " + device + ": " + err.Error())
		return
	}

	// Couldn't find device
	if len(d.Name) == 0 {
		LoggingClient.Error("Error updating device connected/reported times.  Unknown device with identifier of:  " + device)
		return
	}

	// Get the device service
	s := d.Service
	if &s == nil {
		LoggingClient.Error("Error updating device service connected/reported times.  Unknown device service in device:  " + d.Name)
		return
	}

	//Use of context.Background because this function is invoked asynchronously from a channel
	msc.UpdateLastConnected(s.Id, t, context.Background())
	msc.UpdateLastReported(s.Id, t, context.Background())
}
1176458
func (s *Services) update(srvs []*apitypes.UserService) error {
	var err error
	// check if update service list conflicts
	tbd := make(map[serviceKey]bool, len(srvs))
	for _, srv := range srvs {
		key := serviceKey{srv.ServiceIP, srv.ServicePort, srv.Protocol}
		if tbd[key] {
			err = fmt.Errorf("given service list conflict: %v", srv)
			s.Log(ERROR, err)
			return err
		}
		tbd[key] = true
	}

	if s.p.IsRunning() {
		if err = s.commit(srvs, "update"); err != nil {
			return err
		}
	}
	s.spec = srvs

	return nil
}
622475
func (cs *UserService) Update(id int, user UserApi) (*PingdomResponse, error) {
	if err := user.ValidUser(); err != nil {
		return nil, err
	}

	req, err := cs.client.NewRequest("PUT", "/users/"+strconv.Itoa(id), user.PutParams())
	if err != nil {
		return nil, err
	}

	m := &PingdomResponse{}
	_, err = cs.client.Do(req, m)
	if err != nil {
		return nil, err
	}
	return m, err
}
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
}
703580
func (s *VersionService) Update(version *Version) (*Version, *Response, error) {
	apiEndpoint := fmt.Sprintf("rest/api/2/version/%v", version.ID)
	req, err := s.client.NewRequest("PUT", apiEndpoint, version)
	if err != nil {
		return nil, nil, err
	}
	resp, err := s.client.Do(req, nil)
	if err != nil {
		jerr := NewJiraError(resp, err)
		return nil, resp, jerr
	}

	// This is just to follow the rest of the API's convention of returning a version.
	// Returning the same pointer here is pointless, so we return a copy instead.
	ret := *version
	return &ret, resp, nil
}
982894
func (crud *repo) Update(profile service.Entity) error {
	return dbconn.DB.Save(&profile).Error
}
629162
func (c *userIdentityMappings) Update(userIdentityMapping *user.UserIdentityMapping) (result *user.UserIdentityMapping, err error) {
	result = &user.UserIdentityMapping{}
	err = c.client.Put().
		Resource("useridentitymappings").
		Name(userIdentityMapping.Name).
		Body(userIdentityMapping).
		Do().
		Into(result)
	return
}
1047911
func (u *UserService) Update(id string, user *UpdateUserRequest) (*http.Response, error) {
	req, err := u.client.NewRequest("PUT", fmt.Sprintf("user/%s", id), nil, user)
	if err != nil {
		return nil, err
	}

	return u.client.Do(req, nil)
}
291700
func (r *KeyResource) Update(account, key, label string, id int) (*Key, error) {

	values := url.Values{}
	values.Add("key", key)
	values.Add("label", label)

	k := Key{}
	path := fmt.Sprintf("/users/%s/ssh-keys/%v", account, id)
	if err := r.client.do("PUT", path, nil, values, &k); err != nil {
		return nil, err
	}

	return &k, nil
}
1306152
func (s *ServicesService) Update(idOrName string, svc *Service) (*Service, *http.Response, error) {
	return s.UpdateWithContext(context.TODO(), idOrName, svc)
}
35949
func (r *AppService) Update(id string, appupdatereq *AppUpdateReq) *AppUpdateCall {
	c := &AppUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.id = id
	c.appupdatereq = appupdatereq
	return c
}