Skip to content

sending alert object as create alert response body - #3124

Merged
mastercactapus merged 7 commits into
target:masterfrom
sudhabindu-apm:feat-alert-payload
Jul 19, 2023
Merged

mastercactapus merged 7 commits into
target:masterfrom
sudhabindu-apm:feat-alert-payload

Conversation

@sudhabindu-apm

Copy link
Copy Markdown
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.

@mastercactapus mastercactapus left a comment

Copy link
Copy Markdown
Member

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

Comment thread genericapi/handler.go Outdated
Comment thread genericapi/handler.go Outdated
Comment thread genericapi/handler.go Outdated
sudhabindu-apm and others added 2 commits July 14, 2023 15:42
Co-authored-by: Nathaniel Caza <mastercactapus@gmail.com>
@sudhabindu-apm

Copy link
Copy Markdown
Contributor Author

@mastercactapus I have made the requested changes.

Comment thread genericapi/handler.go Outdated
Comment thread genericapi/handler.go Outdated
Comment thread genericapi/handler.go Outdated
Comment thread genericapi/handler.go Outdated
Comment thread genericapi/handler.go Outdated
@sudhabindu-apm

sudhabindu-apm commented Jul 18, 2023

Copy link
Copy Markdown
Contributor Author

@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.

@allending313 allending313 left a comment

Copy link
Copy Markdown
Contributor

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
@sudhabindu-apm

Copy link
Copy Markdown
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