diff --git a/docs/CHANGELOG.rst b/docs/CHANGELOG.rst index 568d5d01..02b0676d 100644 --- a/docs/CHANGELOG.rst +++ b/docs/CHANGELOG.rst @@ -22,6 +22,7 @@ Added ----- - Add support for predictions - Add version to annotation field +- Add a resolwe method for fetching the server module versions =================== diff --git a/src/resdk/resolwe.py b/src/resdk/resolwe.py index 29c29433..0204510e 100644 --- a/src/resdk/resolwe.py +++ b/src/resdk/resolwe.py @@ -32,7 +32,7 @@ from resdk.uploader import Uploader from .constants import CHUNK_SIZE -from .exceptions import ValidationError, handle_http_exception +from .exceptions import ResolweServerError, ValidationError, handle_http_exception from .query import ( AnnotationFieldQuery, AnnotationValueQuery, @@ -65,6 +65,7 @@ AUTOMATIC_LOGIN_POSTFIX = "saml-auth/api-login/" INTERACTIVE_LOGIN_POSTFIX = "saml-auth/remote-login/" MINIMAL_SUPPORTED_VERSION_POSTFIX = "api/resdk_minimal_supported_version" +SERVER_MODULE_VERSIONS_POSTFIX = "/about/versions" class ResolweResource(slumber.Resource): @@ -212,6 +213,15 @@ def version_check(self): "Warning: unable to read the minimal supported version from the server." ) + def version_output(self) -> dict: + """Output the version of the server modules.""" + url = urljoin(self.url, SERVER_MODULE_VERSIONS_POSTFIX) + try: + response = requests.get(url) + except requests.exceptions.RequestException: + raise ResolweServerError("Unable to read the server version.") + return response.json() + def _validate_url(self, url): if not re.match(r"https?://", url): raise ValueError("Server url must start with http(s)://")