From 9354714919d13a5793c9d78b51ab8afc1f63ca44 Mon Sep 17 00:00:00 2001 From: anima Date: Sat, 21 Sep 2024 22:45:04 +0200 Subject: [PATCH] add shutdown --- SatiAPI.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/SatiAPI.py b/SatiAPI.py index 6e48beb..377213f 100644 --- a/SatiAPI.py +++ b/SatiAPI.py @@ -16,7 +16,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) class SatiAPI: """A API wrapper for Satisfactory dedicated server""" __AUTHOR__ = 'anima' - __VERSION__ = '0.10.1' + __VERSION__ = '0.11.0' def __init__(self, host: str = None, port: int = 7777, token: str = None, conffile: str = 'conf.yml', logfile: str = 'SatiAPI.log', loglevel: int = 20) -> None: """create a wrapper for satisfactory dedicated server @@ -198,7 +198,8 @@ class SatiAPI: self._log.error(f'wrong response data {json_response=}') elif response.status_code == 204: - # response from rename server + # response from rename server, shutdown ... + print(query) return True else: @@ -297,6 +298,14 @@ class SatiAPI: response = self.__query('PasswordLogin', data) return self._save_token(response) + def shutdown(self) -> bool: + """Shuts down the Dedicated Server. If automatic restart script is setup, this allows restarting the server to apply new settings or update. Requires Admin privileges. Shutdowns initiated by remote hosts are logged with their IP and their token. Function does not return any data on success, and does not take any parameters. + + :return: true is shutdown successfull init + :rtype: bool + """ + return self.__query('Shutdown', auth=True) + def set_admin_password(self, password: str = None): """Updates the currently set Admin Password. This will invalidate all previously issued Client and Admin authentication tokens. Requires Admin privileges. Function does not return any data on success. @@ -397,7 +406,6 @@ class SatiAPI: ## todo #RunCommand - #Shutdown #SetAutoLoadSessionName #ApplyServerOptions @@ -418,4 +426,4 @@ if __name__ == "__main__": sati = SatiAPI(loglevel=10) # print('Verbundene Spieler: ', sati.get_status()['serverGameState']['numConnectedPlayers']) print(sati.get_status()) - print(sati.set_servername('OtherName')) \ No newline at end of file + print(sati.shutdown()) \ No newline at end of file