Skip to content

trimble.fileservice.operations package

Module contents

class trimble.fileservice.operations.ExportsOperations(*args, **kwargs)

Bases: object

This class is not meant to be instantiated directly. It should be accessed through the exports property of a FileServiceClient instance.

async create(space_id: str, folder_id: str, include_top_level: bool = True) → str

Create a new export

  • Parameters:
    • space_id (str) – The space id
    • folder_id (str) – The folder id
    • include_top_level (bool) – Whether to include the top level folder in the export. Default is True.
  • Returns: The export id
  • Return type: str

Example:

export_id = await client.exports.create(space_id="space_id", folder_id="folder_id")

async get(space_id: str, export_id: str, url_duration: str | Literal[‘12h’, ‘300m’, ‘1d’] = ‘60m’) → Export

Get an export

  • Parameters:
    • space_id (str) – The space id
    • export_id (str) – The export id
    • url_duration (str) – The export download URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
  • Returns: The export
  • Return type: Export

Example:

export = await client.exports.get(space_id="space_id", export_id="export_id")

class trimble.fileservice.operations.FilesOperations(*args, **kwargs)

Bases: object

This class is not meant to be instantiated directly. It should be accessed through the files property of a FileServiceClient instance.

async checkin(space_id: str, file_id: str, complete: bool = True) → File | MinimalFile | SupportFile

Checks in a file

  • Parameters:
    • space_id (str) – The space id
    • file_id (str) – The file id
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
  • Returns: The response of checked-in file
  • Return type: MinimalFile or File or Support File

Example:

file = await client.files.checkin(space_id="space_id", file_id="file_id")

async checkout(space_id: str, file_id: str, reason: str | None = None, complete: bool = True, **kwargs: Any) → File | MinimalFile | SupportFile

Checkout a file

  • Parameters:

    • space_id (str) – The space id
    • file_id (str) – The file id
    • reason (str) – The reason for checking out the file
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments: headers (dict) –

    Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

    • — Matches resource name.

    x.* — Matches any minor version of major version x (e.g., 2.*). x.y — Matches an exact version (e.g., 3.4).

  • Returns: The response of checked-out file

  • Return type: MinimalFile or File or Support File

Example:

file = await client.files.checkin(space_id="space_id", file_id="file_id")

async copy(space_id: str, file_id: str, target_parent_id: str, name: str | None = None, include_support_files: bool = False, overwrite_existing: bool | None = None, complete: bool = True, permissions_local: Dict[Literal[‘acl’, ‘inherits’], List[Dict[Literal[‘actor’, ‘role’], str | Literal[‘spaceManager’, ‘contentManager’, ‘contentContributor’, ‘contentViewer’]]] | bool] | None = None, copy_acl: bool = False, **kwargs: Any) → FileCopyResponse

Copy a file

  • Parameters:

    • space_id (str) – The space id
    • file_id (str) – The file id
    • target_parent_id (str) – The target parent id
    • name (str) – New name of the file. If not provided, the original name will be used
    • include_support_files (bool) – Whether to copy the support files and links
    • overwrite_existing (bool) – Whether to overwrite an existing resource. If true, the existing resource will have a new version created with the copied content.
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
    • permissions_local (PermissionsLocalFile) – The permissions local of the file.
    • copy_acl (bool) – If True, the ACL of the file will be copied to the new file.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments: headers (dict) –

    Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

    • — Matches resource name.

    x.* — Matches any minor version of major version x (e.g., 2.*). x.y — Matches an exact version (e.g., 3.4).

  • Returns: The file copy response

  • Return type: FileCopyResponse

Example:

response = await client.files.copy(
space_id="space_id",
file_id="file_id",
target_parent_id="target_parent_id"
)

async copy_version(space_id: str, file_id: str, version: str, target_parent_id: str, name: str | None = None, include_support_files: bool = False, overwrite_existing: bool | None = None, complete: bool = True, permissions_local: Dict[Literal[‘acl’, ‘inherits’], List[Dict[Literal[‘actor’, ‘role’], str | Literal[‘spaceManager’, ‘contentManager’, ‘contentContributor’, ‘contentViewer’]]] | bool] | None = None, copy_acl: bool = False, **kwargs: Any) → FileCopyResponse

Copy a specific version of a file

  • Parameters:

    • space_id (str) – The space id
    • file_id (str) – The file id
    • version (str) – The version of the file to copy
    • target_parent_id (str) – The target parent id
    • name (str) – New name of the file. If not provided, the original name will be used
    • include_support_files (bool) – Whether to copy the support files and links
    • overwrite_existing (bool) – Whether to overwrite an existing resource. If true, the existing resource will have a new version created with the copied content.
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
    • permissions_local (PermissionsLocalFile) – The permissions local of the file.
    • copy_acl (bool) – If True, the ACL of the file will be copied to the new file.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments: headers (dict) –

    Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

    • — Matches resource name.

    x.* — Matches any minor version of major version x (e.g., 2.*). x.y — Matches an exact version (e.g., 3.4).

  • Returns: The file copy response

  • Return type: FileCopyResponse

Example:

response = await client.files.copy(
space_id="space_id",
file_id="file_id",
target_parent_id="target_parent_id"
)

Create a new file upload

  • Parameters:

    • space_id (str) – The space id
    • name (str) – The name of the file
    • parent_id (str) – The parent id of the file
    • url_duration (str) – The file upload URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
    • restricted_access (bool) – True if the download url of the file should expire according to the url duration query parameter
    • fileset (bool) – The fileset of the file
    • multipart (bool) – True if the client will split the upload into multiple parts
    • response_headers (dict) – The response headers of the file
    • metadata (dict) – The metadata of the file
    • permissions_local (PermissionsLocalFile) – The permissions that are set directly for actors on the resource itself. Contains ‘inherits’ boolean flag that determines whether the permissions need to be inherited from the parent resource or not (default: true), and ‘acl’ list of actor-role mappings
    • expires_at (str) – The expiration timestamp for the file
    • include_links (bool) – True if file should include the support file links from the last version during a file’s major version change
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments: headers (dict) –

    Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

    • — Matches resource name.

    x.* — Matches any minor version of major version x (e.g., 2.*). x.y — Matches an exact version (e.g., 3.4).

  • Returns: The file upload created response

  • Return type: UploadFileResponse

Example:

