diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-11-13 11:32:52 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-11-17 13:41:04 +0100 |
commit | 40cf347e9aa2ded35a8798b8aec0abbf2e993183 (patch) | |
tree | 14661c60f1cb83e73ef1bdc041405014282a98d1 /sonar-ws | |
parent | ad4cf4fb0a36a1b12e9f2719e9fee8a7960a5ee4 (diff) | |
download | sonarqube-40cf347e9aa2ded35a8798b8aec0abbf2e993183.tar.gz sonarqube-40cf347e9aa2ded35a8798b8aec0abbf2e993183.zip |
SONAR-6947 api/permissions/users use UsersWsRequest
Diffstat (limited to 'sonar-ws')
3 files changed, 121 insertions, 2 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsClient.java index 510cf7adcdd..5eb82edcf1c 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsClient.java @@ -24,8 +24,9 @@ import org.sonarqube.ws.WsPermissions; import org.sonarqube.ws.WsPermissions.CreateTemplateWsResponse; import org.sonarqube.ws.WsPermissions.SearchProjectPermissionsWsResponse; import org.sonarqube.ws.WsPermissions.SearchTemplatesWsResponse; -import org.sonarqube.ws.WsPermissions.WsSearchGlobalPermissionsResponse; import org.sonarqube.ws.WsPermissions.UpdateTemplateWsResponse; +import org.sonarqube.ws.WsPermissions.UsersWsResponse; +import org.sonarqube.ws.WsPermissions.WsSearchGlobalPermissionsResponse; import org.sonarqube.ws.client.WsClient; import static org.sonarqube.ws.client.WsRequest.newGetRequest; @@ -196,6 +197,19 @@ public class PermissionsWsClient { UpdateTemplateWsResponse.parser()); } + public UsersWsResponse users(UsersWsRequest request) { + return wsClient.execute( + newGetRequest("users") + .setParam(PARAM_PERMISSION, request.getPermission()) + .setParam(PARAM_PROJECT_ID, request.getProjectId()) + .setParam(PARAM_PROJECT_KEY, request.getProjectKey()) + .setParam("selected", request.getSelected()) + .setParam("p", request.getPage()) + .setParam("ps", request.getPageSize()) + .setParam("q", request.getQuery()), + UsersWsResponse.parser()); + } + private static String action(String action) { return PermissionsWsParameters.ENDPOINT + "/" + action; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/UsersWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/UsersWsRequest.java new file mode 100644 index 00000000000..37e352317bb --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/UsersWsRequest.java @@ -0,0 +1,105 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonarqube.ws.client.permission; + +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + +import static java.util.Objects.requireNonNull; + +public class UsersWsRequest { + private String permission; + private String projectId; + private String projectKey; + private String selected; + private String query; + private Integer page; + private Integer pageSize; + + public String getPermission() { + return permission; + } + + public UsersWsRequest setPermission(String permission) { + this.permission = requireNonNull(permission); + return this; + } + + @CheckForNull + public String getProjectId() { + return projectId; + } + + public UsersWsRequest setProjectId(@Nullable String projectId) { + this.projectId = projectId; + return this; + } + + @CheckForNull + public String getProjectKey() { + return projectKey; + } + + public UsersWsRequest setProjectKey(@Nullable String projectKey) { + this.projectKey = projectKey; + return this; + } + + @CheckForNull + public String getSelected() { + return selected; + } + + public UsersWsRequest setSelected(@Nullable String selected) { + this.selected = selected; + return this; + } + + @CheckForNull + public String getQuery() { + return query; + } + + public UsersWsRequest setQuery(@Nullable String query) { + this.query = query; + return this; + } + + @CheckForNull + public Integer getPage() { + return page; + } + + public UsersWsRequest setPage(int page) { + this.page = page; + return this; + } + + @CheckForNull + public Integer getPageSize() { + return pageSize; + } + + public UsersWsRequest setPageSize(int pageSize) { + this.pageSize = pageSize; + return this; + } +} diff --git a/sonar-ws/src/main/protobuf/ws-permissions.proto b/sonar-ws/src/main/protobuf/ws-permissions.proto index 432eda6cb01..6c27cc37f0d 100644 --- a/sonar-ws/src/main/protobuf/ws-permissions.proto +++ b/sonar-ws/src/main/protobuf/ws-permissions.proto @@ -28,7 +28,7 @@ option optimize_for = SPEED; // WS api/permissions/users for internal use only // and WS api/permissions/template_users for internal use only -message WsUsersResponse { +message UsersWsResponse { optional sonarqube.ws.commons.Paging paging = 1; repeated User users = 2; } |