Opsgenie Java API

The Opsgenie SDK for Java provides a Java API for Opsgenie services, making it easier for java developers to build applications that integrate with Opsgenie. With the Opsgenie SDK for Java, developers get started in minutes with a single, downloadable package that includes the OpsGenie Java library. Developers can build Java applications on top of APIs that take the complexity out of coding directly against a web service interface. The library provides APIs that hide much of the lower-level plumbing, including authentication, request retries, and error handling.

Before you can begin, you must sign up for Opsgenie service, create an API Integration and get your API key. In order to use the Opsgenie SDK for Java, you will need the API key from the API Integration you created. The API key is used to authenticate requests to the service and identify yourself as the sender of a request.

The Opsgenie SDK for Java requires J2SE Development Kit 6.0 - OpenJDK 6 or above. You can download the latest Java software from http://developers.sun.com/downloads/. The SDK also requires Apache Commons (HTTP Client and Logging), and Jackson third-party packages, which are included in the third-party directory of the SDK. You can also use opsgenie-javasdk-all-.jar as a single package with all dependencies included.

View Opsgenie Java SDK Javadoc

Java API for Maven and Gradle

Download Java SDK

Opsgenie Java SDK Source Code - GitHub

Client Configuration

The Opsgenie SDK for Java allows you to change the default client configuration, which is helpful when you want to:

  • Connect to the Internet through proxy
  • Tweak HTTP transport settings, such as connection timeout and request retries.
  • Specify TCP socket buffer size hints

Proxy Configuration

When constructing a client object, you can pass in an optional com.ifountain.opsgenie.client.util.ClientConfiguration object to customize the client's configuration. If you're connecting to the Internet through a proxy server, you'll need to configure your proxy server settings (proxy host, port and username/password) through the ClientConfiguration object.

Http Transport Configuration

Several HTTP transport options can be configured through the com.ifountain.opsgenie.client.util.ClientConfiguration object. Default values will suffice for the majority of users, but users who want more control can configure:

  • Socket timeout
  • Connection timeout
  • Maximum retry attempts for retry-able errors
  • Maximum open HTTP connection

Tcp Socket Buffer Size

Advanced users who want to tune low-level TCP parameters can additionally set TCP buffer size hints through the ClientConfiguration object. The majority of users will never need to tweak these values, but they are provided for advanced users.

Optimal TCP buffer sizes for an application are highly dependent on network and OS configuration and capabilities. For example, most modern operating systems provide auto-tuning logic for TCP buffer sizes, which can have a big impact on performance for TCP connections that are held open long enough for the auto-tuning to optimize buffer sizes.

Large buffer sizes (ex: 2MB) allow the OS to buffer more data in memory without requiring the remote server to acknowledge receipt of that information , so can be particularly useful when the network has high latency.

This is only a hint, and the OS may choose not to honor it. When using this option, users should always check the operating system's configured limits and defaults. Most OS's have a maximum TCP buffer size limit configured, and won't let you go beyond that limit unless you explicitly raise the max TCP buffer size limit.

Exception Handling

The following sections describe the different cases of exceptions that are thrown by the SDK and how to handle them appropriately

ApiException

This is the main type of exception that you'll need to deal with when using the Opsgenie SDK for Java. This exception represents an error response from an Opsgenie service. For example, if you request to close an alert that doesn't exist, Opsgenie will return an error response and all the details of that error response will be included in the thrown ApiException. ApiExceptionUtils could be used for converting this exception to ErrorResponse object, which provides more convenient/detailed representation of ApiException

When you encounter an ApiException, you know that your request was successfully sent to the Opsgenie service, but could not be successfully processed either because of errors in the request's parameters or because of issues on the service side.

For the deprecated alert service, this exception corresponds to OpsgenieClientException

IOException

This exception indicates that a problem occurred inside the Java client code, either while trying to send a request to Opsgenie or while trying to parse a response from Opsgenie. IOExceptions are more severe than ApiException and indicate a major problem that is preventing the client from being able to make service calls to Opsgenie. For example, the Opsgenie Java SDK will throw an IOException if no network connection is available when you try to call an operation on one of the clients.

The Java API Organization

