This sample implements a database to store attributes indexed by Viewer (or Model Derivative) URN, hooking into the same permission settings.
The server side was implemented in .NET and exposes 3 endpoints:
- POST
/api/attributes
: Create a new database entry for the given URN. The body should be in the format of:
{
"urn":"dXJuOmFkc2WXlUUXNPd1E",
"data": {"key": "any valid json"}
}
- PUT
/api/attributes/:urn
: Update the database entry for the give URN. The body should be in the format of:
{
"urn":"dXJuOmFkc2WXlUUXNPd1E",
"data": {"key": "any valid json"}
}
- GET
/api/attributes/:urn
: Returns the database record
All endpoints require a Authorization
header with a valid Autodesk Forge access token (Bearer <<access token>>
).
This sample uses AWS Lambda on-demand compute to react to incoming calls. First it connects to Autodesk Forge to check for permissions for the given URN
. Then connects to Amazon DynamoDB to Save
or Load
the attributes.
There are different options to create a .NET project for AWS Lambda. This sample uses the ASP.NET Core Web API, which is compatible with existing Web API apps, easier to migrate from existing apps. To create a new project, select the following blue print.
A table is required for this sample. The code creates it on demand, but make sure to allow the required permissions. Review the provisioned read & write capacity to adjust to your needs.
The DynamoDBContext SDK class will take care of Save
and Load
documents into the Model.Attributes class. To edit what is saved, change the properties of this class.
- Amazon API Gateway: Receive incomming requests and redirect to the Lambda function
- Amazon S3: The .NET package is deployed and server from a bucket
- AWS CloudFormation: The selected blueprint will define a Stack that can easily maintained.
To use this sample, make sure to edit the AWS Profile and Region at this file.
The AWS Toolkit for Visual Studio is a must have tool for .NET developers. With that, the "Publish to AWS Lambda" toolkit feature will take care of compiling the code, uploading to S3 and triggering the CloudFormation.
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.
Forge Partner Development Team
- Augusto Goncalves @augustomaia
See more at Forge blog.