jira2py 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
jira2py-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Enver
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
jira2py-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.1
2
+ Name: jira2py
3
+ Version: 0.1.0
4
+ Summary: The Python library to interact with Atlassian Jira REST API
5
+ Home-page: https://github.com/en-ver/jira2py
6
+ Author: nEver1
7
+ Author-email: 7fhhwpuuo@mozmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: python-dotenv>=1.0.0
15
+ Requires-Dist: requests>=2.0.0
16
+
17
+ # jira2py
18
+
19
+ **jira2py** is a Python package designed for seamless integration with JIRA API. It provides an intuitive and modular approach to managing issues, searching for data, handling fields, and interacting with JIRA. The package is built on top of the official Jira API and simply wraps the API calls into a Pythonic interface.
20
+
21
+ ---
22
+
23
+ ## Features
24
+
25
+ - **Issue Management**: Retrieve and update JIRA issue data.
26
+ - **JIRA Query Language (JQL) Support**: Search for issues using powerful JQL expressions.
27
+ - **Field Management**: Fetch metadata about JIRA fields and map between field names and IDs.
28
+ - **Changelog Retrieval**: Retrieve the history of changes for specific issues.
@@ -0,0 +1,12 @@
1
+ # jira2py
2
+
3
+ **jira2py** is a Python package designed for seamless integration with JIRA API. It provides an intuitive and modular approach to managing issues, searching for data, handling fields, and interacting with JIRA. The package is built on top of the official Jira API and simply wraps the API calls into a Pythonic interface.
4
+
5
+ ---
6
+
7
+ ## Features
8
+
9
+ - **Issue Management**: Retrieve and update JIRA issue data.
10
+ - **JIRA Query Language (JQL) Support**: Search for issues using powerful JQL expressions.
11
+ - **Field Management**: Fetch metadata about JIRA fields and map between field names and IDs.
12
+ - **Changelog Retrieval**: Retrieve the history of changes for specific issues.
@@ -0,0 +1 @@
1
+ from .jira import Jira
@@ -0,0 +1,10 @@
1
+ from .jirabase import JiraBase
2
+
3
+
4
+ class Fields(JiraBase):
5
+
6
+ def get(self) -> list[dict]:
7
+
8
+ kwargs = {"method": "GET", "context_path": "field"}
9
+
10
+ return self._request_jira(**kwargs)
@@ -0,0 +1,53 @@
1
+ from .jirabase import JiraBase
2
+
3
+
4
+ class Issue(JiraBase):
5
+
6
+ def get(
7
+ self,
8
+ key: str,
9
+ fields: str = "*all",
10
+ expand: str = "names",
11
+ ):
12
+
13
+ kwargs = {
14
+ "method": "GET",
15
+ "context_path": f"issue/{key}",
16
+ "params": {"expand": expand, "fields": fields},
17
+ }
18
+
19
+ issue = self._request_jira(**kwargs)
20
+ return issue
21
+
22
+ def get_changelogs(self, key: str, start_at: int = 0, max_results: int = 100):
23
+
24
+ kwargs = {
25
+ "method": "GET",
26
+ "context_path": f"issue/{key}/changelog",
27
+ "params": {"startAt": start_at, "maxResults": max_results},
28
+ }
29
+
30
+ changelogs = self._request_jira(**kwargs)
31
+ return changelogs
32
+
33
+ def edit(
34
+ self,
35
+ key: str,
36
+ fields: dict,
37
+ return_issue: bool = True,
38
+ notify_users: bool = False,
39
+ expand: str = "names",
40
+ ):
41
+
42
+ kwargs = {
43
+ "method": "PUT",
44
+ "context_path": f"issue/{key}",
45
+ "params": {
46
+ "notifyUsers": notify_users,
47
+ "returnIssue": return_issue,
48
+ "expand": expand,
49
+ },
50
+ "data": {"fields": fields},
51
+ }
52
+ response = self._request_jira(**kwargs)
53
+ return response
@@ -0,0 +1,34 @@
1
+ from requests.auth import HTTPBasicAuth
2
+ import json, os
3
+ from decimal import Decimal
4
+
5
+
6
+ class Jira:
7
+
8
+ def __init__(self, url: str, user: str, api_token: str):
9
+
10
+ os.environ["_JIRA_URL"] = url
11
+ os.environ["_JIRA_USER"] = user
12
+ os.environ["_JIRA_API_TOKEN"] = api_token
13
+
14
+ def search(self):
15
+ from .search import Search
16
+
17
+ return Search()
18
+
19
+ def issue(self):
20
+ from .issue import Issue
21
+
22
+ return Issue()
23
+
24
+ def fields(self):
25
+ from .fields import Fields
26
+
27
+ return Fields()
28
+
29
+
30
+ class DecimalEncoder(json.JSONEncoder):
31
+ def default(self, obj):
32
+ if isinstance(obj, Decimal):
33
+ return float(obj)
34
+ return super().default(obj)
@@ -0,0 +1,42 @@
1
+ from requests.auth import HTTPBasicAuth
2
+ import json, os, requests
3
+ from decimal import Decimal
4
+ from abc import ABC
5
+
6
+
7
+ class DecimalEncoder(json.JSONEncoder):
8
+ def default(self, obj):
9
+ if isinstance(obj, Decimal):
10
+ return float(obj)
11
+ return super().default(obj)
12
+
13
+
14
+ class JiraBase(ABC):
15
+
16
+ def _request_jira(
17
+ self,
18
+ method: str,
19
+ context_path: str,
20
+ params: dict | None = None,
21
+ data: dict | None = None,
22
+ ) -> any:
23
+
24
+ jira_url = os.getenv("_JIRA_URL", None)
25
+ jira_user = os.getenv("_JIRA_USER", None)
26
+ jira_api_token = os.getenv("_JIRA_API_TOKEN", None)
27
+
28
+ try:
29
+ response = requests.request(
30
+ method=method,
31
+ url=f'{jira_url}/rest/api/3/{context_path.strip("/")}',
32
+ params=params,
33
+ data=json.dumps(data, cls=DecimalEncoder) if data else None,
34
+ headers={
35
+ "Accept": "application/json",
36
+ "Content-Type": "application/json",
37
+ },
38
+ auth=HTTPBasicAuth(jira_user, jira_api_token),
39
+ )
40
+ return response.json()
41
+ except Exception as e:
42
+ raise e
@@ -0,0 +1,27 @@
1
+ from .jirabase import JiraBase
2
+
3
+
4
+ class Search(JiraBase):
5
+
6
+ def jql(
7
+ self,
8
+ jql: str,
9
+ fields: list[str] | None = None,
10
+ max_results: int | None = 50,
11
+ next_page_token: str | None = None,
12
+ expand: str | None = None,
13
+ ) -> dict:
14
+
15
+ kwargs = {
16
+ "method": "POST",
17
+ "context_path": "search/jql",
18
+ "data": {
19
+ "jql": jql,
20
+ "nextPageToken": next_page_token,
21
+ "fields": fields,
22
+ "expand": expand,
23
+ "maxResults": max_results,
24
+ },
25
+ }
26
+
27
+ return self._request_jira(**kwargs)
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.1
2
+ Name: jira2py
3
+ Version: 0.1.0
4
+ Summary: The Python library to interact with Atlassian Jira REST API
5
+ Home-page: https://github.com/en-ver/jira2py
6
+ Author: nEver1
7
+ Author-email: 7fhhwpuuo@mozmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: python-dotenv>=1.0.0
15
+ Requires-Dist: requests>=2.0.0
16
+
17
+ # jira2py
18
+
19
+ **jira2py** is a Python package designed for seamless integration with JIRA API. It provides an intuitive and modular approach to managing issues, searching for data, handling fields, and interacting with JIRA. The package is built on top of the official Jira API and simply wraps the API calls into a Pythonic interface.
20
+
21
+ ---
22
+
23
+ ## Features
24
+
25
+ - **Issue Management**: Retrieve and update JIRA issue data.
26
+ - **JIRA Query Language (JQL) Support**: Search for issues using powerful JQL expressions.
27
+ - **Field Management**: Fetch metadata about JIRA fields and map between field names and IDs.
28
+ - **Changelog Retrieval**: Retrieve the history of changes for specific issues.
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ jira2py/__init__.py
6
+ jira2py/fields.py
7
+ jira2py/issue.py
8
+ jira2py/jira.py
9
+ jira2py/jirabase.py
10
+ jira2py/search.py
11
+ jira2py.egg-info/PKG-INFO
12
+ jira2py.egg-info/SOURCES.txt
13
+ jira2py.egg-info/dependency_links.txt
14
+ jira2py.egg-info/requires.txt
15
+ jira2py.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ python-dotenv>=1.0.0
2
+ requests>=2.0.0
@@ -0,0 +1 @@
1
+ jira2py
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
jira2py-0.1.0/setup.py ADDED
@@ -0,0 +1,20 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="jira2py",
5
+ version="0.1.0",
6
+ author="nEver1",
7
+ author_email="7fhhwpuuo@mozmail.com",
8
+ description="The Python library to interact with Atlassian Jira REST API",
9
+ long_description=open("README.md").read(),
10
+ long_description_content_type="text/markdown",
11
+ url="https://github.com/en-ver/jira2py",
12
+ packages=find_packages(),
13
+ install_requires=["python-dotenv>=1.0.0", "requests>=2.0.0"],
14
+ classifiers=[
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ],
19
+ python_requires=">3.10",
20
+ )