feat: evaluate dynamic parameters http endpoint (#18182)

Used when a websocket is too heavy. This implements a single request to
the preview engine.
This commit is contained in:
Steven Masley
2025-06-02 13:50:07 -05:00
committed by GitHub
parent 322f1e4dd2
commit 246a829ea9
6 changed files with 1154 additions and 61 deletions

View File

@ -3281,6 +3281,35 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
| `workspace_prebuilds` | [codersdk.PrebuildsConfig](#codersdkprebuildsconfig) | false | | |
| `write_config` | boolean | false | | |
## codersdk.DiagnosticExtra
```json
{
"code": "string"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|--------|--------|----------|--------------|-------------|
| `code` | string | false | | |
## codersdk.DiagnosticSeverityString
```json
"error"
```
### Properties
#### Enumerated Values
| Value |
|-----------|
| `error` |
| `warning` |
## codersdk.DisplayApp
```json
@ -3299,6 +3328,111 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
| `port_forwarding_helper` |
| `ssh_helper` |
## codersdk.DynamicParametersRequest
```json
{
"id": 0,
"inputs": {
"property1": "string",
"property2": "string"
},
"owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|--------------------|---------|----------|--------------|--------------------------------------------------------------------------------------------------------------|
| `id` | integer | false | | ID identifies the request. The response contains the same ID so that the client can match it to the request. |
| `inputs` | object | false | | |
| » `[any property]` | string | false | | |
| `owner_id` | string | false | | Owner ID if uuid.Nil, it defaults to `codersdk.Me` |
## codersdk.DynamicParametersResponse
```json
{
"diagnostics": [
{
"detail": "string",
"extra": {
"code": "string"
},
"severity": "error",
"summary": "string"
}
],
"id": 0,
"parameters": [
{
"default_value": {
"valid": true,
"value": "string"
},
"description": "string",
"diagnostics": [
{
"detail": "string",
"extra": {
"code": "string"
},
"severity": "error",
"summary": "string"
}
],
"display_name": "string",
"ephemeral": true,
"form_type": "",
"icon": "string",
"mutable": true,
"name": "string",
"options": [
{
"description": "string",
"icon": "string",
"name": "string",
"value": {
"valid": true,
"value": "string"
}
}
],
"order": 0,
"required": true,
"styling": {
"disabled": true,
"label": "string",
"placeholder": "string"
},
"type": "string",
"validations": [
{
"validation_error": "string",
"validation_max": 0,
"validation_min": 0,
"validation_monotonic": "string",
"validation_regex": "string"
}
],
"value": {
"valid": true,
"value": "string"
}
}
]
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|---------------|---------------------------------------------------------------------|----------|--------------|-------------|
| `diagnostics` | array of [codersdk.FriendlyDiagnostic](#codersdkfriendlydiagnostic) | false | | |
| `id` | integer | false | | |
| `parameters` | array of [codersdk.PreviewParameter](#codersdkpreviewparameter) | false | | |
## codersdk.Entitlement
```json
@ -3584,6 +3718,28 @@ Git clone makes use of this by parsing the URL from: 'Username for "https://gith
| `entitlement` | [codersdk.Entitlement](#codersdkentitlement) | false | | |
| `limit` | integer | false | | |
## codersdk.FriendlyDiagnostic
```json
{
"detail": "string",
"extra": {
"code": "string"
},
"severity": "error",
"summary": "string"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|------------|------------------------------------------------------------------------|----------|--------------|-------------|
| `detail` | string | false | | |
| `extra` | [codersdk.DiagnosticExtra](#codersdkdiagnosticextra) | false | | |
| `severity` | [codersdk.DiagnosticSeverityString](#codersdkdiagnosticseveritystring) | false | | |
| `summary` | string | false | | |
## codersdk.GenerateAPIKeyResponse
```json
@ -4548,6 +4704,22 @@ Git clone makes use of this by parsing the URL from: 'Username for "https://gith
|------------|----------------------------|----------|--------------|----------------------------------------------------------------------|
| `endpoint` | [serpent.URL](#serpenturl) | false | | The URL to which the payload will be sent with an HTTP POST request. |
## codersdk.NullHCLString
```json
{
"valid": true,
"value": "string"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|---------|---------|----------|--------------|-------------|
| `valid` | boolean | false | | |
| `value` | string | false | | |
## codersdk.OAuth2AppEndpoints
```json
@ -4818,6 +4990,23 @@ Git clone makes use of this by parsing the URL from: 'Username for "https://gith
| `user_roles_default` | array of string | false | | |
| `username_field` | string | false | | |
## codersdk.OptionType
```json
"string"
```
### Properties
#### Enumerated Values
| Value |
|----------------|
| `string` |
| `number` |
| `bool` |
| `list(string)` |
## codersdk.Organization
```json
@ -4985,6 +5174,30 @@ Git clone makes use of this by parsing the URL from: 'Username for "https://gith
| `count` | integer | false | | |
| `members` | array of [codersdk.OrganizationMemberWithUserData](#codersdkorganizationmemberwithuserdata) | false | | |
## codersdk.ParameterFormType
```json
""
```
### Properties
#### Enumerated Values
| Value |
|----------------|
| `` |
| `radio` |
| `slider` |
| `input` |
| `dropdown` |
| `checkbox` |
| `switch` |
| `multi-select` |
| `tag-select` |
| `textarea` |
| `error` |
## codersdk.PatchGroupIDPSyncConfigRequest
```json
@ -5319,6 +5532,150 @@ Git clone makes use of this by parsing the URL from: 'Username for "https://gith
| `name` | string | false | | |
| `value` | string | false | | |
## codersdk.PreviewParameter
```json
{
"default_value": {
"valid": true,
"value": "string"
},
"description": "string",
"diagnostics": [
{
"detail": "string",
"extra": {
"code": "string"
},
"severity": "error",
"summary": "string"
}
],
"display_name": "string",
"ephemeral": true,
"form_type": "",
"icon": "string",
"mutable": true,
"name": "string",
"options": [
{
"description": "string",
"icon": "string",
"name": "string",
"value": {
"valid": true,
"value": "string"
}
}
],
"order": 0,
"required": true,
"styling": {
"disabled": true,
"label": "string",
"placeholder": "string"
},
"type": "string",
"validations": [
{
"validation_error": "string",
"validation_max": 0,
"validation_min": 0,
"validation_monotonic": "string",
"validation_regex": "string"
}
],
"value": {
"valid": true,
"value": "string"
}
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|-----------------|-------------------------------------------------------------------------------------|----------|--------------|-----------------------------------------|
| `default_value` | [codersdk.NullHCLString](#codersdknullhclstring) | false | | |
| `description` | string | false | | |
| `diagnostics` | array of [codersdk.FriendlyDiagnostic](#codersdkfriendlydiagnostic) | false | | |
| `display_name` | string | false | | |
| `ephemeral` | boolean | false | | |
| `form_type` | [codersdk.ParameterFormType](#codersdkparameterformtype) | false | | |
| `icon` | string | false | | |
| `mutable` | boolean | false | | |
| `name` | string | false | | |
| `options` | array of [codersdk.PreviewParameterOption](#codersdkpreviewparameteroption) | false | | |
| `order` | integer | false | | legacy_variable_name was removed (= 14) |
| `required` | boolean | false | | |
| `styling` | [codersdk.PreviewParameterStyling](#codersdkpreviewparameterstyling) | false | | |
| `type` | [codersdk.OptionType](#codersdkoptiontype) | false | | |
| `validations` | array of [codersdk.PreviewParameterValidation](#codersdkpreviewparametervalidation) | false | | |
| `value` | [codersdk.NullHCLString](#codersdknullhclstring) | false | | |
## codersdk.PreviewParameterOption
```json
{
"description": "string",
"icon": "string",
"name": "string",
"value": {
"valid": true,
"value": "string"
}
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|---------------|--------------------------------------------------|----------|--------------|-------------|
| `description` | string | false | | |
| `icon` | string | false | | |
| `name` | string | false | | |
| `value` | [codersdk.NullHCLString](#codersdknullhclstring) | false | | |
## codersdk.PreviewParameterStyling
```json
{
"disabled": true,
"label": "string",
"placeholder": "string"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|---------------|---------|----------|--------------|-------------|
| `disabled` | boolean | false | | |
| `label` | string | false | | |
| `placeholder` | string | false | | |
## codersdk.PreviewParameterValidation
```json
{
"validation_error": "string",
"validation_max": 0,
"validation_min": 0,
"validation_monotonic": "string",
"validation_regex": "string"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|------------------------|---------|----------|--------------|-----------------------------------------|
| `validation_error` | string | false | | |
| `validation_max` | integer | false | | |
| `validation_min` | integer | false | | |
| `validation_monotonic` | string | false | | |
| `validation_regex` | string | false | | All validation attributes are optional. |
## codersdk.PrometheusConfig
```json

View File

@ -2593,7 +2593,6 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/d
| Name | In | Type | Required | Description |
|-------------------|------|--------------|----------|---------------------|
| `user` | path | string(uuid) | true | Template version ID |
| `templateversion` | path | string(uuid) | true | Template version ID |
### Responses
@ -2604,6 +2603,125 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/d
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Evaluate dynamic parameters for template version
### Code samples
```shell
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/templateversions/{templateversion}/dynamic-parameters/evaluate \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```
`POST /templateversions/{templateversion}/dynamic-parameters/evaluate`
> Body parameter
```json
{
"id": 0,
"inputs": {
"property1": "string",
"property2": "string"
},
"owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05"
}
```
### Parameters
| Name | In | Type | Required | Description |
|-------------------|------|----------------------------------------------------------------------------------|----------|--------------------------|
| `templateversion` | path | string(uuid) | true | Template version ID |
| `body` | body | [codersdk.DynamicParametersRequest](schemas.md#codersdkdynamicparametersrequest) | true | Initial parameter values |
### Example responses
> 200 Response
```json
{
"diagnostics": [
{
"detail": "string",
"extra": {
"code": "string"
},
"severity": "error",
"summary": "string"
}
],
"id": 0,
"parameters": [
{
"default_value": {
"valid": true,
"value": "string"
},
"description": "string",
"diagnostics": [
{
"detail": "string",
"extra": {
"code": "string"
},
"severity": "error",
"summary": "string"
}
],
"display_name": "string",
"ephemeral": true,
"form_type": "",
"icon": "string",
"mutable": true,
"name": "string",
"options": [
{
"description": "string",
"icon": "string",
"name": "string",
"value": {
"valid": true,
"value": "string"
}
}
],
"order": 0,
"required": true,
"styling": {
"disabled": true,
"label": "string",
"placeholder": "string"
},
"type": "string",
"validations": [
{
"validation_error": "string",
"validation_max": 0,
"validation_min": 0,
"validation_monotonic": "string",
"validation_regex": "string"
}
],
"value": {
"valid": true,
"value": "string"
}
}
]
}
```
### Responses
| Status | Meaning | Description | Schema |
|--------|---------------------------------------------------------|-------------|------------------------------------------------------------------------------------|
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.DynamicParametersResponse](schemas.md#codersdkdynamicparametersresponse) |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Get external auth by template version
### Code samples