Browse Source

chore(hybridcloud) Remove deprecated RPC methods and attributes (#71574)

Follow work done in #71445, #71376, to remove deprecated methods and
parameters. These changes also enable strict schema validation as all
tuples have been removed from parameters and return types and we want to
prevent new instances from creeping in.
Mark Story 9 months ago
parent
commit
a6f93ddda8

+ 1 - 1
.github/workflows/openapi-diff.yml

@@ -60,7 +60,7 @@ jobs:
         if: steps.changes.outputs.api_docs == 'true'
         run: |
           mkdir schemas
-          sentry rpcschema --partial > rpc_method_schema.json
+          sentry rpcschema > rpc_method_schema.json
 
       - name: Compare RPC schema with oasdiff
         uses: oasdiff/oasdiff-action/breaking@fc826b9f0d21b85b085842521c7a8cc445412c08 # v0.0.19

+ 1 - 1
.github/workflows/openapi.yml

@@ -56,7 +56,7 @@ jobs:
       - name: Build RPC method schema
         if: steps.changes.outputs.api_docs == 'true'
         run: |
-          sentry rpcschema --partial > rpc_method_schema.json
+          sentry rpcschema > rpc_method_schema.json
 
       - name: Copy artifacts into getsentry/sentry-api-schema
         if: steps.changes.outputs.api_docs == 'true'

+ 0 - 8
src/sentry/services/hybrid_cloud/import_export/model.py

@@ -67,10 +67,6 @@ class RpcPrimaryKeyMap(RpcModel):
     converted to and from `PrimaryKeyMap` immediately on either side of the RPC call.
     """
 
-    # Pydantic duplicates global default models on a per-instance basis, so using `{}` here is safe.
-    # Deprecated, use map_entries going forward as that property does not contain tuples.
-    mapping: dict[str, dict[int, tuple[int, ImportKind, str | None]]] = {}
-
     # Pydantic duplicates global default models on a per-instance basis, so using `{}` here is safe.
     map_entries: dict[str, dict[int, RpcPrimaryKeyEntry]] = {}
 
@@ -84,15 +80,11 @@ class RpcPrimaryKeyMap(RpcModel):
                     entries_data[old_id] = (entry.new_id, entry.kind, entry.slug)
                 pk_mapping[model_name] = entries_data
             pk_map.mapping = pk_mapping
-        else:
-            pk_map.mapping = defaultdict(dict, self.mapping)
         return pk_map
 
     @classmethod
     def into_rpc(cls, base_map: PrimaryKeyMap) -> "RpcPrimaryKeyMap":
         converted = cls()
-        converted.mapping = dict(base_map.mapping)
-
         mapping_entries = dict()
         for model_name, entries in base_map.mapping.items():
             mapping_entries[model_name] = {

+ 0 - 34
src/sentry/services/hybrid_cloud/integration/impl.py

@@ -248,23 +248,6 @@ class DatabaseBackedIntegrationService(IntegrationService):
             integration=context.integration, organization_integration=install
         )
 
-    def get_organization_context(
-        self,
-        *,
-        organization_id: int,
-        integration_id: int | None = None,
-        provider: str | None = None,
-        external_id: str | None = None,
-    ) -> tuple[RpcIntegration | None, RpcOrganizationIntegration | None]:
-        # Depreated use organization_context instead.
-        context = self.organization_context(
-            organization_id=organization_id,
-            integration_id=integration_id,
-            provider=provider,
-            external_id=external_id,
-        )
-        return (context.integration, context.organization_integration)
-
     def organization_contexts(
         self,
         *,
@@ -289,23 +272,6 @@ class DatabaseBackedIntegrationService(IntegrationService):
             integration=integration, organization_integrations=organization_integrations
         )
 
-    def get_organization_contexts(
-        self,
-        *,
-        organization_id: int | None = None,
-        integration_id: int | None = None,
-        provider: str | None = None,
-        external_id: str | None = None,
-    ) -> tuple[RpcIntegration | None, list[RpcOrganizationIntegration]]:
-        # Depreated use organization_contexts instead.
-        context = self.organization_contexts(
-            organization_id=organization_id,
-            integration_id=integration_id,
-            provider=provider,
-            external_id=external_id,
-        )
-        return (context.integration, context.organization_integrations)
-
     def update_integrations(
         self,
         *,

+ 0 - 31
src/sentry/services/hybrid_cloud/integration/service.py

@@ -130,37 +130,6 @@ class IntegrationService(RpcService):
         )
         return ois[0] if len(ois) > 0 else None
 
-    @rpc_method
-    @abstractmethod
-    def get_organization_context(
-        self,
-        *,
-        organization_id: int,
-        integration_id: int | None = None,
-        provider: str | None = None,
-        external_id: str | None = None,
-    ) -> tuple[RpcIntegration | None, RpcOrganizationIntegration | None]:
-        """
-        Returns a tuple of RpcIntegration and RpcOrganizationIntegration. The integration is selected
-        by either integration_id, or a combination of provider and external_id.
-
-        :deprecated: Use organization_context() instead.
-        """
-
-    @rpc_method
-    @abstractmethod
-    def get_organization_contexts(
-        self,
-        *,
-        organization_id: int | None = None,
-        integration_id: int | None = None,
-        provider: str | None = None,
-        external_id: str | None = None,
-    ) -> tuple[RpcIntegration | None, list[RpcOrganizationIntegration]]:
-        """
-        :deprecated: Use organization_contexts() instead.
-        """
-
     @rpc_method
     @abstractmethod
     def organization_context(

+ 0 - 18
src/sentry/services/hybrid_cloud/notifications/impl.py

@@ -113,24 +113,6 @@ class DatabaseBackedNotificationsService(NotificationsService):
             scope_identifier=project_id,
         ).delete()
 
-    def get_subscriptions_for_projects(
-        self,
-        *,
-        user_id: int,
-        project_ids: list[int],
-        type: NotificationSettingEnum,
-    ) -> Mapping[int, tuple[bool, bool, bool]]:
-        """
-        Deprecated: use subscriptions_for_projects instead.
-        """
-        result = self.subscriptions_for_projects(
-            user_id=user_id, project_ids=project_ids, type=type
-        )
-        return {
-            project_id: (sub.is_disabled, sub.is_active, sub.has_only_inactive_subscriptions)
-            for project_id, sub in result.items()
-        }
-
     def subscriptions_for_projects(
         self,
         *,

+ 0 - 12
src/sentry/services/hybrid_cloud/notifications/service.py

@@ -71,18 +71,6 @@ class NotificationsService(RpcService):
     def remove_notification_settings_for_project(self, *, project_id: int) -> None:
         pass
 
-    @rpc_method
-    @abstractmethod
-    def get_subscriptions_for_projects(
-        self,
-        *,
-        user_id: int,
-        project_ids: list[int],
-        type: NotificationSettingEnum,
-    ) -> Mapping[int, tuple[bool, bool, bool]]:
-        """Deprecated: Use subscriptions_for_projects instead."""
-        pass
-
     @rpc_method
     @abstractmethod
     def subscriptions_for_projects(

+ 0 - 2
src/sentry/services/hybrid_cloud/organization_mapping/impl.py

@@ -116,8 +116,6 @@ class DatabaseBackedOrganizationMappingService(OrganizationMappingService):
             require_email_verification=update.require_email_verification,
             codecov_access=update.codecov_access,
         )
-        if isinstance(update.customer_id, (tuple, list)):
-            update_dict["customer_id"] = update.customer_id[0]
         if isinstance(update.customer_id, CustomerId):
             update_dict["customer_id"] = update.customer_id.value
 

+ 2 - 4
src/sentry/services/hybrid_cloud/organization_mapping/model.py

@@ -34,10 +34,8 @@ class RpcOrganizationMappingUpdate(RpcModel):
     slug: str = ""
     region_name: str = ""
     # When not set, no change to customer id performed,
-    # when set with a tuple, the customer_id set to either None or the string
-    # that is the first element.
-    # TODO(hybridcloud) Using a tuple is deprecated and will be removed.
-    customer_id: tuple[str | None] | CustomerId | None = None
+    # when set with a CustomerId, the customer_id set to either None or string
+    customer_id: CustomerId | None = None
     requires_2fa: bool = False
     early_adopter: bool = False
     codecov_access: bool = False

+ 2 - 2
tests/sentry/hybridcloud/test_organizationmapping.py

@@ -99,7 +99,7 @@ class OrganizationMappingServiceControlProvisioningEnabledTest(TransactionTestCa
                 slug=self.organization.slug,
                 status=self.organization.status,
                 region_name="us",
-                customer_id=("128",),
+                customer_id=CustomerId(value="128"),
             ),
         )
         assert_matching_organization_mapping(org=self.organization, customer_id="128")
@@ -112,7 +112,7 @@ class OrganizationMappingServiceControlProvisioningEnabledTest(TransactionTestCa
                 slug=self.organization.slug,
                 status=self.organization.status,
                 region_name="us",
-                customer_id=(None,),
+                customer_id=CustomerId(value=None),
             ),
         )
         assert_matching_organization_mapping(org=self.organization, customer_id=None)