user_groups.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.UserGroups = void 0;
  4. const base_collection_1 = require("./base_collection");
  5. const user_group_1 = require("../models/user_group");
  6. class UserGroups extends base_collection_1.BaseCollection {
  7. static rootElementName = "user_groups";
  8. static prefixURI = "teams/{!:team_id}/groups/{:id}";
  9. static elementClass = user_group_1.UserGroup;
  10. list(request_params) {
  11. return this.doList(request_params);
  12. }
  13. create(user_group_params, request_params) {
  14. return this.doCreate(user_group_params, request_params, this.populateGroupFromJsonRoot);
  15. }
  16. get(user_group_id, request_params) {
  17. return this.doGet(user_group_id, request_params);
  18. }
  19. update(user_group_id, user_group_params, request_params) {
  20. return this.doUpdate(user_group_id, user_group_params, request_params, this.populateGroupFromJsonRoot);
  21. }
  22. delete(user_group_id, request_params) {
  23. return this.doDelete(user_group_id, request_params);
  24. }
  25. add_members_to_group(team_id, group_id, user_ids) {
  26. const params = {
  27. team_id: team_id,
  28. group_id: group_id,
  29. };
  30. const body = { users: user_ids };
  31. return this.createPromise("PUT", params, this.populateGroupFromJsonRoot, this.handleReject, body, "teams/{!:team_id}/groups/{!:group_id}/members/add");
  32. }
  33. remove_members_from_group(team_id, group_id, user_ids) {
  34. const params = {
  35. team_id: team_id,
  36. group_id: group_id,
  37. };
  38. const body = { users: user_ids };
  39. return this.createPromise("PUT", params, this.populateGroupFromJsonRoot, this.handleReject, body, "teams/{!:team_id}/groups/{!:group_id}/members/remove");
  40. }
  41. add_projects_to_group(team_id, group_id, project_ids) {
  42. const params = {
  43. team_id: team_id,
  44. group_id: group_id,
  45. };
  46. const body = { projects: project_ids };
  47. return this.createPromise("PUT", params, this.populateGroupFromJsonRoot, this.handleReject, body, "teams/{!:team_id}/groups/{!:group_id}/projects/add");
  48. }
  49. remove_projects_from_group(team_id, group_id, project_ids) {
  50. const params = {
  51. team_id: team_id,
  52. group_id: group_id,
  53. };
  54. const body = { projects: project_ids };
  55. return this.createPromise("PUT", params, this.populateGroupFromJsonRoot, this.handleReject, body, "teams/{!:team_id}/groups/{!:group_id}/projects/remove");
  56. }
  57. populateGroupFromJsonRoot(json, headers) {
  58. const formatted_json = json["group"];
  59. return this.populateObjectFromJson(formatted_json, headers);
  60. }
  61. }
  62. exports.UserGroups = UserGroups;
  63. //# sourceMappingURL=user_groups.js.map