Add organization API call

fixes
Vadim vtroshchinskiy 2024-10-29 12:19:30 +01:00
parent 5c253cd782
commit ccee9d70be
1 changed files with 20 additions and 0 deletions

View File

@ -613,6 +613,26 @@ class OpengnsysGitInstaller:
self.__logger.info("Request status was %i", r.status_code)
def add_forgejo_organization(self, pubkey, description = ""):
token = ""
with open(os.path.join(self.base_path, "etc", "ogGitApiToken.cfg"), "r", encoding='utf-8') as token_file:
token = token_file.read().strip()
self.__logger.info("Adding SSH key to Forgejo: %s", pubkey)
r = requests.post(
f"http://localhost:{self.forgejo_port}/api/v1/user/keys",
json={
"key" : pubkey,
"read_only" : False,
"title" : description
}, headers={
'Authorization' : f"token {token}"
},
timeout = 60
)
self.__logger.info("Request status was %i", r.status_code)