Reference·.NET SDK · BIMworks.Sdk.NET

FsApi

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

.NET SDK · BIMworks.Sdk.Api · class · 16 methods

BIM.works repository's virtual filesystem related calls.

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

MethodOperationDescription
CreateNodeAsyncCreateNodeCreate a new Node
DeleteNodeAsyncDeleteNodeDelete a Node
DeleteNodeErrorAsyncDeleteNodeErrorClear an error of a Node
DeleteVersionAsyncDeleteVersionDelete a Version of a Node
DownloadAsZipAsyncDownloadAsZipDownload a folder Node and everything below it as a ZIP file
GetNodeAsyncGetNodeGet Node based on a given path, by its UUID or by the UUID of one of its Versions.
GetRootNodeUuidAsyncGetRootNodeUuidGet the UUID of the current root Node.
GetVersionAsyncGetVersionGet a Version by its UUID
ListNodeErrorsAsyncListNodeErrorsGet the errors of the given Node
ListNodesAsyncListNodesGet a list of Nodes that are children of the given Node
ListNodesRecursiveAsyncListNodesRecursiveGet all Nodes below the given Node, recursively
ListVersionsAsyncListVersionsGet a list of all the Versions of the given Node, or the given Versions
MoveNodeAsyncMoveNodeMove a Node to another parent folder
UndeleteNodeAsyncUndeleteNodeRestore a previously deleted Node
UpdateNodeAsyncUpdateNodeUpdate a Node
UpdateVersionAsyncUpdateVersionChange a Version's disciplines or alignment

CreateNodeAsync#

.NET#
Task<ICreateNodeApiResponse> CreateNodeAsync(CreateNodeRequest createNodeRequest, CancellationToken cancellationToken = default)

Create a new Node.

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

Parameters#

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

Returns#

Node — The new Node

Example#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<CreateNodeRequest>("""
    {
      "name": "",
      "folder": false,
      "input_file_type": "IFC",
      "parent_node_uuid": "00000000-0000-0000-0000-000000000000",
      "allow_existing": false
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().CreateNodeAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));

DeleteNodeAsync#

.NET#
Task<IDeleteNodeApiResponse> DeleteNodeAsync(DeleteNodeRequest deleteNodeRequest, CancellationToken cancellationToken = default)

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
deleteNodeRequestDeleteNodeRequestrequiredThe 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#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<DeleteNodeRequest>("""
    {
      "uuid": "<version uuid of the first demo model>"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().DeleteNodeAsync(request);

// 4. The result
// (DeleteNode answers no content: the call returns once it succeeded and throws an HttpRequestException otherwise)
if (!response.IsSuccessStatusCode) throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine("Done");

DeleteNodeErrorAsync#

.NET#
Task<IDeleteNodeErrorApiResponse> DeleteNodeErrorAsync(DeleteNodeErrorRequest deleteNodeErrorRequest, CancellationToken cancellationToken = default)

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
deleteNodeErrorRequestDeleteNodeErrorRequestrequiredThe 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#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<DeleteNodeErrorRequest>("""
    {
      "node_uuid": "00000000-0000-0000-0000-000000000000",
      "error_uuid": "00000000-0000-0000-0000-000000000000"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().DeleteNodeErrorAsync(request);

// 4. The result
// (DeleteNodeError answers no content: the call returns once it succeeded and throws an HttpRequestException otherwise)
if (!response.IsSuccessStatusCode) throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine("Done");

DeleteVersionAsync#

.NET#
Task<IDeleteVersionApiResponse> DeleteVersionAsync(DeleteVersionRequest deleteVersionRequest, CancellationToken cancellationToken = default)

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
deleteVersionRequestDeleteVersionRequestrequiredThe 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#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<DeleteVersionRequest>("""
    {
      "node_uuid": "00000000-0000-0000-0000-000000000000",
      "version_uuid": "<version uuid of the first demo model>"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().DeleteVersionAsync(request);

// 4. The result
// (DeleteVersion answers no content: the call returns once it succeeded and throws an HttpRequestException otherwise)
if (!response.IsSuccessStatusCode) throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine("Done");

DownloadAsZipAsync#

.NET#
Task<IDownloadAsZipApiResponse> DownloadAsZipAsync(DownloadAsZipRequest downloadAsZipRequest, CancellationToken cancellationToken = default)

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
downloadAsZipRequestDownloadAsZipRequestrequiredThe request: its properties are those of the model, its JSON that of DownloadAsZip's request body.

Returns#

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

Example#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<DownloadAsZipRequest>("""
    {
      "uuid": "<version uuid of the first demo model>",
      "include_deleted": false,
      "format": "ZIP"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().DownloadAsZipAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
using var output = File.Create("download-as-zip.zip");
await result.CopyToAsync(output);

GetNodeAsync#

.NET#
Task<IGetNodeApiResponse> GetNodeAsync(GetNodeRequest getNodeRequest, CancellationToken cancellationToken = default)

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
getNodeRequestGetNodeRequestrequiredThe 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#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<GetNodeRequest>("""
    {
      "path": "",
      "uuid": "<version uuid of the first demo model>",
      "version_uuid": "<version uuid of the first demo model>"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().GetNodeAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));

GetRootNodeUuidAsync#

.NET#
Task<IGetRootNodeUuidApiResponse> GetRootNodeUuidAsync(CancellationToken cancellationToken = default)

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#

Guid — The UUID of the Root Node

Example#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

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

// 3. The call
var response = await client.GetRequiredService<IFsApi>().GetRootNodeUuidAsync();

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));

GetVersionAsync#

.NET#
Task<IGetVersionApiResponse> GetVersionAsync(GetVersionRequest getVersionRequest, CancellationToken cancellationToken = default)

Get a Version by its UUID.

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

Parameters#

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

Returns#

ModelVersion — Version information

Example#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<GetVersionRequest>("""
    {
      "uuid": "<version uuid of the first demo model>"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().GetVersionAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));

