Skip to content

api_endpoints

API Endpoints for PlantDB client.

This module provides helper functions to construct URL paths for the PlantDB REST API. Each function returns the endpoint string with optional prefix and performs basic sanitization of identifiers.

Key Features
  • Sanitizes and validates scan, fileset, and file names.
  • Supports optional URL prefixes for API versioning.
  • Generates paths for authentication, health checks, scans, images, and archives.
Usage Examples

from plantdb.client import api_endpoints api_endpoints.login(prefix='/api/v1') '/api/v1/login' api_endpoints.scan('plant1', prefix='/api/v1') '/api/v1/scan/plant1'

archive Link

archive(scan_id, **kwargs)

Return the URL path to the dataset archive endpoint.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan dataset to archive.

required

Returns:

Type Description
str

The URL path to the dataset archive endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.archive('scan1')
'/archive/scan1'
Source code in plantdb/client/api_endpoints.py
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
@url_prefix
def archive(scan_id: str, **kwargs) -> str:
    """Return the URL path to the dataset archive endpoint.

    Parameters
    ----------
    scan_id : str
        The name of the scan dataset to archive.

    Returns
    -------
    str
        The URL path to the dataset archive endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.archive('scan1')
    '/archive/scan1'
    """
    scan_id = sanitize_name(scan_id)
    return f"/archive/{scan_id}"

create_api_token Link

create_api_token()

Return the URL path to the API token creation endpoint.

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to the API token creation endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.create_api_token(prefix='/api/v1')
'/api/v1/create-api-token'
Source code in plantdb/client/api_endpoints.py
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
@url_prefix
def create_api_token():
    """Return the URL path to the API token creation endpoint.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to the API token creation endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.create_api_token(prefix='/api/v1')
    '/api/v1/create-api-token'
    """
    return "/create-api-token"

dataset_files_list Link

dataset_files_list(scan_id=None, **kwargs)

Return the URL path to list all files of a dataset (scan).

Source code in plantdb/client/api_endpoints.py
683
684
685
686
687
688
@url_prefix
def dataset_files_list(scan_id: Optional[str] = None, **kwargs) -> str:
    """Return the URL path to list all files of a dataset (scan)."""
    if scan_id:
        scan_id = sanitize_name(scan_id)
    return f"/files/{scan_id}" if scan_id else "/files"

file Link

file(scan_id, fileset_id, file_id, **kwargs)

Return the URL path to the scan/fileset/file endpoint.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan dataset containing the file.

required

fileset_id Link

str

The name of the fileset containing the file.

required

file_id Link

str

The name of the file.

required

Returns:

Type Description
str

The URL path to the file endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.file('real_plant','images','00000_rgb')
'/files/real_plant/images/00000_rgb'
Source code in plantdb/client/api_endpoints.py
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
@url_prefix
def file(scan_id: str, fileset_id: str, file_id: str, **kwargs) -> str:
    """Return the URL path to the `scan/fileset/file` endpoint.

    Parameters
    ----------
    scan_id : str
        The name of the scan dataset containing the file.
    fileset_id : str
        The name of the fileset containing the file.
    file_id : str
        The name of the file.

    Returns
    -------
    str
        The URL path to the file endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.file('real_plant','images','00000_rgb')
    '/files/real_plant/images/00000_rgb'
    """
    scan_id = sanitize_name(scan_id)
    fileset_id = sanitize_name(fileset_id)
    file_id = sanitize_name(file_id)
    return f"/file/{scan_id}/{fileset_id}/{file_id}"

file_metadata Link

file_metadata(scan_id, fileset_id, file_id, **kwargs)

URL to access the file metadata associated with the given scan and fileset name.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan to access.

required

fileset_id Link

str

The name of the fileset to access.

required

file_id Link

str

The name of the file to access.

required

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to file metadata.

Source code in plantdb/client/api_endpoints.py
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
@url_prefix
def file_metadata(scan_id: str, fileset_id: str, file_id: str, **kwargs) -> str:
    """URL to access the file metadata associated with the given scan and fileset name.

    Parameters
    ----------
    scan_id : str
        The name of the scan to access.
    fileset_id : str
        The name of the fileset to access.
    file_id : str
        The name of the file to access.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to file metadata.
    """
    scan_id = sanitize_name(scan_id)
    fileset_id = sanitize_name(fileset_id)
    file_id = sanitize_name(file_id)
    return f"/file/{scan_id}/{fileset_id}/{file_id}/metadata"

file_path Link

file_path(scan_id, file_path, **kwargs)

Return the URL path to the scan/file_path endpoint.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan dataset containing the file.

required

file_path Link

str

The path to the file in the database.

required

Returns:

Type Description
str

The URL path to the file path endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.file_path('real_plant','images/00000_rgb.jpg')
'/files/real_plant/images/00000_rgb.jpg'
Source code in plantdb/client/api_endpoints.py
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
@url_prefix
def file_path(scan_id: str, file_path: str, **kwargs) -> str:
    """Return the URL path to the `scan/file_path` endpoint.

    Parameters
    ----------
    scan_id : str
        The name of the scan dataset containing the file.
    file_path : str
        The path to the file in the database.

    Returns
    -------
    str
        The URL path to the file path endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.file_path('real_plant','images/00000_rgb.jpg')
    '/files/real_plant/images/00000_rgb.jpg'
    """
    scan_id = sanitize_name(scan_id)
    return f"/files/{scan_id}/{file_path.lstrip('/')}"

fileset Link

fileset(scan_id, fileset_id, **kwargs)

URL path for a fileset belonging to a scan.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan to access.

required

fileset_id Link

str

The name of the fileset to access.

required

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to file metadata.

Source code in plantdb/client/api_endpoints.py
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
@url_prefix
def fileset(scan_id, fileset_id, **kwargs) -> str:
    """URL path for a fileset belonging to a scan.

    Parameters
    ----------
    scan_id : str
        The name of the scan to access.
    fileset_id : str
        The name of the fileset to access.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to file metadata.
    """
    scan_id = sanitize_name(scan_id)
    fileset_id = sanitize_name(fileset_id)
    return f"/fileset/{scan_id}/{fileset_id}"

fileset_files_list Link

fileset_files_list(scan_id, fileset_id, **kwargs)

URL to list the file associated with the given scan and filesets names.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan to access.

required

fileset_id Link

str

The name of the fileset to access.

required

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to the filesets list of files.

Source code in plantdb/client/api_endpoints.py
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
@url_prefix
def fileset_files_list(scan_id: str, fileset_id: str, **kwargs) -> str:
    """URL to list the file associated with the given scan and filesets names.

    Parameters
    ----------
    scan_id : str
        The name of the scan to access.
    fileset_id : str
        The name of the fileset to access.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to the filesets list of files.
    """
    scan_id = sanitize_name(scan_id)
    fileset_id = sanitize_name(fileset_id)
    return f"/fileset/{scan_id}/{fileset_id}/files"

fileset_metadata Link

fileset_metadata(scan_id, fileset_id, **kwargs)

URL to access the fileset metadata associated with the given scan and fileset name.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan to access.

required

fileset_id Link

str

The name of the fileset to access.

required

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to fileset metadata.

Source code in plantdb/client/api_endpoints.py
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
@url_prefix
def fileset_metadata(scan_id: str, fileset_id: str, **kwargs) -> str:
    """URL to access the fileset metadata associated with the given scan and fileset name.

    Parameters
    ----------
    scan_id : str
        The name of the scan to access.
    fileset_id : str
        The name of the fileset to access.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to fileset metadata.
    """
    scan_id = sanitize_name(scan_id)
    fileset_id = sanitize_name(fileset_id)
    return f"/fileset/{scan_id}/{fileset_id}/metadata"

