From 400f8ebb8b3f55cdc64e0b221372953b43e319e0 Mon Sep 17 00:00:00 2001 From: Dominik Buszowiecki Date: Wed, 14 Oct 2026 13:10:14 -0400 Subject: [PATCH] docs(api): Document project performance general settings endpoint Fixes ENG-8777 --- .../project_performance_general_settings.py | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/src/sentry/api/endpoints/project_performance_general_settings.py b/src/sentry/api/endpoints/project_performance_general_settings.py index 52063215287f..591294f0c96e 100644 --- a/src/sentry/api/endpoints/project_performance_general_settings.py +++ b/src/sentry/api/endpoints/project_performance_general_settings.py @@ -1,3 +1,6 @@ +from typing import TypedDict + +from drf_spectacular.utils import extend_schema from rest_framework import serializers, status from rest_framework.request import Request from rest_framework.response import Response @@ -7,18 +10,40 @@ from sentry.api.api_publish_status import ApiPublishStatus from sentry.api.base import cell_silo_endpoint from sentry.api.bases.project import ProjectEndpoint, ProjectSettingPermission +from sentry.apidocs.constants import ( + RESPONSE_BAD_REQUEST, + RESPONSE_FORBIDDEN, + RESPONSE_NO_CONTENT, + RESPONSE_NOT_FOUND, + RESPONSE_UNAUTHORIZED, +) +from sentry.apidocs.parameters import GlobalParams +from sentry.apidocs.utils import inline_sentry_response_serializer from sentry.models.project import Project from sentry.projectoptions.defaults import DEFAULT_PROJECT_PERFORMANCE_GENERAL_SETTINGS SETTINGS_PROJECT_OPTION_KEY = "sentry:performance_general_settings" +class ProjectPerformanceGeneralSettingsResponse(TypedDict): + enable_images: bool + + class ProjectPerformanceGeneralSettingsSerializer(serializers.Serializer): - enable_images = serializers.BooleanField(required=False) + enable_images = serializers.BooleanField( + required=False, + help_text="Whether to display images from real data, such as image resource previews.", + ) +@extend_schema(tags=["Projects"]) @cell_silo_endpoint class ProjectPerformanceGeneralSettingsEndpoint(ProjectEndpoint): + """ + Kept private: these settings only control what the Sentry UI displays (e.g. image + previews on resource spans) and aren't useful outside of it. + """ + owner = ApiOwner.DATA_BROWSING publish_status = { "GET": ApiPublishStatus.PRIVATE, @@ -26,7 +51,23 @@ class ProjectPerformanceGeneralSettingsEndpoint(ProjectEndpoint): } permission_classes = (ProjectSettingPermission,) + @extend_schema( + operation_id="Retrieve a Project's Performance General Settings", + parameters=[GlobalParams.ORG_ID_OR_SLUG, GlobalParams.PROJECT_ID_OR_SLUG], + responses={ + 200: inline_sentry_response_serializer( + "ProjectPerformanceGeneralSettingsResponse", + ProjectPerformanceGeneralSettingsResponse, + ), + 401: RESPONSE_UNAUTHORIZED, + 403: RESPONSE_FORBIDDEN, + 404: RESPONSE_NOT_FOUND, + }, + ) def get(self, request: Request, project) -> Response: + """ + Return the general performance settings for a project. + """ if not self.has_feature(project, request): return self.respond(status=status.HTTP_404_NOT_FOUND) @@ -36,7 +77,22 @@ def get(self, request: Request, project) -> Response: project_option_settings = self.get_current_settings(project) return Response(project_option_settings) + @extend_schema( + operation_id="Update a Project's Performance General Settings", + parameters=[GlobalParams.ORG_ID_OR_SLUG, GlobalParams.PROJECT_ID_OR_SLUG], + request=ProjectPerformanceGeneralSettingsSerializer, + responses={ + 204: RESPONSE_NO_CONTENT, + 400: RESPONSE_BAD_REQUEST, + 401: RESPONSE_UNAUTHORIZED, + 403: RESPONSE_FORBIDDEN, + 404: RESPONSE_NOT_FOUND, + }, + ) def post(self, request: Request, project: Project) -> Response: + """ + Update the general performance settings for a project. Omitted fields are left unchanged. + """ if not self.has_feature(project, request): return self.respond(status=status.HTTP_404_NOT_FOUND)