123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- /*
- * SonarQube
- * Copyright (C) 2009-2021 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.rules;
-
- import java.util.stream.Collectors;
- import javax.annotation.Generated;
- import org.sonarqube.ws.MediaTypes;
- import org.sonarqube.ws.Rules.CreateResponse;
- import org.sonarqube.ws.Rules.ListResponse;
- import org.sonarqube.ws.Rules.SearchResponse;
- import org.sonarqube.ws.Rules.ShowResponse;
- import org.sonarqube.ws.Rules.UpdateResponse;
- 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/rules">Further information about this web service online</a>
- */
- @Generated("sonar-ws-generator")
- public class RulesService extends BaseService {
-
- public RulesService(WsConnector wsConnector) {
- super(wsConnector, "api/rules");
- }
-
- /**
- *
- * This is part of the internal API.
- * This is a GET request.
- * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/rules/app">Further information about this action online (including a response example)</a>
- * @since 4.5
- */
- public String app(AppRequest request) {
- return call(
- new GetRequest(path("app"))
- .setMediaType(MediaTypes.JSON)).content();
- }
-
- /**
- *
- * This is part of the internal API.
- * This is a POST request.
- * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/rules/create">Further information about this action online (including a response example)</a>
- * @since 4.4
- */
- public void create(CreateRequest request) {
- call(
- new PostRequest(path("create"))
- .setParam("custom_key", request.getCustomKey())
- .setParam("markdown_description", request.getMarkdownDescription())
- .setParam("name", request.getName())
- .setParam("params", request.getParams() == null ? null : request.getParams().stream().collect(Collectors.joining(",")))
- .setParam("prevent_reactivation", request.getPreventReactivation())
- .setParam("severity", request.getSeverity())
- .setParam("status", request.getStatus())
- .setParam("template_key", request.getTemplateKey())
- .setParam("type", request.getType()),
- CreateResponse.parser());
- }
-
- /**
- *
- * This is part of the internal API.
- * This is a POST request.
- * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/rules/delete">Further information about this action online (including a response example)</a>
- * @since 4.4
- */
- public void delete(DeleteRequest request) {
- call(
- new PostRequest(path("delete"))
- .setParam("key", request.getKey())
- .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/rules/list">Further information about this action online (including a response example)</a>
- * @since 5.2
- */
- public ListResponse list() {
- return call(
- new GetRequest(path("list")),
- ListResponse.parser());
- }
-
- /**
- *
- * This is part of the internal API.
- * This is a GET request.
- * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/rules/repositories">Further information about this action online (including a response example)</a>
- * @since 4.5
- */
- public String repositories(RepositoriesRequest request) {
- return call(
- new GetRequest(path("repositories"))
- .setParam("language", request.getLanguage())
- .setParam("q", request.getQ())
- .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/rules/search">Further information about this action online (including a response example)</a>
- * @since 4.4
- */
- public SearchResponse search(SearchRequest request) {
- return call(
- new GetRequest(path("search"))
- .setParam("activation", request.getActivation())
- .setParam("active_severities", request.getActiveSeverities() == null ? null : request.getActiveSeverities().stream().collect(Collectors.joining(",")))
- .setParam("asc", request.getAsc())
- .setParam("available_since", request.getAvailableSince())
- .setParam("compareToProfile", request.getCompareToProfile())
- .setParam("f", request.getF() == null ? null : request.getF().stream().collect(Collectors.joining(",")))
- .setParam("facets", request.getFacets() == null ? null : request.getFacets().stream().collect(Collectors.joining(",")))
- .setParam("inheritance", request.getInheritance() == null ? null : request.getInheritance().stream().collect(Collectors.joining(",")))
- .setParam("is_template", request.getIsTemplate())
- .setParam("include_external", request.getIncludeExternal())
- .setParam("languages", request.getLanguages() == null ? null : request.getLanguages().stream().collect(Collectors.joining(",")))
- .setParam("p", request.getP())
- .setParam("ps", request.getPs())
- .setParam("q", request.getQ())
- .setParam("qprofile", request.getQprofile())
- .setParam("repositories", request.getRepositories() == null ? null : request.getRepositories().stream().collect(Collectors.joining(",")))
- .setParam("rule_key", request.getRuleKey())
- .setParam("s", request.getS())
- .setParam("severities", request.getSeverities() == null ? null : request.getSeverities().stream().collect(Collectors.joining(",")))
- .setParam("statuses", request.getStatuses() == null ? null : request.getStatuses().stream().collect(Collectors.joining(",")))
- .setParam("cwe", request.getCwe() == null ? null : request.getCwe().stream().collect(Collectors.joining(",")))
- .setParam("owaspTop10", request.getOwaspTop10() == null ? null : request.getOwaspTop10().stream().collect(Collectors.joining(",")))
- .setParam("sansTop25", request.getSansTop25() == null ? null : request.getSansTop25().stream().collect(Collectors.joining(",")))
- .setParam("sonarsourceSecurity", request.getSonarsourceSecurity() == null ? null : request.getSonarsourceSecurity().stream().collect(Collectors.joining(",")))
- .setParam("tags", request.getTags() == null ? null : request.getTags().stream().collect(Collectors.joining(",")))
- .setParam("template_key", request.getTemplateKey())
- .setParam("types", request.getTypes() == null ? null : request.getTypes().stream().collect(Collectors.joining(","))),
- SearchResponse.parser());
- }
-
- /**
- *
- * This is part of the internal API.
- * This is a GET request.
- * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/rules/show">Further information about this action online (including a response example)</a>
- * @since 4.2
- */
- public ShowResponse show(ShowRequest request) {
- return call(
- new GetRequest(path("show"))
- .setParam("actives", request.getActives())
- .setParam("key", request.getKey()),
- ShowResponse.parser());
- }
-
- /**
- *
- * This is part of the internal API.
- * This is a GET request.
- * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/rules/tags">Further information about this action online (including a response example)</a>
- * @since 4.4
- */
- public String tags(TagsRequest request) {
- return call(
- new GetRequest(path("tags"))
- .setParam("ps", request.getPs())
- .setParam("q", request.getQ())
- .setMediaType(MediaTypes.JSON)).content();
- }
-
- /**
- *
- * This is part of the internal API.
- * This is a POST request.
- * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/rules/update">Further information about this action online (including a response example)</a>
- * @since 4.4
- */
- public void update(UpdateRequest request) {
- call(
- new PostRequest(path("update"))
- .setParam("key", request.getKey())
- .setParam("markdown_description", request.getMarkdownDescription())
- .setParam("markdown_note", request.getMarkdownNote())
- .setParam("name", request.getName())
- .setParam("params", request.getParams() == null ? null : request.getParams().stream().collect(Collectors.joining(",")))
- .setParam("remediation_fn_base_effort", request.getRemediationFnBaseEffort())
- .setParam("remediation_fn_type", request.getRemediationFnType())
- .setParam("remediation_fy_gap_multiplier", request.getRemediationFyGapMultiplier())
- .setParam("severity", request.getSeverity())
- .setParam("status", request.getStatus())
- .setParam("tags", request.getTags() == null ? null : request.getTags().stream().collect(Collectors.joining(","))),
- UpdateResponse.parser());
- }
- }
|