Skip to content

Commit

Permalink
🔧 chore: add logging around delete endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
iamrajjoshi committed Oct 17, 2024
1 parent ff2fc9d commit 6681dab
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/sentry/data_secrecy/api/waive_data_secrecy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from collections.abc import Mapping
from typing import Any

Expand All @@ -20,6 +21,8 @@
from sentry.data_secrecy.models import DataSecrecyWaiver
from sentry.models.organization import Organization

logger = logging.getLogger("sentry.data_secrecy")


class WaiveDataSecrecyPermission(OrganizationPermission):
scope_map = {
Expand Down Expand Up @@ -124,20 +127,29 @@ def delete(self, request: Request, organization: Organization):
Reinstates data secrecy for an organization.
"""
try:
logger.info("Reinstating data secrecy for organization %s", organization.id)
ds = DataSecrecyWaiver.objects.get(organization=organization)
ds.delete()

self.create_audit_entry(
request=request,
organization=organization,
event=audit_log.get_event_id("DATA_SECRECY_REINSTATED"),
)
return Response(
{"detail": "Data secrecy has been reinstated."},
status=status.HTTP_204_NO_CONTENT,
logger.info(
"Data secrecy waiver found for organization %s",
organization.id,
extra={"ds": ds.id},
)
except DataSecrecyWaiver.DoesNotExist:
logger.info("No data secrecy waiver found for organization %s", organization.id)
return Response(
{"detail": "No data secrecy waiver found for this organization."},
status=status.HTTP_404_NOT_FOUND,
)

ds.delete()
logger.info("Data secrecy waiver deleted for organization %s", organization.id)

self.create_audit_entry(
request=request,
organization=organization,
event=audit_log.get_event_id("DATA_SECRECY_REINSTATED"),
)
return Response(
{"detail": "Data secrecy has been reinstated."},
status=status.HTTP_204_NO_CONTENT,
)

0 comments on commit 6681dab

Please sign in to comment.