org.sonar.wsclient
Class SonarClient

java.lang.Object
  extended by org.sonar.wsclient.SonarClient

public class SonarClient
extends Object

Entry point of the Java Client for Sonar Web Services. It does not support all web services yet.

Example:

   SonarClient client = SonarClient.create("http://localhost:9000");
   IssueClient issueClient = client.issueClient();
 

Since:
3.6

Nested Class Summary
static class SonarClient.Builder
           
 
Field Summary
static int DEFAULT_CONNECT_TIMEOUT_MILLISECONDS
           
static int DEFAULT_READ_TIMEOUT_MILLISECONDS
           
 
Method Summary
 ActionPlanClient actionPlanClient()
          New client to interact with web services related to issue action plans
static SonarClient.Builder builder()
          Create a builder of SonarClients.
static SonarClient create(String serverUrl)
          Create a client with default configuration.
 String get(String relativeUrl, Map<String,Object> params)
          Send a GET request on the given relativeUrl, with provided parameters (can be empty).
 String get(String relativeUrl, Object... params)
          Same as get(String, java.util.Map) but parameters are defined as an array of even number of elements (key1, value1, key, value2, ...).
 IssueClient issueClient()
          New client to interact with web services related to issues
 PermissionClient permissionClient()
          New client to interact with web services related to users and groups permissions
 String post(String relativeUrl, Map<String,Object> params)
          Send a POST request on the given relativeUrl, with provided parameters (can be empty).
 String post(String relativeUrl, Object... params)
          Same as post(String, java.util.Map) but parameters are defined as an array of even number of elements (key1, value1, key, value2, ...).
 ProjectClient projectClient()
          New client to interact with web services related to projects
 QProfileClient qProfileClient()
          New client to interact with web services related to quality profiles
 QualityGateClient qualityGateClient()
          New client to interact with web services related to quality gates
 SystemClient systemClient()
           
 UserClient userClient()
          New client to interact with web services related to users
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONNECT_TIMEOUT_MILLISECONDS

public static final int DEFAULT_CONNECT_TIMEOUT_MILLISECONDS
See Also:
Constant Field Values

DEFAULT_READ_TIMEOUT_MILLISECONDS

public static final int DEFAULT_READ_TIMEOUT_MILLISECONDS
See Also:
Constant Field Values
Method Detail

issueClient

public IssueClient issueClient()
New client to interact with web services related to issues


actionPlanClient

public ActionPlanClient actionPlanClient()
New client to interact with web services related to issue action plans


userClient

public UserClient userClient()
New client to interact with web services related to users


permissionClient

public PermissionClient permissionClient()
New client to interact with web services related to users and groups permissions


projectClient

public ProjectClient projectClient()
New client to interact with web services related to projects


qualityGateClient

public QualityGateClient qualityGateClient()
New client to interact with web services related to quality gates


qProfileClient

public QProfileClient qProfileClient()
New client to interact with web services related to quality profiles


systemClient

public SystemClient systemClient()

builder

public static SonarClient.Builder builder()
Create a builder of SonarClients.


create

public static SonarClient create(String serverUrl)
Create a client with default configuration. Use builder() to define a custom configuration (credentials, HTTP proxy, HTTP timeouts).


post

public String post(String relativeUrl,
                   Map<String,Object> params)
Send a POST request on the given relativeUrl, with provided parameters (can be empty). The beginning slash (/) of relativeUrl is supported but not mandatory.

Example:

  Map<String,Object> params = new HashMap<>();
   params.put("name", "My Quality Gate");
   client.post("api/qualitygates/create", params);
 

Returns:
the response body
Since:
4.5

post

public String post(String relativeUrl,
                   Object... params)
Same as post(String, java.util.Map) but parameters are defined as an array of even number of elements (key1, value1, key, value2, ...). Keys must not be null.


get

public String get(String relativeUrl,
                  Map<String,Object> params)
Send a GET request on the given relativeUrl, with provided parameters (can be empty). The beginning slash (/) of relativeUrl is supported but not mandatory.

Returns:
the response body
Since:
4.5

get

public String get(String relativeUrl,
                  Object... params)
Same as get(String, java.util.Map) but parameters are defined as an array of even number of elements (key1, value1, key, value2, ...). Keys must not be null.



Copyright © 2009–2015 SonarSource. All rights reserved.