Trimble.Http
title: “trimble.http” description: “trimble.http Namespace” lead: "" date: 2023-06-12T13:46:25-06:00 lastmod: 2023-06-12T13:46:25-06:00 draft: false images: [] menu: docs: parent: “rego-api” weight: 342 toc: true
Namespace Reference
Definition
Provides remote http functions.
trimble.http.get
trimble.http.get(url, token)Parameters
url string
The URL to specify in the request.
token string
The access token used to authenticate the request. An empty string means that the TID token obtained from the appliance Application token (CLIENT_ID and CLIENT_SECRET environment variables) are used.
Returns
A Rego object with the following members:
status_code number
The response status code.
body any
The response body as a Rego object.
trimble.http.post
trimble.http.post(url, body, token)Parameters
url string
The URL to specify in the request.
body any
A valid JSON object.
token string
The access token used to authenticate the request. An empty string means that the TID token obtained from the appliance Application token (CLIENT_ID and CLIENT_SECRET environment variables) are used.
Returns
A Rego object with the following members:
status_code number
The response status code.
body any
The response body as a Rego object.
trimble.http.get_with_caller_auth
trimble.http.get_with_caller_auth(url)Parameters
url string
The URL to specify in the request.
Returns
A Rego object with the following members:
status_code number
The response status code.
body any
The response body as a Rego object.
trimble.http.post_with_caller_auth
trimble.http.post_with_caller_auth(url, body)Parameters
url string
The URL to specify in the request.
body any
A valid JSON object.
Returns
A Rego object with the following members:
status_code number
The response status code.
body any
The response body as a Rego object.
Remarks
Token
The token argument must be a valid JWT. In most cases, we recommend using the existing methods to inject tokens as part of the request to the appliance decision endpoint (see Input query format). The appliance validates all tokens that are injected via the POST request.
For example, specifying bearer authentication for the auth member of the POST request body of the decision API will allow you to access the token in Rego as input.caller_auth.jwt. The JWT used to authenticate the request to the appliance is also accessible via input.appliance_auth.jwt.
Errors
These built-ins exit immediately if any errors are encountered during policy evaluation and return a 500 status with error details from the appliance decision endpoint. These errors include:
- Any non-2xx or invalid response from the remote HTTP request. The built-ins expect the response to contain a 2xx status code and a valid JSON body.
- Invalid Rego arguments. E.g. an object that cannot be serialized to JSON for the
bodyparameter.