Skip to content
Snippets Groups Projects

Resolve "add get-uri API call to tgcrud"

Merged Ubbo Veentjer requested to merge 101-add-get-uri-api-call-to-tgcrud into main
4 files
+ 71
0
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 43
0
@@ -157,6 +157,30 @@ class TextgridCrudRequest:
)
return self._handle_response(response)
def get_uri(self, sid: str, how_many: int) -> Response:
"""Get TextGrid URIs.
Get an specified amount of TextGrid URIs for assigning to new TextGrid objects.
Useful e.g. for bulk imports.
Args:
sid (str): Session ID
how_many (int): number of URIs to generate
Raises:
TextgridCrudException: if HTTP status code >= 400
Returns:
Response: HTTP response from service with TextGrid URIs in body
"""
params = {'sessionId': sid, 'howMany': how_many}
response = self._requests.get(
self._url + '/getUri',
params=params,
timeout=self._config.http_timeout,
)
return self._handle_response(response)
def update_resource( # noqa: PLR0913
self,
sid: str,
@@ -383,6 +407,25 @@ class TextgridCrud(TextgridCrudRequest):
response = super().create_revision(sid, project_id, textgrid_uri, data, metadata_string)
return self._parser.parse(BytesIO(response.content), MetadataContainerType)
def get_uri(self, sid: str, how_many: int) -> list:
"""Get TextGrid URIs.
Get an specified amount of TextGrid URIs for assigning to new TextGrid objects.
Useful e.g. for bulk imports.
Args:
sid (str): Session ID
how_many (int): number of URIs to generate
Raises:
TextgridCrudException: if HTTP status code >= 400
Returns:
list: List with TextGrid URIs
"""
response = super().get_uri(sid=sid, how_many=how_many)
return response.text.splitlines()
def read_metadata(self, textgrid_uri: str, sid: Optional[str] = None) -> MetadataContainerType:
"""Read Metadata.
Loading