Class NewRelicClientImpl
- java.lang.Object
-
- org.jenkinsci.plugins.newrelicnotifier.api.NewRelicClientImpl
-
- All Implemented Interfaces:
NewRelicClient
public class NewRelicClientImpl extends Object implements NewRelicClient
REST client implementation for the New Relic API.
-
-
Field Summary
Fields Modifier and Type Field Description static StringAPI_HOSTstatic StringAPI_SCHEMEstatic StringAPPLICATIONS_ENDPOINTstatic StringDEPLOYMENT_ENDPOINTstatic StringEUROPEAN_API_HOSTstatic StringEUROPEAN_GRAPHQL_URLstatic StringGRAPHQL_URLstatic StringNERD_GRAPH_ENDPOINTstatic StringPAGE_PARAMETERstatic intPAGE_SIZE
-
Constructor Summary
Constructors Constructor Description NewRelicClientImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetApiEndpoint()Get API Endpoint URL for looking up credentials.StringgetApiEndpoint(boolean european)List<Application>getApplications(String apiKey, boolean european)Get the list of applications available to record deployment notifications for.protected org.apache.http.impl.client.CloseableHttpClientgetHttpClient(String host)StringmakePayload(String changelog, String commit, String deepLink, String deploymentType, String description, String entityGuid, String groupId, String timestamp, String user, String version)StringparseResponseBody(String str)voidsendNotification(String apiKey, String applicationId, String description, String revision, String changelog, String user, boolean european)Submit deployment notificationvoidsendNotificationV2(String apiKey, String changelog, String commit, String deepLink, String deploymentType, String description, String entityGuid, String groupId, String timestamp, String user, String version, boolean european, TaskListener listener)Submit deployment notification
-
-
-
Field Detail
-
API_SCHEME
public static final String API_SCHEME
- See Also:
- Constant Field Values
-
API_HOST
public static final String API_HOST
- See Also:
- Constant Field Values
-
EUROPEAN_API_HOST
public static final String EUROPEAN_API_HOST
- See Also:
- Constant Field Values
-
NERD_GRAPH_ENDPOINT
public static final String NERD_GRAPH_ENDPOINT
- See Also:
- Constant Field Values
-
DEPLOYMENT_ENDPOINT
public static final String DEPLOYMENT_ENDPOINT
- See Also:
- Constant Field Values
-
APPLICATIONS_ENDPOINT
public static final String APPLICATIONS_ENDPOINT
- See Also:
- Constant Field Values
-
PAGE_PARAMETER
public static final String PAGE_PARAMETER
- See Also:
- Constant Field Values
-
GRAPHQL_URL
public static final String GRAPHQL_URL
- See Also:
- Constant Field Values
-
EUROPEAN_GRAPHQL_URL
public static final String EUROPEAN_GRAPHQL_URL
- See Also:
- Constant Field Values
-
PAGE_SIZE
public static final int PAGE_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getApplications
public List<Application> getApplications(String apiKey, boolean european) throws IOException
Get the list of applications available to record deployment notifications for.- Specified by:
getApplicationsin interfaceNewRelicClient- Parameters:
apiKey- New Relic User API keyeuropean- Is the User API key created under a European account- Returns:
- A list of applications available for supplied API key.
- Throws:
IOException- when HttpClient is not able to be closed- See Also:
- https://docs.newrelic.com/docs/apm/apis/requirements/api-key
-
sendNotification
public void sendNotification(String apiKey, String applicationId, String description, String revision, String changelog, String user, boolean european) throws IOException
Submit deployment notification- Specified by:
sendNotificationin interfaceNewRelicClient- Parameters:
apiKey- New Relic API keyapplicationId- Application to register deployment fordescription- Text annotation for the deploymentrevision- The revision number from your source control systemchangelog- A list of changes for this deploymentuser- The name of the user/process that triggered this deployment- Throws:
IOException- when HttpClient is not able to be closed or unexpected status code received- See Also:
- https://docs.newrelic.com/docs/apm/apis/requirements/api-key
-
sendNotificationV2
public void sendNotificationV2(String apiKey, String changelog, String commit, String deepLink, String deploymentType, String description, String entityGuid, String groupId, String timestamp, String user, String version, boolean european, TaskListener listener) throws IOException
Submit deployment notification- Specified by:
sendNotificationV2in interfaceNewRelicClient- Parameters:
apiKey- New Relic API keychangelog- A list of changes for this deploymentcommit- A commit hash for the deploymentdeepLink- A deep link for the deploymentdeploymentType- A deployment type for the deploymentdescription- Text annotation for the deploymententityGuid- An entity GUID to identify the application for Nerdgraph deployment markersgroupId- A group id for the deploymenttimestamp- A timestamp for the deploymentuser- The name of the user/process that triggered this deploymentversion- A version for the deployment- Throws:
IOException- when HttpClient is not able to be closed or unexpected status code received- See Also:
- https://docs.newrelic.com/docs/apm/apis/requirements/api-key
-
getApiEndpoint
public String getApiEndpoint()
Get API Endpoint URL for looking up credentials.- Specified by:
getApiEndpointin interfaceNewRelicClient- Returns:
- The endpoint URL for the New Relic API
-
getApiEndpoint
public String getApiEndpoint(boolean european)
- Specified by:
getApiEndpointin interfaceNewRelicClient
-
makePayload
public String makePayload(String changelog, String commit, String deepLink, String deploymentType, String description, String entityGuid, String groupId, String timestamp, String user, String version)
-
getHttpClient
protected org.apache.http.impl.client.CloseableHttpClient getHttpClient(String host)
-
-