Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jira personal access token with hosted instances #13890

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pip install llama-index-readers-jira
```

The Jira loader returns a set of issues based on the query provided to the dataloader.
We can follow two methods to initialize the loader-
We can follow three methods to initialize the loader-
1- basic_auth -> this takes a dict with the following keys
`basic_auth:{
"email": "email",
Expand All @@ -17,6 +17,11 @@ We can follow two methods to initialize the loader-
"cloud_id": "cloud_id",
"api_token": "token"
}`
3- Personal access Token with Server hosted instance
`PATauth:{
"server_url": "server_url",
"api_token": "token"
}`

You can follow this link for more information regarding Oauth2 -> https://developer.atlassian.com/cloud/confluence/oauth-2-3lo-apps/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class Oauth2(TypedDict):
api_token: str


class PATauth(TypedDict):
server_url: str
api_token: str


class JiraReader(BaseReader):
"""Jira reader. Reads data from Jira issues from passed query.

Expand All @@ -28,6 +33,10 @@ class JiraReader(BaseReader):
"cloud_id": "cloud_id",
"api_token": "token"
}
Optional patauth:{
"server_url": "server_url",
"api_token": "token"
}
"""

def __init__(
Expand All @@ -37,6 +46,7 @@ def __init__(
server_url: Optional[str] = None,
BasicAuth: Optional[BasicAuth] = None,
Oauth2: Optional[Oauth2] = None,
PATauth: Optional[PATauth] = None,
) -> None:
from jira import JIRA

Expand All @@ -53,6 +63,12 @@ def __init__(
"headers": {"Authorization": f"Bearer {Oauth2['api_token']}"},
}
self.jira = JIRA(options=options)
elif PATauth:
options = {
"server": PATauth["server_url"],
"headers": {"Authorization": f"Bearer {PATauth['api_token']}"},
}
self.jira = JIRA(options=options)
else:
self.jira = JIRA(
basic_auth=(BasicAuth["email"], BasicAuth["api_token"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ license = "MIT"
maintainers = ["bearguy"]
name = "llama-index-readers-jira"
readme = "README.md"
version = "0.1.3"
version = "0.1.4"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
Expand Down
Loading