Skip to content

Latest commit

 

History

History
193 lines (142 loc) · 7.52 KB

File metadata and controls

193 lines (142 loc) · 7.52 KB

Autodesk.Forge.DesignAutomation

Design-Automation SDK .NET BUILD nuget

Overview

.NET SDK for Design Automation v3 API, for more information, please visit official documentation

For clients with straightforward needs one high level API client is provided in DesignAutomationClient. For clients with more varied needs the following low level API classes are provided: ActivitiesApi, AppBundlesApi, EnginesApi, ForgeAppsApi, HealthApi, SharesApi, WorkItemsApi.

Requirements

Dependencies

Changelog

The change log for the SDK can be found here.

Contributions

Contributions are welcome! Please open a Pull Request.

Support

Please ask questions on StackOverflow with tag autodesk-designautomation tag. If it turns out that you may have found a bug, please open an issue

Getting Started

To use the API you must instantiate one of the API classes and configure it with the valid forge credentials. You can do this in 2 ways:

  1. By using dependency injection and configuration providers (PREFERRED)
  2. By directly creating instances of one of API classes and the Autodesk.Forge.Core.ForgeConfiguration class and setting is properites

Configuration

There are 2 classes that you can use to configure the API:

  1. Autodesk.Forge.Core.ForgeConfiguration - Allows the configuration of Forge client credentials and alternative authentication service endpoint (default is https://developer.api.autodesk.com/authentication/v2/token)

  2. Autodesk.Forge.DesignAutomation.Configuration- Allows the configuration of non-default API endpoint (default is https://developer.api.autodesk.com/da/us-east/).

This SDK integrates with the .netcore configuration system. You can configure the above values via any configuration provider (e.g. appsettings.json or environment variables). For example to set the Forge credentials you could define the following environment variables:

Forge__ClientId=<your client id>
Forge__ClientSecret=<your client secret>

or the following in your appsettings.json:

{
    "Forge": {
        "ClientId" : "<your client id>",
        "ClientSecret" : "<your client secret>"
    }
}

or using environment variables with ForgeAlternativeConfigurationExtensions:

FORGE_CLIENT_ID=<your client id>
FORGE_CLIENT_SECRET=<your client secret>

Starting with version 4.3 you can also configure multiple ClientId/ClientSecret pairs as follows:

{
 "Forge": {
   "ClientId": "<default clientId>"
   "ClientSecret" : "<default clientSecret>"
   "Agents": {
     "agent1": {
       "ClientId": "<clientId of agent1>"
       "ClientSecret" : "<clientSecret of agent1>"
     },
      "agent2": {
       "ClientId": "<clientId of agent2>"
       "ClientSecret" : "<clientSecret of agent2>"
     }
   },
   ...
}

These credentials are used when you create a named DesignAutomationClient via DesignAutomationFactory.CreateClient(string name) where name should match the name of the agent in configuration.

Examples

Tutorials

Please visit Learn Forge tutorial.

Using dependency injection

First you must add Autodesk.Forge.DesignAutomation services. This is usually done in ConfigureServices(...) method of your Startup class. More information

NOTE: This example assumes that you are building an Asp.Net Core web api or website. If you want to use dependency injection in a console app then follow this example.

using Autodesk.Forge.DesignAutomation;
using Autodesk.Forge.DesignAutomation.Model;
...
public void ConfigureServices(IServiceCollection services)
{
    services.AddDesignAutomation(this.Configuration);
}

Then you can use any of the API classes or interfaces in a constructor:

using Autodesk.Forge.DesignAutomation;
...
public class SomeApiController : ControllerBase
{
    public SomeApiController(IWorkItemsApi forgeApi)
    {
        //use forgeApi here
    }

By directly creating API objects

using Autodesk.Forge.DesignAutomation;
using System.Net.Http;
using System.Threading.Tasks;
using Autodesk.Forge.Core;

internal class Program
{
    public static void Main(string[] args)
    {
        var service =
            new ForgeService(
                new HttpClient(
                    new ForgeHandler(Microsoft.Extensions.Options.Options.Create(new ForgeConfiguration()
                    {
                        ClientId = "<your client id>",
                        ClientSecret = "<your client secret>"
                    }))
                {
                    InnerHandler = new HttpClientHandler()
                })
            );

        var forgeApi = new WorkItemsApi(service);
    }
}

Versioning

Using Semantic Version scheme following the pattern of x.y.z.:

  • x: MAJOR version when you make incompatible changes,
  • y: MINOR version when you add functionality in a backwards-compatible manner, and
  • z: PATCH version when you make backwards-compatible bug fixes.

Source-code

Generated with swagger-codegen.

Build

dotnet build Autodesk.Forge.DesignAutomation.sln

Test

dotnet test Autodesk.Forge.DesignAutomation.sln

License

This sample is licensed under the terms of the Apache License 2.0. Please see the LICENSE file for full details.