Reference·Java SDK · nl.bimbase.bimworks.sdkJava

WorkspacesApi

Java SDK: the Workspaces operations, 5 methods, each with its parameters, result and a complete example.

Java SDK · nl.bimbase.bimworks.sdk.api · 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: new WorkspacesApi(client). Each method is one operation of the API part, where it runs on its page.

MethodOperationDescription
createWorkspaceCreateWorkspaceCreate a workspace
deleteWorkspaceDeleteWorkspaceDelete a workspace
listWorkspacesListWorkspacesList the caller's workspaces
publishWorkspacePublishWorkspacePublish or unpublish a workspace
updateWorkspaceUpdateWorkspaceChange a workspace

createWorkspace#

Java#
public CreateWorkspace200Response createWorkspace(CreateWorkspaceRequest createWorkspaceRequest) throws ApiException

Create a workspace. An account only. A sub-workspace inherits the root folder and the scopes of its parent and can only narrow them.

OperationCreateWorkspace · POST /openapi/workspaces/CreateWorkspace
Scopeworkspaces:write

Parameters#

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

Returns#

CreateWorkspace200Response — The new workspace

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.WorkspacesApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.CreateWorkspaceRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        CreateWorkspaceRequest request = client.getObjectMapper().readValue("""
                {
                  "name": "",
                  "parent_workspace_uuid": "00000000-0000-0000-0000-000000000000",
                  "scopes": {},
                  "filter": "",
                  "load_all_models_initially": false,
                  "current_space": {},
                  "feature_visibility": {}
                }
                """, CreateWorkspaceRequest.class);

        // 3. The call
        var result = new WorkspacesApi(client).createWorkspace(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

deleteWorkspace#

Java#
public void deleteWorkspace(DeleteWorkspaceRequest deleteWorkspaceRequest) throws ApiException

Delete a workspace. Deletes the workspace and its sub-workspaces; their links stop working. The models and actions are kept. Its owner only.

OperationDeleteWorkspace · POST /openapi/workspaces/DeleteWorkspace
Scopeworkspaces:write

Parameters#

NameTypeDescription
deleteWorkspaceRequestDeleteWorkspaceRequestrequiredThe 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#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.WorkspacesApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.DeleteWorkspaceRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        DeleteWorkspaceRequest request = client.getObjectMapper().readValue("""
                {
                  "uuid": "<version uuid of the first demo model>"
                }
                """, DeleteWorkspaceRequest.class);

        // 3. The call
        new WorkspacesApi(client).deleteWorkspace(request);

        // 4. The result
        // (DeleteWorkspace answers no content: the call returns once it succeeded and throws an ApiException otherwise)
        System.out.println("Done");
    }
}

listWorkspaces#

Java#
public List<Workspace> listWorkspaces() throws ApiException

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.

OperationListWorkspaces · POST /openapi/workspaces/ListWorkspaces
Scopeworkspaces:read

Parameters#

None: the operation takes no request.

Returns#

List<Workspace> — The workspaces

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.WorkspacesApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        // (ListWorkspaces takes no request)

        // 3. The call
        var result = new WorkspacesApi(client).listWorkspaces();

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

publishWorkspace#

Java#
public Workspace publishWorkspace(PublishWorkspaceRequest publishWorkspaceRequest) throws ApiException

Publish 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.

OperationPublishWorkspace · POST /openapi/workspaces/PublishWorkspace
Scopeworkspaces:write

Parameters#

NameTypeDescription
publishWorkspaceRequestPublishWorkspaceRequestrequiredThe 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#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.WorkspacesApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
import nl.bimbase.bimworks.sdk.model.PublishWorkspaceRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        PublishWorkspaceRequest request = client.getObjectMapper().readValue("""
                {
                  "uuid": "<version uuid of the first demo model>",
                  "publish": true
                }
                """, PublishWorkspaceRequest.class);

        // 3. The call
        var result = new WorkspacesApi(client).publishWorkspace(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

updateWorkspace#

Java#
public void updateWorkspace(UpdateWorkspaceRequest updateWorkspaceRequest) throws ApiException

Change a workspace. Changes the fields that are passed; the others stay as they are. A field named in clear is removed. Its owner only.

OperationUpdateWorkspace · POST /openapi/workspaces/UpdateWorkspace
Scopeworkspaces:write

Parameters#

NameTypeDescription
updateWorkspaceRequestUpdateWorkspaceRequestrequiredThe 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#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.WorkspacesApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
import nl.bimbase.bimworks.sdk.model.UpdateWorkspaceRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        UpdateWorkspaceRequest request = client.getObjectMapper().readValue("""
                {
                  "uuid": "<version uuid of the first demo model>",
                  "name": "",
                  "scopes": {},
                  "filter": "",
                  "load_all_models_initially": false,
                  "current_space": {},
                  "feature_visibility": {},
                  "sub_path": "",
                  "clear": [
                    "filter"
                  ]
                }
                """, UpdateWorkspaceRequest.class);

        // 3. The call
        new WorkspacesApi(client).updateWorkspace(request);

        // 4. The result
        // (UpdateWorkspace answers no content: the call returns once it succeeded and throws an ApiException otherwise)
        System.out.println("Done");
    }
}