Reference·Python SDK · bimworksPython

FsApi

Python SDK: the Fs - FileSystem operations, 16 methods, each with its parameters, result and a complete example.

Python SDK · bimworks · class · 16 methods

BIM.works repository's virtual filesystem related calls.

Construct it with the client of the connect step: bimworks.FsApi(client). Each method is one operation of the API part, where it runs on its page.

MethodOperationDescription
create_nodeCreateNodeCreate a new Node
delete_nodeDeleteNodeDelete a Node
delete_node_errorDeleteNodeErrorClear an error of a Node
delete_versionDeleteVersionDelete a Version of a Node
download_as_zipDownloadAsZipDownload a folder Node and everything below it as a ZIP file
get_nodeGetNodeGet Node based on a given path, by its UUID or by the UUID of one of its Versions.
get_root_node_uuidGetRootNodeUuidGet the UUID of the current root Node.
get_versionGetVersionGet a Version by its UUID
list_node_errorsListNodeErrorsGet the errors of the given Node
list_nodesListNodesGet a list of Nodes that are children of the given Node
list_nodes_recursiveListNodesRecursiveGet all Nodes below the given Node, recursively
list_versionsListVersionsGet a list of all the Versions of the given Node, or the given Versions
move_nodeMoveNodeMove a Node to another parent folder
undelete_nodeUndeleteNodeRestore a previously deleted Node
update_nodeUpdateNodeUpdate a Node
update_versionUpdateVersionChange a Version's disciplines or alignment

create_node#

Python#
def create_node(self, create_node_request: CreateNodeRequest) -> Node

Create a new Node.

OperationCreateNode · POST /openapi/fs/CreateNode
Scopefs:write

Parameters#

NameTypeDescription
create_node_requestCreateNodeRequestrequiredThe request: its properties are those of the model, its JSON that of CreateNode's request body.

Returns#

Node — The new Node

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.CreateNodeRequest.from_json(r"""
{
  "name": "",
  "folder": false,
  "input_file_type": "IFC",
  "parent_node_uuid": "00000000-0000-0000-0000-000000000000",
  "allow_existing": false
}
""")

