diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2022-02-08 17:20:47 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2022-02-08 17:20:47 +0100 |
commit | ad3ec123d4543c8cc4106d9d11f6e8e806b90de3 (patch) | |
tree | bd444a3337e9db25bc50e271a80e6a53c9ec5bae /rss_to_gitea/gitea.py | |
parent | 1b3996f2faa77e97e4c6bfc88067a2b484611c85 (diff) | |
download | atom_to_gitea-ad3ec123d4543c8cc4106d9d11f6e8e806b90de3.tar.gz |
working
Diffstat (limited to 'rss_to_gitea/gitea.py')
-rw-r--r-- | rss_to_gitea/gitea.py | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/rss_to_gitea/gitea.py b/rss_to_gitea/gitea.py index 39ea763..fcc985c 100644 --- a/rss_to_gitea/gitea.py +++ b/rss_to_gitea/gitea.py @@ -32,11 +32,30 @@ class GiteaAPI: return result.json() + def _api_post(self, _endpoint, _data): + headers={ + 'Authorization':f'token {self.token}', + 'Content-Type': 'application/json', + 'accept': 'application/json' + } + result = requests.post(f'{self.address}/{_endpoint}',headers=headers, json=_data) + + return result.json() + + + def createIssue(self, _owner, _repo, _title, _content, _assign, _labels): + data={ + 'assignee':_assign, +# 'body':_content, + 'labels':_labels, + 'title':_title + } + + result = self._api_post(f'repos/{_owner}/{_repo}/issues', data ) - def createIssue(self, _owner, _repo, _title, _content): - pass + return result - def searchIssue(self, _owner, _repo, _title, _labels, _state='open'): + def searchIssue(self, _owner, _repo, _title, _labels, _state='all'): data= { 'state':_state, 'labels':_labels, @@ -47,8 +66,23 @@ class GiteaAPI: result = self._api_get(f'repos/{_owner}/{_repo}/issues', data ) for issue in result: - print(issue['title']) + if issue['title'] == _title: + return issue + + return None + + def getLabelId(self, _owner, _repo, _label): + data= {} + + result = self._api_get(f'repos/{_owner}/{_repo}/labels', data ) + + label_filtered = filter(lambda a: a['name']==_label, result) + label = list(label_filtered) + + if len(label) != 1: + print('No or more than one label found') + return None + + return label[0]['id'] - def updateIssue(self, _owner, _repo, _issueid): - pass |