Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions filecloudapi/datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 26 additions & 1 deletion filecloudapi/fcserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,6 +32,7 @@
PolicyList,
PolicyUser,
RMCClient,
ServerSettings,
ShareActivity,
SharedType,
SortBy,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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" }]
Expand Down