# 3. The call
result = bimworks.FsApi(client).create_node(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

delete_node#

Python#
def delete_node(self, delete_node_request: DeleteNodeRequest) -> None

Delete a Node. Deletes the given Node, named by uuid or by path. This is a soft delete, a deleted Node can be restored with UndeleteNode. The Root Node of the current token cannot be deleted. With if_exists a Node that does not exist is no error.

OperationDeleteNode · POST /openapi/fs/DeleteNode
Scopefs:write

Parameters#

NameTypeDescription
delete_node_requestDeleteNodeRequestrequiredThe request: its properties are those of the model, its JSON that of DeleteNode's request body.

Returns#

Nothing: the operation answers without a body (The Node was deleted).

Example#

Python#
import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.DeleteNodeRequest.from_json(r"""
{
  "uuid": "<version uuid of the first demo model>"
}
""")

# 3. The call
bimworks.FsApi(client).delete_node(request)

# 4. The result
# (DeleteNode answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")

delete_node_error#

Python#
def delete_node_error(self, delete_node_error_request: DeleteNodeErrorRequest) -> None

Clear an error of a Node. Removes an error record (a failed upload or checkin, see ListNodeErrors) once its cause is dealt with. Needs write rights on the Node.

OperationDeleteNodeError · POST /openapi/fs/DeleteNodeError
Scopefs:write

Parameters#

NameTypeDescription
delete_node_error_requestDeleteNodeErrorRequestrequiredThe request: its properties are those of the model, its JSON that of DeleteNodeError's request body.

Returns#

Nothing: the operation answers without a body (The error is cleared).

Example#

Python#
import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.DeleteNodeErrorRequest.from_json(r"""
{
  "node_uuid": "00000000-0000-0000-0000-000000000000",
  "error_uuid": "00000000-0000-0000-0000-000000000000"
}
""")

# 3. The call
bimworks.FsApi(client).delete_node_error(request)

# 4. The result
# (DeleteNodeError answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")

delete_version#

Python#
def delete_version(self, delete_version_request: DeleteVersionRequest) -> None

Delete a Version of a Node. Only the last Version of a Node can be deleted, intermediate Versions must stay available.

OperationDeleteVersion · POST /openapi/fs/DeleteVersion
Scopefs:write

Parameters#

NameTypeDescription
delete_version_requestDeleteVersionRequestrequiredThe request: its properties are those of the model, its JSON that of DeleteVersion's request body.

Returns#

Nothing: the operation answers without a body (The Version was deleted).

Example#

Python#
import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.DeleteVersionRequest.from_json(r"""
{
  "node_uuid": "00000000-0000-0000-0000-000000000000",
  "version_uuid": "<version uuid of the first demo model>"
}
""")

# 3. The call
bimworks.FsApi(client).delete_version(request)

# 4. The result
# (DeleteVersion answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")

download_as_zip#

Python#
def download_as_zip(self, download_as_zip_request: DownloadAsZipRequest) -> bytes

Download a folder Node and everything below it as a ZIP file. The ZIP file contains the original model files of the last Version of every Node below the given folder Node, with their tree paths as ZIP entry paths. With format ZIP_ZST the same ZIP comes compressed as a whole with zstd, a .zip.zst file.

OperationDownloadAsZip · POST /openapi/fs/DownloadAsZip
Scopemodel:read

Parameters#

NameTypeDescription
download_as_zip_requestDownloadAsZipRequestrequiredThe request: its properties are those of the model, its JSON that of DownloadAsZip's request body.

Returns#

bytes — The ZIP file, or with format ZIP_ZST the zstd-compressed ZIP file

Example#

Python#
import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.DownloadAsZipRequest.from_json(r"""
{
  "uuid": "<version uuid of the first demo model>",
  "include_deleted": false,
  "format": "ZIP"
}
""")

# 3. The call
result = bimworks.FsApi(client).download_as_zip(request)

# 4. The result
with open("download-as-zip.zip", "wb") as file:
    file.write(result)

get_node#

Python#
def get_node(self, get_node_request: GetNodeRequest) -> Node

Get Node based on a given path, by its UUID or by the UUID of one of its Versions. A path is always relative to the Root Node of the used Token.

OperationGetNode · POST /openapi/fs/GetNode
Scopefs:read

Parameters#

NameTypeDescription
get_node_requestGetNodeRequestrequiredThe request: its properties are those of the model, its JSON that of GetNode's request body.

Returns#

Node — All information of the Node on this path

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.GetNodeRequest.from_json(r"""
{
  "path": "",
  "uuid": "<version uuid of the first demo model>",
  "version_uuid": "<version uuid of the first demo model>"
}
""")

# 3. The call
result = bimworks.FsApi(client).get_node(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

get_root_node_uuid#

Python#
def get_root_node_uuid(self) -> UUID

Get the UUID of the current root Node. This depends on the API Token/Auth Token that is being used.

OperationGetRootNodeUuid · GET /openapi/fs/GetRootNodeUuid
Scopefs:read

Parameters#

None: the operation takes no request.

Returns#

UUID — The UUID of the Root Node

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
# (GetRootNodeUuid takes no request)

# 3. The call
result = bimworks.FsApi(client).get_root_node_uuid()

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

get_version#

Python#
def get_version(self, get_version_request: GetVersionRequest) -> ModelVersion

Get a Version by its UUID.

OperationGetVersion · POST /openapi/fs/GetVersion
Scopefs:read

Parameters#

NameTypeDescription
get_version_requestGetVersionRequestrequiredThe request: its properties are those of the model, its JSON that of GetVersion's request body.

Returns#

ModelVersion — Version information

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.GetVersionRequest.from_json(r"""
{
  "uuid": "<version uuid of the first demo model>"
}
""")

# 3. The call
result = bimworks.FsApi(client).get_version(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

list_node_errors#

Python#
def list_node_errors(self, list_node_errors_request: ListNodeErrorsRequest) -> List[ModelError]

Get the errors of the given Node. Model uploads are processed asynchronously. When processing fails, the resulting errors can be retrieved with this call. Errors are sorted oldest first.

OperationListNodeErrors · POST /openapi/fs/ListNodeErrors
Scopefs:read

Parameters#

NameTypeDescription
list_node_errors_requestListNodeErrorsRequestrequiredThe request: its properties are those of the model, its JSON that of ListNodeErrors's request body.

Returns#

List[ModelError] — The errors of the given Node

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.ListNodeErrorsRequest.from_json(r"""
{
  "uuid": "<version uuid of the first demo model>"
}
""")

# 3. The call
result = bimworks.FsApi(client).list_node_errors(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

list_nodes#

Python#
def list_nodes(self, list_nodes_request: ListNodesRequest) -> List[Node]

Get a list of Nodes that are children of the given Node.

OperationListNodes · POST /openapi/fs/ListNodes
Scopefs:read

Parameters#

NameTypeDescription
list_nodes_requestListNodesRequestrequiredThe request: its properties are those of the model, its JSON that of ListNodes's request body.

Returns#

List[Node] — All information of the sub Nodes of the provided Node

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.ListNodesRequest.from_json(r"""
{
  "path": "",
  "uuid": "<version uuid of the first demo model>",
  "version_uuid": "<version uuid of the first demo model>",
  "show_deleted_nodes": false
}
""")

# 3. The call
result = bimworks.FsApi(client).list_nodes(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

list_nodes_recursive#

Python#
def list_nodes_recursive(self, list_nodes_recursive_request: ListNodesRecursiveRequest) -> List[Node]

Get all Nodes below the given Node, recursively. Returns the given Node and all Nodes below it. Use caution on large trees, there is no pagination.

OperationListNodesRecursive · POST /openapi/fs/ListNodesRecursive
Scopefs:read

Parameters#

NameTypeDescription
list_nodes_recursive_requestListNodesRecursiveRequestrequiredThe request: its properties are those of the model, its JSON that of ListNodesRecursive's request body.

Returns#

List[Node] — The Node and all Nodes below it

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.ListNodesRecursiveRequest.from_json(r"""
{
  "uuid": "<version uuid of the first demo model>"
}
""")

# 3. The call
result = bimworks.FsApi(client).list_nodes_recursive(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

list_versions#

Python#
def list_versions(self, list_versions_request: ListVersionsRequest) -> List[ModelVersion]

Get a list of all the Versions of the given Node, or the given Versions. Name the Node with one of path, uuid and version_uuid (a Version of the Node), or pass version_uuids to get those Versions, which may belong to different Nodes. Each Version needs read rights.

OperationListVersions · POST /openapi/fs/ListVersions
Scopefs:read

Parameters#

NameTypeDescription
list_versions_requestListVersionsRequestrequiredThe request: its properties are those of the model, its JSON that of ListVersions's request body.

Returns#

List[ModelVersion] — All information of the Versions of the given Node, or of the given Versions

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.ListVersionsRequest.from_json(r"""
{
  "uuid": "<version uuid of the first demo model>"
}
""")

# 3. The call
result = bimworks.FsApi(client).list_versions(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

move_node#

Python#
def move_node(self, move_node_request: MoveNodeRequest) -> Node

Move a Node to another parent folder. Moves the given Node under a new parent Node. The target Node must be a folder. Renaming is done with UpdateNode.

OperationMoveNode · POST /openapi/fs/MoveNode
Scopefs:write

Parameters#

NameTypeDescription
move_node_requestMoveNodeRequestrequiredThe request: its properties are those of the model, its JSON that of MoveNode's request body.

Returns#

Node — The moved Node

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.MoveNodeRequest.from_json(r"""
{
  "uuid": "<version uuid of the first demo model>",
  "target_parent_uuid": "00000000-0000-0000-0000-000000000000"
}
""")

# 3. The call
result = bimworks.FsApi(client).move_node(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

undelete_node#

Python#
def undelete_node(self, undelete_node_request: UndeleteNodeRequest) -> None

Restore a previously deleted Node.

OperationUndeleteNode · POST /openapi/fs/UndeleteNode
Scopefs:write

Parameters#

NameTypeDescription
undelete_node_requestUndeleteNodeRequestrequiredThe request: its properties are those of the model, its JSON that of UndeleteNode's request body.

Returns#

Nothing: the operation answers without a body (The Node was restored).

Example#

Python#
import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.UndeleteNodeRequest.from_json(r"""
{
  "uuid": "<version uuid of the first demo model>"
}
""")

# 3. The call
bimworks.FsApi(client).undelete_node(request)

# 4. The result
# (UndeleteNode answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")

update_node#

Python#
def update_node(self, update_node_request: UpdateNodeRequest) -> Node

Update a Node.

OperationUpdateNode · POST /openapi/fs/UpdateNode
Scopefs:write

Parameters#

NameTypeDescription
update_node_requestUpdateNodeRequestrequiredThe request: its properties are those of the model, its JSON that of UpdateNode's request body.

Returns#

Node — The updated Node

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.UpdateNodeRequest.from_json(r"""
{
  "path": "",
  "uuid": "<version uuid of the first demo model>",
  "version_uuid": "<version uuid of the first demo model>",
  "name": "",
  "user_data": {}
}
""")

# 3. The call
result = bimworks.FsApi(client).update_node(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

update_version#

Python#
def update_version(self, update_version_request: UpdateVersionRequest) -> ModelVersion

Change a Version's disciplines or alignment. Changes the fields that are passed in one transaction; the others stay as they are. disciplines: [] clears the disciplines, clear: [alignment] the alignment. Needs write rights on the Version.

OperationUpdateVersion · POST /openapi/fs/UpdateVersion
Scopemodel:write

Parameters#

NameTypeDescription
update_version_requestUpdateVersionRequestrequiredThe request: its properties are those of the model, its JSON that of UpdateVersion's request body.

Returns#

ModelVersion — The Version as it is now

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.UpdateVersionRequest.from_json(r"""
{
  "version_uuid": "<version uuid of the first demo model>",
  "disciplines": [
    "STRUCTURAL",
    "ARCHITECTURAL"
  ]
}
""")

# 3. The call
result = bimworks.FsApi(client).update_version(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))