ListNodeErrorsAsync#

.NET#
Task<IListNodeErrorsApiResponse> ListNodeErrorsAsync(ListNodeErrorsRequest listNodeErrorsRequest, CancellationToken cancellationToken = default)

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
listNodeErrorsRequestListNodeErrorsRequestrequiredThe 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#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<ListNodeErrorsRequest>("""
    {
      "uuid": "<version uuid of the first demo model>"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().ListNodeErrorsAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));

ListNodesAsync#

.NET#
Task<IListNodesApiResponse> ListNodesAsync(ListNodesRequest listNodesRequest, CancellationToken cancellationToken = default)

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

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

Parameters#

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

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<ListNodesRequest>("""
    {
      "path": "",
      "uuid": "<version uuid of the first demo model>",
      "version_uuid": "<version uuid of the first demo model>",
      "show_deleted_nodes": false
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().ListNodesAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));

ListNodesRecursiveAsync#

.NET#
Task<IListNodesRecursiveApiResponse> ListNodesRecursiveAsync(ListNodesRecursiveRequest listNodesRecursiveRequest, CancellationToken cancellationToken = default)

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
listNodesRecursiveRequestListNodesRecursiveRequestrequiredThe 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#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<ListNodesRecursiveRequest>("""
    {
      "uuid": "<version uuid of the first demo model>"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().ListNodesRecursiveAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));

ListVersionsAsync#

.NET#
Task<IListVersionsApiResponse> ListVersionsAsync(ListVersionsRequest listVersionsRequest, CancellationToken cancellationToken = default)

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
listVersionsRequestListVersionsRequestrequiredThe 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#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<ListVersionsRequest>("""
    {
      "uuid": "<version uuid of the first demo model>"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().ListVersionsAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));

MoveNodeAsync#

.NET#
Task<IMoveNodeApiResponse> MoveNodeAsync(MoveNodeRequest moveNodeRequest, CancellationToken cancellationToken = default)

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
moveNodeRequestMoveNodeRequestrequiredThe request: its properties are those of the model, its JSON that of MoveNode's request body.

Returns#

Node — The moved Node

Example#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<MoveNodeRequest>("""
    {
      "uuid": "<version uuid of the first demo model>",
      "target_parent_uuid": "00000000-0000-0000-0000-000000000000"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().MoveNodeAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));

UndeleteNodeAsync#

.NET#
Task<IUndeleteNodeApiResponse> UndeleteNodeAsync(UndeleteNodeRequest undeleteNodeRequest, CancellationToken cancellationToken = default)

Restore a previously deleted Node.

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

Parameters#

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

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<UndeleteNodeRequest>("""
    {
      "uuid": "<version uuid of the first demo model>"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().UndeleteNodeAsync(request);

// 4. The result
// (UndeleteNode answers no content: the call returns once it succeeded and throws an HttpRequestException otherwise)
if (!response.IsSuccessStatusCode) throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine("Done");

UpdateNodeAsync#

.NET#
Task<IUpdateNodeApiResponse> UpdateNodeAsync(UpdateNodeRequest updateNodeRequest, CancellationToken cancellationToken = default)

Update a Node.

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

Parameters#

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

Returns#

Node — The updated Node

Example#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<UpdateNodeRequest>("""
    {
      "path": "",
      "uuid": "<version uuid of the first demo model>",
      "version_uuid": "<version uuid of the first demo model>",
      "name": "",
      "user_data": {}
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().UpdateNodeAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));

UpdateVersionAsync#

.NET#
Task<IUpdateVersionApiResponse> UpdateVersionAsync(UpdateVersionRequest updateVersionRequest, CancellationToken cancellationToken = default)

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
updateVersionRequestUpdateVersionRequestrequiredThe 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#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<UpdateVersionRequest>("""
    {
      "version_uuid": "<version uuid of the first demo model>",
      "disciplines": [
        "STRUCTURAL",
        "ARCHITECTURAL"
      ]
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IFsApi>().UpdateVersionAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));