PagerDuty / go-pagerduty

go client library for PagerDuty v2 API
https://v2.developer.pagerduty.com/docs/rest-api
Apache License 2.0
285 stars 241 forks source link

APIObject for teams in EscalationPolicy? #517

Open fchiron opened 6 months ago

fchiron commented 6 months ago

Hi 👋

I'm trying to list escalation policies and get the id and summary of their team, and I noticed EscalationPolicy.Teams is a slice of APIReference (here), so it only contains the team id, not the summary.

However, when looking at the JSON payload of the GET /escalation_policies and GET /escalation_policies/{id} endpoints, I noticed the teams attribute looks like an array of APIObjects, the summary, self, and html_url attributes are there, for example:

{
  // ...
  "teams": [
    {
      "id": "PJ9K5JH",
      "type": "team_reference",
      "summary": "Incident Management",
      "self": "https://api.pagerduty.com/teams/PJ9K5JH",
      "html_url": "https://datadog.pagerduty.com/teams/PJ9K5JH"
    }
  ],
  // ...
}

Would it be possible to make EscalationPolicy.Teams a []APIObject instead of []APIReference? Maybe I'm missing something and it wouldn't work in some cases.

For use cases like mine (getting the escalation policy's team name), it would avoid an extra API call since the information is already there. Currently, as a workaround I think I'll need either to implement something custom using .Do(), or make extra API calls to the teams API endpoint.