Skip to content

Commit

Permalink
WIP: created Jira Adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesWesch committed Apr 9, 2024
1 parent b05d1fe commit eb5828d
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 2 deletions.
79 changes: 77 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ opentelemetry-api = "^1.22.0"
opentelemetry-sdk = "^1.22.0"
huggingface-hub = "^0.22.2"
opentelemetry-exporter-otlp-proto-http = "1.23.0"
jira = "^3.8.0"

[tool.poetry.group.dev.dependencies]
# lint & format
Expand Down
48 changes: 48 additions & 0 deletions src/jira_adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import os
from typing import Sequence
from dotenv import load_dotenv
from jira import JIRA, Issue


class Ticket():
jira_id: str
text: str
labels: Sequence[str]
is_active: bool



class JiraAdapater():
def __init__(self, domain: str, email: str, token: str):
self.jira = JIRA(domain, basic_auth=(email, token))

def get_tickets(self, project_id: str) -> Sequence[Ticket]:
issues = jira_adapter.jira.search_issues(f'project={project_id}')
return [self.issue_to_ticket(issue) for issue in issues]

def get_tickets_by_id(project_id: str, ticket_ids: Sequence[str]) -> Sequence[Ticket]:
pass

def update_ticket(self, ticket_id: str, new_label: str) -> bool:
pass

def issue_to_ticket(self, issue: Issue) -> Ticket:
return Ticket(
jira_id = issue.id,
text = issue.fields.summary + issue.fields.description,
labels = issue.fields.labels,
is_active = issue.fields.status == "Done" # TODO

)




if __name__ == "__main__":
load_dotenv()
token = os.getenv("JIRA_TOKEN")
email = os.getenv("JIRA_EMAIL")
domain = 'https://aleph-alpha.atlassian.net'
jira_adapter = JiraAdapater(domain, email, token)
issue_retrieved = jira_adapter.jira.search_issues('project=IL AND issue=22475')[0]
issue = jira_adapter.jira.issue(id = issue_retrieved.id)

0 comments on commit eb5828d

Please sign in to comment.