Skip to content

Commit 2cd1377

Browse files
authored
Merge pull request #11 from codelathe/product-add-getconfigsetting
Product - add getconfigsetting
2 parents bf358c6 + 432af55 commit 2cd1377

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

filecloudapi/datastructures.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,28 @@ def _set_entries(self, response: Element):
278278
self.entries.append(an_entry)
279279

280280

281+
class ServerSettings:
282+
"""Convienience class represents server settings"""
283+
284+
entries: dict = {}
285+
286+
def __iter__(self):
287+
return iter(self.entries)
288+
289+
def __init__(self, a_response: Element):
290+
""""""
291+
self._set_entries(response=a_response)
292+
293+
def _set_entries(self, response: Element):
294+
a_list = list(response)
295+
296+
for elem in a_list:
297+
if elem.tag != "setting":
298+
continue
299+
300+
self.entries[list(elem)[0].text] = list(elem)[1].text
301+
302+
281303
@dataclass
282304
class StorageRootDetails:
283305
type: str

filecloudapi/fcserver.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import xml.etree.ElementTree as ET
99
from io import SEEK_CUR, SEEK_END, SEEK_SET, BufferedReader, BytesIO
1010
from pathlib import Path
11-
from typing import Dict, Optional, Union
11+
from typing import Dict, List, Optional, Union
1212
from urllib.parse import urlencode
1313

1414
import requests
@@ -32,6 +32,7 @@
3232
PolicyList,
3333
PolicyUser,
3434
RMCClient,
35+
ServerSettings,
3536
ShareActivity,
3637
SharedType,
3738
SortBy,
@@ -1660,6 +1661,30 @@ def admin_resetpolicyforuser(self, username: str) -> None:
16601661

16611662
self._raise_exception_from_command(resp)
16621663

1664+
def admin_get_config_settings(self, config: List[str]) -> ServerSettings:
1665+
"""
1666+
Retrieve Filecloud configuration settings. The config list should
1667+
contain FC configuration keys.
1668+
Args:
1669+
config: List containing FC config keys
1670+
"""
1671+
try:
1672+
count = len(config)
1673+
except (ValueError, TypeError):
1674+
count = 0
1675+
1676+
config_opts = {}
1677+
for i in range(count):
1678+
param_key = f"param{i}"
1679+
config_opts[param_key] = config[i] # type:ignore
1680+
1681+
config_opts["count"] = str(len(config_opts))
1682+
1683+
resp = self._api_call("/admin/getconfigsetting", config_opts)
1684+
1685+
settings = ServerSettings(resp)
1686+
return settings
1687+
16631688
def set_config_setting(self, config_name: str, config_val: str) -> None:
16641689
"""
16651690
Sets a server config setting via admin

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22

33
name = "filecloudapi-python"
4-
version = "0.4.1"
4+
version = "0.4.2"
55
description = "A Python library to connect to a Filecloud server"
66

77
packages = [{ include = "filecloudapi" }]

0 commit comments

Comments
 (0)