Skip to content

Commit

Permalink
hybridcloud(apitoken): add deletion implementation for apitoken (#86069)
Browse files Browse the repository at this point in the history
Add specific deletion implementation/service for replicated API tokens
in region silos.
  • Loading branch information
mdtro authored Feb 28, 2025
1 parent 6890939 commit 1a80654
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/sentry/hybridcloud/services/replica/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ def upsert_replicated_api_token(self, *, api_token: RpcApiToken, region_name: st
)
handle_replication(ApiToken, destination)

def delete_replicated_api_token(self, *, apitoken_id: int, region_name: str) -> None:
with enforce_constraints(transaction.atomic(router.db_for_write(ApiTokenReplica))):
api_token_qs = ApiTokenReplica.objects.filter(apitoken_id=apitoken_id)
api_token_qs.delete()

def upsert_replicated_org_auth_token(self, *, token: RpcOrgAuthToken, region_name: str) -> None:
try:
organization = Organization.objects.get(id=token.organization_id)
Expand Down
5 changes: 5 additions & 0 deletions src/sentry/hybridcloud/services/replica/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ def upsert_replicated_api_key(self, *, api_key: RpcApiKey, region_name: str) ->
def upsert_replicated_api_token(self, *, api_token: RpcApiToken, region_name: str) -> None:
pass

@regional_rpc_method(resolve=ByRegionName())
@abc.abstractmethod
def delete_replicated_api_token(self, *, apitoken_id: int, region_name: str) -> None:
pass

@regional_rpc_method(resolve=ByRegionName())
@abc.abstractmethod
def upsert_replicated_org_auth_token(self, *, token: RpcOrgAuthToken, region_name: str) -> None:
Expand Down

0 comments on commit 1a80654

Please sign in to comment.