diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-11-26 08:40:44 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-11-26 14:13:28 +0100 |
commit | 598d9e8a08c0bcfeac733ae8a7c65743289a96d7 (patch) | |
tree | 6982fd3c8eff8e7776873356b70e95fd2ee0eb50 /sonar-ws/src/main | |
parent | 93e81b2c3c3a4ebc644833cf4b364af800e808de (diff) | |
download | sonarqube-598d9e8a08c0bcfeac733ae8a7c65743289a96d7.tar.gz sonarqube-598d9e8a08c0bcfeac733ae8a7c65743289a96d7.zip |
SONAR-7048 WS user_tokens/search list access tokens of a user
Diffstat (limited to 'sonar-ws/src/main')
4 files changed, 57 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/SearchWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/SearchWsRequest.java new file mode 100644 index 00000000000..ee38993534b --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/SearchWsRequest.java @@ -0,0 +1,34 @@ +/* + * 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.usertoken; + +public class SearchWsRequest { + private String login; + + public String getLogin() { + return login; + } + + public SearchWsRequest setLogin(String login) { + this.login = login; + return this; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/UserTokensWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/UserTokensWsClient.java index 3c956477f4b..fdd7eeca721 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/UserTokensWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/UserTokensWsClient.java @@ -20,12 +20,15 @@ package org.sonarqube.ws.client.usertoken; +import org.sonarqube.ws.WsComponents.SearchWsResponse; import org.sonarqube.ws.WsUserTokens.GenerateWsResponse; import org.sonarqube.ws.client.WsClient; +import static org.sonarqube.ws.client.WsRequest.newGetRequest; import static org.sonarqube.ws.client.WsRequest.newPostRequest; import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.ACTION_GENERATE; import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.ACTION_REVOKE; +import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.ACTION_SEARCH; import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_LOGIN; import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_NAME; import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.USER_TOKENS_ENDPOINT; @@ -53,6 +56,14 @@ public class UserTokensWsClient { .setParam(PARAM_NAME, request.getName())); } + public SearchWsResponse search(SearchWsRequest request) { + return wsClient.execute( + newGetRequest(action(ACTION_SEARCH)) + .setParam(PARAM_LOGIN, request.getLogin()), + SearchWsResponse.parser() + ); + } + private static String action(String action) { return USER_TOKENS_ENDPOINT + SLASH + action; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/UserTokensWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/UserTokensWsParameters.java index 37ddfa0099b..203ee5243a8 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/UserTokensWsParameters.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/UserTokensWsParameters.java @@ -24,6 +24,7 @@ public class UserTokensWsParameters { public static final String USER_TOKENS_ENDPOINT = "api/user_tokens"; public static final String ACTION_GENERATE = "generate"; public static final String ACTION_REVOKE = "revoke"; + public static final String ACTION_SEARCH = "search"; public static final String PARAM_LOGIN = "login"; public static final String PARAM_NAME = "name"; diff --git a/sonar-ws/src/main/protobuf/ws-user_tokens.proto b/sonar-ws/src/main/protobuf/ws-user_tokens.proto index 8ba07bbf483..f25403ea6aa 100644 --- a/sonar-ws/src/main/protobuf/ws-user_tokens.proto +++ b/sonar-ws/src/main/protobuf/ws-user_tokens.proto @@ -30,3 +30,14 @@ message GenerateWsResponse { optional string name = 2; optional string token = 3; } + +// WS api/user_tokens/search +message SearchWsResponse { + optional string login = 1; + repeated UserToken userTokens = 2; + + message UserToken { + optional string name = 1; + optional string createdAt = 2; + } +} |