Skip to content

Conversation

@cathteng
Copy link
Member

@cathteng cathteng commented Dec 13, 2022

Add organization_slug to the url for the MonitorDetails endpoint. Keeps the original orgless URL for now.

For HC-512

monitor = Monitor.objects.get(id=monitor.id)
assert monitor.status == MonitorStatus.PENDING_DELETION
# ScheduledDeletion only available in control silo
assert ScheduledDeletion.objects.filter(
Copy link
Member Author

@cathteng cathteng Dec 13, 2022

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

@cathteng cathteng marked this pull request as ready for review December 13, 2022 21:15
@cathteng cathteng requested a review from a team as a code owner December 13, 2022 21:15
@cathteng cathteng requested review from a team and RyanSkonnord December 13, 2022 21:15
Copy link
Contributor

@RyanSkonnord RyanSkonnord left a 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()
Copy link
Contributor

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?

Copy link
Member Author

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()
Copy link
Contributor

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.

@cathteng cathteng merged commit fde0bd8 into master Dec 14, 2022
@cathteng cathteng deleted the cathyteng17/hc/convert-orgless-monitor-details-api branch December 14, 2022 21:00
@cathteng cathteng changed the title chore(hybrid-cloud): use organization_slug in MonitorDetails ref(hybrid-cloud): use organization_slug in MonitorDetails Dec 14, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants