diff --git a/filecloudapi/datastructures.py b/filecloudapi/datastructures.py index daa20a4..ad041b1 100644 --- a/filecloudapi/datastructures.py +++ b/filecloudapi/datastructures.py @@ -278,6 +278,28 @@ def _set_entries(self, response: Element): self.entries.append(an_entry) +class ServerSettings: + """Convienience class represents server settings""" + + entries: dict = {} + + def __iter__(self): + return iter(self.entries) + + def __init__(self, a_response: Element): + """""" + self._set_entries(response=a_response) + + def _set_entries(self, response: Element): + a_list = list(response) + + for elem in a_list: + if elem.tag != "setting": + continue + + self.entries[list(elem)[0].text] = list(elem)[1].text + + @dataclass class StorageRootDetails: type: str diff --git a/filecloudapi/fcserver.py b/filecloudapi/fcserver.py index 521cd5d..cb0345e 100644 --- a/filecloudapi/fcserver.py +++ b/filecloudapi/fcserver.py @@ -8,7 +8,7 @@ import xml.etree.ElementTree as ET from io import SEEK_CUR, SEEK_END, SEEK_SET, BufferedReader, BytesIO from pathlib import Path -from typing import Dict, Optional, Union +from typing import Dict, List, Optional, Union from urllib.parse import urlencode import requests @@ -32,6 +32,7 @@ PolicyList, PolicyUser, RMCClient, + ServerSettings, ShareActivity, SharedType, SortBy, @@ -1660,6 +1661,30 @@ def admin_resetpolicyforuser(self, username: str) -> None: self._raise_exception_from_command(resp) + def admin_get_config_settings(self, config: List[str]) -> ServerSettings: + """ + Retrieve Filecloud configuration settings. The config list should + contain FC configuration keys. + Args: + config: List containing FC config keys + """ + try: + count = len(config) + except (ValueError, TypeError): + count = 0 + + config_opts = {} + for i in range(count): + param_key = f"param{i}" + config_opts[param_key] = config[i] # type:ignore + + config_opts["count"] = str(len(config_opts)) + + resp = self._api_call("/admin/getconfigsetting", config_opts) + + settings = ServerSettings(resp) + return settings + def set_config_setting(self, config_name: str, config_val: str) -> None: """ Sets a server config setting via admin diff --git a/pyproject.toml b/pyproject.toml index e5173fa..a26ab60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "filecloudapi-python" -version = "0.4.1" +version = "0.4.2" description = "A Python library to connect to a Filecloud server" packages = [{ include = "filecloudapi" }]