The following packages in the Opsgenie SDK for Java provide the API:

  • com.ifountain.opsgenie.client: Provides the implementation APIs for Opsgenie operations. For example, it provides methods to create, close and get alerts, attach files, adding comments, etc.
  • com.ifountain.opsgenie.client.model: Provides the low-level API classes to create requests and process responses. For example, it includes the GetAlertRequest class to describe your get alert request, the CreateAlertRequest class to describe your alert create requests, etc.
  • com.ifountain.opsgenie.client.util: Provides some utility classes like ClientConfiguration, etc.
  • com.ifountain.opsgenie.client.swagger.api: Provides the implementation of Async Alert API for Opsgenie operations (generated by Swagger Codegen)
  • com.ifountain.opsgenie.client.swagger.model: Provides the low-level Async Alert API classes to create requests and process responses (generated by Swagger Codegen). For example, it includes the GetAlertRequest class to describe your get alert request, the CreateAlertRequest class to describe your alert create requests, etc.

For more information about the Opsgenie SDK for Java API, go to Java API Reference.

Actions

📘

Deprecated Java SDK

The Opsgenie SDK for Java provides the following actions that can be executed on Opsgenie service. For the deprecated actions (Opsgenie SDK older than 2.8.0), you can refer here.

Setting API Key

There are two ways for setting api key:

  1. Global (Using Client):
OpsGenieClient client = new OpsGenieClient();
client.setApiKey("ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079");
  1. Domain Based:
OpsGenieClient client = new OpsGenieClient();
AlertApi alertApi = client.alertV2();
alertApi.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079");

Create Alert

Creates alerts at Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

CreateAlertRequest request = new CreateAlertRequest();
request.setMessage("AppServer1 is down!");
request.setAlias("Tron");
request.setDescription("CPU usage is over 87%");
request.setTeams(Arrays.asList(new TeamRecipient().name("OperationTeam"), new TeamRecipient().name("NetworkTeam")));
request.setVisibleTo(Collections.singletonList((Recipient) new TeamRecipient().name("NetworkTeam")));
request.setActions(Arrays.asList("ping", "restart"));
request.setTags(Arrays.asList("network", "operations"));
request.setEntity("ApppServer1");
request.setPriority(CreateAlertRequest.PriorityEnum.P2);
request.setUser("[email protected]");
request.setNote("Alert created");

SuccessResponse response = client.createAlert(request);
Float took = response.getTook();
String requestId = response.getRequestId();
String message = response.getResult();

Close Alert

Closes alerts at Opsgenie.

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

CloseAlertRequest request = new CloseAlertRequest();
request.setUser("[email protected]");
request.setNote("Alert was unnecessary, closed by System");
request.setSource("System");

SuccessResponse response = client.closeAlert("66", "tiny", request);
String requestId = response.getRequestId();

Delete Alert

Deletes alerts at Opsgenie.

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

DeleteAlertRequest request = new DeleteAlertRequest();
request.setIdentifier("29c4d6f6-0919-40ec-8d37-4ab2alp042c8");
request.setIdentifierType(DeleteAlertRequest.IdentifierTypeEnum.ID);
request.setSource("System");
request.setUser("[email protected]");

SuccessResponse response = client.deleteAlert(request);
String requestId = response.getRequestId();

Get Alert

Retrieves specified alert details from Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

String identifier = "29c4d6f6-0919-40ec-8d37-4ab2alp042c8";
String identifierType = "id";

GetAlertResponse response = client.getAlert(identifier, identifierType);
String requestId = response.getRequestId();
Alert data = response.getData();
String alertId = data.getId();

List Alerts

Retrieves latest alerts with given limit at Opsgenie. If limit is not set it retrieves latest 20 alerts and 100 alerts max per request.

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

ListAlertsRequest request = new ListAlertsRequest();
request.setQuery("status: open");
request.setLimit(20);
request.setOrder(ListAlertsRequest.OrderEnum.DESC);
request.setSort(ListAlertsRequest.SortEnum.CREATEDAT);

ListAlertsResponse response = client.listAlerts(request);
String requestId = response.getRequestId();
BaseAlert data = response.getData().get(0);
String alertId = data.getId();
String alertMessage = data.getMessage();

List Alerts With Paging

Let's say we have 100 alerts at the system. We want to get 5 alerts per request and we want to start polling from the oldest alert.

Our first request will be like the following:

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

ListAlertsRequest request = new ListAlertsRequest();
request.setLimit(5);
request.setSort(ListAlertsRequest.SortEnum.CREATEDAT);
request.setOrder(ListAlertsRequest.OrderEnum.ASC);

List alerts = client.listAlerts(request).getData();
int offset = alerts.size();

Now, we have the latest "offset" value of the retrieved 5 alerts shown above. We will use the "offset" value at our next request to retrieve 6th to 10th alerts.

Our next request will be like the following:

ListAlertsRequest request = new ListAlertsRequest();
request.setLimit(5);
request.setSort(ListAlertsRequest.SortEnum.CREATEDAT);
request.setOrder(ListAlertsRequest.OrderEnum.ASC);
request.setOffset(offset); //  offset value from the first request.

List alerts = client.listAlerts(request).getData();
offset += alerts.size();

The next request will be the same as above.

Acknowledge

Acknowledges alerts in Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

AcknowledgeAlertRequest request = new AcknowledgeAlertRequest();
request.setUser("[email protected]");
request.setNote("Alert was unnecessary, acknowledged by System");
request.setSource("System");

String identifier = "engine";
String identifierType = "alias";

SuccessResponse response = client.acknowledgeAlert(identifier, identifierType, request);
Float took = response.getTook();
String requestId = response.getRequestId();

Unacknowledge

Unacknowledges alerts in Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

String identifier = "23";
String identifierType = "tiny";

UnAcknowledgeAlertRequest request = new UnAcknowledgeAlertRequest();
request.setUser("[email protected]");
request.setNote("Alert was necessary, unacknowledged by System");
request.setSource("System");

SuccessResponse response = client.unAcknowledgeAlert(identifier, identifierType, request);
Float took = response.getTook();
String requestId = response.getRequestId();

Snooze Request

Snooze request is used to snooze alerts in Opsgenie.

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

String identifier = "29c4d6f6-0919-40ec-8d37-4ab2ed2042c8";
String identifierType = "id";

SnoozeAlertRequest request = new SnoozeAlertRequest();
request.setEndTime(DateTime.now());
request.setUser("[email protected]");
request.setNote("Snoozed because of vacation by System");
request.setSource("System");

SuccessResponse response = client.snoozeAlert(identifier, request, identifierType);
String requestId = response.getRequestId();

Escalate To Next Request

Escalate to Next request is used to immediately process the next available rule in the specified escalation.

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

EscalationRecipient recipient = new EscalationRecipient();
recipient.setId("39d50168-24b3-4355-b285-b91060823dee");

EscalateAlertToNextRequest request = new EscalateAlertToNextRequest();
request.setEscalation(recipient);
request.setUser("[email protected]");
request.setNote("Snoozed because of vacation by System");
request.setSource("System");

SuccessResponse response = client.escalateAlert("29c4d6f6-0919-40ec-8d37-4ab2ed2042c8", request, "id");
String requestId = response.getRequestId();

Assign

Assigns the ownership of alerts in Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

AssignAlertRequest request = new AssignAlertRequest();
request.setOwner(new UserRecipient().username("[email protected]"));
request.setUser("[email protected]");
request.setNote("Snoozed because of vacation by System");
request.setSource("System");

SuccessResponse response = client.assignAlert("33", request, "tiny");
String requestId = response.getRequestId();

Add Note

Add notes to alerts in Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

AddAlertNoteRequest request = new AddAlertNoteRequest();
request.setUser("[email protected]");
request.setNote("We should find another solution.");
request.setSource("HR");

SuccessResponse response = client.addNote("33", request, "tiny");
String requestId = response.getRequestId();

Add Tags

Add tags to alerts in Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

AddAlertTagsRequest request = new AddAlertTagsRequest();
request.setUser("[email protected]");
request.setNote("We should find another tag.");
request.setSource("Server");
request.setTags(Arrays.asList("support", "network"));

SuccessResponse response = client.addTags("33", request, "tiny");
String requestId = response.getRequestId();

Remove Tags

Remove tags from alerts in Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

DeleteAlertTagsRequest request = new DeleteAlertTagsRequest();
request.setIdentifier("29c4d6f6-0919-40ec-8d37-4ab2ed2042c8");
request.setIdentifierType(DeleteAlertTagsRequest.IdentifierTypeEnum.ID);
request.setTags(Arrays.asList("business", "general", "IT"));
request.setSource("System");
request.setUser("[email protected]");
request.setNote("Unnecessary tags are removed");

SuccessResponse response = client.deleteTags(request);
String requestId = response.getRequestId();

Add Team

Add alert team request is used to add new teams to alerts in Opsgenie.

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

