def serialize( self, obj: ExternalActor, attrs: Mapping[str, Any], user: User, key: Optional[str] = None, **kwargs: Any, ) -> Mapping[str, Any]: provider = get_provider_string(obj.provider) data = { "id": str(obj.id), "provider": provider, "externalName": obj.external_name, "integrationId": str(obj.integration_id), } if obj.external_id: data["externalId"] = obj.external_id # Extra context `key` tells the API how to resolve actor_id. if key == "user": data["userId"] = str(attrs[key].id) elif key == "team": data["teamId"] = str(attrs[key].id) return data
def serialize(self, obj, attrs, user): provider = get_provider_string(obj.provider) return { "id": str(obj.id), "memberId": str(obj.organizationmember_id), "provider": provider, "externalName": obj.external_name, }
def serialize(self, obj, attrs, user): provider = get_provider_string(obj.provider) return { "id": str(obj.id), "teamId": str(obj.team_id), "provider": provider, "externalName": obj.external_name, }
def test_create_existing_association(self): self.external_team = self.create_external_team( self.team, external_name="@getsentry/ecosystem") data = { "externalName": self.external_team.external_name, "provider": get_provider_string(self.external_team.provider), } with self.feature({"organizations:import-codeowners": True}): response = self.get_success_response(self.organization.slug, self.team.slug, **data) assert response.data == { "id": str(self.external_team.id), "teamId": str(self.team.id), **data, }
def test_list_external_teams(self): self.external_team = self.create_external_team( self.team, external_name="@getsentry/ecosystem") path = f"/api/0/organizations/{self.organization.slug}/teams/?detailed=1" self.login_as(user=self.user) response = self.client.get(path) assert response.status_code == 200, response.content assert len(response.data) == 1 assert response.data[0]["id"] == str(self.team.id) assert len(response.data[0]["externalTeams"]) == 1 assert response.data[0]["externalTeams"][0] == { "id": str(self.external_team.id), "integrationId": str(self.external_team.integration.id), "provider": get_provider_string(self.external_team.provider), "externalName": self.external_team.external_name, "teamId": str(self.team.id), }