WorkspacesApi
Python SDK: the Workspaces operations, 5 methods, each with its parameters, result and a complete example.
Python SDK · bimworks · class · 5 methods
Curated views on a folder for visitors of the BIM.works web app, and their share links
Construct it with the client of the connect step: bimworks.WorkspacesApi(client). Each method is one operation of the API part, where it runs on its page.
| Method | Operation | Description |
|---|---|---|
create_workspace | CreateWorkspace | Create a workspace |
delete_workspace | DeleteWorkspace | Delete a workspace |
list_workspaces | ListWorkspaces | List the caller's workspaces |
publish_workspace | PublishWorkspace | Publish or unpublish a workspace |
update_workspace | UpdateWorkspace | Change a workspace |
create_workspace#
def create_workspace(self, create_workspace_request: CreateWorkspaceRequest) -> CreateWorkspace200ResponseCreate a workspace. An account only. A sub-workspace inherits the root folder and the scopes of its parent and can only narrow them.
| Operation | CreateWorkspace · POST /openapi/workspaces/CreateWorkspace |
|---|---|
| Scope | workspaces:write |
Parameters#
| Name | Type | Description |
|---|---|---|
create_workspace_request | CreateWorkspaceRequestrequired | The request: its properties are those of the model, its JSON that of CreateWorkspace's request body. |
Returns#
CreateWorkspace200Response — The new workspace
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.CreateWorkspaceRequest.from_json(r"""
{
"name": "",
"parent_workspace_uuid": "00000000-0000-0000-0000-000000000000",
"scopes": {},
"filter": "",
"load_all_models_initially": false,
"current_space": {},
"feature_visibility": {}
}
""")
# 3. The call
result = bimworks.WorkspacesApi(client).create_workspace(request)
# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))delete_workspace#
def delete_workspace(self, delete_workspace_request: DeleteWorkspaceRequest) -> NoneDelete a workspace. Deletes the workspace and its sub-workspaces; their links stop working. The models and actions are kept. Its owner only.
| Operation | DeleteWorkspace · POST /openapi/workspaces/DeleteWorkspace |
|---|---|
| Scope | workspaces:write |
Parameters#
| Name | Type | Description |
|---|---|---|
delete_workspace_request | DeleteWorkspaceRequestrequired | The request: its properties are those of the model, its JSON that of DeleteWorkspace's request body. |
Returns#
Nothing: the operation answers without a body (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.DeleteWorkspaceRequest.from_json(r"""
{
"uuid": "<version uuid of the first demo model>"
}
""")
# 3. The call
bimworks.WorkspacesApi(client).delete_workspace(request)
# 4. The result
# (DeleteWorkspace answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")list_workspaces#
def list_workspaces(self) -> List[Workspace]List the caller's workspaces. The caller's workspaces with their sub-workspaces (children). A workspace is a curated view on a folder for visitors of the BIM.works web app: its scopes, object filter and visible features; PublishWorkspace makes it a share link.
| Operation | ListWorkspaces · POST /openapi/workspaces/ListWorkspaces |
|---|---|
| Scope | workspaces:read |
Parameters#
None: the operation takes no request.
Returns#
List[Workspace] — The workspaces
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
# (ListWorkspaces takes no request)
# 3. The call
result = bimworks.WorkspacesApi(client).list_workspaces()
# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))publish_workspace#
def publish_workspace(self, publish_workspace_request: PublishWorkspaceRequest) -> WorkspacePublish or unpublish a workspace. Publishing gives the workspace a new publish_uuid, the share link into the web app; publishing again replaces the link and ends the old one. publish: false unpublishes it and ends the visitors' sessions. Its owner only.
| Operation | PublishWorkspace · POST /openapi/workspaces/PublishWorkspace |
|---|---|
| Scope | workspaces:write |
Parameters#
| Name | Type | Description |
|---|---|---|
publish_workspace_request | PublishWorkspaceRequestrequired | The request: its properties are those of the model, its JSON that of PublishWorkspace's request body. |
Returns#
Workspace — The workspace with its publish_uuid
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.PublishWorkspaceRequest.from_json(r"""
{
"uuid": "<version uuid of the first demo model>",
"publish": true
}
""")
# 3. The call
result = bimworks.WorkspacesApi(client).publish_workspace(request)
# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))update_workspace#
def update_workspace(self, update_workspace_request: UpdateWorkspaceRequest) -> NoneChange a workspace. Changes the fields that are passed; the others stay as they are. A field named in clear is removed. Its owner only.
| Operation | UpdateWorkspace · POST /openapi/workspaces/UpdateWorkspace |
|---|---|
| Scope | workspaces:write |
Parameters#
| Name | Type | Description |
|---|---|---|
update_workspace_request | UpdateWorkspaceRequestrequired | The request: its properties are those of the model, its JSON that of UpdateWorkspace's request body. |
Returns#
Nothing: the operation answers without a body (Changed).
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.UpdateWorkspaceRequest.from_json(r"""
{
"uuid": "<version uuid of the first demo model>",
"name": "",
"scopes": {},
"filter": "",
"load_all_models_initially": false,
"current_space": {},
"feature_visibility": {},
"sub_path": "",
"clear": [
"filter"
]
}
""")
# 3. The call
bimworks.WorkspacesApi(client).update_workspace(request)
# 4. The result
# (UpdateWorkspace answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")