public class CodeDxClient extends Object
Modifier and Type | Field and Description |
---|---|
protected org.apache.http.impl.client.HttpClientBuilder |
httpClientBuilder |
protected String |
key |
protected String |
url |
Constructor and Description |
---|
CodeDxClient(String url,
String key)
Creates a new client, ready to be used for communications with CodeDx.
|
CodeDxClient(String url,
String key,
org.apache.http.impl.client.HttpClientBuilder clientBuilder)
Creates a new client, ready to be used for communications with CodeDx.
|
Modifier and Type | Method and Description |
---|---|
String |
buildBrowsableAnalysisRunUrl(int projectId)
Deprecated.
|
String |
buildLatestFindingsUrl(int projectId) |
protected <T> T |
doHttpRequest(org.apache.http.client.methods.HttpRequestBase request,
String path,
boolean isXApi,
Type responseType,
Object requestBody)
Perform an HttpRequest to the given api path, with an optional request body, and parse the response
|
CodeDxVersion |
getCodeDxVersion() |
int |
getFindingsCount(int projectId,
Filter filter)
Retrieves the total findings count for a given project using the provided Filter
|
int |
getFindingsCount(String id)
Retrieves the total findings count for a given run.
|
List<CountGroup> |
getFindingsGroupedCounts(int projectId,
Filter filter,
String countBy)
Retrieves an array of CountGroups using the provided Filter and countBy field name.
|
Job |
getJob(String id)
Retrieves a specific job from CodeDx
|
String |
getJobStatus(String id)
Retrieves a job status from CodeDx.
|
Project |
getProject(int id)
Retrieves a specific project from CodeDx
|
List<Project> |
getProjects()
Retrieves a list of projects from CodeDx.
|
Map<String,TriageStatus> |
getTriageStatuses(int id)
Retrieves all Triage statuses for a given project.
|
void |
setAnalysisName(int projectId,
int analysisId,
String name) |
StartAnalysisResponse |
startAnalysis(int projectId,
Map<String,InputStream> artifacts)
Kicks off a CodeDx analysis run on a specified project
|
protected String key
protected String url
protected org.apache.http.impl.client.HttpClientBuilder httpClientBuilder
public CodeDxClient(String url, String key)
url
- URL of the CodeDx web application. The '/api' part of the URL is optional.key
- The API key. Note that permissions must be set for this key on CodeDx admin page.public CodeDxClient(String url, String key, org.apache.http.impl.client.HttpClientBuilder clientBuilder)
url
- URL of the CodeDx web application. The '/api' part of the URL is optional.key
- The API key. Note that permissions must be set for this key on CodeDx admin page.clientBuilder
- an HttpClientBuilder that can handle the certificate used by the server@Deprecated public String buildBrowsableAnalysisRunUrl(int projectId)
public String buildLatestFindingsUrl(int projectId)
public List<Project> getProjects() throws CodeDxClientException, IOException
CodeDxClientException
org.apache.http.client.ClientProtocolException
IOException
public Project getProject(int id) throws CodeDxClientException, IOException
id
- The project IDCodeDxClientException
org.apache.http.client.ClientProtocolException
IOException
public Map<String,TriageStatus> getTriageStatuses(int id) throws CodeDxClientException, IOException
id
- The project IDCodeDxClientException
org.apache.http.client.ClientProtocolException
IOException
public Job getJob(String id) throws CodeDxClientException, IOException
id
- The job IDCodeDxClientException
org.apache.http.client.ClientProtocolException
IOException
public String getJobStatus(String id) throws CodeDxClientException, IOException
id
- The job IDCodeDxClientException
org.apache.http.client.ClientProtocolException
IOException
public int getFindingsCount(String id) throws CodeDxClientException, IOException
id
- The run IDCodeDxClientException
org.apache.http.client.ClientProtocolException
IOException
public int getFindingsCount(int projectId, Filter filter) throws CodeDxClientException, IOException
projectId
- The project IDfilter
- A Filter object (set to null to not filter)CodeDxClientException
org.apache.http.client.ClientProtocolException
IOException
public List<CountGroup> getFindingsGroupedCounts(int projectId, Filter filter, String countBy) throws CodeDxClientException, IOException
projectId
- The project IDfilter
- A Filter objectcountBy
- The field to group the counts byCodeDxClientException
org.apache.http.client.ClientProtocolException
IOException
public void setAnalysisName(int projectId, int analysisId, String name) throws IOException, CodeDxClientException
IOException
CodeDxClientException
public CodeDxVersion getCodeDxVersion() throws IOException, CodeDxClientException
IOException
CodeDxClientException
protected <T> T doHttpRequest(org.apache.http.client.methods.HttpRequestBase request, String path, boolean isXApi, Type responseType, Object requestBody) throws IOException, CodeDxClientException
T
- Type parameter that determines the parsed response typerequest
- Generally a new `HttpGet`, `HttpPost`, or `HttpPut`path
- The relative API path (not including /x/ or /api/)isXApi
- Flag that determines whether the request will prepend /x/ or /api/ to the path (true = /x/)responseType
- A type instance that helps `gson` parse the response bodyrequestBody
- An optional payload that will be converted to json and sent with the requestIOException
- If the underlying IO goes wrongCodeDxClientException
- For non 2xx response codespublic StartAnalysisResponse startAnalysis(int projectId, Map<String,InputStream> artifacts) throws IOException, CodeDxClientException
projectId
- The project IDartifacts
- An array of streams to send over as analysis artifactsorg.apache.http.client.ClientProtocolException
IOException
CodeDxClientException
Copyright © 2004-2017. All Rights Reserved.