From 83deb3c2f088270407c78bdd087175c844c3516b Mon Sep 17 00:00:00 2001 From: Colin Adler Date: Tue, 15 Aug 2023 02:26:09 +0000 Subject: [PATCH 1/2] chore: add request body to patch groups openapi spec --- coderd/apidoc/docs.go | 38 +++++++++++++++++++++++++++++++++++++ coderd/apidoc/swagger.json | 38 +++++++++++++++++++++++++++++++++++++ docs/api/enterprise.md | 21 +++++++++++++++++--- docs/api/schemas.md | 24 +++++++++++++++++++++++ enterprise/coderd/groups.go | 1 + 5 files changed, 119 insertions(+), 3 deletions(-) diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 406fe15e422fa..058c22a5a2d05 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -860,6 +860,15 @@ const docTemplate = `{ "name": "group", "in": "path", "required": true + }, + { + "description": "Patch group request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/codersdk.PatchGroupRequest" + } } ], "responses": { @@ -8727,6 +8736,35 @@ const docTemplate = `{ } } }, + "codersdk.PatchGroupRequest": { + "type": "object", + "properties": { + "add_users": { + "type": "array", + "items": { + "type": "string" + } + }, + "avatar_url": { + "type": "string" + }, + "display_name": { + "type": "string" + }, + "name": { + "type": "string" + }, + "quota_allowance": { + "type": "integer" + }, + "remove_users": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "codersdk.PatchTemplateVersionRequest": { "type": "object", "properties": { diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index c0c71d2888337..fd3df773dbdc5 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -740,6 +740,15 @@ "name": "group", "in": "path", "required": true + }, + { + "description": "Patch group request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/codersdk.PatchGroupRequest" + } } ], "responses": { @@ -7835,6 +7844,35 @@ } } }, + "codersdk.PatchGroupRequest": { + "type": "object", + "properties": { + "add_users": { + "type": "array", + "items": { + "type": "string" + } + }, + "avatar_url": { + "type": "string" + }, + "display_name": { + "type": "string" + }, + "name": { + "type": "string" + }, + "quota_allowance": { + "type": "integer" + }, + "remove_users": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "codersdk.PatchTemplateVersionRequest": { "type": "object", "properties": { diff --git a/docs/api/enterprise.md b/docs/api/enterprise.md index 15ba8c12b4ea3..ed65fe332efae 100644 --- a/docs/api/enterprise.md +++ b/docs/api/enterprise.md @@ -279,17 +279,32 @@ To perform this operation, you must be authenticated. [Learn more](authenticatio ```shell # Example request using curl curl -X PATCH http://coder-server:8080/api/v2/groups/{group} \ + -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Coder-Session-Token: API_KEY' ``` `PATCH /groups/{group}` +> Body parameter + +```json +{ + "add_users": ["string"], + "avatar_url": "string", + "display_name": "string", + "name": "string", + "quota_allowance": 0, + "remove_users": ["string"] +} +``` + ### Parameters -| Name | In | Type | Required | Description | -| ------- | ---- | ------ | -------- | ----------- | -| `group` | path | string | true | Group name | +| Name | In | Type | Required | Description | +| ------- | ---- | ------------------------------------------------------------------ | -------- | ------------------- | +| `group` | path | string | true | Group name | +| `body` | body | [codersdk.PatchGroupRequest](schemas.md#codersdkpatchgrouprequest) | true | Patch group request | ### Example responses diff --git a/docs/api/schemas.md b/docs/api/schemas.md index f40e8e65486f0..b053464f82f1c 100644 --- a/docs/api/schemas.md +++ b/docs/api/schemas.md @@ -3459,6 +3459,30 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in | `updated_at` | string | false | | | | `user_id` | string | false | | | +## codersdk.PatchGroupRequest + +```json +{ + "add_users": ["string"], + "avatar_url": "string", + "display_name": "string", + "name": "string", + "quota_allowance": 0, + "remove_users": ["string"] +} +``` + +### Properties + +| Name | Type | Required | Restrictions | Description | +| ----------------- | --------------- | -------- | ------------ | ----------- | +| `add_users` | array of string | false | | | +| `avatar_url` | string | false | | | +| `display_name` | string | false | | | +| `name` | string | false | | | +| `quota_allowance` | integer | false | | | +| `remove_users` | array of string | false | | | + ## codersdk.PatchTemplateVersionRequest ```json diff --git a/enterprise/coderd/groups.go b/enterprise/coderd/groups.go index 5119f3f91a5d8..1025dbc08c2a9 100644 --- a/enterprise/coderd/groups.go +++ b/enterprise/coderd/groups.go @@ -84,6 +84,7 @@ func (api *API) postGroupByOrganization(rw http.ResponseWriter, r *http.Request) // @Produce json // @Tags Enterprise // @Param group path string true "Group name" +// @Param request body codersdk.PatchGroupRequest true "Patch group request" // @Success 200 {object} codersdk.Group // @Router /groups/{group} [patch] func (api *API) patchGroup(rw http.ResponseWriter, r *http.Request) { From 1a542e67710bf88bf9777f9f988fc323d8ce3edc Mon Sep 17 00:00:00 2001 From: Colin Adler Date: Tue, 15 Aug 2023 14:50:53 +0000 Subject: [PATCH 2/2] fixup! chore: add request body to patch groups openapi spec --- coderd/apidoc/docs.go | 3 +++ coderd/apidoc/swagger.json | 1 + enterprise/coderd/groups.go | 1 + 3 files changed, 5 insertions(+) diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 058c22a5a2d05..93f4a13d8e24e 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -845,6 +845,9 @@ const docTemplate = `{ "CoderSessionToken": [] } ], + "consumes": [ + "application/json" + ], "produces": [ "application/json" ], diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index fd3df773dbdc5..d47dc092b6b02 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -729,6 +729,7 @@ "CoderSessionToken": [] } ], + "consumes": ["application/json"], "produces": ["application/json"], "tags": ["Enterprise"], "summary": "Update group by name", diff --git a/enterprise/coderd/groups.go b/enterprise/coderd/groups.go index 1025dbc08c2a9..91210480b2a84 100644 --- a/enterprise/coderd/groups.go +++ b/enterprise/coderd/groups.go @@ -81,6 +81,7 @@ func (api *API) postGroupByOrganization(rw http.ResponseWriter, r *http.Request) // @Summary Update group by name // @ID update-group-by-name // @Security CoderSessionToken +// @Accept json // @Produce json // @Tags Enterprise // @Param group path string true "Group name"