Added four new endpoints: notifications_new, repos_issues_search, repos_owner_repo_issues and repos_owner_repo_issues_comments

This commit is contained in:
spla 2022-08-12 21:39:51 +02:00
parent 84571c9d0f
commit be546301b6

View file

@ -1,7 +1,6 @@
import os
import sys
import requests
import pdb
class Gitea:
@ -66,6 +65,68 @@ class Gitea:
return (response_ok, user_list)
def notifications_new(self):
data = {
}
endpoint = self._Gitea__api_base_url + f'/api/v1/notifications/new?token={self._Gitea__access_token}'
response = self.__api_request('GET', endpoint, data)
response_ok = response.ok
notifications = response.json()
return (response_ok, notifications)
def repos_issues_search(self, username):
data = {
}
endpoint = self._Gitea__api_base_url + f'/api/v1/repos/issues/search?state=open&owner={username}&token={self._Gitea__access_token}'
response = self.__api_request('GET', endpoint, data)
response_ok = response.ok
notifications = response.json()
return (response_ok, notifications)
def repos_owner_repo_issues(self, username, repo):
data = {
}
endpoint = self._Gitea__api_base_url + f'/api/v1/repos/{username}/{repo}/issues?state=all&token={self._Gitea__access_token}'
response = self.__api_request('GET', endpoint, data)
response_ok = response.ok
notifications = response.json()
return (response_ok, notifications)
def repos_owner_repo_issues_comments(self, username, repo):
data = {
}
endpoint = self._Gitea__api_base_url + f'/api/v1/repos/{username}/{repo}/issues/comments?token={self._Gitea__access_token}'
response = self.__api_request('GET', endpoint, data)
response_ok = response.ok
notifications = response.json()
return (response_ok, notifications)
@staticmethod
def __check_setup(self):
@ -110,6 +171,8 @@ class Gitea:
def __api_request(self, method, endpoint, data):
response = None
try:
response = self.session.request(method, url = endpoint, data = data)