Skip to content

Conversation

tuannvm
Copy link

@tuannvm tuannvm commented Jun 23, 2021

Why?

  • Add from parameter
  • According to API document, from header is mandatory

@theckman theckman added this to the v1.5.0 milestone Jun 23, 2021
}

// ManageIncidentAlertsWithContext allows you to manage the alerts of an incident.
func (c *Client) ManageIncidentAlertsWithContext(ctx context.Context, incidentID string, alerts *IncidentAlertList) (*ListAlertsResponse, error) {
lar, _, err := c.manageIncidentAlertsWithContext(context.Background(), incidentID, alerts)
func (c *Client) ManageIncidentAlertsWithContext(ctx context.Context, from string, incidentID string, alerts *IncidentAlertList) (*ListAlertsResponse, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add to the GoDoc comment of both of these methods some context around the from parameter? Maybe something like // The from parameter is the email address of a valid user, associated with the PagerDuty account, making the request.

func (c *Client) manageIncidentAlertsWithContext(ctx context.Context, incidentID string, alerts *IncidentAlertList) (*ListAlertsResponse, *http.Response, error) {
resp, err := c.put(ctx, "/incidents/"+incidentID+"/alerts/", alerts, nil)
func (c *Client) manageIncidentAlertsWithContext(ctx context.Context, from string, incidentID string, alerts *IncidentAlertList) (*ListAlertsResponse, *http.Response, error) {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this line of whitespace from the top of the function, so h := ... is right up against the header?

@@ -649,7 +649,7 @@ func TestIncident_ManageAlerts(t *testing.T) {
},
},
}
res, _, err := client.ManageIncidentAlerts(incidentID, input)
res, _, err := client.ManageIncidentAlerts(from, incidentID, input)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to actually assert that the from value is making it through as an HTTP header. Could you update the handler above (on line 635) to look for that header and the correct value, and fail the request/test otherwise?

"From": from,
}

resp, err := c.put(ctx, "/incidents/"+incidentID+"/alerts/", alerts, h)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this existed before you made the change, but it seems like the trailing / on /alerts/ is a mistake. Could you remove it so that it just reads "/alerts"?

@theckman
Copy link
Collaborator

theckman commented Jul 7, 2021

Thank you for the contribution! There are a few opportunities to improve this PR, and so I added some comments with my feedback/thoughts. Let me know if you have any questions.

@theckman
Copy link
Collaborator

@tuannvm thank you again for this contribution. I wanted to reach back out to see if you had a moment to address the comments I made above, as well as whether you can resolve the merge conflicts and then rebase/squash your commit(s)? The v1.5.0 merge window is now open and I'd like to make sure this is included.

@theckman
Copy link
Collaborator

theckman commented Oct 7, 2021

@tuannvm I wanted to ping one last time to see if you may want to help shepherd this PR forward. Because I can't easily merge my own PRs, I would appreciate any time you could spare to help get this ready to be merged.

If not I totally understand, and appreciate you raising this PR.

@theckman
Copy link
Collaborator

theckman commented Nov 9, 2021

I opened #380 to supersede this PR.

@theckman theckman closed this in 52e8c50 Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants