jetraw.client module

class jetraw.client.Client(*, organization=None, config_file=None, shared_credentials_file=None, host=None, access_token=None, refresh_token=None, refresh_token_if_empty=True, skip_compatibility_check=False)

Bases: object

Main client for interacting with Jetraw services.

Provides authentication, file operations, and connection management for the Jetraw filesystem and services.

Example

>>> # Create client with organization
>>> client = Client(organization="my-org")
>>>
>>> # Create client with explicit host and token
>>> client = Client(host="https://my-org.jetraw.com", access_token="token")
>>>
>>> # Create client from config file
>>> client = Client(config_file="~/.jetraw/config")
property access_token

Get the current access token.

authorize(timeout=datetime.timedelta(seconds=60))

Authorize the client with Jetraw services.

Parameters:

timeout (Optional[timedelta]) – Maximum time to wait for authorization (default: 1 minute)

Return type:

None

Example

>>> client = Client()
>>> client.authorize()
download(from_path, to_path='', *, storages=None)

Download files from Jetraw (convenience method).

Parameters:
  • from_path (Union[List[Path], Path]) – Remote path(s) to download from

  • to_path (PathLike) – Local path to download to (current directory if empty)

  • storages (Optional[List[str]]) – List of storage IDs to use

Returns:

Result of the download operation

Return type:

str

Example

>>> client = Client()
>>> # Download single file
>>> result = client.download(JetrawPath("/my-space/file.tiff"), "/local/")
>>> # Download multiple files
>>> result = client.download([JetrawPath("/my-space/file1.tiff"), JetrawPath("/my-space/file2.tiff")])
enqueue_download(from_path, to_path='', *, queue_id=None, storages=None)

Add a download operation to the queue.

Parameters:
  • from_path (Path) – Remote path to download from

  • to_path (PathLike) – Local path to download to (current directory if empty)

  • queue_id (Optional[str]) – Queue ID (generates new if None)

  • storages (Optional[List[str]]) – List of storage IDs to use

Returns:

Queue ID for the operation

Return type:

str

Example

>>> client = Client()
>>> queue_id = client.enqueue_download(
...     JetrawPath("/my-space/file.tiff"),
...     "/local/path/file.tiff"
... )
enqueue_downloads(from_paths, to_path='', *, queue_id=None, storages=None)

Add multiple download operations to the queue.

Parameters:
  • from_paths (List[Path]) – List of remote paths to download from

  • to_path (PathLike) – Local directory to download to (current directory if empty)

  • queue_id (Optional[str]) – Queue ID (generates new if None)

  • storages (Optional[List[str]]) – List of storage IDs to use

Returns:

Queue ID for the operations

Return type:

str

Example

>>> client = Client()
>>> queue_id = client.enqueue_downloads(
...     [JetrawPath("/my-space/file1.tiff"), JetrawPath("/my-space/file2.tiff")],
...     "/local/directory/"
... )
enqueue_upload(from_path, to_path, *, queue_id=None, calibration_id=None)

Add an upload operation to the queue.

Parameters:
  • from_path (PathLike) – Local path to upload from

  • to_path (Path) – Remote path to upload to

  • queue_id (Optional[str]) – Queue ID (generates new if None)

  • calibration_id (Optional[str]) – Calibration ID for the upload

Returns:

Queue ID for the operation

Return type:

str

Example

>>> client = Client()
>>> queue_id = client.enqueue_upload(
...     "/local/file.tiff",
...     JetrawPath("/my-space/file.tiff")
... )
enqueue_uploads(from_paths, to_path, *, queue_id=None, calibration_id=None)

Add multiple upload operations to the queue.

Parameters:
  • from_paths (List[PathLike]) – List of local paths to upload from

  • to_path (Path) – Remote directory to upload to

  • queue_id (Optional[str]) – Queue ID (generates new if None)

  • calibration_id (Optional[str]) – Calibration ID for the uploads

Returns:

Queue ID for the operations

Return type:

str

Example

>>> client = Client()
>>> queue_id = client.enqueue_uploads(
...     ["/local/file1.tiff", "/local/file2.tiff"],
...     JetrawPath("/my-space/directory/")
... )
execute_queue(queue_id)

Execute all operations in a queue.

Parameters:

queue_id (str) – ID of the queue to execute

Returns:

Result of the queue execution

Return type:

str

Example

>>> client = Client()
>>> queue_id = client.enqueue_download(JetrawPath("/my-space/file.tiff"))
>>> result = client.execute_queue(queue_id)
property host

Get the Jetraw host URL.

is_compatible()

Check if the SDK version is compatible with the Jetraw server.

Returns:

True if compatible, False otherwise

Return type:

bool

Example

>>> client = Client()
>>> if not client.is_compatible():
...     print("SDK version is not compatible")
load_configuration(*, organization=None, config_file=None, shared_credentials_file=None)

Load credentials from configuration files.

Parameters:
  • organization (Optional[str]) – Organization to load credentials for (uses default if None)

  • config_file (Union[str, Path, None]) – Path to config file (uses default if None)

  • shared_credentials_file (Union[str, Path, None]) – Path to shared credentials file (uses default if None)

Raises:

ValueError – If the specified organization is not found in credentials

Return type:

None

Example

>>> client = Client()
>>> client.load_configuration(organization="my-org")
refresh_token()

Refresh the access token using stored credentials.

Return type:

None

Example

>>> client = Client()
>>> client.refresh_token()
property state

Get the state client for API operations.

upload(from_path, to_path, *, calibration_id=None)

Upload files to Jetraw (convenience method).

Parameters:
  • from_path (Union[List[PathLike], PathLike]) – Local path(s) to upload from

  • to_path (Path) – Remote path to upload to

  • calibration_id (Optional[str]) – Calibration ID for the upload

Returns:

Result of the upload operation

Return type:

str

Example

>>> client = Client()
>>> # Upload single file
>>> result = client.upload("/local/file.tiff", JetrawPath("/my-space/file.tiff"))
>>> # Upload multiple files
>>> result = client.upload(["/local/file1.tiff", "/local/file2.tiff"], JetrawPath("/my-space/"))