Added extra fields management for Jira search
This commit is contained in:
@@ -9,7 +9,7 @@ from core.Expando import Expando
|
||||
|
||||
JIRA_ROOT = "https://altares.atlassian.net/rest/api/3"
|
||||
DEFAULT_HEADERS = {"Accept": "application/json"}
|
||||
|
||||
DEFAULT_SEARCH_FIELDS = "summary,status,assignee"
|
||||
logger = logging.getLogger("jql")
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class JiraRequestTypes(Enum):
|
||||
class Jira:
|
||||
"""Manage default operation to JIRA"""
|
||||
|
||||
def __init__(self, user_name: str, api_token: str):
|
||||
def __init__(self, user_name: str, api_token: str, fields=DEFAULT_SEARCH_FIELDS):
|
||||
"""
|
||||
Prepare a connection to JIRA
|
||||
The initialisation do not to anything,
|
||||
@@ -38,6 +38,7 @@ class Jira:
|
||||
self.user_name = user_name
|
||||
self.api_token = api_token
|
||||
self.auth = HTTPBasicAuth(self.user_name, self.api_token)
|
||||
self.fields = fields
|
||||
|
||||
def test(self):
|
||||
url = f"{JIRA_ROOT}/myself"
|
||||
@@ -85,7 +86,7 @@ class Jira:
|
||||
as_dict = json.loads(response.text)
|
||||
return [Expando(field) for field in as_dict]
|
||||
|
||||
def issues(self, jql: str, fields="summary,status,assignee") -> list[Expando]:
|
||||
def issues(self, jql: str, fields=None) -> list[Expando]:
|
||||
"""
|
||||
Executes a JQL and returns the list of issues
|
||||
:param jql:
|
||||
@@ -93,6 +94,13 @@ class Jira:
|
||||
:return:
|
||||
"""
|
||||
logger.debug(f"Processing jql '{jql}'")
|
||||
|
||||
if not jql:
|
||||
raise ValueError("Jql cannot be empty.")
|
||||
|
||||
if not fields:
|
||||
fields = self.fields
|
||||
|
||||
url = f"{JIRA_ROOT}/search"
|
||||
|
||||
headers = DEFAULT_HEADERS.copy()
|
||||
|
||||
Reference in New Issue
Block a user