response = await client.files.create_file_upload(
space_id="space_id",
name="name",
parent_id="parent_id",
permissions_local={
"inherits": False,
"acl": [
{
"actor": "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1",
"role": "contentManager"
},
{
"actor": "trn:tid:user:f85bc802-5481-4581-b972-c4652d595ec7",
"role": "contentContributor"
}
]
}
)

Link support files to a file

  • Parameters:
    • space_id (str) – The space id
    • file_id (str) – The file id
    • file_major_version (str) – The major version of the parent file
    • links (dict *[*str , SupportFileLinkParams ]) – The links in the form of a dictionary with support file key and SupportFileLinkParams
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
  • Returns: The file response. If complete is False, the response will be a MinimalFile. Otherwise, it will be a File.
  • Return type: MinimalFile or File

Example:: : from trimble.fileservice.models import SupportFileLinkParams
file = await client.files.create_or_update_links( : space_id=”space_id”, file_id=”file_id”, file_major_version=1, links={
> “key1”: SupportFileLinkParams(id=”id”, version=”version”), > “key2”: SupportFileLinkParams(id=”id”, version=”version”)
}
)

async create_package_upload(space_id: str, name: str, parent_id: str, support_file_resources: list[SupportFileResourceParams], url_duration: str | Literal[‘12h’, ‘300m’, ‘1d’] = ‘60m’, restricted_access: bool = True, fileset: bool = False, multipart: bool = False, response_headers: Mapping[str, str] | None = None, metadata: object | None = None, permissions_local: Dict[Literal[‘acl’, ‘inherits’], List[Dict[Literal[‘actor’, ‘role’], str | Literal[‘spaceManager’, ‘contentManager’, ‘contentContributor’, ‘contentViewer’]]] | bool] | None = None, expires_at: str | None = None, **kwargs: Any) → UploadPackageResponse

Create a new file upload

  • Parameters:

    • space_id (str) – The space id
    • name (str) – The name of the file
    • parent_id (str) – The parent id of the file
    • support_file_resources (list [SupportFileResourceParams ]) – The support file resources
    • url_duration (str) – The file upload URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
    • restricted_access (bool) – True if the download url of the file should expire according to the url duration query parameter
    • fileset (bool) – The fileset of the file
    • multipart (bool) – True if the client will split the upload into multiple parts
    • response_headers (dict) – The response headers of the file
    • metadata (dict) – The metadata of the file
    • permissions_local (dict) – The permissions that are set directly for actors on the resource itself. Contains ‘inherits’ boolean flag that determines whether the permissions need to be inherited from the parent resource or not (default: true), and ‘acl’ list of actor-role mappings
    • expires_at (str) – The expiration timestamp for the file
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments: headers (dict) –

    Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

    • — Matches resource name.

    x.* — Matches any minor version of major version x (e.g., 2.*). x.y — Matches an exact version (e.g., 3.4).

  • Returns: The package upload created response

  • Return type: UploadPackageResponse

Example:

response = await client.files.create_package_upload(
space_id="space_id",
name="name",
parent_id="parent_id",
support_file_resources=[
{
"key": "key",
"name": "name",
"size": 0,
"mimeType": "application/octet-stream"
}
],
permissions_local={
"inherits": False,
"acl": [
{
"actor": "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1",
"role": "contentManager"
},
{
"actor": "trn:tid:user:f85bc802-5481-4581-b972-c4652d595ec7",
"role": "contentContributor"
}
]
}
)

Create a new support file upload

  • Parameters:
    • space_id (str) – The space id
    • name (str) – The name of the support file
    • file_id (str) – The id of the parent file
    • file_major_version (str) – The major version of the parent file
    • support_file_key (str) – The key of the support file. Filename is used if not provided
    • add_to_links (bool) – Whether to link the support file to the file. Default is True
    • url_duration (str) – The support file upload URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
    • restricted_access (bool) – True if the download url of the support file should expire according to the url duration query parameter
    • fileset (bool) – The fileset of the support file
    • multipart (bool) – True if the client will split the upload into multiple parts
    • response_headers (dict) – The response headers of the support file
    • metadata (dict) – The metadata of the support file
    • expires_at (str) – The expiration timestamp for the support file
  • Returns: The support file upload created response
  • Return type: UploadSupportFileResponse

Example:

response = await client.files.create_support_file_upload(space_id="space_id", name="name", parent_id="parent_id")

async delete(space_id: str, file_id: str, permanent: bool = False, **kwargs: Any) → str | None

Delete a file

  • Parameters:

    • space_id (str) – The space id
    • file_id (str) – The file id
    • permanent (bool) – If the deletion should be permanent
  • Keyword Arguments: headers (dict) –

    Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

    • — Matches resource name.

    x.* — Matches any minor version of major version x (e.g., 2.*). x.y — Matches an exact version (e.g., 3.4).

  • Returns: The job id if the file has support files, None otherwise

  • Return type: Optional[str]

Example:

job_id = await client.files.delete(space_id="space_id", file_id="file_id")

async download_file(space_id: str, file_id: str, file_object: IO[bytes], version: str | None = None, **kwargs) → None

Download a file to file stream

  • Parameters:
    • space_id (str) – The space id
    • file_id (str) – The file id
    • file_obj (FileObj) – The file like object where the content will be downloaded
    • version (str) – The version of the file to download
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • concurrent_limit (int) – The maximum number of chunks to download concurrently. (Default is 8)
    • chunk_size (int) – The maximum size of each chunk to download in MB. (Default is 15 (MB)).
    • url_duration (str) – The file download URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).

Example:

file_object = open("file_path", "wb")
await client.files.download_file(space_id="space_id", file_id="file_id", file_object=file_object)

async download_file_by_path(space_id: str, path: str, file_object: IO[bytes], version: str | None = None, **kwargs) → None

Download a file to file stream

  • Parameters:
    • space_id (str) – The space id
    • path (str) – The path of the file
    • file_obj (FileObj) – The file like object where the content will be downloaded
    • version (str) – The version of the file to download
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • concurrent_limit (int) – The maximum number of chunks to download concurrently
    • chunk_size (int) – The maximum size of each chunk to download in MB. (Default is 15 (MB)).
    • url_duration (str) – The file download URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).

Example:

file_object = open("file_path", "wb")
await client.files.download_file_by_path(space_id="space_id", path="path", file_object=file_object)

async get(space_id: str, file_id: str, url_duration: str | Literal[‘12h’, ‘300m’, ‘1d’] = ‘60m’, response_content_type: str | None = None, status: Literal[‘active’, ‘deleted’, ‘active,deleted’] = ‘active’, complete: bool = True) → MinimalFile | File | SupportFile

Get a file

  • Parameters:
    • space_id (str) – The space id
    • file_id (str) – The file id
    • url_duration (str) – The file download URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
    • response_content_type (str) – The response content type
    • status (str) – The status of the file
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
  • Returns: The file response. If complete is False, the response will be a MinimalFile. Otherwise, it will be a File or SupportFile.
  • Return type: MinimalFile or File or SupportFile

Example:

file = await client.files.get(space_id="space_id", file_id="file_id")

async get_by_path(space_id: str, path: str, url_duration: str | Literal[‘12h’, ‘300m’, ‘1d’] = ‘60m’, response_content_type: str | None = None, status: Literal[‘active’, ‘deleted’, ‘active,deleted’] = ‘active’, complete: bool = True) → MinimalFile | File | SupportFile

Get a file by path

  • Parameters:
    • space_id (str) – The space id
    • path (str) – The path of the file
    • url_duration (str) – The file download URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
    • response_content_type (str) – The response content type
    • status (str) – The status of the file
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
  • Returns: The file response. If complete is False, the response will be a MinimalFile. Otherwise, it will be a File or SupportFile.
  • Return type: MinimalFile or File or SupportFile

Example:

file = await client.files.get_by_path(space_id="space_id", path="path")

async get_upload_details(space_id: str, upload_id: str, url_duration: str | Literal[‘12h’, ‘300m’, ‘1d’] = ‘60m’) → UploadFileResponse | UploadSupportFileResponse | UploadPackageResponse

Get the details of an upload

  • Parameters:
    • space_id (str) – The space id
    • upload_id (str) – The upload id
    • url_duration (str) – The upload URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
  • Returns: The upload details response
  • Return type: UploadFileResponse or UploadSupportFileResponse or UploadPackageResponse

Example:

upload = await client.files.get_upload_details(space_id="space_id", upload_id="upload_id")

async get_version(space_id: str, file_id: str, version: str, url_duration: str | Literal[‘12h’, ‘300m’, ‘1d’] = ‘60m’, response_content_type: str | None = None, status: Literal[‘active’, ‘deleted’, ‘active,deleted’] = ‘active’, complete: bool = True) → MinimalFile | File | SupportFile

Get a file version

  • Parameters:
    • space_id (str) – The space id
    • file_id (str) – The file id
    • version (str) – The version of the file
    • url_duration (str) – The file download URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
    • response_content_type (str) – The response content type
    • status (str) – The status of the file
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
  • Returns: The file version response. If complete is False, the response will be a MinimalFile. Otherwise, it will be a File or SupportFile.
  • Return type: MinimalFile or File or SupportFile

Example:

file = await client.files.get_version(space_id="space_id", file_id="file_id", version="version")

async get_version_by_path(space_id: str, path: str, version: str, url_duration: str | Literal[‘12h’, ‘300m’, ‘1d’] = ‘60m’, response_content_type: str | None = None, status: Literal[‘active’, ‘deleted’, ‘active,deleted’] = ‘active’, complete: bool = True) → MinimalFile | File | SupportFile

Get a file version

  • Parameters:
    • space_id (str) – The space id
    • path (str) – The path of the file
    • version (str) – The version of the file
    • url_duration (str) – The file download URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
    • response_content_type (str) – The response content type
    • status (str) – The status of the file
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
  • Returns: The file version response. If complete is False, the response will be a MinimalFile. Otherwise, it will be a File or SupportFile.
  • Return type: MinimalFile or File or SupportFile

Example:

file = await client.files.get_version_by_path(space_id="space_id", path="path", version="version")

static limited_as_completed(coros, limit, maintain_order=False)

Run the coroutines (or futures) supplied in the iterable coros, ensuring that there are at most limit coroutines running concurrently.

https://www.artificialworlds.net/blog/2017/05/31/python-3-large-numbers-of-tasks-with-limited-concurrency/

  • Parameters:
    • coros – An iterable of coroutines to schedule for execution.
    • limit – The maximum number of coroutines to run concurrently
    • maintain_order – Whether to maintain the order of the coroutines returned from the generator
  • Returns: Return an generator of Future instances. The futures can be awaited to obtain the results of the coroutines. If maintain_order is False the results may be provided in any order, as they become available.

list_support_files_by_path_sync(space_id: str, path: str, complete: bool = True, **kwargs: Any) → Iterable[MinimalFile | SupportFile]

Lists all support files of a file by path

  • Parameters:
    • space_id (str) – The space id
    • path (str) – The path of the file
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • max_results (int) – The maximum number of items to return. Default is 100.
    • status (str) – The status of the support file. Default is “active”.
  • Returns: The list of support files. If complete is False, the response will be a MinimalFile. Otherwise, it will be a SupportFile.
  • Return type: Iterable[MinimalFile or SupportFile]

Example:

files = client.files.list_support_files_sync(space_id="space_id", path="path")
for support_file in files:
print(support_file)

list_support_files_sync(space_id: str, file_id: str, complete: bool = True, **kwargs: Any) → Iterable[MinimalFile | SupportFile]

Lists all support files of a file

  • Parameters:
    • space_id (str) – The space id
    • file_id (str) – The file id
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • max_results (int) – The maximum number of items to return. Default is 100.
    • status (str) – The status of the support file. Default is “active”.
  • Returns: The list of support files. If complete is False, the response will be a MinimalFile. Otherwise, it will be a SupportFile.
  • Return type: Iterable[MinimalFile or SupportFile]

Example:

files = client.files.list_support_files_sync(space_id="space_id", file_id="file_id")
for file in files:
print(file)

list_versions_by_path_sync(space_id: str, path: str, complete: bool = True, **kwargs: Any) → Iterable[MinimalFile | File]

List file versions by path

  • Parameters:
    • space_id (str) – The space id
    • path (str) – The path of the file
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • max_results (int) – The maximum number of items to return. Default is 100.
    • status (str) – The status of the file. Default is “active”.
  • Returns: The list of file versions. If complete is False, the response will be a MinimalFile. Otherwise, it will be a File.
  • Return type: Iterable[MiminalFile or File]

Example:

file_versions = client.files.list_versions_by_path_sync(space_id="space_id", path="path")
for version in file_versions:
print(version)

list_versions_sync(space_id: str, file_id: str, complete: bool = True, **kwargs: Any) → Iterable[MinimalFile | File]

