Skip to content

Commit

Permalink
Async requests branched out from 18
Browse files Browse the repository at this point in the history
  • Loading branch information
talsabagport committed Oct 21, 2024
1 parent 677b034 commit c0e6b42
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
25 changes: 16 additions & 9 deletions integrations/jira/jira/client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import typing
from typing import Any, AsyncGenerator

Expand Down Expand Up @@ -49,20 +50,24 @@ def _generate_base_req_params(
}

async def _get_paginated_projects(self, params: dict[str, Any]) -> dict[str, Any]:
project_response = self.client.get(
f"{self.api_url}/project/search", params=params
project_response = await asyncio.to_thread(
self.client.get, f"{self.api_url}/project/search", params=params
)
project_response.raise_for_status()
return project_response.json()

async def _get_paginated_issues(self, params: dict[str, Any]) -> dict[str, Any]:
issue_response = self.client.get(f"{self.api_url}/search", params=params)
issue_response = await asyncio.to_thread(
self.client.get, f"{self.api_url}/search", params=params
)
issue_response.raise_for_status()
return issue_response.json()

async def create_events_webhook(self, app_host: str) -> None:
webhook_target_app_host = f"{app_host}/integration/webhook"
webhook_check_response = self.client.get(f"{self.webhooks_url}")
webhook_check_response = await asyncio.to_thread(
self.client.get, f"{self.webhooks_url}"
)
webhook_check_response.raise_for_status()
webhook_check = webhook_check_response.json()

Expand All @@ -77,15 +82,15 @@ async def create_events_webhook(self, app_host: str) -> None:
"events": WEBHOOK_EVENTS,
}

webhook_create_response = self.client.post(
f"{self.webhooks_url}", json=body
webhook_create_response = await asyncio.to_thread(
self.client.post, f"{self.webhooks_url}", json=body
)
webhook_create_response.raise_for_status()
logger.info("Ocean real time reporting webhook created")

async def get_single_project(self, project_key: str) -> dict[str, Any]:
project_response = self.client.get(
f"{self.api_url}/project/{project_key}"
project_response = await asyncio.to_thread(
self.client.get, f"{self.api_url}/project/{project_key}"
)
project_response.raise_for_status()
return project_response.json()
Expand Down Expand Up @@ -114,7 +119,9 @@ async def get_paginated_projects(
params["startAt"] += PAGE_SIZE

async def get_single_issue(self, issue_key: str) -> dict[str, Any]:
issue_response = self.client.get(f"{self.api_url}/issue/{issue_key}")
issue_response = await asyncio.to_thread(
self.client.get, f"{self.api_url}/issue/{issue_key}"
)
issue_response.raise_for_status()
return issue_response.json()

Expand Down
2 changes: 1 addition & 1 deletion integrations/jira/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "jira"
version = "0.1.89-dev018"
version = "0.1.89-dev026"
description = "Integration to bring information from Jira into Port"
authors = ["Mor Paz <mor@getport.io>"]

Expand Down

0 comments on commit c0e6b42

Please sign in to comment.