VersionsApi
.NET SDK: the Versions operations, 1 method, each with its parameters, result and a complete example.
.NET SDK · BIMworks.Sdk.Api · class · 1 method
Calls related to Versions
Construct it with the client of the connect step: client.GetRequiredService<IVersionsApi>(). Each method is one operation of the API part, where it runs on its page.
| Method | Operation | Description |
|---|---|---|
VersionAsync | Version | The metadata of a Version by its UUID (deprecated, use GetVersion, or Download for the file) |
VersionAsync#
Task<IVersionApiResponse> VersionAsync(Guid uuid, CancellationToken cancellationToken = default)The metadata of a Version by its UUID (deprecated, use GetVersion, or Download for the file). Deprecated, this operation will be removed in a later release. Earlier versions of this specification said it answers the file of the Version; it answers the Version's metadata as JSON, the same as GetVersion. For the file, use Download. The binary content types are listed only so that the Accept header of older generated clients still matches; the body is always the JSON.
| Operation | Version · GET /openapi/Versions/{uuid} |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
uuid | Guidrequired |
Returns#
ModelVersion — The metadata of this Version
Example#
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 uuid = Guid.Parse("<version uuid of the first demo model>");
// 3. The call
var response = await client.GetRequiredService<IVersionsApi>().VersionAsync(uuid: uuid);
// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));