sensu-plugins / sensu-plugins-opsgenie

Sensu plugins for OpsGenie
http://sensu-plugins.io
MIT License
4 stars 24 forks source link

Recipients and Teams are deprecated fields #83

Closed bodgit closed 2 years ago

bodgit commented 3 years ago

The handler code currently creates an alert like this:

{
  ...
  "recipients": "the recipients",
  "teams": [
    { "name": "the-team" },
    { "id": "4513b7ea-3b91-438f-b7e4-e3e54af9147c" }
  ]
}

According to https://docs.opsgenie.com/docs/alert-api#create-alert neither of those two fields are documented as supported but they still work for now as a hangover from the old API. The JSON instead should look like this:

{
  ...
  "responders": [
    {
      "name": "a recipient",
      "type": "user"
    },
    {
      "name": "the-team",
      "type": "team"
    },
    {
      "id": "4513b7ea-3b91-438f-b7e4-e3e54af9147c",
      "type": "team"
    }
  ]
}

Also, the escalation and schedule types are not currently supported. I propose adding users, escalations, and schedules keys that take the same schema as the teams key and then the handler can munge all four into the one responders field, adding the correct type key along the way. The current recipients key can be supported instead of/as well as users by munging it into additional users entries.