diff --git a/api/swagger.json b/api/swagger.json index c9c36de1..cbad2856 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -958,8 +958,11 @@ "/api/user/{id}": { "post": { "description": "Allows admins to add/remove roles and projects for a user", + "consumes": [ + "application/json" + ], "produces": [ - "text/plain" + "application/json" ], "tags": [ "User" @@ -974,35 +977,26 @@ "required": true }, { - "type": "string", - "description": "Role to add", - "name": "add-role", - "in": "formData" - }, - { - "type": "string", - "description": "Role to remove", - "name": "remove-role", - "in": "formData" - }, - { - "type": "string", - "description": "Project to add", - "name": "add-project", - "in": "formData" - }, - { - "type": "string", - "description": "Project to remove", - "name": "remove-project", - "in": "formData" + "description": "Single Field Changes", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api.UpdateUserAPIRequest" + } } ], "responses": { "200": { - "description": "Success message", + "description": "OK", "schema": { - "type": "string" + "$ref": "#/definitions/api.DefaultAPIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" } }, "403": { @@ -1933,6 +1927,31 @@ } } }, + "api.UpdateUserAPIRequest": { + "type": "object", + "properties": { + "add-role": { + "description": "Role to add to user $ID", + "type": "string", + "example": "user" + }, + "remove-role": { + "description": "Role to remove from user $ID", + "type": "string", + "example": "user" + }, + "add-project": { + "description": "Project to add to user $ID managed array", + "type": "string", + "example": "abcd100" + }, + "remove-project": { + "description": "Project to remove from user $ID managed array", + "type": "string", + "example": "abcd100" + } + } + }, "api.DefaultAPIResponse": { "type": "object", "properties": { diff --git a/api/swagger.yaml b/api/swagger.yaml index def939dd..7aa215eb 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -31,6 +31,25 @@ definitions: example: Debug type: string type: object + api.UpdateUserAPIRequest: + properties: + add-project: + description: Project to add to user $ID managed array + example: abcd100 + type: string + add-role: + description: Role to add to user $ID + example: user + type: string + remove-project: + description: Project to remove from user $ID managed array + example: abcd100 + type: string + remove-role: + description: Role to remove from user $ID + example: user + type: string + type: object api.DefaultAPIResponse: properties: msg: @@ -1388,6 +1407,8 @@ paths: - Nodestates /api/user/{id}: post: + consumes: + - application/json description: Allows admins to add/remove roles and projects for a user parameters: - description: Username @@ -1395,29 +1416,23 @@ paths: name: id required: true type: string - - description: Role to add - in: formData - name: add-role - type: string - - description: Role to remove - in: formData - name: remove-role - type: string - - description: Project to add - in: formData - name: add-project - type: string - - description: Project to remove - in: formData - name: remove-project - type: string + - description: Single Field Changes + in: body + name: request + required: true + schema: + $ref: '#/definitions/api.UpdateUserAPIRequest' produces: - - text/plain + - application/json responses: "200": - description: Success message + description: OK schema: - type: string + $ref: '#/definitions/api.DefaultAPIResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.ErrorResponse' "403": description: Forbidden schema: diff --git a/internal/api/docs.go b/internal/api/docs.go index de3cf506..2c3b0540 100644 --- a/internal/api/docs.go +++ b/internal/api/docs.go @@ -965,8 +965,11 @@ const docTemplate = `{ "/api/user/{id}": { "post": { "description": "Allows admins to add/remove roles and projects for a user", + "consumes": [ + "application/json" + ], "produces": [ - "text/plain" + "application/json" ], "tags": [ "User" @@ -981,35 +984,26 @@ const docTemplate = `{ "required": true }, { - "type": "string", - "description": "Role to add", - "name": "add-role", - "in": "formData" - }, - { - "type": "string", - "description": "Role to remove", - "name": "remove-role", - "in": "formData" - }, - { - "type": "string", - "description": "Project to add", - "name": "add-project", - "in": "formData" - }, - { - "type": "string", - "description": "Project to remove", - "name": "remove-project", - "in": "formData" + "description": "Single Field Changes", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api.UpdateUserAPIRequest" + } } ], "responses": { "200": { - "description": "Success message", + "description": "OK", "schema": { - "type": "string" + "$ref": "#/definitions/api.DefaultAPIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" } }, "403": { @@ -1940,6 +1934,31 @@ const docTemplate = `{ } } }, + "api.UpdateUserAPIRequest": { + "type": "object", + "properties": { + "add-role": { + "description": "Role to add to user $ID", + "type": "string", + "example": "user" + }, + "remove-role": { + "description": "Role to remove from user $ID", + "type": "string", + "example": "user" + }, + "add-project": { + "description": "Project to add to user $ID managed array", + "type": "string", + "example": "abcd100" + }, + "remove-project": { + "description": "Project to remove from user $ID managed array", + "type": "string", + "example": "abcd100" + } + } + }, "api.DefaultAPIResponse": { "type": "object", "properties": {