Skip to content

Commit

Permalink
Use convert args
Browse files Browse the repository at this point in the history
  • Loading branch information
EricHasegawa committed Sep 14, 2023
1 parent def5205 commit 7e7ebe8
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/sentry/api/endpoints/release_threshold_details.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Any, Tuple

from django.http import HttpResponse
from rest_framework.request import Request
from rest_framework.response import Response
Expand All @@ -6,8 +8,9 @@
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import region_silo_endpoint
from sentry.api.bases.project import ProjectEndpoint
from sentry.api.exceptions import ResourceDoesNotExist
from sentry.api.serializers import serialize
from sentry.models import Project
from sentry.models.project import Project
from sentry.models.release_threshold.releasethreshold import ReleaseThreshold


Expand All @@ -18,12 +21,28 @@ class ReleaseThresholdDetailsEndpoint(ProjectEndpoint):
"GET": ApiPublishStatus.PRIVATE,
}

def get(self, request: Request, project: Project, threshold_id: str) -> HttpResponse:
def convert_args(
self,
request: Request,
organization_slug: str,
project_slug: str,
threshold_id: str,
*args,
**kwargs,
) -> Tuple[Any, Any]:
parsed_args, parsed_kwargs = super().convert_args(
request, organization_slug, project_slug, *args, **kwargs
)
try:
release_threshold = ReleaseThreshold.objects.get(
parsed_kwargs["release_threshold"] = ReleaseThreshold.objects.get(
id=threshold_id,
project=project,
project=parsed_kwargs["project"],
)
return Response(serialize(release_threshold, request.user), status=200)
except ReleaseThreshold.DoesNotExist:
return Response(status=404)
raise ResourceDoesNotExist
return parsed_args, parsed_kwargs

def get(
self, request: Request, project: Project, release_threshold: ReleaseThreshold
) -> HttpResponse:
return Response(serialize(release_threshold, request.user), status=200)

0 comments on commit 7e7ebe8

Please sign in to comment.