AddAlertTeamRequest request = new AddAlertTeamRequest();
request.setTeam(new TeamRecipient().name("OperationTeam"));
request.setSource("System");
request.setUser("[email protected]");
request.setNote("Team is added");

SuccessResponse response = client.addTeam("29c4d6f6-0919-40ec-8d37-4ab2ed2042c8", request, "id");
String requestId = response.getRequestId();

Add Details

Add details request is used to add properties to alert details in Opsgenie.

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

Map details = new HashMap();
details.put("prop1", "val1");
details.put("prop2", "val2");

AddAlertDetailsRequest request = new AddAlertDetailsRequest();
request.setUser("[email protected]");
request.setNote("Add these details to document");
request.setSource("HR");
request.setDetails(details);

SuccessResponse response = client.addDetails("29c4d6f6-0919-40ec-8d37-4ab2ed2042c8", request, "id");
String requestId = response.getRequestId();

Remove Details

Remove details request is used to remove properties from alert details in Opsgenie.

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

DeleteAlertDetailsRequest request = new DeleteAlertDetailsRequest();
request.setIdentifier("29c4d6f6-0919-40ec-8d37-4ab2ed2042c8");
request.setIdentifierType(DeleteAlertDetailsRequest.IdentifierTypeEnum.ID);
request.setKeys(Arrays.asList("prop1", "prop2"));
request.setSource("System");
request.setUser("[email protected]");
request.setNote("Remove unrelated details.");

SuccessResponse response = client.deleteDetails(request);
String requestId = response.getRequestId();

Execute Alert Action

Executes actions on alerts in Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

String identifier = "29c4d6f6-0919-40ec-8d37-4ab2ed2042c8";
String identifierType = "id";
String actionName = "rebase";

ExecuteCustomAlertActionRequest request = new ExecuteCustomAlertActionRequest();
request.setUser("[email protected]");
request.setNote("Executing rebase action");
request.setSource("Automation");

SuccessResponse response = client.executeCustomAction(identifier, actionName, identifierType, request);
String requestId = response.getRequestId();

List Recipients

Retrieves recipients of the specified alert in Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

ListAlertRecipientsResponse response = client.listRecipients("29c4d6f6-0919-40ec-8d37-4ab2ed2042c8", "id");
String requestId = response.getRequestId();
AlertRecipient data = response.getData().get(0);
String state = data.getState();
UserMeta user = data.getUser();

List Logs

Retrieves latest alert logs with given limit at Opsgenie. If limit is not set it retrieves latest 100 logs. 100 is also max log to be retrieved per request.

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

ListAlertLogsRequest request = new ListAlertLogsRequest();
request.setIdentifier("29c4d6f6-0919-40ec-8d37-4ab2ed2042c8");
request.setIdentifierType(ListAlertLogsRequest.IdentifierTypeEnum.ID);
request.setLimit(50);
request.setOrder(ListAlertLogsRequest.OrderEnum.ASC);

ListAlertLogsResponse response = client.listLogs(request);
String requestId = response.getRequestId();
AlertLog data = response.getData().get(0);
String logMessage = data.getLog();
DateTime createdAt = data.getCreatedAt();
String offset = data.getOffset();

To make pagination while getting logs:

  1. Make the request above. Notice that "offset" value response returned. You will use it in the second request.
  2. Make the second request like above, but make sure you populate the new requests offset parameter with the offset you obtained from the first request.
client.alertV2().listLogs(...newPageValue...);

List Notes

Retrieves latest alert notes with given limit at Opsgenie. If the limit is not set it retrieves latest 100 notes. 100 is also max note to be retrieved per request.

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

ListAlertNotesRequest request = new ListAlertNotesRequest();
request.setIdentifier("29c4d6f6-0919-40ec-8d37-4ab2ed2042c8");
request.setIdentifierType(ListAlertNotesRequest.IdentifierTypeEnum.ID);
request.setLimit(50);
request.setOrder(ListAlertNotesRequest.OrderEnum.ASC);
request.setDirection(ListAlertNotesRequest.DirectionEnum.NEXT);

ListAlertNotesResponse response = client.listNotes(request);
Float took = response.getTook();
String requestId = response.getRequestId();
AlertNote data = response.getData().get(0);
String offset = data.getOffset();
String note = data.getNote();
String owner = data.getOwner();
DateTime createdAt = data.getCreatedAt();

