Skip to content

IApplianceApi


title: “IApplianceApi” description: “IApplianceApi Interface” lead: "" date: 2023-06-12T13:46:25-06:00 lastmod: 2023-06-12T13:46:25-06:00 draft: false images: [] menu: docs: parent: “dotnet-api” weight: 323 toc: true

Section titled “title: “IApplianceApi” description: “IApplianceApi Interface” lead: "" date: 2023-06-12T13:46:25-06:00 lastmod: 2023-06-12T13:46:25-06:00 draft: false images: [] menu: docs: parent: “dotnet-api” weight: 323 toc: true”

Interface Reference

Provides an interface to call an Appliance API.

  • Namespace: TrimbleCloud.Tam
  • Assembly: TrimbleCloud.Tam.dll
public interface IApplianceApi

This interface will be injected through AddAccessManagement.

Calls an appliance to evaluate a decision

Task<JsonDocument> Evaluate(string packageNamespace, string? rule, object input, CancellationToken cancellationToken);

packageNamespace string The namespace of the package containing the rule[s] to evaluate.

rule string The optional name of the rule to evaulate. Omitting this will evaluate all rules in the package.

input object An object that will be serialized and sent as input into the decision.

cancellationToken CancellationToken A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Task<JsonDocument>

The task object representing the asynchronous operation.

AccessManagementException The decision wasn’t able to be evaluated due to failure status code returned from the appliance.

This operation will not block. The returned Task<JsonDocument> object will complete after the decision is made.

package httpapi.authz
default allow := false
allow {
some username
input.method == "GET"
input.path = ["finance", "salary", username]
input.subordiantes[input.user][_] == username
}
public class DecisionInput
{
public string subject = "bob";
public Dictionary<string, string[]> subordiantes = new { { "charlie", new string[0] }, { "bob", new string[] { "alice" } } }
}
public class ExampleClass
{
private readonly IApplianceApi _applianceDecision;
public ExampleClass(IApplianceApi applianceDecision)
{
_applianceDecision = applianceDecision;
}
public async Task<bool> EvaluateRule(DecisionInput input, CancellationToken cancellationToken)
{
await applianceDecision.Evaluate("httpapi.authz", "allow", input, cancellationToken);
}
}