Skip to content

Commit 65c05de

Browse files
committed
Make endpoint work for snapshots too
1 parent 834ce3a commit 65c05de

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/sentry/objectstore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from sentry.objectstore.service import ClientBuilder
22

33
attachments = ClientBuilder("attachments")
4-
app_icons = ClientBuilder("app-icons")
4+
preprod = ClientBuilder("preprod")

src/sentry/preprod/api/endpoints/project_preprod_artifact_icon.py renamed to src/sentry/preprod/api/endpoints/project_preprod_artifact_image.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from sentry.api.base import region_silo_endpoint
1111
from sentry.api.bases.project import ProjectEndpoint
1212
from sentry.models.project import Project
13-
from sentry.objectstore import app_icons
13+
from sentry.objectstore import preprod
1414
from sentry.objectstore.service import ClientError
1515

1616
logger = logging.getLogger(__name__)
@@ -56,7 +56,7 @@ def detect_image_content_type(image_data: bytes) -> str:
5656

5757

5858
@region_silo_endpoint
59-
class ProjectPreprodArtifactIconEndpoint(ProjectEndpoint):
59+
class ProjectPreprodArtifactImageEndpoint(ProjectEndpoint):
6060
owner = ApiOwner.EMERGE_TOOLS
6161
publish_status = {
6262
"GET": ApiPublishStatus.EXPERIMENTAL,
@@ -66,36 +66,36 @@ def get(
6666
self,
6767
request: Request,
6868
project: Project,
69-
app_icon_id: str,
69+
image_id: str,
7070
) -> HttpResponse:
7171
organization_id = project.organization_id
7272
project_id = project.id
7373

74-
# object_key = f"{organization_id}/{project_id}/{app_icon_id}"
74+
object_key = f"{organization_id}/{project_id}/{image_id}"
7575
logger.info(
76-
"Retrieving app icon from objectstore",
76+
"Retrieving image from objectstore",
7777
extra={
7878
"organization_id": organization_id,
7979
"project_id": project_id,
80-
"app_icon_id": app_icon_id,
80+
"image_id": image_id,
8181
},
8282
)
83-
client = app_icons.for_project(organization_id, project_id)
83+
client = preprod.for_project(organization_id, project_id)
8484

8585
try:
86-
result = client.get(app_icon_id)
86+
result = client.get(object_key)
8787
# Read the entire stream at once
8888
image_data = result.payload.read()
8989

9090
# Detect content type from the image data
9191
content_type = detect_image_content_type(image_data)
9292

9393
logger.info(
94-
"Retrieved app icon from objectstore",
94+
"Retrieved image from objectstore",
9595
extra={
9696
"organization_id": organization_id,
9797
"project_id": project_id,
98-
"app_icon_id": app_icon_id,
98+
"image_id": image_id,
9999
"size_bytes": len(image_data),
100100
"content_type": content_type,
101101
},
@@ -109,7 +109,7 @@ def get(
109109
extra={
110110
"organization_id": organization_id,
111111
"project_id": project_id,
112-
"app_icon_id": app_icon_id,
112+
"image_id": image_id,
113113
},
114114
)
115115

@@ -121,7 +121,7 @@ def get(
121121
extra={
122122
"organization_id": organization_id,
123123
"project_id": project_id,
124-
"app_icon_id": app_icon_id,
124+
"image_id": image_id,
125125
"error": str(e),
126126
"status": e.status,
127127
},
@@ -134,7 +134,7 @@ def get(
134134
extra={
135135
"organization_id": organization_id,
136136
"project_id": project_id,
137-
"app_icon_id": app_icon_id,
137+
"image_id": image_id,
138138
},
139139
)
140140
return HttpResponse({"error": "Internal server error"}, status=500)

src/sentry/preprod/api/endpoints/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django.urls import re_path
44

55
from sentry.preprod.api.endpoints.project_preprod_artifact_icon import (
6-
ProjectPreprodArtifactIconEndpoint,
6+
ProjectPreprodArtifactImageEndpoint,
77
)
88
from sentry.preprod.api.endpoints.size_analysis.project_preprod_size_analysis_compare import (
99
ProjectPreprodArtifactSizeAnalysisCompareEndpoint,
@@ -85,8 +85,8 @@
8585
name="sentry-api-0-installable-preprod-artifact-download",
8686
),
8787
re_path(
88-
r"^(?P<organization_id_or_slug>[^/]+)/(?P<project_id_or_slug>[^/]+)/files/app-icons/(?P<app_icon_id>[^/]+)/$",
89-
ProjectPreprodArtifactIconEndpoint.as_view(),
88+
r"^(?P<organization_id_or_slug>[^/]+)/(?P<project_id_or_slug>[^/]+)/files/images/(?P<image_id>[^/]+)/$",
89+
ProjectPreprodArtifactImageEndpoint.as_view(),
9090
name="sentry-api-0-project-preprod-app-icon",
9191
),
9292
# Size analysis

0 commit comments

Comments
 (0)