health Link

health(**kwargs)

Return the URL path to the health endpoint.

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to the health endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.health(prefix='/api/v1')
'/api/v1/health'
Source code in plantdb/client/api_endpoints.py
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
@url_prefix
def health(**kwargs) -> str:
    """Return the URL path to the health endpoint.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to the health endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.health(prefix='/api/v1')
    '/api/v1/health'
    """
    return "/health"

image Link

image(scan_id, fileset_id, file_id, size, as_base64, **kwargs)

Return the URL path to the image endpoint.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan dataset containing the image.

required

fileset_id Link

str

The name of the fileset containing the image.

required

file_id Link

str

The name of the image.

required

size Link

str or int

The size parameter of the image request.

required

as_base64 Link

bool

A boolean flag indicating whether to return an image as a base64 string.

required

Returns:

Type Description
str

The URL path to the image endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.image('real_plant','images','00000_rgb', 'orig', False)
'/image/real_plant/images/00000_rgb?size=orig'
>>> api_endpoints.image('real_plant','images','00000_rgb', 'thumb', True)
'/image/real_plant/images/00000_rgb?size=thumb&as_base64=true'
Source code in plantdb/client/api_endpoints.py
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
@url_prefix
def image(scan_id: str, fileset_id: str, file_id: str, size: str, as_base64: bool, **kwargs) -> str:
    """Return the URL path to the image endpoint.

    Parameters
    ----------
    scan_id : str
        The name of the scan dataset containing the image.
    fileset_id : str
        The name of the fileset containing the image.
    file_id : str
        The name of the image.
    size : str or int
        The size parameter of the image request.
    as_base64 : bool
        A boolean flag indicating whether to return an image as a base64 string.

    Returns
    -------
    str
        The URL path to the image endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.image('real_plant','images','00000_rgb', 'orig', False)
    '/image/real_plant/images/00000_rgb?size=orig'
    >>> api_endpoints.image('real_plant','images','00000_rgb', 'thumb', True)
    '/image/real_plant/images/00000_rgb?size=thumb&as_base64=true'
    """
    scan_id = sanitize_name(scan_id)
    fileset_id = sanitize_name(fileset_id)
    file_id = sanitize_name(file_id)

    # Assemble optional query parameters
    query: dict[str, str] = {}
    if size is not None:
        query["size"] = str(size)
    if as_base64 is not None:
        # Use lower‑case JSON‑style booleans for consistency
        query["as_base64"] = str(as_base64).lower()

    query_str = f"?{parse.urlencode(query)}" if query else ""
    return f"/image/{scan_id}/{fileset_id}/{file_id}{query_str}"

login Link

login(**kwargs)

Return the URL path to the login endpoint.

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to the login endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.login(prefix='/api/v1')
'/api/v1/login'
Source code in plantdb/client/api_endpoints.py
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
@url_prefix
def login(**kwargs) -> str:
    """Return the URL path to the login endpoint.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to the login endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.login(prefix='/api/v1')
    '/api/v1/login'
    """
    return "/login"

logout Link

logout(**kwargs)

Return the URL path to the logout endpoint.

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to the logout endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.logout(prefix='/api/v1')
'/api/v1/logout'
Source code in plantdb/client/api_endpoints.py
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
@url_prefix
def logout(**kwargs) -> str:
    """Return the URL path to the logout endpoint.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to the logout endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.logout(prefix='/api/v1')
    '/api/v1/logout'
    """
    return "/logout"

mesh Link

mesh(scan_id, fileset_id, file_id, **kwargs)

Return the URL path to the mesh endpoint.

Source code in plantdb/client/api_endpoints.py
709
710
711
712
713
714
715
@url_prefix
def mesh(scan_id: str, fileset_id: str, file_id: str, **kwargs) -> str:
    """Return the URL path to the mesh endpoint."""
    scan_id = sanitize_name(scan_id)
    fileset_id = sanitize_name(fileset_id)
    file_id = sanitize_name(file_id)
    return f"/mesh/{scan_id}/{fileset_id}/{file_id}"