List file versions

  • Parameters:
    • space_id (str) – The space id
    • file_id (str) – The file id
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • max_results (int) – The maximum number of items to return. Default is 100.
    • status (str) – The status of the file. Default is “active”.
  • Returns: The list of file versions. If complete is False, the response will be a MinimalFile. Otherwise, it will be a File.
  • Return type: Iterable[MinimalFile or File]

Example:

file_versions = client.files.list_versions_sync(space_id="space_id", file_id="file_id")
for version in file_versions:
print(version)

async lock(space_id: str, file_id: str, reason: str | None = None, complete: bool = True) → MinimalFile | File

Lock a file

  • Parameters:
    • space_id (str) – The space id
    • file_id (str) – The file id
    • reason (str) – The reason for locking the file
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
  • Returns: The locked file. If complete is False, the response will be a MinimalFile. Otherwise, it will be a File.
  • Return type: MinimalFile or File

Example:

file = await client.files.lock(space_id="space_id", file_id="file_id", reason="Working on this file")

async move(space_id: str, file_id: str, target_parent_id: str, complete: bool = True, name: str | None = None, **kwargs: Any) → MinimalFile | File

Move a file

  • Parameters:

    • space_id (str) – The space id
    • file_id (str) – The file id
    • target_parent_id (str) – The target parent id
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
    • name (str) – The new name of the file. If not provided, the original name will be used.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments: headers (dict) –

    Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

    • — Matches resource name.

    x.* — Matches any minor version of major version x (e.g., 2.*). x.y — Matches an exact version (e.g., 3.4).

  • Returns: The moved file. If complete is False, the response will be a MinimalFile. Otherwise, it will be a File.

  • Return type: MinimalFile or File

Example:

file = await client.files.move(space_id="space_id", file_id="file_id", target_parent_id="target_parent_id")

async rename(space_id: str, file_id: str, name: str, complete: bool = True, **kwargs: Any) → MinimalFile | File | SupportFile

Rename a file

  • Parameters:

    • space_id (str) – The space id
    • file_id (str) – The file id
    • name (str) – The new name of the file
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments: headers (dict) –

    Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

    • — Matches resource name.

    x.* — Matches any minor version of major version x (e.g., 2.*). x.y — Matches an exact version (e.g., 3.4).

  • Returns: The renamed file. If complete is False, the response will be a MinimalFile. Otherwise, it will be a File or SupportFile.

  • Return type: MinimalFile or File or SupportFile

Example:

file = await client.files.rename(space_id="space_id", file_id="file_id", name="new_name")

async restore(space_id: str, file_id: str, complete: bool = True, **kwargs: Any) → FileRestoreResponse

Restore a file

  • Parameters:
    • space_id (str) – The space id
    • file_id (str) – The file id
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • name (str) – New name of the file

    • target_parent_id (str) – Target parent id where the file need to be restored to

    • headers (dict) –

      Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

      • — Matches resource name.

      x.* — Matches any minor version of major version x (e.g., 2.*). x.y — Matches an exact version (e.g., 3.4).

  • Returns: The file restore response
  • Return type: FileRestoreResponse

Example:

response = await client.files.restore(space_id="space_id", file_id="file_id")

async unlock(space_id: str, file_id: str, complete: bool = True) → MinimalFile | File

Unlock a file

  • Parameters:
    • space_id (str) – The space id
    • file_id (str) – The file id
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
  • Returns: The unlocked file. If complete is False, the response will be a MinimalFile. Otherwise, it will be a File.
  • Return type: MinimalFile or File

Example:

file = await client.files.unlock(space_id="space_id", file_id="file_id")

async update(space_id: str, file_id: str, complete: bool = True, **kwargs) → MinimalFile | File | SupportFile

Update a file

  • Parameters:
    • space_id (str) – The space id
    • file_id (str) – The file id
    • complete (bool) – If False, the response will only include the minimal attributes of the File. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • metadata (dict) – The metadata of the file

    • links (dict *[*str , SupportFileLinkParams ]) – The links of the file in the form of a dictionary with support file key and SupportFileLinkParams

    • permissions_local (PermissionLocalUpdate) – The permissions that are set directly for actors on the resource itself. Contains ‘inherits’ boolean flag that determines whether the permissions need to be inherited from the parent resource or not (default: true), and ‘acl’ list of actor-role mappings

    • headers (dict) –

      Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

      • — Matches resource name.

      x.* — Matches any minor version of major version x (e.g., 2.*). x.y — Matches an exact version (e.g., 3.4).

  • Returns: The updated file. If complete is False, the response will be a MinimalFile. Otherwise, it will be a File or SupportFile.
  • Return type: MinimalFile or File or SupportFile

Example:

file = await client.files.update(
space_id="space_id",
file_id="file_id",
metadata={"key": "value"},
permissions_local={
"inherits": False,
"acl": [
{
"actor": "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1",
"role": "contentManager"
},
{
"actor": "trn:tid:user:f85bc802-5481-4581-b972-c4652d595ec7",
"role": "contentContributor"
}
]
}
)

async upload_file(space_id: str, upload_id: str, file_object: IO[bytes], **kwargs) → None

Upload a file

  • Parameters:
    • space_id (str) – The space id
    • upload_id (str) – The upload id of the file/support file
    • file_object (FileObj) – The file like object
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • concurrent_limit (int) – The maximum number of chunks to upload concurrently. This should be used only for multipart uploads. (Default is 8)
    • chunk_size (int) – The partition size of each part in MB. This should be used only for multipart uploads. (Default is 15 (MB)).

Example:

file_object = open("file_path", "rb")
await client.files.upload_file(space_id="space_id", upload_id="upload_id", file_object=file_object)

async upload_file_object(upload_response: UploadFileResponse | UploadSupportFileResponse, file_object: IO[bytes], **kwargs) → None

Upload a file

  • Parameters:
    • space_id (str) – The space id
    • upload_response (UploadFileResponse | UploadSupportFileResponse) – The upload response
    • file_object (FileObj) – The file like object
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • concurrent_limit (int) – The maximum number of chunks to upload concurrently. This should be used only for multipart uploads. (Default is 8)
    • chunk_size (int) – The partition size of each part in MB. This should be used only for multipart uploads. (Default is 15 (MB)).

Example:

file_object = open("file_path", "rb")
await client.files.upload_file_object(upload_response=upload_response, file_object=file_object)

async upload_package(space_id: str, upload_id: str, file_object: IO[bytes], support_files: list[SupportFileResourceUpload], **kwargs) → None

