mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add GET /api/v2/templatebuilder/bases endpoint (#26116)
Implement `GET /api/v2/templatebuilder/bases`, which returns the list of base templates available in the template builder. Reads from the bundled catalog by cross-referencing `templatebuilder.BaseTemplateIDs()` with `examples.List()`, enriching each entry with the OS from the `exampleID -> OS` map. The endpoint is gated behind the template builder feature flag (returns 404 when disabled) and requires `policy.ActionRead` on `rbac.ResourceTemplate`. Depends on #26115 > [!NOTE] > This PR was authored by Coder Agents on behalf of @jeremyruppel.
This commit is contained in:
@@ -1611,6 +1611,10 @@
|
||||
"title": "Tasks",
|
||||
"path": "./reference/api/tasks.md"
|
||||
},
|
||||
{
|
||||
"title": "TemplateBuilder",
|
||||
"path": "./reference/api/templatebuilder.md"
|
||||
},
|
||||
{
|
||||
"title": "Templates",
|
||||
"path": "./reference/api/templates.md"
|
||||
|
||||
Generated
+44
@@ -12046,6 +12046,50 @@ Restarts will only happen on weekdays in this list on weeks which line up with W
|
||||
|------------------|------------------------------------------------------|----------|--------------|-------------|
|
||||
| `[any property]` | [codersdk.TransitionStats](#codersdktransitionstats) | false | | |
|
||||
|
||||
## codersdk.TemplateBuilderBase
|
||||
|
||||
```json
|
||||
{
|
||||
"description": "string",
|
||||
"icon": "string",
|
||||
"id": "string",
|
||||
"name": "string",
|
||||
"os": "string"
|
||||
}
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|---------------|--------|----------|--------------|-------------|
|
||||
| `description` | string | false | | |
|
||||
| `icon` | string | false | | |
|
||||
| `id` | string | false | | |
|
||||
| `name` | string | false | | |
|
||||
| `os` | string | false | | |
|
||||
|
||||
## codersdk.TemplateBuilderBasesResponse
|
||||
|
||||
```json
|
||||
{
|
||||
"bases": [
|
||||
{
|
||||
"description": "string",
|
||||
"icon": "string",
|
||||
"id": "string",
|
||||
"name": "string",
|
||||
"os": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|---------|-----------------------------------------------------------------------|----------|--------------|-------------|
|
||||
| `bases` | array of [codersdk.TemplateBuilderBase](#codersdktemplatebuilderbase) | false | | |
|
||||
|
||||
## codersdk.TemplateBuilderConfig
|
||||
|
||||
```json
|
||||
|
||||
Generated
+40
@@ -0,0 +1,40 @@
|
||||
# TemplateBuilder
|
||||
|
||||
## List template builder base templates
|
||||
|
||||
### Code samples
|
||||
|
||||
```shell
|
||||
# Example request using curl
|
||||
curl -X GET http://coder-server:8080/api/v2/templatebuilder/bases \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Coder-Session-Token: API_KEY'
|
||||
```
|
||||
|
||||
`GET /api/v2/templatebuilder/bases`
|
||||
|
||||
### Example responses
|
||||
|
||||
> 200 Response
|
||||
|
||||
```json
|
||||
{
|
||||
"bases": [
|
||||
{
|
||||
"description": "string",
|
||||
"icon": "string",
|
||||
"id": "string",
|
||||
"name": "string",
|
||||
"os": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
| Status | Meaning | Description | Schema |
|
||||
|--------|---------------------------------------------------------|-------------|------------------------------------------------------------------------------------------|
|
||||
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.TemplateBuilderBasesResponse](schemas.md#codersdktemplatebuilderbasesresponse) |
|
||||
|
||||
To perform this operation, you must be authenticated. [Learn more](authentication.md).
|
||||
Reference in New Issue
Block a user