Set template variable hosts
/v1/templates/{id}/secrets/variables/{name}/hostsNarrows the hosts one of the template's kept-out variables is sent to, without sending its value again: each host has to be one it is sent to now, or under one of its wildcards. Its value and its stand-in stay as they are. A host it is not sent to now is refused with hosts_widened, since only someone who has the value may send it somewhere new: set it again with its value and hosts. A plain variable is refused with not_hidden: to keep one out, set it with its value and hosts. A sandbox on the template takes the change when it next starts, or when POST /v1/templates/{id}/apply names it.
- import { Agental } from "agental-sdk";
- const agental = new Agental();
- const template = await agental.templates.get("tpl_0123456789abcdef");
- await template.secrets.setHosts("GITHUB_TOKEN", ["api.github.com"]);
- {
- "name": string,
- "hidden": "true",
- "hosts": string[],
- "standIn": string,
- }
The variable as it is kept, with its hosts from now on.
Path
idrequiredstring | e.g. "tpl_0123456789abcdef" |
namerequiredstring | e.g. "DATABASE_URL" |
Headers
AuthorizationrequiredBearer key | An API key that may make this call. |
Body
hostsrequiredarray of string | 1 to 10 hosts its value may be sent to, over HTTPS: hostnames, as api.github.com, and wildcards, as *.example.com, which cover every name under example.com and not example.com itself. Lowercase, with no scheme, port, path or address. A name on the Public Suffix List, private section included, is refused, and so is a wildcard directly over one: *.com, *.co.uk, *.github.io. e.g. ["api.github.com","github.com"] |
Returns
200 The variable as it is kept, with its hosts from now on.
namehiddenMore
Its value is never given back, to its owner or anyone.hostsstandInMore
It stays the same when the value is replaced, so a file that holds it keeps working, and it is the same in every sandbox on a template. Sent anywhere but its hosts it is worth nothing.Errors and other answers
| 400 | invalid_request the name or value is not one that can be kept. |
| 400 | invalid_host a host cannot be one, or there are none or more than 10, and the message says which and why. |
| 404 | Not found. |
| 409 | not_hidden the variable is plain: its commands read its value. |
| 409 | hosts_widened a host is not among those it is sent to now, and sending it somewhere new needs its value. Nothing was changed. |
| 501 | hidden_variables_unavailable hosts were sent where GET /v1/policy says hiddenVariables is false. Nothing was changed. |
Every error answers { "error": { "code", "message" } }; a key without the action a call needs answers 403 key_action_forbidden, naming it.