aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWs.java42
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWsAction.java26
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWsModule.java33
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java (renamed from server/sonar-server/src/main/java/org/sonar/server/setting/ws/UpdateNewCodePeriodAction.java)13
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java (renamed from server/sonar-server/src/main/java/org/sonar/server/setting/ws/ShowNewCodePeriodAction.java)34
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/UnsetAction.java (renamed from server/sonar-server/src/main/java/org/sonar/server/setting/ws/DeleteNewCodePeriodAction.java)11
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWsModuleTest.java36
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/SetActionTest.java (renamed from server/sonar-server/src/test/java/org/sonar/server/setting/ws/UpdateNewCodePeriodActionTest.java)10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/ShowActionTest.java (renamed from server/sonar-server/src/test/java/org/sonar/server/setting/ws/ShowNewCodePeriodActionTest.java)50
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/UnsetActionTest.java (renamed from server/sonar-server/src/test/java/org/sonar/server/setting/ws/DeleteNewCodePeriodActionTest.java)10
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/SettingsWsModule.java7
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SettingsWsModuleTest.java2
-rw-r--r--server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java4
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java8
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java3
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/NewCodePeriodsService.java89
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/SetRequest.java86
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/ShowRequest.java60
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/UnsetRequest.java60
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/package-info.java26
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/settings/SettingsService.java50
-rw-r--r--sonar-ws/src/main/protobuf/ws-newcodeperiods.proto42
-rw-r--r--sonar-ws/src/main/protobuf/ws-settings.proto15
23 files changed, 583 insertions, 134 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWs.java b/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWs.java
new file mode 100644
index 00000000000..3cb959ade82
--- /dev/null
+++ b/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWs.java
@@ -0,0 +1,42 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.sonar.server.newcodeperiod.ws;
+
+import org.sonar.api.server.ws.WebService;
+
+public class NewCodePeriodsWs implements WebService {
+
+ private final NewCodePeriodsWsAction[] actions;
+
+ public NewCodePeriodsWs(NewCodePeriodsWsAction... actions) {
+ this.actions = actions;
+ }
+
+ @Override
+ public void define(Context context) {
+ NewController controller = context.createController("api/new_code_periods")
+ .setDescription("Manage new code periods.")
+ .setSince("8.0");
+ for (NewCodePeriodsWsAction action : actions) {
+ action.define(controller);
+ }
+ controller.done();
+ }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWsAction.java
new file mode 100644
index 00000000000..09b614abf72
--- /dev/null
+++ b/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWsAction.java
@@ -0,0 +1,26 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.sonar.server.newcodeperiod.ws;
+
+import org.sonar.server.ws.WsAction;
+
+public interface NewCodePeriodsWsAction extends WsAction {
+ // marker interface
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWsModule.java b/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWsModule.java
new file mode 100644
index 00000000000..77a400b0ed1
--- /dev/null
+++ b/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWsModule.java
@@ -0,0 +1,33 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.sonar.server.newcodeperiod.ws;
+
+import org.sonar.core.platform.Module;
+
+public class NewCodePeriodsWsModule extends Module {
+ @Override
+ protected void configureModule() {
+ add(
+ NewCodePeriodsWs.class,
+ ShowAction.class,
+ SetAction.class,
+ UnsetAction.class);
+ }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/UpdateNewCodePeriodAction.java b/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java
index d3126956172..d540e41933f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/UpdateNewCodePeriodAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java
@@ -17,7 +17,7 @@
* 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.sonar.server.setting.ws;
+package org.sonar.server.newcodeperiod.ws;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
@@ -50,7 +50,7 @@ import static org.sonar.db.newcodeperiod.NewCodePeriodType.PREVIOUS_VERSION;
import static org.sonar.db.newcodeperiod.NewCodePeriodType.SPECIFIC_ANALYSIS;
import static org.sonar.server.component.ComponentFinder.ParamNames.PROJECT_ID_AND_KEY;
-public class UpdateNewCodePeriodAction implements SettingsWsAction {
+public class SetAction implements NewCodePeriodsWsAction {
private static final String PARAM_BRANCH = "branch";
private static final String PARAM_PROJECT = "project";
private static final String PARAM_TYPE = "type";
@@ -64,7 +64,7 @@ public class UpdateNewCodePeriodAction implements SettingsWsAction {
private final ComponentFinder componentFinder;
private final NewCodePeriodDao newCodePeriodDao;
- public UpdateNewCodePeriodAction(DbClient dbClient, UserSession userSession, ComponentFinder componentFinder, NewCodePeriodDao newCodePeriodDao) {
+ public SetAction(DbClient dbClient, UserSession userSession, ComponentFinder componentFinder, NewCodePeriodDao newCodePeriodDao) {
this.dbClient = dbClient;
this.userSession = userSession;
this.componentFinder = componentFinder;
@@ -73,8 +73,9 @@ public class UpdateNewCodePeriodAction implements SettingsWsAction {
@Override
public void define(WebService.NewController context) {
- WebService.NewAction action = context.createAction("update_new_code_period")
- .setDescription("Updates the setting for the New Code Period.<br>" +
+ WebService.NewAction action = context.createAction("set")
+ .setPost(true)
+ .setDescription("Sets the setting for the New Code Period.<br>" +
"Requires one of the following permissions: " +
"<ul>" +
"<li>'Administer System' to change the global setting</li>" +
@@ -132,7 +133,7 @@ public class UpdateNewCodePeriodAction implements SettingsWsAction {
}
private void setValue(DbSession dbSession, NewCodePeriodDto dto, NewCodePeriodType type, @Nullable ComponentDto projectBranch,
- @Nullable String branch, @Nullable String value) {
+ @Nullable String branch, @Nullable String value) {
switch (type) {
case PREVIOUS_VERSION:
Preconditions.checkArgument(value == null, "Unexpected value for type '%s'", type);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/ShowNewCodePeriodAction.java b/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java
index bf03c299380..97993f401bf 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/ShowNewCodePeriodAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java
@@ -17,7 +17,7 @@
* 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.sonar.server.setting.ws;
+package org.sonar.server.newcodeperiod.ws;
import java.util.Optional;
import javax.annotation.Nullable;
@@ -36,15 +36,15 @@ import org.sonar.db.newcodeperiod.NewCodePeriodType;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Settings;
-import org.sonarqube.ws.Settings.ShowNewCodePeriodResponse;
+import org.sonarqube.ws.NewCodePeriods;
+import org.sonarqube.ws.NewCodePeriods.ShowWSResponse;
import static com.google.common.base.Preconditions.checkArgument;
import static java.lang.String.format;
import static org.sonar.server.component.ComponentFinder.ParamNames.PROJECT_ID_AND_KEY;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
-public class ShowNewCodePeriodAction implements SettingsWsAction {
+public class ShowAction implements NewCodePeriodsWsAction {
private static final String PARAM_BRANCH = "branch";
private static final String PARAM_PROJECT = "project";
@@ -53,7 +53,7 @@ public class ShowNewCodePeriodAction implements SettingsWsAction {
private final ComponentFinder componentFinder;
private final NewCodePeriodDao newCodePeriodDao;
- public ShowNewCodePeriodAction(DbClient dbClient, UserSession userSession, ComponentFinder componentFinder, NewCodePeriodDao newCodePeriodDao) {
+ public ShowAction(DbClient dbClient, UserSession userSession, ComponentFinder componentFinder, NewCodePeriodDao newCodePeriodDao) {
this.dbClient = dbClient;
this.userSession = userSession;
this.componentFinder = componentFinder;
@@ -62,7 +62,7 @@ public class ShowNewCodePeriodAction implements SettingsWsAction {
@Override
public void define(WebService.NewController context) {
- WebService.NewAction action = context.createAction("show_new_code_period")
+ WebService.NewAction action = context.createAction("show")
.setDescription("Shows a setting for the New Code Period.<br>" +
"Requires one of the following permissions: " +
"<ul>" +
@@ -104,7 +104,7 @@ public class ShowNewCodePeriodAction implements SettingsWsAction {
projectUuid = projectBranch.getMainBranchProjectUuid() != null ? projectBranch.getMainBranchProjectUuid() : projectBranch.uuid();
}
- ShowNewCodePeriodResponse.Builder builder = get(dbSession, projectUuid, branchUuid, false);
+ ShowWSResponse.Builder builder = get(dbSession, projectUuid, branchUuid, false);
if (projectStr != null) {
builder.setProjectKey(projectStr);
@@ -116,7 +116,7 @@ public class ShowNewCodePeriodAction implements SettingsWsAction {
}
}
- private ShowNewCodePeriodResponse.Builder get(DbSession dbSession, @Nullable String projectUuid, @Nullable String branchUuid, boolean inherited) {
+ private ShowWSResponse.Builder get(DbSession dbSession, @Nullable String projectUuid, @Nullable String branchUuid, boolean inherited) {
if (projectUuid == null) {
Optional<NewCodePeriodDto> dto = newCodePeriodDao.selectGlobal(dbSession);
return dto.map(d -> build(d, inherited))
@@ -133,8 +133,8 @@ public class ShowNewCodePeriodAction implements SettingsWsAction {
.orElseGet(() -> get(dbSession, projectUuid, null, true));
}
- private ShowNewCodePeriodResponse.Builder build(NewCodePeriodDto dto, boolean inherited) {
- ShowNewCodePeriodResponse.Builder builder = ShowNewCodePeriodResponse.newBuilder()
+ private ShowWSResponse.Builder build(NewCodePeriodDto dto, boolean inherited) {
+ ShowWSResponse.Builder builder = ShowWSResponse.newBuilder()
.setType(convertType(dto.getType()))
.setInherited(inherited);
@@ -144,22 +144,22 @@ public class ShowNewCodePeriodAction implements SettingsWsAction {
return builder;
}
- private ShowNewCodePeriodResponse.Builder buildDefault(boolean inherited) {
- return ShowNewCodePeriodResponse.newBuilder()
+ private ShowWSResponse.Builder buildDefault(boolean inherited) {
+ return ShowWSResponse.newBuilder()
.setType(convertType(NewCodePeriodType.PREVIOUS_VERSION))
.setInherited(inherited);
}
- private Settings.NewCodePeriodType convertType(NewCodePeriodType type) {
+ private NewCodePeriods.NewCodePeriodType convertType(NewCodePeriodType type) {
switch (type) {
case NUMBER_OF_DAYS:
- return Settings.NewCodePeriodType.NUMBER_OF_DAYS;
+ return NewCodePeriods.NewCodePeriodType.NUMBER_OF_DAYS;
case DATE:
- return Settings.NewCodePeriodType.DATE;
+ return NewCodePeriods.NewCodePeriodType.DATE;
case PREVIOUS_VERSION:
- return Settings.NewCodePeriodType.PREVIOUS_VERSION;
+ return NewCodePeriods.NewCodePeriodType.PREVIOUS_VERSION;
case SPECIFIC_ANALYSIS:
- return Settings.NewCodePeriodType.SPECIFIC_ANALYSIS;
+ return NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS;
default:
throw new IllegalStateException("Unexpected type: " + type);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/DeleteNewCodePeriodAction.java b/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/UnsetAction.java
index 452be227986..2ef7d0ca728 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/DeleteNewCodePeriodAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/newcodeperiod/ws/UnsetAction.java
@@ -17,7 +17,7 @@
* 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.sonar.server.setting.ws;
+package org.sonar.server.newcodeperiod.ws;
import javax.annotation.Nullable;
import org.sonar.api.server.ws.Request;
@@ -38,7 +38,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static java.lang.String.format;
import static org.sonar.server.component.ComponentFinder.ParamNames.PROJECT_ID_AND_KEY;
-public class DeleteNewCodePeriodAction implements SettingsWsAction {
+public class UnsetAction implements NewCodePeriodsWsAction {
private static final String PARAM_BRANCH = "branch";
private static final String PARAM_PROJECT = "project";
@@ -47,7 +47,7 @@ public class DeleteNewCodePeriodAction implements SettingsWsAction {
private final ComponentFinder componentFinder;
private final NewCodePeriodDao newCodePeriodDao;
- public DeleteNewCodePeriodAction(DbClient dbClient, UserSession userSession, ComponentFinder componentFinder, NewCodePeriodDao newCodePeriodDao) {
+ public UnsetAction(DbClient dbClient, UserSession userSession, ComponentFinder componentFinder, NewCodePeriodDao newCodePeriodDao) {
this.dbClient = dbClient;
this.userSession = userSession;
this.componentFinder = componentFinder;
@@ -56,8 +56,9 @@ public class DeleteNewCodePeriodAction implements SettingsWsAction {
@Override
public void define(WebService.NewController context) {
- WebService.NewAction action = context.createAction("delete_new_code_period")
- .setDescription("Removes the New Code Period setting for a branch, project or global.<br>" +
+ WebService.NewAction action = context.createAction("unset")
+ .setPost(true)
+ .setDescription("Unset the New Code Period setting for a branch, project or global.<br>" +
"Requires one of the following permissions: " +
"<ul>" +
"<li>'Administer System' to change the global setting</li>" +
diff --git a/server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWsModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWsModuleTest.java
new file mode 100644
index 00000000000..93c20e3330d
--- /dev/null
+++ b/server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/NewCodePeriodsWsModuleTest.java
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.sonar.server.newcodeperiod.ws;
+
+import org.junit.Test;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class NewCodePeriodsWsModuleTest {
+
+ @Test
+ public void verify_count_of_added_components() {
+ ComponentContainer container = new ComponentContainer();
+ new NewCodePeriodsWsModule().configure(container);
+ assertThat(container.size()).isEqualTo(6);
+ }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/UpdateNewCodePeriodActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/SetActionTest.java
index 23ff28ab461..4fe9ee623b0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/UpdateNewCodePeriodActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/SetActionTest.java
@@ -17,7 +17,7 @@
* 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.sonar.server.setting.ws;
+package org.sonar.server.newcodeperiod.ws;
import javax.annotation.Nullable;
import org.junit.Rule;
@@ -46,7 +46,7 @@ import org.sonar.server.ws.WsActionTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
-public class UpdateNewCodePeriodActionTest {
+public class SetActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Rule
@@ -60,17 +60,17 @@ public class UpdateNewCodePeriodActionTest {
private ComponentFinder componentFinder = TestComponentFinder.from(db);
private NewCodePeriodDao dao = new NewCodePeriodDao(System2.INSTANCE, UuidFactoryFast.getInstance());
- private UpdateNewCodePeriodAction underTest = new UpdateNewCodePeriodAction(dbClient, userSession, componentFinder, dao);
+ private SetAction underTest = new SetAction(dbClient, userSession, componentFinder, dao);
private WsActionTester ws = new WsActionTester(underTest);
@Test
public void test_definition() {
WebService.Action definition = ws.getDef();
- assertThat(definition.key()).isEqualTo("update_new_code_period");
+ assertThat(definition.key()).isEqualTo("set");
assertThat(definition.isInternal()).isFalse();
assertThat(definition.since()).isEqualTo("8.0");
- assertThat(definition.isPost()).isFalse();
+ assertThat(definition.isPost()).isTrue();
assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("value", "type", "project", "branch");
assertThat(definition.param("value").isRequired()).isFalse();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/ShowNewCodePeriodActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/ShowActionTest.java
index 926793a44d3..069093cdb89 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/ShowNewCodePeriodActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/ShowActionTest.java
@@ -17,7 +17,7 @@
* 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.sonar.server.setting.ws;
+package org.sonar.server.newcodeperiod.ws;
import org.junit.Rule;
import org.junit.Test;
@@ -42,12 +42,12 @@ import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.Settings;
-import org.sonarqube.ws.Settings.ShowNewCodePeriodResponse;
+import org.sonarqube.ws.NewCodePeriods;
+import org.sonarqube.ws.NewCodePeriods.ShowWSResponse;
import static org.assertj.core.api.Assertions.assertThat;
-public class ShowNewCodePeriodActionTest {
+public class ShowActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Rule
@@ -61,14 +61,14 @@ public class ShowNewCodePeriodActionTest {
private ComponentFinder componentFinder = TestComponentFinder.from(db);
private NewCodePeriodDao dao = new NewCodePeriodDao(System2.INSTANCE, UuidFactoryFast.getInstance());
private NewCodePeriodDbTester tester = new NewCodePeriodDbTester(db);
- private ShowNewCodePeriodAction underTest = new ShowNewCodePeriodAction(dbClient, userSession, componentFinder, dao);
+ private ShowAction underTest = new ShowAction(dbClient, userSession, componentFinder, dao);
private WsActionTester ws = new WsActionTester(underTest);
@Test
public void test_definition() {
WebService.Action definition = ws.getDef();
- assertThat(definition.key()).isEqualTo("show_new_code_period");
+ assertThat(definition.key()).isEqualTo("show");
assertThat(definition.isInternal()).isFalse();
assertThat(definition.since()).isEqualTo("8.0");
assertThat(definition.isPost()).isFalse();
@@ -140,10 +140,10 @@ public class ShowNewCodePeriodActionTest {
public void show_global_setting() {
tester.insert(new NewCodePeriodDto().setType(NewCodePeriodType.PREVIOUS_VERSION));
- ShowNewCodePeriodResponse response = ws.newRequest()
- .executeProtobuf(ShowNewCodePeriodResponse.class);
+ ShowWSResponse response = ws.newRequest()
+ .executeProtobuf(ShowWSResponse.class);
- assertResponse(response, "", "", Settings.NewCodePeriodType.PREVIOUS_VERSION, "", false);
+ assertResponse(response, "", "", NewCodePeriods.NewCodePeriodType.PREVIOUS_VERSION, "", false);
}
@Test
@@ -156,11 +156,11 @@ public class ShowNewCodePeriodActionTest {
.setType(NewCodePeriodType.NUMBER_OF_DAYS)
.setValue("4"));
- ShowNewCodePeriodResponse response = ws.newRequest()
+ ShowWSResponse response = ws.newRequest()
.setParam("project", project.getKey())
- .executeProtobuf(ShowNewCodePeriodResponse.class);
+ .executeProtobuf(ShowWSResponse.class);
- assertResponse(response, project.getKey(), "", Settings.NewCodePeriodType.NUMBER_OF_DAYS, "4", false);
+ assertResponse(response, project.getKey(), "", NewCodePeriods.NewCodePeriodType.NUMBER_OF_DAYS, "4", false);
}
@Test
@@ -176,12 +176,12 @@ public class ShowNewCodePeriodActionTest {
.setType(NewCodePeriodType.DATE)
.setValue("2018-04-05"));
- ShowNewCodePeriodResponse response = ws.newRequest()
+ ShowWSResponse response = ws.newRequest()
.setParam("project", project.getKey())
.setParam("branch", "branch")
- .executeProtobuf(ShowNewCodePeriodResponse.class);
+ .executeProtobuf(ShowWSResponse.class);
- assertResponse(response, project.getKey(), "branch", Settings.NewCodePeriodType.DATE, "2018-04-05", false);
+ assertResponse(response, project.getKey(), "branch", NewCodePeriods.NewCodePeriodType.DATE, "2018-04-05", false);
}
@Test
@@ -190,11 +190,11 @@ public class ShowNewCodePeriodActionTest {
logInAsProjectAdministrator(project);
tester.insert(new NewCodePeriodDto().setType(NewCodePeriodType.PREVIOUS_VERSION));
- ShowNewCodePeriodResponse response = ws.newRequest()
+ ShowWSResponse response = ws.newRequest()
.setParam("project", project.getKey())
- .executeProtobuf(ShowNewCodePeriodResponse.class);
+ .executeProtobuf(ShowWSResponse.class);
- assertResponse(response, project.getKey(), "", Settings.NewCodePeriodType.PREVIOUS_VERSION, "", true);
+ assertResponse(response, project.getKey(), "", NewCodePeriods.NewCodePeriodType.PREVIOUS_VERSION, "", true);
}
@Test
@@ -209,12 +209,12 @@ public class ShowNewCodePeriodActionTest {
.setType(NewCodePeriodType.DATE)
.setValue("2018-04-05"));
- ShowNewCodePeriodResponse response = ws.newRequest()
+ ShowWSResponse response = ws.newRequest()
.setParam("project", project.getKey())
.setParam("branch", "branch")
- .executeProtobuf(ShowNewCodePeriodResponse.class);
+ .executeProtobuf(ShowWSResponse.class);
- assertResponse(response, project.getKey(), "branch", Settings.NewCodePeriodType.DATE, "2018-04-05", true);
+ assertResponse(response, project.getKey(), "branch", NewCodePeriods.NewCodePeriodType.DATE, "2018-04-05", true);
}
@Test
@@ -224,15 +224,15 @@ public class ShowNewCodePeriodActionTest {
ComponentDto branch = componentDb.insertProjectBranch(project, b -> b.setKey("branch"));
tester.insert(new NewCodePeriodDto().setType(NewCodePeriodType.NUMBER_OF_DAYS).setValue("3"));
- ShowNewCodePeriodResponse response = ws.newRequest()
+ ShowWSResponse response = ws.newRequest()
.setParam("project", project.getKey())
.setParam("branch", "branch")
- .executeProtobuf(ShowNewCodePeriodResponse.class);
+ .executeProtobuf(ShowWSResponse.class);
- assertResponse(response, project.getKey(), "branch", Settings.NewCodePeriodType.NUMBER_OF_DAYS, "3", true);
+ assertResponse(response, project.getKey(), "branch", NewCodePeriods.NewCodePeriodType.NUMBER_OF_DAYS, "3", true);
}
- private void assertResponse(ShowNewCodePeriodResponse response, String projectKey, String branchKey, Settings.NewCodePeriodType type, String value, boolean inherited) {
+ private void assertResponse(ShowWSResponse response, String projectKey, String branchKey, NewCodePeriods.NewCodePeriodType type, String value, boolean inherited) {
assertThat(response.getBranchKey()).isEqualTo(branchKey);
assertThat(response.getProjectKey()).isEqualTo(projectKey);
assertThat(response.getInherited()).isEqualTo(inherited);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/DeleteNewCodePeriodActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/UnsetActionTest.java
index ace4cf9d9ae..c3391fa346f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/DeleteNewCodePeriodActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/newcodeperiod/ws/UnsetActionTest.java
@@ -17,7 +17,7 @@
* 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.sonar.server.setting.ws;
+package org.sonar.server.newcodeperiod.ws;
import javax.annotation.Nullable;
import org.junit.Rule;
@@ -45,7 +45,7 @@ import org.sonar.server.ws.WsActionTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
-public class DeleteNewCodePeriodActionTest {
+public class UnsetActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Rule
@@ -59,17 +59,17 @@ public class DeleteNewCodePeriodActionTest {
private ComponentFinder componentFinder = TestComponentFinder.from(db);
private NewCodePeriodDao dao = new NewCodePeriodDao(System2.INSTANCE, UuidFactoryFast.getInstance());
- private DeleteNewCodePeriodAction underTest = new DeleteNewCodePeriodAction(dbClient, userSession, componentFinder, dao);
+ private UnsetAction underTest = new UnsetAction(dbClient, userSession, componentFinder, dao);
private WsActionTester ws = new WsActionTester(underTest);
@Test
public void test_definition() {
WebService.Action definition = ws.getDef();
- assertThat(definition.key()).isEqualTo("delete_new_code_period");
+ assertThat(definition.key()).isEqualTo("unset");
assertThat(definition.isInternal()).isFalse();
assertThat(definition.since()).isEqualTo("8.0");
- assertThat(definition.isPost()).isFalse();
+ assertThat(definition.isPost()).isTrue();
assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("project", "branch");
assertThat(definition.param("project").isRequired()).isFalse();
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/SettingsWsModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/SettingsWsModule.java
index a6aa98ac31a..c05d791baaa 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/SettingsWsModule.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/SettingsWsModule.java
@@ -26,7 +26,7 @@ public class SettingsWsModule extends Module {
protected void configureModule() {
add(
SettingsWs.class,
- SetAction.class,
+ org.sonar.server.setting.ws.SetAction.class,
SettingsWsSupport.class,
ListDefinitionsAction.class,
ValuesAction.class,
@@ -35,9 +35,6 @@ public class SettingsWsModule extends Module {
GenerateSecretKeyAction.class,
CheckSecretKeyAction.class,
SettingsUpdater.class,
- SettingValidations.class,
- ShowNewCodePeriodAction.class,
- UpdateNewCodePeriodAction.class,
- DeleteNewCodePeriodAction.class);
+ SettingValidations.class);
}
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SettingsWsModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SettingsWsModuleTest.java
index c99fc2a4487..b3dd8904a60 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SettingsWsModuleTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SettingsWsModuleTest.java
@@ -29,6 +29,6 @@ public class SettingsWsModuleTest {
public void verify_count_of_added_components() {
ComponentContainer container = new ComponentContainer();
new SettingsWsModule().configure(container);
- assertThat(container.size()).isEqualTo(14 + 2);
+ assertThat(container.size()).isEqualTo(11 + 2);
}
}
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
index da9712f4f48..2ae9b1a7cc8 100644
--- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
+++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
@@ -100,6 +100,7 @@ import org.sonar.server.measure.ws.TimeMachineWs;
import org.sonar.server.metric.CoreCustomMetrics;
import org.sonar.server.metric.DefaultMetricFinder;
import org.sonar.server.metric.ws.MetricsWsModule;
+import org.sonar.server.newcodeperiod.ws.NewCodePeriodsWsModule;
import org.sonar.server.notification.NotificationModule;
import org.sonar.server.notification.ws.NotificationWsModule;
import org.sonar.server.organization.BillingValidationsProxyImpl;
@@ -464,6 +465,9 @@ public class PlatformLevel4 extends PlatformLevel {
TypeValidationModule.class,
+ //New Code Periods
+ NewCodePeriodsWsModule.class,
+
// Project Links
ProjectLinksModule.class,
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java
index 587899c7824..b532a4145e7 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java
@@ -40,6 +40,7 @@ import org.sonarqube.ws.client.languages.LanguagesService;
import org.sonarqube.ws.client.measures.MeasuresService;
import org.sonarqube.ws.client.metrics.MetricsService;
import org.sonarqube.ws.client.navigation.NavigationService;
+import org.sonarqube.ws.client.newcodeperiods.NewCodePeriodsService;
import org.sonarqube.ws.client.notifications.NotificationsService;
import org.sonarqube.ws.client.organizations.OrganizationsService;
import org.sonarqube.ws.client.permissions.PermissionsService;
@@ -103,6 +104,7 @@ class DefaultWsClient implements WsClient {
private final MeasuresService measuresService;
private final MetricsService metricsService;
private final NavigationService navigationService;
+ private final NewCodePeriodsService newCodePeriodsService;
private final NotificationsService notificationsService;
private final OrganizationsService organizationsService;
private final PermissionsService permissionsService;
@@ -159,6 +161,7 @@ class DefaultWsClient implements WsClient {
this.measuresService = new MeasuresService(wsConnector);
this.metricsService = new MetricsService(wsConnector);
this.navigationService = new NavigationService(wsConnector);
+ this.newCodePeriodsService = new NewCodePeriodsService(wsConnector);
this.notificationsService = new NotificationsService(wsConnector);
this.organizationsService = new OrganizationsService(wsConnector);
this.permissionsService = new PermissionsService(wsConnector);
@@ -296,6 +299,11 @@ class DefaultWsClient implements WsClient {
}
@Override
+ public NewCodePeriodsService newCodePeriods() {
+ return newCodePeriodsService;
+ }
+
+ @Override
public NotificationsService notifications() {
return notificationsService;
}
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 5fdba68259d..45bda4afc9d 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
@@ -40,6 +40,7 @@ import org.sonarqube.ws.client.languages.LanguagesService;
import org.sonarqube.ws.client.measures.MeasuresService;
import org.sonarqube.ws.client.metrics.MetricsService;
import org.sonarqube.ws.client.navigation.NavigationService;
+import org.sonarqube.ws.client.newcodeperiods.NewCodePeriodsService;
import org.sonarqube.ws.client.notifications.NotificationsService;
import org.sonarqube.ws.client.organizations.OrganizationsService;
import org.sonarqube.ws.client.permissions.PermissionsService;
@@ -134,6 +135,8 @@ public interface WsClient {
NavigationService navigation();
+ NewCodePeriodsService newCodePeriods();
+
NotificationsService notifications();
OrganizationsService organizations();
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/NewCodePeriodsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/NewCodePeriodsService.java
new file mode 100644
index 00000000000..ca470c3af25
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/NewCodePeriodsService.java
@@ -0,0 +1,89 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.newcodeperiods;
+
+import javax.annotation.Generated;
+import org.sonarqube.ws.MediaTypes;
+import org.sonarqube.ws.NewCodePeriods;
+import org.sonarqube.ws.client.BaseService;
+import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.PostRequest;
+import org.sonarqube.ws.client.WsConnector;
+
+/**
+ * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/new_code_periods">Further information about this web service online</a>
+ */
+@Generated("sonar-ws-generator")
+public class NewCodePeriodsService extends BaseService {
+
+ public NewCodePeriodsService(WsConnector wsConnector) {
+ super(wsConnector, "api/new_code_periods");
+ }
+
+ /**
+ * This is part of the internal API.
+ * This is a POST request.
+ *
+ * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/new_code_periods/set">Further information about this action online (including a response example)</a>
+ * @since 8.0
+ */
+ public void set(SetRequest request) {
+ call(
+ new PostRequest(path("set"))
+ .setParam("branch", request.getBranch())
+ .setParam("project", request.getProject())
+ .setParam("type", request.getType())
+ .setParam("value", request.getValue())
+ .setMediaType(MediaTypes.JSON)
+ ).content();
+ }
+
+ /**
+ * This is part of the internal API.
+ * This is a GET request.
+ *
+ * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/new_code_periods/show">Further information about this action online (including a response example)</a>
+ * @since 8.0
+ */
+ public NewCodePeriods.ShowWSResponse show(ShowRequest request) {
+ return call(
+ new GetRequest(path("show"))
+ .setParam("branch", request.getBranch())
+ .setParam("project", request.getProject())
+ .setMediaType(MediaTypes.JSON),
+ NewCodePeriods.ShowWSResponse.parser());
+ }
+
+ /**
+ * This is part of the internal API.
+ * This is a POST request.
+ *
+ * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/new_code_periods/unset">Further information about this action online (including a response example)</a>
+ * @since 8.0
+ */
+ public void unset(UnsetRequest request) {
+ call(
+ new PostRequest(path("unset"))
+ .setParam("branch", request.getBranch())
+ .setParam("project", request.getProject())
+ .setMediaType(MediaTypes.JSON)
+ ).content();
+ }
+}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/SetRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/SetRequest.java
new file mode 100644
index 00000000000..7baadac2f2c
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/SetRequest.java
@@ -0,0 +1,86 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.newcodeperiods;
+
+import javax.annotation.Generated;
+
+/**
+ * This is part of the internal API.
+ * This is a POST request.
+ *
+ * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/new_code_periods/set">Further information about this action online (including a response example)</a>
+ * @since 8.0
+ */
+@Generated("sonar-ws-generator")
+public class SetRequest {
+
+ private String branch;
+ private String project;
+ private String type;
+ private String value;
+
+ /**
+ *
+ */
+ public SetRequest setBranch(String branch) {
+ this.branch = branch;
+ return this;
+ }
+
+ public String getBranch() {
+ return branch;
+ }
+
+ /**
+ *
+ */
+ public SetRequest setProject(String project) {
+ this.project = project;
+ return this;
+ }
+
+ public String getProject() {
+ return project;
+ }
+
+ /**
+ * This is a mandatory parameter.
+ */
+ public SetRequest setType(String type) {
+ this.type = type;
+ return this;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ /**
+ *
+ */
+ public SetRequest setValue(String value) {
+ this.value = value;
+ return this;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/ShowRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/ShowRequest.java
new file mode 100644
index 00000000000..bb861d0fe23
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/ShowRequest.java
@@ -0,0 +1,60 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.newcodeperiods;
+
+import javax.annotation.Generated;
+
+/**
+ * This is part of the internal API.
+ * This is a POST request.
+ *
+ * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/new_code_periods/show">Further information about this action online (including a response example)</a>
+ * @since 8.0
+ */
+@Generated("sonar-ws-generator")
+public class ShowRequest {
+
+ private String branch;
+ private String project;
+
+ /**
+ *
+ */
+ public ShowRequest setBranch(String branch) {
+ this.branch = branch;
+ return this;
+ }
+
+ public String getBranch() {
+ return branch;
+ }
+
+ /**
+ *
+ */
+ public ShowRequest setProject(String project) {
+ this.project = project;
+ return this;
+ }
+
+ public String getProject() {
+ return project;
+ }
+}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/UnsetRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/UnsetRequest.java
new file mode 100644
index 00000000000..985a1cef159
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/UnsetRequest.java
@@ -0,0 +1,60 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.newcodeperiods;
+
+import javax.annotation.Generated;
+
+/**
+ * This is part of the internal API.
+ * This is a POST request.
+ *
+ * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/new_code_periods/unset">Further information about this action online (including a response example)</a>
+ * @since 8.0
+ */
+@Generated("sonar-ws-generator")
+public class UnsetRequest {
+
+ private String branch;
+ private String project;
+
+ /**
+ *
+ */
+ public UnsetRequest setBranch(String branch) {
+ this.branch = branch;
+ return this;
+ }
+
+ public String getBranch() {
+ return branch;
+ }
+
+ /**
+ *
+ */
+ public UnsetRequest setProject(String project) {
+ this.project = project;
+ return this;
+ }
+
+ public String getProject() {
+ return project;
+ }
+}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/package-info.java
new file mode 100644
index 00000000000..b7e60ae1992
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/newcodeperiods/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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
+@Generated("sonar-ws-generator")
+package org.sonarqube.ws.client.newcodeperiods;
+
+import javax.annotation.Generated;
+import javax.annotation.ParametersAreNonnullByDefault;
+
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/settings/SettingsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/settings/SettingsService.java
index bcb034d4797..90feda2e5b8 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/settings/SettingsService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/settings/SettingsService.java
@@ -22,7 +22,6 @@ package org.sonarqube.ws.client.settings;
import java.util.stream.Collectors;
import javax.annotation.Generated;
import org.sonarqube.ws.MediaTypes;
-import org.sonarqube.ws.Settings;
import org.sonarqube.ws.Settings.CheckSecretKeyWsResponse;
import org.sonarqube.ws.Settings.EncryptWsResponse;
import org.sonarqube.ws.Settings.GenerateSecretKeyWsResponse;
@@ -57,22 +56,6 @@ public class SettingsService extends BaseService {
}
/**
- *
- * This is part of the internal API.
- * This is a GET request.
- * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/settings/delete_new_code_period">Further information about this action online (including a response example)</a>
- * @since 8.0
- */
- public void deleteNewCodePeriod(DeleteNewCodePeriodRequest request) {
- call(
- new GetRequest(path("delete_new_code_period"))
- .setParam("branch", request.getBranch())
- .setParam("project", request.getProject())
- .setMediaType(MediaTypes.JSON)
- ).content();
- }
-
- /**
* This is part of the internal API.
* This is a GET request.
*
@@ -158,39 +141,6 @@ public class SettingsService extends BaseService {
* This is part of the internal API.
* This is a GET request.
*
- * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/settings/show_new_code_period">Further information about this action online (including a response example)</a>
- * @since 8.0
- */
- public Settings.ShowNewCodePeriodResponse showNewCodePeriod(ShowNewCodePeriodRequest request) {
- return call(
- new GetRequest(path("show_new_code_period"))
- .setParam("branch", request.getBranch())
- .setParam("project", request.getProject()),
- Settings.ShowNewCodePeriodResponse.parser());
- }
-
- /**
- * This is part of the internal API.
- * This is a GET request.
- *
- * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/settings/update_new_code_period">Further information about this action online (including a response example)</a>
- * @since 8.0
- */
- public void updateNewCodePeriod(UpdateNewCodePeriodRequest request) {
- call(
- new GetRequest(path("update_new_code_period"))
- .setParam("branch", request.getBranch())
- .setParam("project", request.getProject())
- .setParam("type", request.getType())
- .setParam("value", request.getValue())
- .setMediaType(MediaTypes.JSON)
- ).content();
- }
-
- /**
- * This is part of the internal API.
- * This is a GET request.
- *
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/settings/values">Further information about this action online (including a response example)</a>
* @since 6.3
*/
diff --git a/sonar-ws/src/main/protobuf/ws-newcodeperiods.proto b/sonar-ws/src/main/protobuf/ws-newcodeperiods.proto
new file mode 100644
index 00000000000..bfb3caf5fde
--- /dev/null
+++ b/sonar-ws/src/main/protobuf/ws-newcodeperiods.proto
@@ -0,0 +1,42 @@
+// SonarQube, open source software quality management tool.
+// Copyright (C) 2008-2019 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.
+
+syntax = "proto2";
+
+package sonarqube.ws.batch;
+
+option java_package = "org.sonarqube.ws";
+option java_outer_classname = "NewCodePeriods";
+
+option optimize_for = SPEED;
+
+// WS api/new_code_periods/show
+message ShowWSResponse {
+ optional string projectKey = 1;
+ optional string branchKey = 2;
+ required NewCodePeriodType type = 3;
+ optional string value = 4;
+ required bool inherited = 5;
+}
+
+enum NewCodePeriodType {
+ PREVIOUS_VERSION = 0;
+ NUMBER_OF_DAYS = 1;
+ DATE = 2;
+ SPECIFIC_ANALYSIS = 3;
+}
diff --git a/sonar-ws/src/main/protobuf/ws-settings.proto b/sonar-ws/src/main/protobuf/ws-settings.proto
index 180e7d4c463..db185b54446 100644
--- a/sonar-ws/src/main/protobuf/ws-settings.proto
+++ b/sonar-ws/src/main/protobuf/ws-settings.proto
@@ -44,21 +44,6 @@ message CheckSecretKeyWsResponse {
bool secretKeyAvailable = 1;
}
-message ShowNewCodePeriodResponse {
- string projectKey = 1;
- string branchKey = 2;
- NewCodePeriodType type = 3;
- string value = 4;
- bool inherited = 5;
-}
-
-enum NewCodePeriodType {
- PREVIOUS_VERSION = 0;
- NUMBER_OF_DAYS = 1;
- DATE = 2;
- SPECIFIC_ANALYSIS = 3;
-}
-
message Definition {
string key = 1;
oneof nameOneOf {string name = 2;}