feat: archive template versions to hide them from the ui (#10179)

* api + cli implementation
This commit is contained in:
Steven Masley
2023-10-11 09:26:22 -05:00
committed by GitHub
parent edbd51955c
commit 1e950fa9a8
35 changed files with 1472 additions and 38 deletions
+16
View File
@@ -987,6 +987,20 @@ _None_
| `service_banner` | [codersdk.ServiceBannerConfig](#codersdkservicebannerconfig) | false | | |
| `support_links` | array of [codersdk.LinkConfig](#codersdklinkconfig) | false | | |
## codersdk.ArchiveTemplateVersionsRequest
```json
{
"all": true
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
| ----- | ------- | -------- | ------------ | ------------------------------------------------------------------------------------------------------------------------ |
| `all` | boolean | false | | By default, only failed versions are archived. Set this to true to archive all unused versions regardless of job status. |
## codersdk.AssignableRoles
```json
@@ -4709,6 +4723,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
```json
{
"archived": true,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"avatar_url": "http://example.com",
@@ -4748,6 +4763,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
| Name | Type | Required | Restrictions | Description |
| ----------------- | --------------------------------------------------------------------------- | -------- | ------------ | ----------- |
| `archived` | boolean | false | | |
| `created_at` | string | false | | |
| `created_by` | [codersdk.MinimalUser](#codersdkminimaluser) | false | | |
| `id` | string | false | | |
+151
View File
@@ -373,6 +373,7 @@ curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/templat
```json
{
"archived": true,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"avatar_url": "http://example.com",
@@ -443,6 +444,7 @@ curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/templat
```json
{
"archived": true,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"avatar_url": "http://example.com",
@@ -537,6 +539,7 @@ curl -X POST http://coder-server:8080/api/v2/organizations/{organization}/templa
```json
{
"archived": true,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"avatar_url": "http://example.com",
@@ -838,6 +841,7 @@ curl -X GET http://coder-server:8080/api/v2/templates/{template}/versions \
```json
[
{
"archived": true,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"avatar_url": "http://example.com",
@@ -887,6 +891,7 @@ Status Code **200**
| Name | Type | Required | Restrictions | Description |
| -------------------- | ------------------------------------------------------------------------ | -------- | ------------ | ----------- |
| `[array item]` | array | false | | |
| `» archived` | boolean | false | | |
| `» created_at` | string(date-time) | false | | |
| `» created_by` | [codersdk.MinimalUser](schemas.md#codersdkminimaluser) | false | | |
| `»» avatar_url` | string(uri) | false | | |
@@ -984,6 +989,60 @@ curl -X PATCH http://coder-server:8080/api/v2/templates/{template}/versions \
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Archive template unused versions by template id
### Code samples
```shell
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/templates/{template}/versions/archive \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```
`POST /templates/{template}/versions/archive`
> Body parameter
```json
{
"all": true
}
```
### Parameters
| Name | In | Type | Required | Description |
| ---------- | ---- | -------------------------------------------------------------------------------------------- | -------- | --------------- |
| `template` | path | string(uuid) | true | Template ID |
| `body` | body | [codersdk.ArchiveTemplateVersionsRequest](schemas.md#codersdkarchivetemplateversionsrequest) | true | Archive request |
### Example responses
> 200 Response
```json
{
"detail": "string",
"message": "string",
"validations": [
{
"detail": "string",
"field": "string"
}
]
}
```
### Responses
| Status | Meaning | Description | Schema |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------ |
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.Response](schemas.md#codersdkresponse) |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Get template version by template ID and name
### Code samples
@@ -1011,6 +1070,7 @@ curl -X GET http://coder-server:8080/api/v2/templates/{template}/versions/{templ
```json
[
{
"archived": true,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"avatar_url": "http://example.com",
@@ -1060,6 +1120,7 @@ Status Code **200**
| Name | Type | Required | Restrictions | Description |
| -------------------- | ------------------------------------------------------------------------ | -------- | ------------ | ----------- |
| `[array item]` | array | false | | |
| `» archived` | boolean | false | | |
| `» created_at` | string(date-time) | false | | |
| `» created_by` | [codersdk.MinimalUser](schemas.md#codersdkminimaluser) | false | | |
| `»» avatar_url` | string(uri) | false | | |
@@ -1128,6 +1189,7 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion} \
```json
{
"archived": true,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"avatar_url": "http://example.com",
@@ -1207,6 +1269,7 @@ curl -X PATCH http://coder-server:8080/api/v2/templateversions/{templateversion}
```json
{
"archived": true,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"avatar_url": "http://example.com",
@@ -1250,6 +1313,50 @@ curl -X PATCH http://coder-server:8080/api/v2/templateversions/{templateversion}
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Archive template version
### Code samples
```shell
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/templateversions/{templateversion}/archive \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```
`POST /templateversions/{templateversion}/archive`
### Parameters
| Name | In | Type | Required | Description |
| ----------------- | ---- | ------------ | -------- | ------------------- |
| `templateversion` | path | string(uuid) | true | Template version ID |
### Example responses
> 200 Response
```json
{
"detail": "string",
"message": "string",
"validations": [
{
"detail": "string",
"field": "string"
}
]
}
```
### Responses
| Status | Meaning | Description | Schema |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------ |
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.Response](schemas.md#codersdkresponse) |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Cancel template version by ID
### Code samples
@@ -2342,6 +2449,50 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/s
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Unarchive template version
### Code samples
```shell
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/templateversions/{templateversion}/unarchive \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```
`POST /templateversions/{templateversion}/unarchive`
### Parameters
| Name | In | Type | Required | Description |
| ----------------- | ---- | ------------ | -------- | ------------------- |
| `templateversion` | path | string(uuid) | true | Template version ID |
### Example responses
> 200 Response
```json
{
"detail": "string",
"message": "string",
"validations": [
{
"detail": "string",
"field": "string"
}
]
}
```
### Responses
| Status | Meaning | Description | Schema |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------ |
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.Response](schemas.md#codersdkresponse) |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Get template variables by template version
### Code samples