From 5f7aefa6a13ae7ebc168a0cc5d772b30cdb4888f Mon Sep 17 00:00:00 2001 From: Stefan Hynek <stefan.hynek@uni-goettingen.de> Date: Tue, 24 May 2022 14:11:15 +0200 Subject: [PATCH] feat(crud): add lock and unlock resource functions --- src/tgclients/crud.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/tgclients/crud.py b/src/tgclients/crud.py index 6446d22..e8cb374 100644 --- a/src/tgclients/crud.py +++ b/src/tgclients/crud.py @@ -87,6 +87,38 @@ class TextgridCRUD: response.encoding = RESPONSE_ENCODING return response + def lock_resource(self, sid: str, textgrid_uri: str): + """Lock a Textgrid Resource. + + Args: + sid (str): Session ID + textgrid_uri (str): Textgrid URI + + Returns: + Response: HTTP response from service + """ + params = {'sessionId': sid} + response = requests.get( + self._url + '/' + textgrid_uri + '/lock', params=params) + response.encoding = RESPONSE_ENCODING + return response + + def unlock_resource(self, sid: str, textgrid_uri: str): + """Unlock a Textgrid Resource. + + Args: + sid (str): Session ID + textgrid_uri (str): Textgrid URI + + Returns: + Response: HTTP response from service + """ + params = {'sessionId': sid} + response = requests.get( + self._url + '/' + textgrid_uri + '/unlock', params=params) + response.encoding = RESPONSE_ENCODING + return response + @staticmethod def _prepare_multipart(data, metadata): """Create a streaming multipart object. -- GitLab