pc_ground_truth Link

pc_ground_truth(scan_id, fileset_id, file_id, **kwargs)

Return the URL path to the point‑cloud ground‑truth endpoint.

Source code in plantdb/client/api_endpoints.py
700
701
702
703
704
705
706
@url_prefix
def pc_ground_truth(scan_id: str, fileset_id: str, file_id: str, **kwargs) -> str:
    """Return the URL path to the point‑cloud ground‑truth endpoint."""
    scan_id = sanitize_name(scan_id)
    fileset_id = sanitize_name(fileset_id)
    file_id = sanitize_name(file_id)
    return f"/pcGroundTruth/{scan_id}/{fileset_id}/{file_id}"

pointcloud Link

pointcloud(scan_id, fileset_id, file_id, **kwargs)

Return the URL path to the point‑cloud endpoint.

Source code in plantdb/client/api_endpoints.py
691
692
693
694
695
696
697
@url_prefix
def pointcloud(scan_id: str, fileset_id: str, file_id: str, **kwargs) -> str:
    """Return the URL path to the point‑cloud endpoint."""
    scan_id = sanitize_name(scan_id)
    fileset_id = sanitize_name(fileset_id)
    file_id = sanitize_name(file_id)
    return f"/pointcloud/{scan_id}/{fileset_id}/{file_id}"

refresh Link

refresh(scan_id=None, **kwargs)

Return the URL path to the dataset archive endpoint.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan dataset to archive.

None

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to the refresh endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.refresh(prefix='/api/v1')
'/api/v1/refresh'
>>> api_endpoints.refresh('scan1')
'/refresh?scan_id=scan1'
Source code in plantdb/client/api_endpoints.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
@url_prefix
def refresh(scan_id: str = None, **kwargs) -> str:
    """Return the URL path to the dataset archive endpoint.

    Parameters
    ----------
    scan_id : str
        The name of the scan dataset to archive.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to the refresh endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.refresh(prefix='/api/v1')
    '/api/v1/refresh'
    >>> api_endpoints.refresh('scan1')
    '/refresh?scan_id=scan1'
    """
    params = ""
    if scan_id:
        scan_id = sanitize_name(scan_id)
        params = f"?scan_id={scan_id}"
    return f"/refresh{params}"

register Link

register(**kwargs)

Return the URL path to the register endpoint.

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to the register endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.register(prefix='/api/v1')
'/api/v1/register'
Source code in plantdb/client/api_endpoints.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
@url_prefix
def register(**kwargs) -> str:
    """Return the URL path to the register endpoint.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to the register endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.register(prefix='/api/v1')
    '/api/v1/register'
    """
    return "/register"

sanitize_name Link

sanitize_name(name)

Sanitizes and validates the provided name.

The function ensures that the input string adheres to predefined naming rules by:

  • stripping leading/trailing spaces,
  • isolating the last segment after splitting by slashes,
  • validating the name against an alphanumeric pattern with optional underscores (_), dashes (-), or periods (.).

Parameters:

Name Type Description Default

name Link

str

The name to sanitize and validate.

required

Returns:

Type Description
str

Sanitized name that conforms to the rules.

Raises:

Type Description
ValueError

If the provided name contains invalid characters or does not meet the naming rules.