To make pagination while getting notes:

  1. Make the request above. Notice that "offset" value response returned. You will use it in the second request.
  2. Make a second request like above, but make sure you populate the new requests offset parameter with the offset you obtained from the first request.
client.alertV2().listNotes(...offset...);

Get Request Status

Retrieves status information of request with specified id in Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

GetRequestStatusResponse response = client.getRequestStatus("29c4d6f6-0919-40ec-8d37-4ab2ed2042c8");
String requestId = response.getRequestId();
AlertRequestStatus data = response.getData();
String alertId = data.getAlertId();
String integrationId = data.getIntegrationId();
String status = data.getStatus();
Boolean isSuccess = data.getIsSuccess();

Add Saved Search

Creates new saved search with given fields

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

AddSavedSearchRequest request = new AddSavedSearchRequest();
request.setName("My Saved Search");
request.setDescription("Saved search for open alerts");
request.setQuery("status: open");
request.setOwner(new UserRecipient().username("[email protected]"));

AddSavedSearchResponse response = client.addSavedSearches(request);
String requestId = response.getRequestId();
SavedSearchMeta data = response.getData();
String searchId = data.getId();
String searchName = data.getName();

Get Saved Search

Retrieves saved search of the specified id

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

String identifier = "29c4d6f6-0919-40ec-8d37-4ab2ed2042c8";
String identifierType = "id";

GetSavedSearchResponse response = client.getSavedSearch(identifier, identifierType);
String requestId = response.getRequestId();
SavedSearch data = response.getData();
String searchId = data.getId();
String searchName = data.getName();
String description = data.getDescription();
DateTime updatedAt = data.getUpdatedAt();
List teams = data.getTeams();

Remove Saved Search

Removes saved search of the specified alert in Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

String identifier = "29c4d6f6-0919-40ec-8d37-4ab2ed2042c8";
String identifierType = "id";

SuccessResponse response = client.deleteSavedSearch(identifier, identifierType);
String requestId = response.getRequestId();
String result = response.getResult();

Remove Saved Search

Retrieves saved searches of the specified alert in Opsgenie

AlertApi client = new OpsGenieClient().alertV2();
client.getApiClient().setApiKey("ab5454992-fabb2-4ba2-ad44f-1alp5ds8b5c079");

ListSavedSearchResponse response = client.listSavedSearches();
String requestId = response.getRequestId();
SavedSearchMeta data = response.getData().get(0);
String searchId = data.getId();
String searchName = data.getName();

Heartbeat Requests

Ping heartbeat is used send periodic heartbeat messages to Opsgenie. The heartbeat should be added to Opsgenie before sending a heartbeat, If a heartbeat with 10 minutes interval is added and Opsgenie does not get a heartbeat message within 10 minutes, Opsgenie creates an alert to notify the specified people.

For more information please refer to Heartbeat Monitoring and Heartbeat API pages.

Java SDK supports most of the functionality listed in the Heartbeats API page.

Add Heartbeat

Adds a heartbeat definition to OpsGenie

OpsGenieClient client = new OpsGenieClient();
AddHeartbeatRequest request = new AddHeartbeatRequest();
request.setApiKey("ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079");
request.setName("ServerX");

//optional props
request.setInterval(15);
request.setIntervalUnit(Heartbeat.IntervalUnit.minutes);
request.setEnabled(true);
request.setDescription("detailed description for this heartbeat");
AddHeartbeatResponse response = client.addHeartbeat(request);
String name = response.getName();

Ping Heartbeat

Used send periodic heartbeat messages to Opsgenie

OpsGenieClient client = new OpsGenieClient();

HeartbeatRequest request = new HeartbeatRequest();
request.setApiKey("ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079");
request.setName("ServerX");
HeartbeatResponse response = client.heartbeat(request);
long heartbeatInMillis = response.getHeartbeat();

Copy Notification Rules Request

Copies a user's current notification rules to multiple other users.

For more information please refer to Copying Notification Rules To Other Users page.

OpsGenieClient client = new OpsGenieClient();

CopyNotificationRulesRequest request = new CopyNotificationRulesRequest();
request.setApiKey("ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079");
request.setFromUser("[email protected]");
request.setToUsers(Arrays.asList("[email protected]"));
request.setRuleTypes(Arrays.asList("New Alert", "Closed Alert"));
CopyNotificationRulesResponse response = client.copyNotificationRules(request);
assert response.isSuccess();