diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-11-13 11:16:04 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-11-17 13:41:04 +0100 |
commit | ad4cf4fb0a36a1b12e9f2719e9fee8a7960a5ee4 (patch) | |
tree | b8ea5579d9f39d8cb81ae3206085fca4c07f7da6 /sonar-ws | |
parent | 5c82c160f7d5849bde026cb1a7ed2cef29389680 (diff) | |
download | sonarqube-ad4cf4fb0a36a1b12e9f2719e9fee8a7960a5ee4.tar.gz sonarqube-ad4cf4fb0a36a1b12e9f2719e9fee8a7960a5ee4.zip |
SONAR-6947 api/permissions/update_template use UpdateTemplateWsRequest
Diffstat (limited to 'sonar-ws')
3 files changed, 85 insertions, 1 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 747c520d402..510cf7adcdd 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 @@ -25,6 +25,7 @@ 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.client.WsClient; import static org.sonarqube.ws.client.WsRequest.newGetRequest; @@ -32,6 +33,7 @@ import static org.sonarqube.ws.client.WsRequest.newPostRequest; import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_DESCRIPTION; import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_ID; import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_ID; import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_NAME; import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_ID; @@ -184,6 +186,16 @@ public class PermissionsWsClient { .setParam(PARAM_TEMPLATE_NAME, request.getTemplateName())); } + public UpdateTemplateWsResponse updateTemplate(UpdateTemplateWsRequest request) { + return wsClient.execute( + newPostRequest("update_template") + .setParam(PARAM_DESCRIPTION, request.getDescription()) + .setParam(PARAM_ID, request.getId()) + .setParam(PARAM_NAME, request.getName()) + .setParam(PARAM_PROJECT_KEY_PATTERN, request.getProjectKeyPattern()), + UpdateTemplateWsResponse.parser()); + } + private static String action(String action) { return PermissionsWsParameters.ENDPOINT + "/" + action; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/UpdateTemplateWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/UpdateTemplateWsRequest.java new file mode 100644 index 00000000000..f35436674d9 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/UpdateTemplateWsRequest.java @@ -0,0 +1,72 @@ +/* + * 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 UpdateTemplateWsRequest { + private String id; + private String description; + private String name; + private String projectKeyPattern; + + public String getId() { + return id; + } + + public UpdateTemplateWsRequest setId(String id) { + this.id = requireNonNull(id); + return this; + } + + @CheckForNull + public String getDescription() { + return description; + } + + public UpdateTemplateWsRequest setDescription(@Nullable String description) { + this.description = description; + return this; + } + + @CheckForNull + public String getName() { + return name; + } + + public UpdateTemplateWsRequest setName(@Nullable String name) { + this.name = name; + return this; + } + + @CheckForNull + public String getProjectKeyPattern() { + return projectKeyPattern; + } + + public UpdateTemplateWsRequest setProjectKeyPattern(@Nullable String projectKeyPattern) { + this.projectKeyPattern = projectKeyPattern; + return this; + } +} diff --git a/sonar-ws/src/main/protobuf/ws-permissions.proto b/sonar-ws/src/main/protobuf/ws-permissions.proto index 6f0c6243f0c..432eda6cb01 100644 --- a/sonar-ws/src/main/protobuf/ws-permissions.proto +++ b/sonar-ws/src/main/protobuf/ws-permissions.proto @@ -62,7 +62,7 @@ message CreateTemplateWsResponse { optional PermissionTemplate permissionTemplate = 1; } -message WsUpdatePermissionTemplateResponse { +message UpdateTemplateWsResponse { optional PermissionTemplate permissionTemplate = 1; } |