gitea-repo-migrator/domain/API.py

37 lines
469 B
Python
Raw Normal View History

2024-06-17 23:45:40 -07:00
import gitea
class API:
__DEFAULT_API_PATH = "/api/v1"
def __init__(self):
pass
@staticmethod
def _make_api_base_url(hostname, port):
base = f"https://{hostname}"
if port is not None:
base += f":{port}"
return base
@staticmethod
def factory(hostname, port, token) -> gitea.Gitea:
url = API._make_api_base_url(
hostname=hostname,
port=port
)
g = gitea.Gitea(
gitea_url=url,
token_text=token
)
return g