ShapeDiver.SDK.TokenGenerator 1.17.1

dotnet add package ShapeDiver.SDK.TokenGenerator --version 1.17.1                
NuGet\Install-Package ShapeDiver.SDK.TokenGenerator -Version 1.17.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ShapeDiver.SDK.TokenGenerator" Version="1.17.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ShapeDiver.SDK.TokenGenerator --version 1.17.1                
#r "nuget: ShapeDiver.SDK.TokenGenerator, 1.17.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ShapeDiver.SDK.TokenGenerator as a Cake Addin
#addin nuget:?package=ShapeDiver.SDK.TokenGenerator&version=1.17.1

// Install ShapeDiver.SDK.TokenGenerator as a Cake Tool
#tool nuget:?package=ShapeDiver.SDK.TokenGenerator&version=1.17.1                

ShapeDiver SDK for .NET - Geometry Backend Token Generator

This package provides an implementation of the interface IGeometryBackendTokenGenerator contained in ShapeDiver.SDK. The implementation can be used to call the token generator lambda function which comes with ShapeDiver Geometry Backend systems. Appropriate AWS credentials are required to call the lambda function. As an example this can be achieved using AWS access keys, or by instance credentials when running this code on AWS EC2.

How to get support

Examples

We provide examples on how to use the SDK on github and .NET Fiddle. Ask us on the Forum if you don’t understand how they work, or you want suggest further examples to be added.

Usage

Use case 1 - Create a token for creating and uploading a model to a Geometry Backend system

using Amazon.Lambda;
using ShapeDiver.SDK.GeometryBackend;
using ShapeDiver.SDK.GeometryBackend.DTO;
using ShapeDiver.SDK.GeometryBackend.DTO.Request;

// create configuration for lambda client
var config = new AmazonLambdaConfig();
config.RegionEndpoint = Amazon.RegionEndpoint.EUCentral1;
config.Profile = new Amazon.Profile("tokengeneratortest");

// create an instance of the token generator
var functionName = "SYSTEMPREFIX-tokenGenerator";
var aud = "827bcbdc-8a5c-481a-b09a-e498074d91ca";
var sdUserId = null;
var generator = new GeometryBackendTokenGeneratorLambda(config, functionName, aud, sdUserId);

// create a "backend" token that allows to create a new model and get a model upload link
var token = await generator.CreateToken("backend", new List<TokenScopeEnum>() { TokenScopeEnum.Create, TokenScopeEnum.FileUpload });

// make use of token
var modelViewUrl = "https://SYSTEMPREFIX.eu-central-1.shapediver.com";
var client = new GeometryBackendClientResources(modelViewUrl, token);
var result = await client_session.Client.Model.Create(new RequestModelDto()
{
    Ftype = ModelFileTypeEnum.GrasshopperBinary
});

// TODO: upload model to result.File.Upload

Use case 2 - Create a token for creating a session

using Amazon.Lambda;
using ShapeDiver.SDK.GeometryBackend;
using ShapeDiver.SDK.GeometryBackend.DTO;
using ShapeDiver.SDK.GeometryBackend.DTO.Request;

// create configuration for lambda client
var config = new AmazonLambdaConfig();
config.RegionEndpoint = Amazon.RegionEndpoint.EUCentral1;
config.Profile = new Amazon.Profile("tokengeneratortest");

// create an instance of the token generator
var functionName = "SYSTEMPREFIX-tokenGenerator";
var aud = "827bcbdc-8a5c-481a-b09a-e498074d91ca";
var sdUserId = "5B4796C0-B92D-424A-B35E-01FB30497B3C";
var generator = new GeometryBackendTokenGeneratorLambda(config, functionName, aud, sdUserId);

// id of the model to access on the geometry backend system
var modelId = "15F65BAD-7B69-4B48-8D34-D804E6ABF14A";

// create a model token that allows to create a new model and get a model upload link
var token = await generator.CreateToken(modelId), new List<TokenScopeEnum>() { TokenScopeEnum.AuthSession, TokenScopeEnum.GroupView, TokenScopeEnum.GroupExport });

// Model View URL (API endpoint) of the geometry backend system
var modelViewUrl = "SYSTEMPREFIX.REGION.shapediver.com";

// create an instance of IGeometryBackendClient and use it to create a session context
var client = new GeometryBackendClient();
var context = await client.GetSessionContext(modelId, modelViewUrl, generator);

// Example: use the context to do computations, exports, etc
var result = await client.ComputeOutputs(context, /* parameter values */ );

// Note: Calling RefreshToken on the context will use the generator to create a new token.
//       This happens automatically inside the SDK should an API call fail due to an expired token.
await context.RefreshToken();

// close the session context
await client.CloseSessionContext(context);

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.17.1 125 4/5/2024
1.17.0 156 1/8/2024
1.17.0-beta 152 11/30/2023
1.16.1 136 9/15/2023