Upload a file along with its support files

  • Parameters:
    • space_id (str) – The space id
    • upload_id (str) – The upload id of the file
    • file_object (FileObj) – The file like object for the main file to which the support files are linked
    • support_files (list [SupportFileResourceUpload ]) – The support file keys and file objects. The keys should match the support file keys provided while creating the package upload
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • concurrent_limit (int) – The maximum number of chunks to upload concurrently. This should be used only for multipart uploads. (Default is 8)
    • chunk_size (int) – The partition size of each part in MB. This should be used only for multipart uploads. (Default is 15 (MB)).

Example:

main_file_object = open("file_path", "rb")
support_file_object = open("support_file_path", "rb")
support_file_objects = [SupportFileResourceUpload(key="key", file_object=support_file_object)]
await client.files.upload_package(space_id="space_id", upload_id="upload_id", file_object=main_file_object, support_file_objects=support_file_objects)

class trimble.fileservice.operations.FoldersOperations(*args, **kwargs)

Bases: object

This class is not meant to be instantiated directly. It should be accessed through the folders property of a FileServiceClient instance.

async copy(space_id: str, folder_id: str, target_parent_id: str, name: str | None = None, include_support_files: bool = False, overwrite_existing: bool | None = None, complete: bool = True, permissions_local: Dict[Literal[‘acl’, ‘inherits’], List[Dict[Literal[‘actor’, ‘role’], str | Literal[‘spaceManager’, ‘contentManager’, ‘contentContributor’, ‘contentViewer’]]] | bool] | None = None, copy_acl: bool = False, **kwargs: Any) → FolderCopyResponse

Copy a folder

  • Parameters:

    • space_id (str) – The space id
    • folder_id (str) – The folder id
    • target_parent_id (str) – The target parent id
    • name (str) – The name of the folder. If not provided, the name of the original folder will be used
    • include_support_files (bool) – Whether to copy the support files and links
    • overwrite_existing (bool) – Whether to overwrite an existing resource. If true, the existing resource will have a new version created with the copied content.
    • complete (bool) – If False, the response will only include the minimal attributes of the Folder. Otherwise, all attributes will be included.
    • permissions_local (PermissionsLocalFolder) – The permissions local of the folder.
    • copy_acl (bool) – If True, the ACL of the folder will be copied to the new folder.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments: headers (dict) –

    Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

    • — Matches the latest resource state.

    x — Matches the exact version x (e.g., 3).

  • Returns: The copy job

  • Return type: FolderCopyResponse

Example:

response = await client.folders.copy(
space_id="space_id",
folder_id="folder_id",
target_parent_id="target_parent_id"
)

async create(space_id: str, name: str, parent_id: str, permissions_local: Dict[Literal[‘acl’, ‘inherits’], List[Dict[Literal[‘actor’, ‘role’], str | Literal[‘spaceManager’, ‘contentManager’, ‘contentContributor’, ‘contentViewer’]]] | bool] | None = None, metadata: object | None = None, complete: bool = True) → MinimalFolder | Folder

Create a new folder

  • Parameters:
    • space_id (str) – The space id
    • name (str) – The name of the folder
    • parent_id (str) – The parent id of the folder
    • permissions_local (PermissionsLocalFolder) – The permissions structure directly set on the folder
    • metadata (dict) – The metadata of the folder
    • complete (bool) – If False, the response will only include the minimal attributes of the Folder. Otherwise, all attributes will be included.
  • Returns: The created folder. MinimalFolder if complete is False, Folder otherwise.
  • Return type: MinimalFolder or Folder

Example:

folder = await client.folders.create(
space_id="space_id",
name="folder_name",
parent_id="parent_id",
permissions_local={
"inherits": false,
"acl": [
{
"actor": "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1",
"role": "contentManager"
},
{
"actor": "trn:tid:user:f85bc802-5481-4581-b972-c4652d595ec7",
"role": "contentContributor"
}
]
}
)

async delete(space_id: str, folder_id: str, recursive: bool = False, permanent: bool = False, **kwargs: Any) → str | None

Delete a folder

  • Parameters:

    • space_id (str) – The space id
    • folder_id (str) – The folder id
    • recursive (bool) – If the deletion should be recursive
    • permanent (bool) – If the deletion should be permanent
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments: headers (dict) –

    Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

    • — Matches the latest resource state.

    x — Matches the exact version x (e.g., 3).

  • Returns: The job id if the delete is recursive, None otherwise

  • Return type: Optional[str]

Example:

job_id = await client.folders.delete(space_id="space_id", folder_id="folder_id", recursive=True)

async get(space_id: str, folder_id: str, status: Literal[‘active’, ‘deleted’, ‘active,deleted’] = ‘active’, complete: bool = True) → MinimalFolder | Folder

Get a folder

  • Parameters:
    • space_id (str) – The space id
    • folder_id (str) – The folder id
    • status (str) – The status of the folder
    • complete (bool) – If False, the response will only include the minimal attributes of the Folder. Otherwise, all attributes will be included.
  • Returns: The folder. MinimalFolder if complete is False, Folder otherwise.
  • Return type: MinimalFolder or Folder

Example:

folder = await client.folders.get(space_id="space_id", folder_id="folder_id")

async get_by_path(space_id: str, path: str, status: Literal[‘active’, ‘deleted’, ‘active,deleted’] = ‘active’, complete: bool = True) → MinimalFolder | Folder

Get a folder by path

  • Parameters:
    • space_id (str) – The space id
    • path (str) – The path of the folder
    • status (str) – The status of the folder
    • complete (bool) – If False, the response will only include the minimal attributes of the Folder. Otherwise, all attributes will be included.
  • Returns: The folder. MinimalFolder if complete is False, Folder otherwise.
  • Return type: MinimalFolder or Folder

Example:

folder = await client.folders.get_by_path(space_id="space_id", path="path")

async get_version(space_id: str, folder_id: str, version: str, status: Literal[‘active’, ‘deleted’, ‘active,deleted’] = ‘active’, complete: bool = True) → MinimalFolder | Folder

Get a folder version

  • Parameters:
    • space_id (str) – The space id
    • folder_id (str) – The folder id
    • version (str) – The version of the folder
    • status (str) – The status of the folder
    • complete (bool) – If False, the response will only include the minimal attributes of the Folder. Otherwise, all attributes will be included.
  • Returns: The folder. MinimalFolder if complete is False, Folder otherwise.
  • Return type: MinimalFolder or Folder

Example:

folder = await client.folders.get(space_id="space_id", folder_id="folder_id", version="version")