Source code in plantdb/client/api_endpoints.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def sanitize_name(name) -> str:
    """Sanitizes and validates the provided name.

    The function ensures that the input string adheres to predefined naming rules by:

    - stripping leading/trailing spaces,
    - isolating the last segment after splitting by slashes,
    - validating the name against an alphanumeric pattern
      with optional underscores (`_`), dashes (`-`), or periods (`.`).

    Parameters
    ----------
    name : str
        The name to sanitize and validate.

    Returns
    -------
    str
        Sanitized name that conforms to the rules.

    Raises
    ------
    ValueError
        If the provided name contains invalid characters or does not meet
        the naming rules.
    """
    import re
    sanitized_name = name.strip()  # Remove leading/trailing spaces
    sanitized_name = sanitized_name.split('/')[-1]  # isolate the last segment after splitting by slashes
    # Validate against an alphanumeric pattern with optional underscores, dashes, or periods
    if not re.match(r"^[a-zA-Z0-9_.-]+$", sanitized_name):
        raise ValueError(
            f"Invalid name: '{name}'. Names must be alphanumeric and can include underscores, dashes, or periods.")
    return sanitized_name

scan Link

scan(scan_id, **kwargs)

Return the URL path to the scan endpoint.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan to access.

required

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to the scan endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.scan('scan1')
'/scan/scan1'
>>> api_endpoints.scan('scan1', prefix='/api/v1')
'/api/v1/scan/scan1'
Source code in plantdb/client/api_endpoints.py
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
@url_prefix
def scan(scan_id: str, **kwargs) -> str:
    """Return the URL path to the scan endpoint.

    Parameters
    ----------
    scan_id : str
        The name of the scan to access.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to the scan endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.scan('scan1')
    '/scan/scan1'
    >>> api_endpoints.scan('scan1', prefix='/api/v1')
    '/api/v1/scan/scan1'
    """
    scan_id = sanitize_name(scan_id)
    return f"/scan/{scan_id}"

scan_filesets_list Link

scan_filesets_list(scan_id, **kwargs)

URL to list the filesets associated with the given scan name.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan to access.

required

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to filesets.

Source code in plantdb/client/api_endpoints.py
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
@url_prefix
def scan_filesets_list(scan_id: str, **kwargs) -> str:
    """URL to list the filesets associated with the given scan name.

    Parameters
    ----------
    scan_id : str
        The name of the scan to access.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to filesets.
    """
    scan_id = sanitize_name(scan_id)
    return f"/scan/{scan_id}/filesets"

scan_metadata Link

scan_metadata(scan_id, **kwargs)

URL to access the metadata associated with the given scan name.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan to access.

required

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to scan metadata.

Source code in plantdb/client/api_endpoints.py
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
@url_prefix
def scan_metadata(scan_id: str, **kwargs) -> str:
    """URL to access the metadata associated with the given scan name.

    Parameters
    ----------
    scan_id : str
        The name of the scan to access.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to scan metadata.
    """
    scan_id = sanitize_name(scan_id)
    return f"/scan/{scan_id}/metadata"

scans Link

scans(**kwargs)

Return the URL path to the scans' endpoint.

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to the scans' endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.scans(prefix='/api/v1')
'/api/v1/scans'
Source code in plantdb/client/api_endpoints.py
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
@url_prefix
def scans(**kwargs) -> str:
    """Return the URL path to the scans' endpoint.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to the scans' endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.scans(prefix='/api/v1')
    '/api/v1/scans'
    """
    return "/scans"

scans_info Link

scans_info(**kwargs)

Return the URL path to the list of scan dataset information endpoint.

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to the list of scan dataset information endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.scans_info(prefix='/api/v1')
'/api/v1/scans_info'
Source code in plantdb/client/api_endpoints.py
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
@url_prefix
def scans_info(**kwargs) -> str:
    """Return the URL path to the list of scan dataset information endpoint.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to the list of scan dataset information endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.scans_info(prefix='/api/v1')
    '/api/v1/scans_info'
    """
    return "/scans_info"

sequence Link

sequence(scan_id, type, **kwargs)

Return the URL path to the sequence endpoint.

Parameters:

Name Type Description Default

scan_id Link

str

The name of the scan dataset containing the angles and internodes sequence.

required

type Link

str or int

