-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
ref(hybrid-cloud): use organization_slug in MonitorDetails #42300
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
ref(hybrid-cloud): use organization_slug in MonitorDetails #42300
Conversation
| monitor = Monitor.objects.get(id=monitor.id) | ||
| assert monitor.status == MonitorStatus.PENDING_DELETION | ||
| # ScheduledDeletion only available in control silo | ||
| assert ScheduledDeletion.objects.filter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ScheduledDeletion is a control silo only model so this test cannot be made region stable until a service exists for this
RyanSkonnord
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some notes for possible refactoring; otherwise looks good.
| """ | ||
| if organization_slug: | ||
| if project.organization.slug != organization_slug: | ||
| return self.respond_invalid() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does "details": "Invalid monitor" make sense here? Or is it just following a convention from other endpoints?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is sort of following convention, but my thinking here was that if the organization slug is incorrect, then it's an invalid monitor for that organization?
| """ | ||
| if organization_slug: | ||
| if project.organization.slug != organization_slug: | ||
| return self.respond_invalid() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like us to think about a way to abstract out these three duplicated lines, especially across other, similar endpoints. A utility function for the slug comparison is a good start. It would be even better if we can get rid of the "if...return" by raising an exception to trigger the 400 response. To generalize across other endpoints, a mixin superclass might be the way to go. We can work on this later -- just something to think about for now.
Add
organization_slugto the url for the MonitorDetails endpoint. Keeps the original orgless URL for now.For HC-512