async get_version_by_path(space_id: str, path: str, version: str, status: Literal[‘active’, ‘deleted’, ‘active,deleted’] = ‘active’, complete: bool = True) → MinimalFolder | Folder

Get a folder version by path

  • Parameters:
    • space_id (str) – The space id
    • path (str) – The path of the folder
    • version (str) – The version of the folder
    • status (str) – The status of the folder
    • complete (bool) – If False, the response will only include the minimal attributes of the Folder. Otherwise, all attributes will be included.
  • Returns: The folder. MinimalFolder if complete is False, Folder otherwise.
  • Return type: MinimalFolder or Folder

Example:

folder = await client.folders.get_by_path(space_id="space_id", path="path", version="version")

list_children_by_path_sync(space_id: str, path: str, **kwargs: Any) → Iterable[FileOrFolder]

Lists all children of a folder in a space by path

  • Parameters:
    • space_id (str) – The space id
    • path (str) – The path of the folder
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • max_results (int) – The maximum number of items to return. Default is 100.
    • status (str) – The status of the folder. Default is “active”.
    • url_duration (str) – The duration of the url. Default is “60m”.
    • sort_order (str) – The order of the children. Default is “asc”. Possible values are “asc” or “desc”.
    • sort_by (str) – The field to sort the children by. Default is “name”. Example values are “size”, “createdAt”, “updatedAt”.
    • recursive (bool) – Whether to list all children recursively. Default is False.
  • Returns: The list the children of a folder
  • Return type: Iterable[FileOrFolder]

Example:

children = client.folders.list_children_by_path_sync(space_id="space_id", path="path")
for item in children:
print(item)

list_children_sync(space_id: str, folder_id: str, **kwargs: Any) → Iterable[FileOrFolder]

Lists all children of a folder in a space by folder id

  • Parameters:
    • space_id (str) – The space id
    • folder_id (str) – The folder id
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • max_results (int) – The maximum number of items to return. Default is 100.
    • status (str) – The status of the folder. Default is “active”.
    • url_duration (str) – The duration of the url. Default is “60m”.
    • sort_order (str) – The order of the children. Default is “asc”. Possible values are “asc” or “desc”.
    • sort_by (str) – The field to sort the children by. Default is “name”. Example values are “size”, “createdAt”, “updatedAt”.
    • recursive (bool) – Whether to list all children recursively. Default is False.
  • Returns: The list the children of a folder
  • Return type: Iterable[FileOrFolder]

Example:

children = client.folders.list_children_sync(space_id="space_id", folder_id="folder_id")
for item in children:
print(item)

list_versions_by_path_sync(space_id: str, path: str, complete: bool = True, **kwargs: Any) → Iterable[MinimalFolder | Folder]

List folders by path

  • Parameters:
    • space_id (str) – The space id
    • path (str) – The path of the folder
    • complete (bool) – If False, the response will only include the minimal attributes of the Folder. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • max_results (int) – The maximum number of items to return. Default is 100.
    • status (str) – The status of the folder. Default is “active”.
  • Returns: The list of folders. MinimalFolder if complete is False, Folder otherwise.
  • Return type: Iterable[MinimalFolder or Folder]

Example:

folder_versions = client.folders.list_versions_by_path_sync(space_id="space_id", path="path")
for version in folder_versions:
print(version)

list_versions_sync(space_id: str, folder_id: str, complete: bool = True, **kwargs: Any) → Iterable[MinimalFolder | Folder]

List folders

  • Parameters:
    • space_id (str) – The space id
    • folder_id (str) – The folder id
    • complete (bool) – If False, the response will only include the minimal attributes of the Folder. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • max_results (int) – The maximum number of items to return. Default is 100.
    • status (str) – The status of the folder. Default is “active”.
  • Returns: The list of folders. MinimalFolder if complete is False, Folder otherwise.
  • Return type: Iterable[MinimalFolder or Folder]

Example:

folder_versions = client.folders.list_versions_sync(space_id="space_id", folder_id="folder_id")
for version in folder_versions:
print(version)

async move(space_id: str, folder_id: str, target_parent_id: str, complete: bool = True, **kwargs: Any) → FolderMoveResponse

Move a folder

  • Parameters:
    • space_id (str) – The space id
    • folder_id (str) – The folder id
    • target_parent_id (str) – The target parent id
    • complete (bool) – If False, the response will only include the minimal attributes of the Folder. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • name (str) – The name of the folder. If not provided, the name of the original folder will be used

    • headers (dict) –

      Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

      • — Matches the latest resource state.

      x — Matches the exact version x (e.g., 3).

  • Returns: The move job
  • Return type: FolderMoveResponse

Example:

response = await client.folders.move(
space_id="space_id",
folder_id="folder_id",
target_parent_id="target_parent_id"
)

async rename(space_id: str, folder_id: str, name: str, complete: bool = True, **kwargs: Any) → FolderRenameResponse

Rename a folder

  • Parameters:

    • space_id (str) – The space id
    • folder_id (str) – The folder id
    • name (str) – The name of the folder
    • complete (bool) – If False, the response will only include the minimal attributes of the Folder. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments: headers (dict) –

    Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

    • — Matches the latest resource state.

    x — Matches the exact version x (e.g., 3).

  • Returns: The rename job

  • Return type: FolderRenameResponse

Example:

response = await client.folders.rename(
space_id="space_id",
folder_id="folder_id",
name="new_name"
)

async restore(space_id: str, folder_id: str, complete: bool = True, **kwargs: Any) → FolderRestoreResponse

Restore a folder

  • Parameters:
    • space_id (str) – The space id
    • folder_id (str) – The folder id
    • complete (bool) – If False, the response will only include the minimal attributes of the Folder. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • name (str) – New name of the folder

    • target_parent_id (str) – Target parent id where the folder need to be restored to

    • headers (dict) –

      Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

      • — Matches the latest resource state.

      x — Matches the exact version x (e.g., 3).

  • Returns: The restored folder and the job id if the restore is asynchronous, None otherwise
  • Return type: FolderRestoreResponse

Example:

response = await client.folders.restore(
space_id="space_id",
folder_id="folder_id",
name="new_name"
)

async update(space_id: str, folder_id: str, metadata: object | None = None, permissions_local: Dict[Literal[‘acl’, ‘updateAcl’], List[Dict[Literal[‘actor’, ‘role’], str | Literal[‘spaceManager’, ‘contentManager’, ‘contentContributor’, ‘contentViewer’]]] | Dict[Literal[‘add’, ‘remove’], List[Dict[Literal[‘actor’, ‘role’], str | Literal[‘spaceManager’, ‘contentManager’, ‘contentContributor’, ‘contentViewer’]]] | List[Dict[Literal[‘actor’, ‘role’], str]]]] | None = None, complete: bool = True, **kwargs: Any) → MinimalFolder | Folder

