Skip to content

Commit

Permalink
Add optional json parameter to get_file_contents (#81)
Browse files Browse the repository at this point in the history
method for files requiring response, ex.  latest.log
  • Loading branch information
Pokeylooted authored Oct 31, 2024
1 parent 00eb9b4 commit aae6f08
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pydactyl/api/client/servers/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ def download_file(self, server_id: str, path: str) -> str:
response = self._api_request(endpoint=endpoint, params=params)
return response.get('attributes').get('url')

def get_file_contents(self, server_id: str, path: str) -> str:
def get_file_contents(self, server_id: str, path: str, json: bool = True) -> str:
"""Get contents of the specified file on the specified server.
Args:
server_id(str): Server identifier (abbreviated UUID)
path(str): URL encoded path to desired file (e.g. 'eula.txt')
json(bool): Whether to get the json_response (default: True)
"""
endpoint = 'client/servers/{}/files/contents'.format(server_id)
params = {'file': path}
response = self._api_request(endpoint=endpoint, params=params)
response = self._api_request(endpoint=endpoint, params=params, json=json)
return response

def rename_file(self, server_id: str, old_name: str, new_name: str,
Expand Down

0 comments on commit aae6f08

Please sign in to comment.