Python Access for JIRA Part I
A while ago we were required to add functionality for some project. It was about a portal where customers could log in and manage some assets. Our client wanted their customers to be able to create JIRA tickets so the support team would be able to take action. Of course JIRA is too complex for the regular user, so we were required to build a simple interface with JIRA, and to add some fancy stuff like charts showing working progress and amount of tickets by priority.
JIRA RPC service is very limited, so we decided to create our own interface to JIRA in Python.
This is what the class looks like:
class JiraHTTPConnection:
def init(self, domain, username, password):
print domain
self.__cookie = None
self.__headers = None
self.__connection = httplib.HTTPConnection(domain)
response = self.get("/")
data = response.read()
self.__headers = response.getheaders()
self.__cookie = [x[1] for x in self.__headers if x[0] == "set-cookie"][0]
self.__login(username, password)
def get(self, path, headers=None):
if headers is None:
headers = {"Cookie": self.__cookie}
self.__connection.request("GET", path, "", headers)
return self.__connection.getresponse()
def post(self, path, post_data, headers=None):
if not headers:
headers = {"Cookie": self.__cookie}
self.__connection.request("POST", path, post_data, headers)
return self.__connection.getresponse()
These are our implemented methods:
projects project_issues filtered_issues issues issue user add_comment watchers add_watchers
I’ll post details about these methods in upcoming posts.