package org.sonar.server.v2.api.model;
import com.google.common.annotations.VisibleForTesting;
-import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
public record RestPage(
@Min(1)
@Max(500)
- @Parameter(
- description = "Number of results per page",
- schema = @Schema(defaultValue = DEFAULT_PAGE_SIZE, implementation = Integer.class))
+ @Schema(defaultValue = DEFAULT_PAGE_SIZE, description = "Number of results per page")
Integer pageSize,
@Positive
- @Parameter(
- description = "1-based page number",
- schema = @Schema(defaultValue = DEFAULT_PAGE_INDEX, implementation = Integer.class))
+ @Schema(defaultValue = DEFAULT_PAGE_INDEX, description = "Number of results per page")
Integer pageIndex
) {
@DeleteMapping(path = "/{login}")
@ResponseStatus(HttpStatus.NO_CONTENT)
- @Operation(summary = "Deactivate a user", description = "Deactivate a user. Requires Administer System permission.")
+ @Operation(summary = "Deactivate a user", description = "Deactivates a user. Requires Administer System permission.")
void deactivate(
- @PathVariable("login") @Parameter(description = "The login of the user to delete.", required = true, in = ParameterIn.PATH) String login,
- @RequestParam(value = "anonymize", required = false, defaultValue = "false") @Parameter(description = "Anonymize user in addition to deactivating it.") Boolean anonymize);
+ @PathVariable("login")
+ @Parameter(description = "The login of the user to delete.", required = true, in = ParameterIn.PATH)
+ String login,
+ @RequestParam(value = "anonymize", required = false, defaultValue = "false")
+ @Parameter(description = "Anonymize user in addition to deactivating it.")
+ Boolean anonymize);
@GetMapping(path = "/{login}")
@ResponseStatus(HttpStatus.OK)
If a deactivated user account exists with the given login, it will be reactivated.
Requires Administer System permission
""")
- RestUser create(@Valid @RequestBody(required = true) UserCreateRestRequest userCreateRestRequest);
+ RestUser create(@Valid @RequestBody UserCreateRestRequest userCreateRestRequest);
}
*/
package org.sonar.server.v2.api.user.request;
-import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.annotation.Nullable;
public record UsersSearchRestRequest(
- @Parameter(
- description = "Return active/inactive users",
- schema = @Schema(defaultValue = "true", implementation = Boolean.class))
+ @Schema(defaultValue = "true", description = "Return active/inactive users")
Boolean active,
@Nullable
- @Parameter(description = "Return managed or non-managed users. Only available for managed instances, throws for non-managed instances")
+ @Schema(description = "Return managed or non-managed users. Only available for managed instances, throws for non-managed instances")
Boolean managed,
@Nullable
- @Parameter(description = "Filter on login, name and email.\n"
+ @Schema(description = "Filter on login, name and email.\n"
+ "This parameter can either perform an exact match, or a partial match (contains), it is case insensitive.")
String q,
@Nullable
- @Parameter(description = "Filter the users based on the last connection date field. Only users who interacted with this instance at or after the date will be returned. "
+ @Schema(description = "Filter the users based on the last connection date field. Only users who interacted with this instance at or after the date will be returned. "
+ "The format must be ISO 8601 datetime format (YYYY-MM-DDThh:mm:ss±hhmm)",
example = "2020-01-01T00:00:00+0100")
String sonarQubeLastConnectionDateFrom,
@Nullable
- @Parameter(description = "Filter the users based on the last connection date field. Only users that never connected or who interacted with this instance at "
+ @Schema(description = "Filter the users based on the last connection date field. Only users that never connected or who interacted with this instance at "
+ "or before the date will be returned. The format must be ISO 8601 datetime format (YYYY-MM-DDThh:mm:ss±hhmm)",
example = "2020-01-01T00:00:00+0100")
String sonarQubeLastConnectionDateTo,
@Nullable
- @Parameter(description = "Filter the users based on the sonar lint last connection date field Only users who interacted with this instance using SonarLint at or after "
+ @Schema(description = "Filter the users based on the sonar lint last connection date field Only users who interacted with this instance using SonarLint at or after "
+ "the date will be returned. The format must be ISO 8601 datetime format (YYYY-MM-DDThh:mm:ss±hhmm)",
example = "2020-01-01T00:00:00+0100")
String sonarLintLastConnectionDateFrom,
@Nullable
- @Parameter(description = "Filter the users based on the sonar lint last connection date field. Only users that never connected or who interacted with this instance "
+ @Schema(description = "Filter the users based on the sonar lint last connection date field. Only users that never connected or who interacted with this instance "
+ "using SonarLint at or before the date will be returned. The format must be ISO 8601 datetime format (YYYY-MM-DDThh:mm:ss±hhmm)",
example = "2020-01-01T00:00:00+0100")
String sonarLintLastConnectionDateTo
import org.sonar.server.v2.api.response.PageRestResponse;
import org.sonar.server.v2.api.user.model.RestUser;
-public record UsersSearchRestResponse(List<RestUser> users, PageRestResponse pageRestResponse) {
+public record UsersSearchRestResponse(List<RestUser> users, PageRestResponse page) {
}
UsersSearchRestResponse actualUsersSearchRestResponse = gson.fromJson(mvcResult.getResponse().getContentAsString(), UsersSearchRestResponse.class);
assertThat(actualUsersSearchRestResponse.users())
.containsExactlyElementsOf(restUsers);
- assertThat(actualUsersSearchRestResponse.pageRestResponse().total()).isEqualTo(users.size());
+ assertThat(actualUsersSearchRestResponse.page().total()).isEqualTo(users.size());
}
UsersSearchRestResponse usersForResponse = usersSearchRestResponseGenerator.toUsersForResponse(List.of(), paging);
assertThat(usersForResponse.users()).isEmpty();
- assertPaginationInformationAreCorrect(paging, usersForResponse.pageRestResponse());
+ assertPaginationInformationAreCorrect(paging, usersForResponse.page());
}
@Test
RestUser expectUser1 = buildExpectedResponseForAdmin(userSearchResult1);
RestUser expectUser2 = buildExpectedResponseForAdmin(userSearchResult2);
assertThat(usersForResponse.users()).containsExactly(expectUser1, expectUser2);
- assertPaginationInformationAreCorrect(paging, usersForResponse.pageRestResponse());
+ assertPaginationInformationAreCorrect(paging, usersForResponse.page());
}
private static RestUser buildExpectedResponseForAdmin(UserSearchResult userSearchResult) {
RestUser expectUser1 = buildExpectedResponseForUser(userSearchResult1);
RestUser expectUser2 = buildExpectedResponseForUser(userSearchResult2);
assertThat(usersForResponse.users()).containsExactly(expectUser1, expectUser2);
- assertPaginationInformationAreCorrect(paging, usersForResponse.pageRestResponse());
+ assertPaginationInformationAreCorrect(paging, usersForResponse.page());
}
private static RestUser buildExpectedResponseForUser(UserSearchResult userSearchResult) {
RestUser expectUser1 = buildExpectedResponseForAnonymous(userSearchResult1);
RestUser expectUser2 = buildExpectedResponseForAnonymous(userSearchResult2);
assertThat(usersForResponse.users()).containsExactly(expectUser1, expectUser2);
- assertPaginationInformationAreCorrect(paging, usersForResponse.pageRestResponse());
+ assertPaginationInformationAreCorrect(paging, usersForResponse.page());
}
private static RestUser buildExpectedResponseForAnonymous(UserSearchResult userSearchResult) {