Skip to content

Commit 1920bee

Browse files
authored
feat(api-idorslug): Rename Path paramaters to team_id_or_slug (#69618)
I renamed `team_slug` to `team_id_or_slug`. I also had to change some tests since they used `team_slug`
1 parent d5eb287 commit 1920bee

File tree

19 files changed

+97
-91
lines changed

19 files changed

+97
-91
lines changed

api-docs/openapi.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@
8787
}
8888
],
8989
"paths": {
90-
"/api/0/teams/{organization_slug}/{team_slug}/": {
90+
"/api/0/teams/{organization_slug}/{team_id_or_slug}/": {
9191
"$ref": "paths/teams/by-slug.json"
9292
},
93-
"/api/0/teams/{organization_slug}/{team_slug}/stats/": {
93+
"/api/0/teams/{organization_slug}/{team_id_or_slug}/stats/": {
9494
"$ref": "paths/teams/stats.json"
9595
},
9696
"/api/0/organizations/": {

api-docs/paths/teams/by-slug.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
}
1515
},
1616
{
17-
"name": "team_slug",
17+
"name": "team_id_or_slug",
1818
"in": "path",
19-
"description": "The slug of the team to get.",
19+
"description": "The id or slug of the team to get.",
2020
"required": true,
2121
"schema": {
2222
"type": "string"
@@ -92,9 +92,9 @@
9292
}
9393
},
9494
{
95-
"name": "team_slug",
95+
"name": "team_id_or_slug",
9696
"in": "path",
97-
"description": "The slug of the team to get.",
97+
"description": "The id or slug of the team to get.",
9898
"required": true,
9999
"schema": {
100100
"type": "string"
@@ -181,9 +181,9 @@
181181
}
182182
},
183183
{
184-
"name": "team_slug",
184+
"name": "team_id_or_slug",
185185
"in": "path",
186-
"description": "The slug of the team to get.",
186+
"description": "The id or slug of the team to get.",
187187
"required": true,
188188
"schema": {
189189
"type": "string"

api-docs/paths/teams/stats.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
}
1616
},
1717
{
18-
"name": "team_slug",
18+
"name": "team_id_or_slug",
1919
"in": "path",
20-
"description": "The slug of the team to get.",
20+
"description": "The id or slug of the team to get.",
2121
"required": true,
2222
"schema": {
2323
"type": "string"

src/sentry/api/bases/team.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,20 @@ def has_object_permission(self, request: Request, view, team):
3636
class TeamEndpoint(Endpoint):
3737
permission_classes: tuple[type[BasePermission], ...] = (TeamPermission,)
3838

39-
def convert_args(self, request: Request, organization_slug, team_slug, *args, **kwargs):
39+
def convert_args(self, request: Request, organization_slug, team_id_or_slug, *args, **kwargs):
4040
try:
4141
if id_or_slug_path_params_enabled(self.convert_args.__qualname__):
4242
team = (
4343
Team.objects.filter(
44-
organization__slug__id_or_slug=organization_slug, slug__id_or_slug=team_slug
44+
organization__slug__id_or_slug=organization_slug,
45+
slug__id_or_slug=team_id_or_slug,
4546
)
4647
.select_related("organization")
4748
.get()
4849
)
4950
else:
5051
team = (
51-
Team.objects.filter(organization__slug=organization_slug, slug=team_slug)
52+
Team.objects.filter(organization__slug=organization_slug, slug=team_id_or_slug)
5253
.select_related("organization")
5354
.get()
5455
)

src/sentry/api/endpoints/codeowners/external_actor/team_details.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ def convert_args(
2929
self,
3030
request: Request,
3131
organization_slug: str,
32-
team_slug: str,
32+
team_id_or_slug: int | str,
3333
external_team_id: int,
3434
*args: Any,
3535
**kwargs: Any,
3636
) -> tuple[Any, Any]:
37-
args, kwargs = super().convert_args(request, organization_slug, team_slug, *args, **kwargs)
37+
args, kwargs = super().convert_args(
38+
request, organization_slug, team_id_or_slug, *args, **kwargs
39+
)
3840
kwargs["external_team"] = self.get_external_actor_or_404(
3941
external_team_id, kwargs["team"].organization
4042
)
@@ -47,7 +49,7 @@ def put(self, request: Request, team: Team, external_team: ExternalActor) -> Res
4749
4850
:pparam string organization_slug: the slug of the organization the
4951
team belongs to.
50-
:pparam string team_slug: the slug of the team to get.
52+
:pparam string team_id_or_slug: the id or slug of the team to get.
5153
:pparam string external_team_id: id of external_team object
5254
:param string external_id: the associated user ID for this provider
5355
:param string external_name: the Github/Gitlab team name.

src/sentry/api/endpoints/codeowners/external_actor/team_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def post(self, request: Request, team: Team) -> Response:
2929
3030
:pparam string organization_slug: the slug of the organization the
3131
team belongs to.
32-
:pparam string team_slug: the slug of the team to get.
32+
:pparam string team_id_or_slug: the team_id_or_slug of the team to get.
3333
:param required string provider: enum("github", "gitlab")
3434
:param required string external_name: the associated Github/Gitlab team name.
3535
:param optional string integration_id: the id of the integration if it exists.

src/sentry/api/endpoints/organization_member/team_details.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def convert_args(
106106
) -> tuple[tuple[Any, ...], dict[str, Any]]:
107107
args, kwargs = super().convert_args(request, organization_slug, *args, **kwargs)
108108

109-
team_slug = kwargs.pop("team_slug")
109+
team_id_or_slug = kwargs.pop("team_id_or_slug")
110110
organization = kwargs["organization"]
111111
member = kwargs["member"]
112112

@@ -116,11 +116,11 @@ def convert_args(
116116
self.get.__qualname__, organization_slug=organization.slug
117117
):
118118
omt = OrganizationMemberTeam.objects.get(
119-
team__slug__id_or_slug=team_slug, organizationmember=member
119+
team__slug__id_or_slug=team_id_or_slug, organizationmember=member
120120
)
121121
else:
122122
omt = OrganizationMemberTeam.objects.get(
123-
team__slug=team_slug, organizationmember=member
123+
team__slug=team_id_or_slug, organizationmember=member
124124
)
125125
except OrganizationMemberTeam.DoesNotExist:
126126
raise ResourceDoesNotExist
@@ -133,10 +133,11 @@ def convert_args(
133133
self.post.__qualname__, organization_slug=organization.slug
134134
):
135135
team = Team.objects.get(
136-
organization__slug__id_or_slug=organization.slug, slug__id_or_slug=team_slug
136+
organization__slug__id_or_slug=organization.slug,
137+
slug__id_or_slug=team_id_or_slug,
137138
)
138139
else:
139-
team = Team.objects.get(organization=organization, slug=team_slug)
140+
team = Team.objects.get(organization=organization, slug=team_id_or_slug)
140141
except Team.DoesNotExist:
141142
raise ResourceDoesNotExist
142143
kwargs["team"] = team
@@ -230,7 +231,7 @@ def get(
230231
parameters=[
231232
GlobalParams.ORG_SLUG,
232233
GlobalParams.member_id("The ID of the organization member to add to the team"),
233-
GlobalParams.TEAM_SLUG,
234+
GlobalParams.TEAM_ID_OR_SLUG,
234235
],
235236
request=None,
236237
responses={
@@ -420,7 +421,7 @@ def _change_team_member_role(
420421
parameters=[
421422
GlobalParams.ORG_SLUG,
422423
GlobalParams.member_id("The ID of the organization member to delete from the team"),
423-
GlobalParams.TEAM_SLUG,
424+
GlobalParams.TEAM_ID_OR_SLUG,
424425
],
425426
responses={
426427
200: BaseTeamSerializer,

src/sentry/api/endpoints/project_team_details.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def convert_args(
4141
request: Request,
4242
organization_slug: str | int,
4343
project_slug: str | int,
44-
team_slug: str | int,
44+
team_id_or_slug: int | str,
4545
*args,
4646
**kwargs,
4747
):
@@ -57,10 +57,12 @@ def convert_args(
5757
):
5858
team = Team.objects.get(
5959
organization__slug__id_or_slug=project.organization.slug,
60-
slug__id_or_slug=team_slug,
60+
slug__id_or_slug=team_id_or_slug,
6161
)
6262
else:
63-
team = Team.objects.get(organization_id=project.organization_id, slug=team_slug)
63+
team = Team.objects.get(
64+
organization_id=project.organization_id, slug=team_id_or_slug
65+
)
6466
except Team.DoesNotExist:
6567
raise ResourceDoesNotExist(detail="Team does not exist.")
6668

@@ -72,7 +74,7 @@ def convert_args(
7274
parameters=[
7375
GlobalParams.ORG_SLUG,
7476
GlobalParams.PROJECT_SLUG,
75-
GlobalParams.TEAM_SLUG,
77+
GlobalParams.TEAM_ID_OR_SLUG,
7678
],
7779
request=None,
7880
responses={
@@ -103,7 +105,7 @@ def post(self, request: Request, project, team: Team) -> Response:
103105
parameters=[
104106
GlobalParams.ORG_SLUG,
105107
GlobalParams.PROJECT_SLUG,
106-
GlobalParams.TEAM_SLUG,
108+
GlobalParams.TEAM_ID_OR_SLUG,
107109
],
108110
responses={
109111
200: ProjectWithTeamSerializer,

src/sentry/api/endpoints/team_details.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def get(self, request: Request, team) -> Response:
5353
5454
:pparam string organization_slug: the slug of the organization the
5555
team belongs to.
56-
:pparam string team_slug: the slug of the team to get.
56+
:pparam string team_id_or_slug: the id or slug of the team to get.
5757
:qparam list expand: an optional list of strings to opt in to additional
5858
data. Supports `projects`, `externalTeams`.
5959
:qparam list collapse: an optional list of strings to opt out of certain
@@ -83,7 +83,7 @@ def put(self, request: Request, team) -> Response:
8383
8484
:pparam string organization_slug: the slug of the organization the
8585
team belongs to.
86-
:pparam string team_slug: the slug of the team to get.
86+
:pparam string team_id_or_slug: the id or slug of the team to get.
8787
:param string name: the new name for the team.
8888
:param string slug: a new slug for the team. It has to be unique
8989
and available.

src/sentry/api/endpoints/team_projects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class TeamProjectsEndpoint(TeamEndpoint, EnvironmentMixin):
8888
operation_id="List a Team's Projects",
8989
parameters=[
9090
GlobalParams.ORG_SLUG,
91-
GlobalParams.TEAM_SLUG,
91+
GlobalParams.TEAM_ID_OR_SLUG,
9292
CursorQueryParam,
9393
],
9494
request=None,
@@ -143,7 +143,7 @@ def get(self, request: Request, team) -> Response:
143143
operation_id="Create a New Project",
144144
parameters=[
145145
GlobalParams.ORG_SLUG,
146-
GlobalParams.TEAM_SLUG,
146+
GlobalParams.TEAM_ID_OR_SLUG,
147147
],
148148
request=ProjectPostSerializer,
149149
responses={

src/sentry/api/endpoints/team_stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get(self, request: Request, team) -> Response:
3434
resolutions.
3535
3636
:pparam string organization_slug: the slug of the organization.
37-
:pparam string team_slug: the slug of the team.
37+
:pparam string team_id_or_slug: the id or slug of the team.
3838
:qparam string stat: the name of the stat to query (``"received"``,
3939
``"rejected"``)
4040
:qparam timestamp since: a timestamp to set the start of the query

src/sentry/api/urls.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ def create_group_urls(name_prefix: str) -> list[URLPattern | URLResolver]:
17001700
name="sentry-api-0-organization-member-unreleased-commits",
17011701
),
17021702
re_path(
1703-
r"^(?P<organization_slug>[^\/]+)/members/(?P<member_id>[^\/]+)/teams/(?P<team_slug>[^\/]+)/$",
1703+
r"^(?P<organization_slug>[^\/]+)/members/(?P<member_id>[^\/]+)/teams/(?P<team_id_or_slug>[^\/]+)/$",
17041704
OrganizationMemberTeamDetailsEndpoint.as_view(),
17051705
name="sentry-api-0-organization-member-team-details",
17061706
),
@@ -2542,7 +2542,7 @@ def create_group_urls(name_prefix: str) -> list[URLPattern | URLResolver]:
25422542
name="sentry-api-0-project-teams",
25432543
),
25442544
re_path(
2545-
r"^(?P<organization_slug>[^\/]+)/(?P<project_slug>[^\/]+)/teams/(?P<team_slug>[^\/]+)/$",
2545+
r"^(?P<organization_slug>[^\/]+)/(?P<project_slug>[^\/]+)/teams/(?P<team_id_or_slug>[^\/]+)/$",
25462546
ProjectTeamDetailsEndpoint.as_view(),
25472547
name="sentry-api-0-project-team-details",
25482548
),
@@ -2752,72 +2752,72 @@ def create_group_urls(name_prefix: str) -> list[URLPattern | URLResolver]:
27522752

27532753
TEAM_URLS = [
27542754
re_path(
2755-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/$",
2755+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/$",
27562756
TeamDetailsEndpoint.as_view(),
27572757
name="sentry-api-0-team-details",
27582758
),
27592759
re_path(
2760-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/issues/old/$",
2760+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/issues/old/$",
27612761
TeamGroupsOldEndpoint.as_view(),
27622762
name="sentry-api-0-team-oldest-issues",
27632763
),
27642764
re_path(
2765-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/release-count/$",
2765+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/release-count/$",
27662766
TeamReleaseCountEndpoint.as_view(),
27672767
name="sentry-api-0-team-release-count",
27682768
),
27692769
re_path(
2770-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/time-to-resolution/$",
2770+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/time-to-resolution/$",
27712771
TeamTimeToResolutionEndpoint.as_view(),
27722772
name="sentry-api-0-team-time-to-resolution",
27732773
),
27742774
re_path(
2775-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/unresolved-issue-age/$",
2775+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/unresolved-issue-age/$",
27762776
TeamUnresolvedIssueAgeEndpoint.as_view(),
27772777
name="sentry-api-0-team-unresolved-issue-age",
27782778
),
27792779
re_path(
2780-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/alerts-triggered/$",
2780+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/alerts-triggered/$",
27812781
TeamAlertsTriggeredTotalsEndpoint.as_view(),
27822782
name="sentry-api-0-team-alerts-triggered",
27832783
),
27842784
re_path(
2785-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/alerts-triggered-index/$",
2785+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/alerts-triggered-index/$",
27862786
TeamAlertsTriggeredIndexEndpoint.as_view(),
27872787
name="sentry-api-0-team-alerts-triggered-index",
27882788
),
27892789
re_path(
2790-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/issue-breakdown/$",
2790+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/issue-breakdown/$",
27912791
TeamIssueBreakdownEndpoint.as_view(),
27922792
name="sentry-api-0-team-issue-breakdown",
27932793
),
27942794
re_path(
2795-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/all-unresolved-issues/$",
2795+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/all-unresolved-issues/$",
27962796
TeamAllUnresolvedIssuesEndpoint.as_view(),
27972797
name="sentry-api-0-team-all-unresolved-issues",
27982798
),
27992799
re_path(
2800-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/members/$",
2800+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/members/$",
28012801
TeamMembersEndpoint.as_view(),
28022802
name="sentry-api-0-team-members",
28032803
),
28042804
re_path(
2805-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/projects/$",
2805+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/projects/$",
28062806
TeamProjectsEndpoint.as_view(),
28072807
name="sentry-api-0-team-project-index",
28082808
),
28092809
re_path(
2810-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/stats/$",
2810+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/stats/$",
28112811
TeamStatsEndpoint.as_view(),
28122812
name="sentry-api-0-team-stats",
28132813
),
28142814
re_path(
2815-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/external-teams/$",
2815+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/external-teams/$",
28162816
ExternalTeamEndpoint.as_view(),
28172817
name="sentry-api-0-external-team",
28182818
),
28192819
re_path(
2820-
r"^(?P<organization_slug>[^\/]+)/(?P<team_slug>[^\/]+)/external-teams/(?P<external_team_id>[^\/]+)/$",
2820+
r"^(?P<organization_slug>[^\/]+)/(?P<team_id_or_slug>[^\/]+)/external-teams/(?P<external_team_id>[^\/]+)/$",
28212821
ExternalTeamDetailsEndpoint.as_view(),
28222822
name="sentry-api-0-external-team-details",
28232823
),

0 commit comments

Comments
 (0)