Class GroupsController
java.lang.Object
org.craftercms.studio.controller.rest.v2.GroupsController
@Validated
@RequestMapping("/api/2/groups")
@RestController
public class GroupsController
extends Object
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddGroupMembers
(int groupId, AddGroupMembers addGroupMembers) Add group members APIcreateGroup
(@Valid Group group) Create group APIdeleteGroups
(List<Long> groupIds) Delete group APIgetAllGroups
(String keyword, @jakarta.validation.constraints.PositiveOrZero int offset, @jakarta.validation.constraints.PositiveOrZero int limit, String sort) Get groups APIgetGroup
(int groupId) Get group APIgetGroupMembers
(int groupId, @jakarta.validation.constraints.PositiveOrZero int offset, @jakarta.validation.constraints.PositiveOrZero int limit, String sort) Get group members APIremoveGroupMembers
(int groupId, List<Long> userIds, List<@NotBlank String> usernames) Remove group members APIupdateGroup
(@Valid UpdateGroupRequest updateRequest) Update group API
-
Constructor Details
-
GroupsController
-
-
Method Details
-
getAllGroups
@GetMapping public PaginatedResultList<Group> getAllGroups(@RequestParam(value="keyword",required=false) String keyword, @PositiveOrZero @RequestParam(value="offset",required=false,defaultValue="0") @jakarta.validation.constraints.PositiveOrZero int offset, @PositiveOrZero @RequestParam(value="limit",required=false,defaultValue="10") @jakarta.validation.constraints.PositiveOrZero int limit, @RequestParam(value="sort",required=false,defaultValue="group_name asc") String sort) throws ServiceLayerException, OrganizationNotFoundException Get groups API- Parameters:
keyword
- keyword parameteroffset
- offset parameterlimit
- limit parametersort
- sort parameter- Returns:
- Response containing list of groups
- Throws:
ServiceLayerException
OrganizationNotFoundException
-
createGroup
@ResponseStatus(CREATED) @PostMapping(consumes="application/json") public ResultOne<Group> createGroup(@Valid @RequestBody @Valid Group group) throws GroupAlreadyExistsException, ServiceLayerException, AuthenticationException Create group API- Parameters:
group
- Group to create- Returns:
- Response object
- Throws:
GroupAlreadyExistsException
ServiceLayerException
AuthenticationException
-
updateGroup
@PatchMapping(consumes="application/json") public ResultOne<Group> updateGroup(@Valid @RequestBody @Valid UpdateGroupRequest updateRequest) throws ServiceLayerException, GroupNotFoundException, AuthenticationException, GroupExternallyManagedException Update group API- Parameters:
updateRequest
-UpdateGroupRequest
to update- Returns:
- Response object
- Throws:
ServiceLayerException
GroupNotFoundException
AuthenticationException
GroupExternallyManagedException
-
deleteGroups
@DeleteMapping public Result deleteGroups(@RequestParam("id") List<Long> groupIds) throws ServiceLayerException, GroupNotFoundException, AuthenticationException, GroupExternallyManagedException Delete group API- Parameters:
groupIds
- Group identifier- Returns:
- Response object
- Throws:
ServiceLayerException
GroupNotFoundException
AuthenticationException
GroupExternallyManagedException
-
getGroup
@GetMapping("/{id}") public ResultOne<Group> getGroup(@PathVariable("id") int groupId) throws ServiceLayerException, GroupNotFoundException Get group API- Parameters:
groupId
- Group identifier- Returns:
- Response containing requested group
- Throws:
ServiceLayerException
GroupNotFoundException
-
getGroupMembers
@GetMapping("/{id}/members") public PaginatedResultList<UserResponse> getGroupMembers(@PathVariable("id") int groupId, @PositiveOrZero @RequestParam(value="offset",required=false,defaultValue="0") @jakarta.validation.constraints.PositiveOrZero int offset, @PositiveOrZero @RequestParam(value="limit",required=false,defaultValue="10") @jakarta.validation.constraints.PositiveOrZero int limit, @RequestParam(value="sort",required=false,defaultValue="id asc") String sort) throws ServiceLayerException, GroupNotFoundException Get group members API- Parameters:
groupId
- Group identifieroffset
- Result set offsetlimit
- Result set limitsort
- Sort order- Returns:
- Response containing list od users
- Throws:
ServiceLayerException
GroupNotFoundException
-
addGroupMembers
@PostMapping(value="/{id}/members", consumes="application/json") public ResultList<UserResponse> addGroupMembers(@PathVariable("id") int groupId, @RequestBody AddGroupMembers addGroupMembers) throws ServiceLayerException, UserNotFoundException, GroupNotFoundException, AuthenticationException Add group members API- Parameters:
groupId
- Group identifiersaddGroupMembers
- Add members request body (json representation)- Returns:
- Response object
- Throws:
ServiceLayerException
UserNotFoundException
GroupNotFoundException
AuthenticationException
-
removeGroupMembers
@DeleteMapping("/{id}/members") public Result removeGroupMembers(@PathVariable("id") int groupId, @RequestParam(value="userId",required=false) List<Long> userIds, @RequestParam(value="username",required=false) List<@NotBlank String> usernames) throws ServiceLayerException, UserNotFoundException, GroupNotFoundException, AuthenticationException Remove group members API- Parameters:
groupId
- Group identifieruserIds
- List of user identifiersusernames
- List of usernames- Returns:
- Response object
- Throws:
ServiceLayerException
UserNotFoundException
GroupNotFoundException
AuthenticationException
-