(self, data: Mapping[str, Any], **kwargs: Any)
| 245 | return [repo_field, *fields, assignee_field, label_field] |
| 246 | |
| 247 | def create_issue(self, data: Mapping[str, Any], **kwargs: Any) -> Mapping[str, Any]: |
| 248 | client = self.get_client() |
| 249 | repo = data.get("repo") |
| 250 | if not repo: |
| 251 | raise IntegrationFormError({"repo": "Repository is required"}) |
| 252 | |
| 253 | # Check the repository belongs to the integration |
| 254 | if not Repository.objects.filter( |
| 255 | name=repo, |
| 256 | integration_id=self.model.id, |
| 257 | organization_id=self.organization_id, |
| 258 | status=ObjectStatus.ACTIVE, |
| 259 | ).exists(): |
| 260 | raise IntegrationFormError( |
| 261 | {"repo": f"Given repository, {repo} does not belong to this installation"} |
| 262 | ) |
| 263 | |
| 264 | # Create clean issue data with required fields |
| 265 | if not data.get("title"): |
| 266 | raise IntegrationFormError({"title": "Title is required"}) |
| 267 | |
| 268 | if not data.get("description"): |
| 269 | raise IntegrationFormError({"description": "Description is required"}) |
| 270 | |
| 271 | issue_data = { |
| 272 | "title": data["title"], |
| 273 | "body": data["description"], |
| 274 | } |
| 275 | |
| 276 | # Only include optional fields if they have valid values |
| 277 | if data.get("assignee"): |
| 278 | issue_data["assignee"] = data["assignee"] |
| 279 | if data.get("labels"): |
| 280 | issue_data["labels"] = data["labels"] |
| 281 | |
| 282 | try: |
| 283 | issue = client.create_issue(repo=repo, data=issue_data) |
| 284 | except ApiError as e: |
| 285 | self.raise_error(e) |
| 286 | |
| 287 | return { |
| 288 | "key": issue["number"], |
| 289 | "title": issue["title"], |
| 290 | "description": issue["body"], |
| 291 | "url": issue["html_url"], |
| 292 | "repo": repo, |
| 293 | } |
| 294 | |
| 295 | def get_link_issue_config(self, group: Group, **kwargs: Any) -> list[dict[str, Any]]: |
| 296 | params = kwargs.pop("params", {}) |
nothing calls this directly
no test coverage detected