aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws/src/main/java/org/sonarqube
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-ws/src/main/java/org/sonarqube')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java7
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/GenerateWsRequest.java44
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/UserTokensWsClient.java51
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/UserTokensWsParameters.java33
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/package-info.java25
5 files changed, 160 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java
index b9822ee9872..39886b57a61 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java
@@ -27,6 +27,7 @@ import org.sonarqube.ws.client.component.ComponentsWsClient;
import org.sonarqube.ws.client.issue.IssuesWsClient;
import org.sonarqube.ws.client.permission.PermissionsWsClient;
import org.sonarqube.ws.client.qualityprofile.QualityProfilesWsClient;
+import org.sonarqube.ws.client.usertoken.UserTokensWsClient;
import static org.sonarqube.ws.client.WsRequest.MediaType.PROTOBUF;
@@ -48,6 +49,7 @@ public class WsClient {
private final ComponentsWsClient componentsWsClient;
private final QualityProfilesWsClient qualityProfilesWsClient;
private final IssuesWsClient issuesWsClient;
+ private final UserTokensWsClient userTokensWsClient;
public WsClient(WsConnector wsConnector) {
this.wsConnector = wsConnector;
@@ -55,6 +57,7 @@ public class WsClient {
this.componentsWsClient = new ComponentsWsClient(this);
this.qualityProfilesWsClient = new QualityProfilesWsClient(this);
this.issuesWsClient = new IssuesWsClient(this);
+ userTokensWsClient = new UserTokensWsClient(this);
}
public String execute(WsRequest wsRequest) {
@@ -80,4 +83,8 @@ public class WsClient {
public IssuesWsClient issuesWsClient() {
return issuesWsClient;
}
+
+ public UserTokensWsClient userTokensWsClient() {
+ return userTokensWsClient;
+ }
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/GenerateWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/GenerateWsRequest.java
new file mode 100644
index 00000000000..c5072110cad
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/GenerateWsRequest.java
@@ -0,0 +1,44 @@
+/*
+ * 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 GenerateWsRequest {
+ private String login;
+ private String name;
+
+ public String getLogin() {
+ return login;
+ }
+
+ public GenerateWsRequest setLogin(String login) {
+ this.login = login;
+ return this;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public GenerateWsRequest setName(String name) {
+ this.name = name;
+ 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
new file mode 100644
index 00000000000..21e076f3594
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/UserTokensWsClient.java
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+import org.sonarqube.ws.WsUserTokens.GenerateWsResponse;
+import org.sonarqube.ws.client.WsClient;
+
+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.USER_TOKENS_ENDPOINT;
+import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_LOGIN;
+import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_NAME;
+
+public class UserTokensWsClient {
+ private static final String SLASH = "/";
+ private final WsClient wsClient;
+
+ public UserTokensWsClient(WsClient wsClient) {
+ this.wsClient = wsClient;
+ }
+
+ public GenerateWsResponse generate(GenerateWsRequest request) {
+ return wsClient.execute(
+ newPostRequest(action(ACTION_GENERATE))
+ .setParam(PARAM_LOGIN, request.getLogin())
+ .setParam(PARAM_NAME, request.getName()),
+ GenerateWsResponse.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
new file mode 100644
index 00000000000..856fd6cdffd
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/UserTokensWsParameters.java
@@ -0,0 +1,33 @@
+/*
+ * 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 UserTokensWsParameters {
+ public static final String USER_TOKENS_ENDPOINT = "api/user_tokens";
+ public static final String ACTION_GENERATE = "generate";
+
+ public static final String PARAM_LOGIN = "login";
+ public static final String PARAM_NAME = "name";
+
+ private UserTokensWsParameters() {
+ // constants only
+ }
+}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/package-info.java
new file mode 100644
index 00000000000..b3b9a3e7648
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usertoken/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+@ParametersAreNonnullByDefault
+package org.sonarqube.ws.client.usertoken;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+