The type of measure to reques, in ['all', 'angles', 'internodes', 'fruit_points', 'manual_angles', 'manual_internodes'].

required

Returns:

Type Description
str

The URL path to the angles and internodes sequences endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.sequence('real_plant', 'all')
'/sequence/real_plant?type=all'
Source code in plantdb/client/api_endpoints.py
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
@url_prefix
def sequence(scan_id: str, type: str, **kwargs) -> str:
    """Return the URL path to the sequence endpoint.

    Parameters
    ----------
    scan_id : str
        The name of the scan dataset containing the angles and internodes sequence.
    type : str or int
        The type of measure to reques, in ['all', 'angles', 'internodes', 'fruit_points',
         'manual_angles', 'manual_internodes'].

    Returns
    -------
    str
        The URL path to the angles and internodes sequences endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.sequence('real_plant', 'all')
    '/sequence/real_plant?type=all'
    """
    valid_types = ['all', 'angles', 'internodes', 'fruit_points', 'manual_angles', 'manual_internodes']
    type = 'all' if type not in valid_types else type
    scan_id = sanitize_name(scan_id)

    # Assemble optional query parameters
    query: dict[str, str] = {}
    if type is not None:
        query["type"] = str(type)

    query_str = f"?{parse.urlencode(query)}" if query else ""
    return f"/sequence/{scan_id}{query_str}"

skeleton Link

skeleton(scan_id, **kwargs)

Return the URL path to the skeleton endpoint.

Source code in plantdb/client/api_endpoints.py
718
719
720
721
722
@url_prefix
def skeleton(scan_id: str, **kwargs) -> str:
    """Return the URL path to the skeleton endpoint."""
    scan_id = sanitize_name(scan_id)
    return f"/skeleton/{scan_id}"

token_refresh Link

token_refresh(**kwargs)

Return the URL path to the token refresh endpoint.

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to the token refresh endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.token_refresh(prefix='/api/v1')
'/api/v1/token-refresh'
Source code in plantdb/client/api_endpoints.py
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
@url_prefix
def token_refresh(**kwargs) -> str:
    """Return the URL path to the token refresh endpoint.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to the token refresh endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.token_refresh(prefix='/api/v1')
    '/api/v1/token-refresh'
    """
    return "/token-refresh"

token_validation Link

token_validation(**kwargs)

Return the URL path to the token validation endpoint.

Other Parameters:

Name Type Description
prefix str

An optional prefix to prepend to the URL path.

Returns:

Type Description
str

The URL path to the token validation endpoint.

Examples:

>>> from plantdb.client import api_endpoints
>>> api_endpoints.token_validation(prefix='/api/v1')
'/api/v1/token-validation'
Source code in plantdb/client/api_endpoints.py
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
@url_prefix
def token_validation(**kwargs) -> str:
    """Return the URL path to the token validation endpoint.

    Other Parameters
    ----------------
    prefix : str
        An optional prefix to prepend to the URL path.

    Returns
    -------
    str
        The URL path to the token validation endpoint.

    Examples
    --------
    >>> from plantdb.client import api_endpoints
    >>> api_endpoints.token_validation(prefix='/api/v1')
    '/api/v1/token-validation'
    """
    return "/token-validation"

url_prefix Link

url_prefix(endpoint_path)

Wrap an endpoint path generator with an optional URL prefix.

Source code in plantdb/client/api_endpoints.py
65
66
67
68
69
70
71
72
73
74
75
76
def url_prefix(endpoint_path):
    """Wrap an endpoint path generator with an optional URL prefix."""

    def wrapper(*args, **kwargs):
        if "prefix" in kwargs and kwargs["prefix"]:
            prefix = kwargs["prefix"]
            prefix = '/' + prefix.lstrip('/').rstrip('/')
            return prefix + endpoint_path(*args, **kwargs)
        else:
            return endpoint_path(*args, **kwargs)

    return wrapper