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.
| Method | Operation | Description |
|---|---|---|
create_node | CreateNode | Create a new Node |
delete_node | DeleteNode | Delete a Node |
delete_node_error | DeleteNodeError | Clear an error of a Node |
delete_version | DeleteVersion | Delete a Version of a Node |
download_as_zip | DownloadAsZip | Download a folder Node and everything below it as a ZIP file |
get_node | GetNode | Get Node based on a given path, by its UUID or by the UUID of one of its Versions. |
get_root_node_uuid | GetRootNodeUuid | Get the UUID of the current root Node. |
get_version | GetVersion | Get a Version by its UUID |
list_node_errors | ListNodeErrors | Get the errors of the given Node |
list_nodes | ListNodes | Get a list of Nodes that are children of the given Node |
list_nodes_recursive | ListNodesRecursive | Get all Nodes below the given Node, recursively |
list_versions | ListVersions | Get a list of all the Versions of the given Node, or the given Versions |
move_node | MoveNode | Move a Node to another parent folder |
undelete_node | UndeleteNode | Restore a previously deleted Node |
update_node | UpdateNode | Update a Node |
update_version | UpdateVersion | Change a Version's disciplines or alignment |
create_node#
def create_node(self, create_node_request: CreateNodeRequest) -> NodeCreate a new Node.
| Operation | CreateNode · POST /openapi/fs/CreateNode |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
create_node_request | CreateNodeRequestrequired | The request: its properties are those of the model, its JSON that of CreateNode's request body. |
Returns#
Node — The new Node
Example#
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#
def delete_node(self, delete_node_request: DeleteNodeRequest) -> NoneDelete 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.
| Operation | DeleteNode · POST /openapi/fs/DeleteNode |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
delete_node_request | DeleteNodeRequestrequired | The 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#
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#
def delete_node_error(self, delete_node_error_request: DeleteNodeErrorRequest) -> NoneClear 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.
| Operation | DeleteNodeError · POST /openapi/fs/DeleteNodeError |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
delete_node_error_request | DeleteNodeErrorRequestrequired | The 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#
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#
def delete_version(self, delete_version_request: DeleteVersionRequest) -> NoneDelete a Version of a Node. Only the last Version of a Node can be deleted, intermediate Versions must stay available.
| Operation | DeleteVersion · POST /openapi/fs/DeleteVersion |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
delete_version_request | DeleteVersionRequestrequired | The 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#
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#
def download_as_zip(self, download_as_zip_request: DownloadAsZipRequest) -> bytesDownload 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.
| Operation | DownloadAsZip · POST /openapi/fs/DownloadAsZip |
|---|---|
| Scope | model:read |
Parameters#
| Name | Type | Description |
|---|---|---|
download_as_zip_request | DownloadAsZipRequestrequired | The 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#
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#
def get_node(self, get_node_request: GetNodeRequest) -> NodeGet 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.
| Operation | GetNode · POST /openapi/fs/GetNode |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
get_node_request | GetNodeRequestrequired | The 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#
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#
def get_root_node_uuid(self) -> UUIDGet the UUID of the current root Node. This depends on the API Token/Auth Token that is being used.
| Operation | GetRootNodeUuid · GET /openapi/fs/GetRootNodeUuid |
|---|---|
| Scope | fs:read |
Parameters#
None: the operation takes no request.
Returns#
UUID — The UUID of the Root Node
Example#
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#
def get_version(self, get_version_request: GetVersionRequest) -> ModelVersionGet a Version by its UUID.
| Operation | GetVersion · POST /openapi/fs/GetVersion |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
get_version_request | GetVersionRequestrequired | The request: its properties are those of the model, its JSON that of GetVersion's request body. |
Returns#
ModelVersion — Version information
Example#
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#
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.
| Operation | ListNodeErrors · POST /openapi/fs/ListNodeErrors |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
list_node_errors_request | ListNodeErrorsRequestrequired | The 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#
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#
def list_nodes(self, list_nodes_request: ListNodesRequest) -> List[Node]Get a list of Nodes that are children of the given Node.
| Operation | ListNodes · POST /openapi/fs/ListNodes |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
list_nodes_request | ListNodesRequestrequired | The 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#
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#
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.
| Operation | ListNodesRecursive · POST /openapi/fs/ListNodesRecursive |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
list_nodes_recursive_request | ListNodesRecursiveRequestrequired | The 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#
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#
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.
| Operation | ListVersions · POST /openapi/fs/ListVersions |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
list_versions_request | ListVersionsRequestrequired | The 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#
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#
def move_node(self, move_node_request: MoveNodeRequest) -> NodeMove 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.
| Operation | MoveNode · POST /openapi/fs/MoveNode |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
move_node_request | MoveNodeRequestrequired | The request: its properties are those of the model, its JSON that of MoveNode's request body. |
Returns#
Node — The moved Node
Example#
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#
def undelete_node(self, undelete_node_request: UndeleteNodeRequest) -> NoneRestore a previously deleted Node.
| Operation | UndeleteNode · POST /openapi/fs/UndeleteNode |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
undelete_node_request | UndeleteNodeRequestrequired | The 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#
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#
def update_node(self, update_node_request: UpdateNodeRequest) -> NodeUpdate a Node.
| Operation | UpdateNode · POST /openapi/fs/UpdateNode |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
update_node_request | UpdateNodeRequestrequired | The request: its properties are those of the model, its JSON that of UpdateNode's request body. |
Returns#
Node — The updated Node
Example#
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#
def update_version(self, update_version_request: UpdateVersionRequest) -> ModelVersionChange 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.
| Operation | UpdateVersion · POST /openapi/fs/UpdateVersion |
|---|---|
| Scope | model:write |
Parameters#
| Name | Type | Description |
|---|---|---|
update_version_request | UpdateVersionRequestrequired | The 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#
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))