// Delete the User from Influx Enterprise
358590
func (c *UserStore) Delete(ctx context.Context, u *chronograf.User) error {
	return c.Ctrl.DeleteUser(ctx, u.Name)
}
1060590
func (m *GormUserRepository) PermanentDelete(ctx context.Context, ID uuid.UUID) error {
	defer goa.MeasureSince([]string{"goa", "db", "user", "permanent_delete"}, time.Now())
	tx := m.db.Unscoped().Delete(&User{ID: ID})
	if err := tx.Error; err != nil {
		log.Error(ctx, map[string]interface{}{
			"user_id": ID.String(),
			"err":     err,
		}, "unable to permanently delete the user")
		return errors.NewInternalError(ctx, err)
	}
	if tx.RowsAffected == 0 {
		log.Error(ctx, map[string]interface{}{
			"user_id": ID.String(),
		}, "none row was affected by the permanently deletion operation")
		return errors.NewNotFoundError("user", ID.String())
	}
	log.Debug(ctx, map[string]interface{}{
		"user_id": ID,
	}, "User permanently deleted!")

	return nil
}
648168
func (s *AccountsService) Delete(k AccountKey) (*http.Response, error) {
	return s.client.delete(k.URI(), nil)
}
459194
func (s *Service) RemoveUser(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()
	idStr := httprouter.GetParamFromContext(ctx, "id")
	id, err := strconv.ParseUint(idStr, 10, 64)
	if err != nil {
		Error(w, http.StatusBadRequest, fmt.Sprintf("invalid user id: %s", err.Error()), s.Logger)
		return
	}

	u, err := s.Store.Users(ctx).Get(ctx, chronograf.UserQuery{ID: &id})
	if err != nil {
		Error(w, http.StatusNotFound, err.Error(), s.Logger)
		return
	}
	if err := s.Store.Users(ctx).Delete(ctx, u); err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}

	w.WriteHeader(http.StatusNoContent)
}
1300744
func (c *UsersController) Delete(ctx *app.DeleteUsersContext) error {
	isSvcAuth, err := isServiceAccount(ctx, serviceNameAuth)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err,
		}, "failed to determine if account is a service account")
		return jsonapi.JSONErrorResponse(ctx, err)

	}
	if !isSvcAuth {
		log.Error(ctx, map[string]interface{}{
			"username": ctx.Username,
		}, "account used to call delete API is not a admin-console service account")
		return jsonapi.JSONErrorResponse(ctx, errors.NewUnauthorizedError("account used to call delete API is not a admin-console service account"))
	}
	username := ctx.Username
	if username == "" {
		log.Error(ctx, map[string]interface{}{}, "failed to retrieve user by username")
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("invalid username", ctx.Username).Expected("user name should not be empty"))
	}
	err = application.Transactional(c.db, func(appl application.Application) error {
		// Collect all identities for a given username. Used to delete associated spaces, work_items, comments.
		identities, err := appl.Identities().Query(account.IdentityFilterByUsername(username))
		if err != nil || len(identities) == 0 {
			log.Error(ctx, map[string]interface{}{
				"username": username,
				"err":      err,
			}, "unable to retrieve the identity associated to this user id")
			return errors.NewNotFoundError("user", username)
		}
		// Collect all users for a given name to delete all users and identities (with on-cascade FK)
		users, err := appl.Users().LoadByUsername(ctx, username)
		if err != nil || len(users) == 0 {
			log.Error(ctx, map[string]interface{}{
				"username": username,
				"err":      err,
			}, "unable to load the user")
			return errors.NewNotFoundError("user", username)
		}
		// Delete all users, identities.
		for _, user := range users {
			if err := appl.Users().PermanentDelete(ctx, user.ID); err != nil {
				log.Error(ctx, map[string]interface{}{
					"user_id": user.ID,
					"err":     err,
				}, "unable to delete the user")
				return err
			}
			log.Debug(ctx, map[string]interface{}{
				"username": username,
				"user_id":  user.ID,
			}, "User permanently deleted!")
		}
		// Delete all spaces owned by this username. With on-cascade foreign keys, it will delete all wit,
		// comments associated.
		for _, identity := range identities {
			spaces, _, err := appl.Spaces().LoadByOwner(ctx, &identity.ID, nil, nil)
			if err != nil {
				log.Error(ctx, map[string]interface{}{
					"identity_id": identity.ID,
					"err":         err,
				}, "unable to find spaces with this owner")
				return err
			}
			for _, space := range spaces {
				if err := appl.Spaces().PermanentDelete(ctx, space.ID); err != nil {
					log.Error(ctx, map[string]interface{}{
						"space_id": space.ID,
						"err":      err,
					}, "unable to permanently delete space")
					return err
				}
			}
			log.Debug(ctx, map[string]interface{}{
				"identity_id": identity.ID,
			}, "Space deleted!")

		}
		return nil
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	return ctx.OK([]byte{})
}
800325
func Delete(c *deis.Client, username string) error {
	var body []byte
	var err error

	if username != "" {
		req := api.AuthCancelRequest{Username: username}
		body, err = json.Marshal(req)

		if err != nil {
			return err
		}
	}

	res, err := c.Request("DELETE", "/v2/auth/cancel/", body)
	if err == nil {
		res.Body.Close()
	}
	return err
}
323066
func (s *inmem) DeleteUser(ctx context.Context, id platform.ID) error {
	return s.delete(ctx, id, getUser)
}
86742
func (user User) Delete() error {
	if !user.Exists() {
		return fmt.Errorf("auth: users without IDs cannot be deleted")
	}
	return user.manager.Delete(user.ID)
}
663856
func (s *Store) DeleteUser(ctx context.Context, id platform.ID) error {
	userID, err := id.Encode()
	if err != nil {
		return err
	}

	err = s.db.Update(func(tx *bolt.Tx) error {
		b := tx.Bucket(s.bucket)
		ub := b.Bucket(usersPath).Bucket(userID)
		if ub == nil {
			return backend.ErrUserNotFound
		}
		c := ub.Cursor()
		i := 0
		for k, _ := c.First(); k != nil; k, _ = c.Next() {
			i++
			// check for cancelation every 256 tasks deleted
			if i&0xFF == 0 {
				select {
				case <-ctx.Done():
					return ctx.Err()
				default:
				}
			}
			if err := b.Bucket(tasksPath).Delete(k); err != nil {
				return err
			}
			if err := b.Bucket(taskMetaPath).Delete(k); err != nil {
				return err
			}
			if err := b.Bucket(orgByTaskID).Delete(k); err != nil {
				return err
			}
			if err := b.Bucket(userByTaskID).Delete(k); err != nil {
				return err
			}
			if err := b.Bucket(nameByTaskID).Delete(k); err != nil {
				return err
			}

			org := b.Bucket(orgByTaskID).Get(k)
			if len(org) > 0 {
				ob := b.Bucket(orgsPath).Bucket(org)
				if ob != nil {
					if err := ob.Delete(k); err != nil {
						return err
					}
				}
			}
		}

		// check for cancelation one last time before we return
		select {
		case <-ctx.Done():
			return ctx.Err()
		default:
			return b.Bucket(usersPath).DeleteBucket(userID)
		}
	})

	return err
}
255686
func (c *Client) DeleteUser(user User) error {
	uri := fmt.Sprintf("/1/users/%s", user.ObjectID())
	resp, err := c.doSimple("DELETE", uri)
	defer resp.Body.Close()
	c.trace("DeleteUser", uri)
	return err
}
1044848
func (a *API) DeleteUserConfig(user int, key string) error {
	url := a.BuildURL("/v2/user/%d/config/%s/", user, key)
	return a.Delete(url, Params{})
}
33275
func (s *Service) DeleteSource(ctx context.Context, id influxdb.ID) error {
	return s.kv.Update(ctx, func(tx Tx) error {
		pe := s.deleteSource(ctx, tx, id)
		if pe != nil {
			return &influxdb.Error{
				Err: pe,
			}
		}
		return nil
	})
}
301192
func (auth *Auth) DeleteUser(ctx context.Context, userID string) error {
	if len(userID) == 0 {
		return ErrRequireUID
	}

	_, err := auth.client.DeleteAccount(&identitytoolkit.IdentitytoolkitRelyingpartyDeleteAccountRequest{
		LocalId: userID,
	}).Context(ctx).Do()
	if err != nil {
		return err
	}
	return nil
}
756621
func (s UserResource) Delete(id string, r api2go.Request) (api2go.Responder, error) {
	err := s.UserStorage.Delete(id)
	return &Response{Code: http.StatusNoContent}, err
}
199703
func DeleteUserCookie(w http.ResponseWriter, r *http.Request) {
	DeleteUserCookieName(w, r, Config.CookieName)
}
305891
func (c *Client) RemoveUser(name string) error {
	return c.delete(nil, "/user/"+name)
}
977748
func Delete(c *client.Client, username string) error {
	var body []byte
	var err error

	if username != "" {
		req := api.AuthCancelRequest{Username: username}
		body, err = json.Marshal(req)

		if err != nil {
			return err
		}
	}

	_, err = c.BasicRequest("DELETE", "/v1/auth/cancel/", body)
	return err
}