fix jira integration.
This commit is contained in:
parent
014a51602a
commit
7967915b91
3 changed files with 15 additions and 9 deletions
|
|
@ -9,6 +9,9 @@ class BaseIntegration(ABC):
|
|||
self._user_id = user_id
|
||||
self._issue_handler = ISSUE_CLASS(self.integration_token)
|
||||
|
||||
async def init():
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def provider(self):
|
||||
|
|
@ -43,17 +46,17 @@ class BaseIntegration(ABC):
|
|||
pass
|
||||
|
||||
@abstractmethod
|
||||
def update(self, changes, obfuscate=False):
|
||||
async def update(self, changes, obfuscate=False):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def _add(self, data):
|
||||
async def _add(self, data):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def delete(self):
|
||||
async def delete(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def add_edit(self, data):
|
||||
async def add_edit(self, data):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -18,10 +18,12 @@ class JIRAIntegration(integration_base.BaseIntegration):
|
|||
# super(JIRAIntegration, self).__init__(jwt, user_id, JIRACloudIntegrationProxy)
|
||||
self._issue_handler = None
|
||||
self._user_id = user_id
|
||||
|
||||
self.integeration = None
|
||||
|
||||
async def init(self):
|
||||
self.integration = self.get()
|
||||
if self.integration is not None:
|
||||
return
|
||||
self.integration = await self.get()
|
||||
if self.integration is None:
|
||||
return
|
||||
self.integration["valid"] = True
|
||||
|
|
@ -116,9 +118,9 @@ class JIRAIntegration(integration_base.BaseIntegration):
|
|||
)
|
||||
return {"state": "success"}
|
||||
|
||||
def add_edit(self, data: schemas.IssueTrackingJiraSchema):
|
||||
async def add_edit(self, data: schemas.IssueTrackingJiraSchema):
|
||||
if self.integration is not None:
|
||||
return self.update(
|
||||
return await self.update(
|
||||
changes={
|
||||
"username": data.username,
|
||||
"token": data.token if len(data.token) > 0 and data.token.find("***") == -1 \
|
||||
|
|
@ -128,7 +130,7 @@ class JIRAIntegration(integration_base.BaseIntegration):
|
|||
obfuscate=True
|
||||
)
|
||||
else:
|
||||
return self.add(
|
||||
return await self.add(
|
||||
username=data.username,
|
||||
token=data.token,
|
||||
url=str(data.url)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ async def get_integration(tenant_id, user_id, tool=None, for_delete=False):
|
|||
return {"errors": [f"issue tracking tool not supported yet, available: {SUPPORTED_TOOLS}"]}, None
|
||||
if tool == integration_jira_cloud.PROVIDER:
|
||||
integration = integration_jira_cloud.JIRAIntegration(tenant_id=tenant_id, user_id=user_id)
|
||||
await integration.init()
|
||||
if not for_delete and integration.integration is not None and not integration.integration.get("valid", True):
|
||||
return {"errors": ["JIRA: connexion issue/unauthorized"]}, integration
|
||||
return None, integration
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue