opsgenie/opsgenie-nodejs-sdk

Return alertId for all operations (like in the case of create)

gabipetrovay opened this issue · 2 comments

When a create request is made the result contains also the newly created alertId:

{
    "took": 84,
    "code": 200,
    "alertId": "8faa119e-3d24-4878-abba-c69d7fee8c8b",
    "message": "alert created",
    "status": "successful",
    "httpStatusCode": 200
}

It would be very practical if other operations as well would return the alertId. For example the close operation, where one can close alerts based on an alias as well (and hence not having the alertId). Currently the close operation returns:

POST /v1/json/alert/close
{
    "alias": "myalias"
}
{
    "took": 54,
    "code": 200,
    "status": "successful",
    "httpStatusCode": 2
}

Here, the alertID would avoid us doing an extra request to get the alert with the given alias.

For the delete operation this might not make much sense from the OpsGenie point of view. But when correlating these alert IDs with external systems, it would be nice to always return the ID.

(I know this is an extension that should be added to the underlying WebAPI)

Hi Gabriel, thank you for your suggestion! As you said at the end, this is related with WebAPI not Node.js SDK. Our new Alert REST API is about to be released. Let me check what we will return in the new API. If it does not return alertId, I'll discuss with the team about this. I'll get back to you soon.

Hi @gabipetrovay for current SDK/Web API it is not possible to do what you want and we will not add new features to this API.

Today, we have released our brand new REST API. https://www.opsgenie.com/docs/rest-api/alert-api
For alert actions, it works in an async way. Note that SDK's will be ready soon but for now you can need to implement request flow by yourself.

In your case, you close the alert with the alias. You get a requestId from close request. Then, you use asynchronous request status endpoint to get the status of your request which has the alertId in response. Hope this helps.

Here is the related news https://www.opsgenie.com/news/#269

Thanks again!