Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sending alert object as create alert response body #3124

Merged
merged 7 commits into from
Jul 19, 2023

Conversation

sudhabindu-apm
Copy link
Contributor

  • Identified the issue which this PR solves.
  • Read the CONTRIBUTING document.
  • Code builds clean without any errors or warnings.
  • Added appropriate tests for any new functionality.
  • All new and existing tests passed.
  • Added comments in the code, where necessary.
  • Ran make check to catch common errors. Fixed any that came up.

Description:
This PR adds the sends the created alert as response body in create alert generic API.

Which issue(s) this PR fixes:
Fixes #3123

Screenshots:
Screenshot 2023-06-26 at 12 41 54 PM

Describe any introduced API changes:
This PR changes the response of the createAlert API (POST /api/v2/generic/incoming) from 204 to 200 with the alert object as the payload.

Copy link
Member

@mastercactapus mastercactapus left a comment

Choose a reason for hiding this comment

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

For the response value, let's start as small as possible, and re-use existing field names from what already exists so we're consistent.

The closest we have for this is probably the webhook sender, so maybe something like this:

type CreateAlertResponse struct {
	AlertID     int64
	ServiceID   string
	IsDuplicate bool
}

reference: https://github.com/target/goalert/blob/master/notification/webhook/sender.go#L19

genericapi/handler.go Outdated Show resolved Hide resolved
genericapi/handler.go Outdated Show resolved Hide resolved
genericapi/handler.go Outdated Show resolved Hide resolved
@sudhabindu-apm
Copy link
Contributor Author

@mastercactapus I have made the requested changes.

genericapi/handler.go Outdated Show resolved Hide resolved
genericapi/handler.go Outdated Show resolved Hide resolved
genericapi/handler.go Outdated Show resolved Hide resolved
genericapi/handler.go Outdated Show resolved Hide resolved
genericapi/handler.go Outdated Show resolved Hide resolved
@sudhabindu-apm
Copy link
Contributor Author

sudhabindu-apm commented Jul 18, 2023

@mastercactapus I have made the required changes. I have changed the IsDuplicate parameter of the returned object to IsNew as CreateOrUpdate is returning that so that we don't do unnecessary negation.

Copy link
Collaborator

@allending313 allending313 left a comment

Choose a reason for hiding this comment

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

lgtm!

@mastercactapus mastercactapus merged commit 45aa4c2 into target:master Jul 19, 2023
6 checks passed
@sudhabindu-apm
Copy link
Contributor Author

Thank you!

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.

Provide alert metadata in the response body when creating an alert
4 participants