Update a folder

  • Parameters:

    • space_id (str) – The space id
    • folder_id (str) – The folder id
    • metadata (dict) – The metadata of the folder
    • permissions_local (PermissionsLocalUpdate) – The permissions structure directly set on the folder
    • complete (bool) – If False, the response will only include the minimal attributes of the Folder. Otherwise, all attributes will be included.
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments: headers (dict) –

    Conditional Request Headers. Enables optimistic concurrency control by validating the resource’s current state. Only one of If-Match or If-None-Match may be included in a request. Providing both headers will result in a bad request. Supported formats:

    • — Matches the latest resource state.

    x — Matches the exact version x (e.g., 3).

  • Returns: The updated folder. MinimalFolder if complete is False, Folder otherwise.

  • Return type: MinimalFolder or Folder

Example:

# Replace Acl
folder = await client.folders.update(
space_id="space_id",
folder_id="folder_id",
metadata={"key": "value"},
permissions_local={
"inherits": false,
"acl": [
{
"actor": "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1",
"role": "contentManager"
},
{
"actor": "trn:tid:user:f85bc802-5481-4581-b972-c4652d595ec7",
"role": "contentContributor"
}
]
}
)
# Update Acl
folder = await client.folders.update(
space_id="space_id",
folder_id="folder_id",
permissions_local={
"updateAcl": {
"add": [
{
"actor": "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1",
"role": "contentManager"
}
]
}
}
)

class trimble.fileservice.operations.JobsOperations(*args, **kwargs)

Bases: object

This class is not meant to be instantiated directly. It should be accessed through the jobs property of a FileServiceClient instance.

async get(job_id: str) → Job

Get a job

  • Parameters: job_id (str) – The job id
  • Returns: The job
  • Return type: Job

Example:

job = await client.jobs.get(job_id="job_id")

class trimble.fileservice.operations.ResourceOperations(*args, **kwargs)

Bases: object

Operations for working with resources (files and folders) using the V2 API.

This class is not meant to be instantiated directly. It should be accessed through the resources property of a FileServiceClient instance.

async get(space_id: str, resource_id: str, url_duration: str | Literal[‘12h’, ‘300m’, ‘1d’] = ‘60m’, response_content_type: str | None = None, status: Literal[‘active’, ‘deleted’, ‘active,deleted’] = ‘active’, complete: bool = True) → Folder | File | SupportFile | MinimalFile | MinimalFolder

Get a file or folder resource by ID.

  • Parameters:
    • space_id (str) – The space ID.
    • resource_id (str) – The ID of the resource.
    • url_duration (str) – The download URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
    • response_content_type (str , optional) – The response content type.
    • status (str) – The status of the resources. Can be “active”, “deleted”, or “all”.
    • complete (bool) – If True, returns all attributes of the resources. Otherwise, returns only minimal attributes.
  • Returns: The resource response. If complete is False, the response will be a MinimalFile or MinimalFolder. Otherwise, it will be a File or Folder.
  • Return type: Folder, File, SupportFile, MinimalFile, MinimalFolder

Example:

file = await client.resources.get(space_id="space_id", resource_id="resource_id")
folder = await client.resources.get(space_id="space_id", resource_id="resource_id")
support_file = await client.resources.get(space_id="space_id", resource_id="resource_id")
minimal_file = await client.resources.get(space_id="space_id", resource_id="resource_id", complete=False)
minimal_folder = await client.resources.get(space_id="space_id", resource_id="resource_id", complete=False)

async get_by_path(space_id: str, path: str, url_duration: str | Literal[‘12h’, ‘300m’, ‘1d’] = ‘60m’, response_content_type: str | None = None, status: Literal[‘active’, ‘deleted’, ‘active,deleted’] = ‘active’, complete: bool = True) → Folder | File | SupportFile | MinimalFile | MinimalFolder

Get a resource by path.

  • Parameters:
    • space_id (str) – The space ID.
    • path (str) – The path of the resource.
    • url_duration (str) – The download URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
    • response_content_type (str , optional) – The response content type.
    • status (str) – The status of the resources. Can be “active”, “deleted”, or “all”.
    • complete (bool) – If True, returns all attributes of the resources. Otherwise, returns only minimal attributes.
  • Returns: The resource response. If complete is False, the response will be a MinimalFile or MinimalFolder. Otherwise, it will be a File or Folder.
  • Return type: Folder, File, SupportFile, MinimalFile, MinimalFolder

Example:

file = await client.resources.get_by_path(space_id="space_id", path="path")
folder = await client.resources.get_by_path(space_id="space_id", path="path")
support_file = await client.resources.get_by_path(space_id="space_id", path="path")
minimal_file = await client.resources.get_by_path(space_id="space_id", path="path", complete=False)
minimal_folder = await client.resources.get_by_path(space_id="space_id", path="path", complete=False)

async get_in_batch(space_id: str, ids: List[str] | None = None, paths: List[str] | None = None, url_duration: str | Literal[‘12h’, ‘300m’, ‘1d’] = ‘60m’, response_content_type: str | None = None, status: Literal[‘active’, ‘deleted’, ‘active,deleted’] = ‘active’, complete: bool = True) → BatchGetResourceResponse

Get multiple resources (files and folders) in a batch by IDs or paths.

  • Parameters:
    • space_id (str) – The space ID.
    • ids (List *[*str ] , optional) – List of resource IDs to retrieve. Either ids or paths must be provided, not both.
    • paths (List *[*str ] , optional) – List of resource paths to retrieve. Either ids or paths must be provided, not both.
    • url_duration (str) – The download URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
    • response_content_type (str , optional) – The response content type.
    • status (str) – The status of the resources. Can be “active”, “deleted”, or “all”.
    • complete (bool) – If True, returns all attributes of the resources. Otherwise, returns only minimal attributes.
    • fields (List *[*str ] , optional) – Specific fields to include in the response.
  • Returns: Contains the list of retrieved resources and any invalid items.
  • Return type: BatchGetResourceResponse
  • Raises: FileServiceError – If neither ids nor paths are provided, or if both are provided.

Example:

# Get resources by IDs
resources = await client.resources.get_in_batch(
space_id="space_id",
ids=["resource_id1", "resource_id2"]
)
# Get resources by paths
resources = await client.resources.get_in_batch(
space_id="space_id",
paths=["/folder1/file1.txt", "/folder2/file2.txt"]
)

class trimble.fileservice.operations.SpacesOperations(*args, **kwargs)

Bases: object

This class is not meant to be instantiated directly. It should be accessed through the spaces property of a FileServiceClient instance.

async create(name: str, account_id: str, permissions_local: Dict[Literal[‘acl’], List[Dict[Literal[‘actor’, ‘role’], str | Literal[‘spaceManager’, ‘contentManager’, ‘contentContributor’, ‘contentViewer’]]]] | None = None, provider: Literal[‘aws’, ‘azure’] | None = ‘aws’, soft_delete_retention: Literal[‘30d’, ‘180d’, ‘1y’, ‘never-delete’] = ‘30d’, complete: bool = True) → MinimalSpace | Space

Create a new space

  • Parameters:
    • name (str) – The name of the space
    • account_id (str) – The unique identifier of the CDH account
    • permissions_local (PermissionsLocalSpace) – The permissions structure directly set on the space
    • provider (str) – The cloud provider of the space
    • soft_delete_retention (str) – Duration of soft deleted resources being retained before being permanently removed
    • complete (bool) – If False, the response will only include the minimal attributes of the Space. Otherwise, all attributes will be included.
  • Returns: The created space. MinimalSpace if complete is False, Space otherwise.
  • Return type: MinimalSpace or Space

Example:

permissions = {
"acl": [
{
"actor": "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1",
"role": "contentManager"
},
{
"actor": "trn:tid:user:f85bc802-5481-4581-b972-c4652d595ec7",
"role": "contentContributor"
}
]
}
space = await client.spaces.create(
name="space_name",
account_id="1234567890",
permissions_local=permissions
)

async delete(space_id: str, recursive: bool = False, permanent: bool = False) → str | None

Delete a space

  • Parameters:
    • space_id (str) – The space id
    • recursive (bool) – If the deletion should be recursive
    • permanent (bool) – If the deletion should be permanent
  • Returns: The job id if the delete is recursive, None otherwise
  • Return type: Optional[str]

Example:

job_id = await client.spaces.delete(space_id="space_id", recursive=True)

async get(space_id: str, status: Literal[‘active’, ‘deleted’, ‘active,deleted’] = ‘active’, complete: bool = True) → MinimalSpace | Space

Get a space

  • Parameters:
    • space_id (str) – The space id
    • status (str) – The status of the space
    • complete (bool) – If False, the response will only include the minimal attributes of the Space. Otherwise, all attributes will be included.
  • Returns: The space. MinimalSpace if complete is False, Space otherwise.
  • Return type: MinimalSpace or Space

Example:

space = await client.spaces.get(space_id="space_id")

list_children_sync(space_id: str, **kwargs: Any) → Iterable[SpaceChildrenResponse]

List child resources of the space by Id

  • Parameters:
    • space_id (str) – The space id
    • **kwargs – Arbitrary keyword arguments. See below.
  • Keyword Arguments:
    • max_results (int) – The maximum number of items to return. Default is 100.
    • status (str) – The status of the folder. Default is “active”.
    • optional (resource_type) – The sinceTime query parameter is used to filter the resources based on their last update time. It accepts an ISO 8601 formatted date time that is in the past. The API will return resources that have been updated since the specified time.
    • optional – The resource type to filter the resources by. FILE or FOLDER
    • support_files (bool) – include support files in the response. Default is False.
    • url_duration (str) – The file download URL’s validity duration, set in days (d), hours (h), or minutes (m). Minimum value is 5 minutes (5m), maximum value is 7 days (7d).
    • sort_order (str) – The sort order of the resources. “asc” or “desc”. Default is “asc”.
  • Returns: The list the children of a folder
  • Return type: Iterable[FileOrFolder]

Example:

children = client.folders.list_children_sync(space_id="space_id", folder_id="folder_id")
for item in children:
print(item)

async restore(space_id: str, complete: bool = True) → SpaceRestoreResponse

Restore a space

  • Parameters:
    • space_id (str) – The space id
    • complete (bool) – If False, the response will only include the minimal attributes of the Space. Otherwise, all attributes will be included.
  • Returns: The restored space and the job id if the restore is asynchronous, None otherwise
  • Return type: SpaceRestoreResponse

Example:

response = await client.spaces.restore(space_id="space_id")

async update(space_id: str, name: str | None = None, permissions_local: Dict[Literal[‘acl’, ‘updateAcl’], List[Dict[Literal[‘actor’, ‘role’], str | Literal[‘spaceManager’, ‘contentManager’, ‘contentContributor’, ‘contentViewer’]]] | Dict[Literal[‘add’, ‘remove’], List[Dict[Literal[‘actor’, ‘role’], str | Literal[‘spaceManager’, ‘contentManager’, ‘contentContributor’, ‘contentViewer’]]] | List[Dict[Literal[‘actor’, ‘role’], str]]]] | None = None, soft_delete_retention: Literal[‘30d’, ‘180d’, ‘1y’, ‘never-delete’] | None = None, complete: bool = True) → MinimalSpace | Space

Update a space

  • Parameters:
    • space_id (str) – The space id
    • name (str) – The name of the space
    • permissions_local (PermissionsLocalUpdate) – The permissions structure to update on the space. Can contain either ‘acl’ to replace permissions or ‘updateAcl’ with ‘add’/’remove’ actions.
    • acl (dict) – The access control list of the space (deprecated)
    • soft_delete_retention (str) – Duration of soft deleted resources being retained before being permanently removed
    • complete (bool) – If False, the response will only include the minimal attributes of the Space. Otherwise, all attributes will be included.
  • Returns: The updated space. MinimalSpace if complete is False, Space otherwise.
  • Return type: MinimalSpace or Space

Example:

# Replace all permissions with new permissions
permissions = {
"acl": [
{
"actor": "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1",
"role": "contentManager"
},
{
"actor": "trn:tid:user:f85bc802-5481-4581-b972-c4652d595ec7",
"role": "contentContributor"
}
]
}
# Or incrementally update permissions
update_permissions = {
"updateAcl": {
"add": [
{
"actor": "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1",
"role": "contentManager"
}
],
"remove": [
{
"actor": "trn:tid:user:f85bc802-5481-4581-b972-c4652d595ec7"
}
]
}
}
space = await client.spaces.update(
space_id="space_id",
name="new_name",
permissions_local=permissions
)