This is a .NET SDK for Aries Cloud APIM. It facilitates the configuration & communication to the Aries Cloud APIM for .NET consumers.
PM> Install-Package AriesCloudDotnet
> dotnet add package AriesCloudDotnet
Add the following configuration to your appsettings.json:
{
...
"AriesCloudAPI": {
"BaseUri": "http://localhost:8000",
"APIKey": "{API_KEY}"
}
}
BaseUri
is the url of the Aries Cloud APIMAPIKey
is your consumer api-key
Add the following to your application startup:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddAriesCloudAPI(Configuration);
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
app.UseAriesCloudAPI();
}
To communicate with the Aries Cloud APIM, a client-proxy must first be created via the AriesCloudClientFactory
class.
This is provided by the Dependency Injection.
It provides the following methods to create clients for the respective contexts:
-
CreateTenantClient(string tenantId) creates a client for the specified tenantId
-
CreateTenantAdminClient() creates a client under the context of the 'governance' role as defined in Aries Cloud API.
-
CreateGoveranceClient() creates a client under the context of the 'tenant-admin' role as defined in Aries Cloud API.
Example:
public class ValuesController : ControllerBase
{
private AriesCloudClientFactory _clientFactory;
public ValuesController(AriesCloudClientFactory clientFactory)
{
_clientFactory = clientFactory;
}
[HttpGet]
public async System.Threading.Tasks.Task<IEnumerable<string>> GetAsync()
{
// create client
var client = _clientFactory.CreateTenantClient("{TENANT_ID}");
// example usage
var tenants = await client.GetCredentialsAsync();
return tenants?.Select(x => x.ToString());
}
}
for more exmaples, see the AriesCloudDotnet.IntegrationTests
project in the source code.