Skip to content

Commit 4472225

Browse files
committed
WIP add folders get/create/list
1 parent 83315dd commit 4472225

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

src/picterra/detector_platform_client.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,68 @@ def add_raster_to_detector(self, raster_id: str, detector_id: str):
373373
if not resp.status_code == 201:
374374
raise APIError(resp.text)
375375

376+
def list_folders(
377+
self,
378+
search_string: str | None = None,
379+
):
380+
""""
381+
Lists folders, see `ResultsPage` for explanations on pagination
382+
383+
Args:
384+
search_string: A search string to use to search by folder name
385+
386+
Returns:
387+
A list of folders dictionaries
388+
389+
Example:
390+
391+
::
392+
393+
{
394+
'id' :'42',
395+
'name': 'project 1',
396+
'created_at': '2024-10-14T07:05:59.070698Z'
397+
},
398+
{
399+
'id' :'43',
400+
'name': 'project 2',
401+
'created_at': '2023-10-14T07:05:59.070698Z'
402+
}
403+
404+
"""
405+
params: dict[str, Any] = {}
406+
if search_string:
407+
params["search"] = search_string
408+
return self._return_results_page("folders", params)
409+
410+
def get_folder(self, folder_id: str) -> dict[str, Any]:
411+
"""
412+
Returns metadata about a folder
413+
414+
Args:
415+
folder_id: The id of the folder
416+
417+
Returns:
418+
A dictionary containing metadata about the folder
419+
420+
Example:
421+
422+
::
423+
424+
{
425+
}
426+
"""
427+
resp = self.sess.get(self._full_url("folders/%s/" % folder_id))
428+
if not resp.ok:
429+
raise APIError(resp.text)
430+
return resp.json()
431+
432+
def create_folder(self, name: str):
433+
resp = self.sess.post(self._full_url("folders/"), { "name": name })
434+
if not resp.ok:
435+
raise APIError(resp.text)
436+
return resp.json()
437+
376438
def create_detector(
377439
self,
378440
name: str | None = None,

0 commit comments

Comments
 (0)