A dotnet client library for the KMD Logic Gateway service, which helps Logic client applications to automatically manage their APIs and Products published in Logic Marketplace.
In your application that handles management of APIs and Products add a NuGet package reference to Kmd.Logic.Gateway.Automation.
Probably the easiest way to configure is
{
"TokenProvider": {
"ClientId": "",
"ClientSecret": "",
"AuthorizationScope": ""
},
"Gateway": {
"SubscriptionId": "",
"ProviderId": ""
},
"FolderPath": ""
}
Then you must create configuration objects.
/// Create LogicTokenProviderFactory from Kmd.Logic.Identity.Authorization
var logicTokenProviderFactory = new LogicTokenProviderFactory(
new LogicTokenProviderOptions
{
AuthorizationScope = cmd.AuthorizationScope,
ClientId = cmd.ClientId,
ClientSecret = cmd.ClientSecret,
});
// Create Gateway options
var gatewayOptions = new GatewayOptions
{
SubscriptionId = cmd.SubscriptionId,
ProviderId = cmd.ProviderId,
};
To get started:
- Create a subscription in Logic Console. This will provide you the
SubscriptionId
which will be linked to the client credentials. - Request a client credential. Once issued you can view the
ClientId
,ClientSecret
andAuthorizationScope
in Logic Console. - Create provider in Logic Marketplace. This will provide you the
ProviderId
. Provider must be approved by Logic Admin.
using var httpClient = new HttpClient();
var gatewayAutomation = new GatewayAutomation(httpClient, logicTokenProviderFactory, gatewayOptions);
// Path of the folder containing publish.yml file.
var folderPath = "./SomeFolder";
// Validate
var result = await gatewayAutomation.ValidateAsync(folderPath).ConfigureAwait(false);
// Publish
var publish = await gatewayAutomation.PublishAsync(folderPath).ConfigureAwait(false);
A simple console application is included to demonstrate how to use Logic Gateway Automation. You will need to provide the settings described above in appsettings.json
.
Logic Gateway Automation requires specific file structure with file in the root folder called publish.yml
. You can find example file structure in the sample application source.
To use Logic Gateway Automation using CLI you must download it from NuGet.org - Kmd.Logic.Gateway.Automation.Tool.
To check if it was properly installed, run the following command:
kmd-logic-gateway-automation version
- Validate -
kmd-logic-gateway-automation validate
- Publish -
kmd-logic-gateway-automation publish
Parameter name | Description |
---|---|
-f, --folderPath | Required. Path of the root folder with 'publish.yml' file. |
-g, --gatewayUrl | Gateway URL. |
--scope | Authorization scope in Logic Subscription Client Credentials. |
--clientId | Required. Client ID in Logic Subscription Client Credentials. |
--secret | Required. Client secret in Logic Subscription Client Credentials. |
-p, --providerId | Provider ID in Logic. |
-s, --subscriptionId | Required. Subscription ID in Logic. |
-o, --output | Output format. Supported values are list and json. Default is list. |
Here is the example tasks definition, that are must have for proper KMD Logic Gateway Automation Tool utilization in Azure Pipelines:
- task: UseDotNet@2
displayName: Use .NET Core 3.1
inputs:
packageType: 'sdk'
version: '3.1.x'
- task: PowerShell@2
displayName: KMD Logic Gateway Automation CLI
inputs:
targetType: 'inline'
script: |
dotnet tool install --global kmd.logic.gateway.automation.tool --version <<tool_version>>
kmd-logic-gateway-automation <<command>> <<parameters>>