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
Definition
Section titled “Definition”Provides an interface to call an Appliance API.
- Namespace: TrimbleCloud.Tam
- Assembly: TrimbleCloud.Tam.dll
public interface IApplianceApiInitialization
Section titled “Initialization”This interface will be injected through AddAccessManagement.
Methods
Section titled “Methods”Evaluate
Section titled “Evaluate”Calls an appliance to evaluate a decision
Task<JsonDocument> Evaluate(string packageNamespace, string? rule, object input, CancellationToken cancellationToken);Parameters
Section titled “Parameters”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.
Returns
Section titled “Returns”Task<JsonDocument>
The task object representing the asynchronous operation.
Exceptions
Section titled “Exceptions”AccessManagementException The decision wasn’t able to be evaluated due to failure status code returned from the appliance.
Remarks
Section titled “Remarks”This operation will not block. The returned Task<JsonDocument> object will complete after the decision is made.
Example
Section titled “Example”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); }}