feat: add user-level parameter autofill (#11731)

This PR solves #10478 by auto-filling previously used template values in create and update workspace flows.

I decided against explicit user values in settings for these reasons:

* Autofill is far easier to implement
* Users benefit from autofill _by default_ — we don't need to teach them new concepts
* If we decide that autofill creates more harm than good, we can remove it without breaking compatibility
This commit is contained in:
Ammar Bandukwala
2024-01-30 16:02:21 -06:00
committed by GitHub
parent aeb4112513
commit adbb025e74
44 changed files with 862 additions and 137 deletions
+51
View File
@@ -513,6 +513,57 @@ curl -X PUT http://coder-server:8080/api/v2/users/{user}/appearance \
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Get autofill build parameters for user
### Code samples
```shell
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/autofill-parameters?template_id=string \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```
`GET /users/{user}/autofill-parameters`
### Parameters
| Name | In | Type | Required | Description |
| ------------- | ----- | ------ | -------- | ------------------------ |
| `user` | path | string | true | User ID, username, or me |
| `template_id` | query | string | true | Template ID |
### Example responses
> 200 Response
```json
[
{
"name": "string",
"value": "string"
}
]
```
### Responses
| Status | Meaning | Description | Schema |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------------- |
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | array of [codersdk.UserParameter](schemas.md#codersdkuserparameter) |
<h3 id="get-autofill-build-parameters-for-user-responseschema">Response Schema</h3>
Status Code **200**
| Name | Type | Required | Restrictions | Description |
| -------------- | ------ | -------- | ------------ | ----------- |
| `[array item]` | array | false | | |
| `» name` | string | false | | |
| `» value` | string | false | | |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Get user Git SSH key
### Code samples