mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-25 12:59:06 +01:00
Improve user endpoint swagger docs
This commit is contained in:
parent
f6c4c963ec
commit
f36f62fb47
108
api/swagger.json
108
api/swagger.json
@ -735,14 +735,28 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"enum": [
|
||||||
|
"admin",
|
||||||
|
"support",
|
||||||
|
"manager",
|
||||||
|
"user",
|
||||||
|
"api"
|
||||||
|
],
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Priority 1: Role to add, one of: [admin, support, manager, user, api]",
|
"description": "Priority 1: Role to add",
|
||||||
"name": "add-role",
|
"name": "add-role",
|
||||||
"in": "formData"
|
"in": "formData"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"enum": [
|
||||||
|
"admin",
|
||||||
|
"support",
|
||||||
|
"manager",
|
||||||
|
"user",
|
||||||
|
"api"
|
||||||
|
],
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Priority 2: Role to remove, one of: [admin, support, manager, user, api]",
|
"description": "Priority 2: Role to remove",
|
||||||
"name": "remove-role",
|
"name": "remove-role",
|
||||||
"in": "formData"
|
"in": "formData"
|
||||||
},
|
},
|
||||||
@ -761,7 +775,7 @@
|
|||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Task successful",
|
"description": "Success Response Message",
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
@ -769,31 +783,31 @@
|
|||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request",
|
"description": "Bad Request",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"401": {
|
"401": {
|
||||||
"description": "Unauthorized",
|
"description": "Unauthorized",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"403": {
|
"403": {
|
||||||
"description": "Forbidden",
|
"description": "Forbidden",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"422": {
|
"422": {
|
||||||
"description": "Unprocessable Entity: The user could not be updated",
|
"description": "Unprocessable Entity: The user could not be updated",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"500": {
|
"500": {
|
||||||
"description": "Internal Server Error",
|
"description": "Internal Server Error",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -807,9 +821,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Returns a JSON-encoded list of users.\nRequired query-parameter defines if all users or only users with additional special roles are returned.",
|
"description": "Returns a JSON-encoded list of users.\nRequired query-parameter defines if all users or only users with additional special roles are returned.",
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
"produces": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@ -828,33 +839,36 @@
|
|||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Users returned successfully",
|
"description": "List of users returned successfully",
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/api.ApiReturnedUser"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request",
|
"description": "Bad Request",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"401": {
|
"401": {
|
||||||
"description": "Unauthorized",
|
"description": "Unauthorized",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"403": {
|
"403": {
|
||||||
"description": "Forbidden",
|
"description": "Forbidden",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"500": {
|
"500": {
|
||||||
"description": "Internal Server Error",
|
"description": "Internal Server Error",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -892,8 +906,15 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"enum": [
|
||||||
|
"admin",
|
||||||
|
"support",
|
||||||
|
"manager",
|
||||||
|
"user",
|
||||||
|
"api"
|
||||||
|
],
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "User role, one of: [admin, support, manager, user, api]",
|
"description": "User role",
|
||||||
"name": "role",
|
"name": "role",
|
||||||
"in": "formData",
|
"in": "formData",
|
||||||
"required": true
|
"required": true
|
||||||
@ -919,7 +940,7 @@
|
|||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "User added successfully",
|
"description": "Success Response",
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
@ -927,31 +948,31 @@
|
|||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request",
|
"description": "Bad Request",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"401": {
|
"401": {
|
||||||
"description": "Unauthorized",
|
"description": "Unauthorized",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"403": {
|
"403": {
|
||||||
"description": "Forbidden",
|
"description": "Forbidden",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"422": {
|
"422": {
|
||||||
"description": "Unprocessable Entity: creating user failed",
|
"description": "Unprocessable Entity: creating user failed",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"500": {
|
"500": {
|
||||||
"description": "Internal Server Error",
|
"description": "Internal Server Error",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -966,6 +987,9 @@
|
|||||||
"consumes": [
|
"consumes": [
|
||||||
"multipart/form-data"
|
"multipart/form-data"
|
||||||
],
|
],
|
||||||
|
"produces": [
|
||||||
|
"text/plain"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"remove"
|
"remove"
|
||||||
],
|
],
|
||||||
@ -986,31 +1010,31 @@
|
|||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request",
|
"description": "Bad Request",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"401": {
|
"401": {
|
||||||
"description": "Unauthorized",
|
"description": "Unauthorized",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"403": {
|
"403": {
|
||||||
"description": "Forbidden",
|
"description": "Forbidden",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"422": {
|
"422": {
|
||||||
"description": "Unprocessable Entity: deleting user failed",
|
"description": "Unprocessable Entity: deleting user failed",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"500": {
|
"500": {
|
||||||
"description": "Internal Server Error",
|
"description": "Internal Server Error",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1018,6 +1042,32 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
|
"api.ApiReturnedUser": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"email": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"projects": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"roles": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"username": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"api.ApiTag": {
|
"api.ApiTag": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -1,5 +1,22 @@
|
|||||||
basePath: /api
|
basePath: /api
|
||||||
definitions:
|
definitions:
|
||||||
|
api.ApiReturnedUser:
|
||||||
|
properties:
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
projects:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
roles:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
username:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
api.ApiTag:
|
api.ApiTag:
|
||||||
properties:
|
properties:
|
||||||
name:
|
name:
|
||||||
@ -1007,13 +1024,23 @@ paths:
|
|||||||
name: id
|
name: id
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
- description: 'Priority 1: Role to add, one of: [admin, support, manager, user,
|
- description: 'Priority 1: Role to add'
|
||||||
api]'
|
enum:
|
||||||
|
- admin
|
||||||
|
- support
|
||||||
|
- manager
|
||||||
|
- user
|
||||||
|
- api
|
||||||
in: formData
|
in: formData
|
||||||
name: add-role
|
name: add-role
|
||||||
type: string
|
type: string
|
||||||
- description: 'Priority 2: Role to remove, one of: [admin, support, manager,
|
- description: 'Priority 2: Role to remove'
|
||||||
user, api]'
|
enum:
|
||||||
|
- admin
|
||||||
|
- support
|
||||||
|
- manager
|
||||||
|
- user
|
||||||
|
- api
|
||||||
in: formData
|
in: formData
|
||||||
name: remove-role
|
name: remove-role
|
||||||
type: string
|
type: string
|
||||||
@ -1029,29 +1056,29 @@ paths:
|
|||||||
- text/plain
|
- text/plain
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Task successful
|
description: Success Response Message
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
"400":
|
"400":
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"401":
|
"401":
|
||||||
description: Unauthorized
|
description: Unauthorized
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"403":
|
"403":
|
||||||
description: Forbidden
|
description: Forbidden
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"422":
|
"422":
|
||||||
description: 'Unprocessable Entity: The user could not be updated'
|
description: 'Unprocessable Entity: The user could not be updated'
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"500":
|
"500":
|
||||||
description: Internal Server Error
|
description: Internal Server Error
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
security:
|
security:
|
||||||
- ApiKeyAuth: []
|
- ApiKeyAuth: []
|
||||||
summary: Updates an existing user
|
summary: Updates an existing user
|
||||||
@ -1068,37 +1095,37 @@ paths:
|
|||||||
name: username
|
name: username
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
produces:
|
||||||
|
- text/plain
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: User deleted successfully
|
description: User deleted successfully
|
||||||
"400":
|
"400":
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"401":
|
"401":
|
||||||
description: Unauthorized
|
description: Unauthorized
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"403":
|
"403":
|
||||||
description: Forbidden
|
description: Forbidden
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"422":
|
"422":
|
||||||
description: 'Unprocessable Entity: deleting user failed'
|
description: 'Unprocessable Entity: deleting user failed'
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"500":
|
"500":
|
||||||
description: Internal Server Error
|
description: Internal Server Error
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
security:
|
security:
|
||||||
- ApiKeyAuth: []
|
- ApiKeyAuth: []
|
||||||
summary: Deletes a user
|
summary: Deletes a user
|
||||||
tags:
|
tags:
|
||||||
- remove
|
- remove
|
||||||
get:
|
get:
|
||||||
consumes:
|
|
||||||
- application/json
|
|
||||||
description: |-
|
description: |-
|
||||||
Returns a JSON-encoded list of users.
|
Returns a JSON-encoded list of users.
|
||||||
Required query-parameter defines if all users or only users with additional special roles are returned.
|
Required query-parameter defines if all users or only users with additional special roles are returned.
|
||||||
@ -1113,25 +1140,27 @@ paths:
|
|||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Users returned successfully
|
description: List of users returned successfully
|
||||||
schema:
|
schema:
|
||||||
type: string
|
items:
|
||||||
|
$ref: '#/definitions/api.ApiReturnedUser'
|
||||||
|
type: array
|
||||||
"400":
|
"400":
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"401":
|
"401":
|
||||||
description: Unauthorized
|
description: Unauthorized
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"403":
|
"403":
|
||||||
description: Forbidden
|
description: Forbidden
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"500":
|
"500":
|
||||||
description: Internal Server Error
|
description: Internal Server Error
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
security:
|
security:
|
||||||
- ApiKeyAuth: []
|
- ApiKeyAuth: []
|
||||||
summary: Returns a list of users
|
summary: Returns a list of users
|
||||||
@ -1152,7 +1181,13 @@ paths:
|
|||||||
name: password
|
name: password
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
- description: 'User role, one of: [admin, support, manager, user, api]'
|
- description: User role
|
||||||
|
enum:
|
||||||
|
- admin
|
||||||
|
- support
|
||||||
|
- manager
|
||||||
|
- user
|
||||||
|
- api
|
||||||
in: formData
|
in: formData
|
||||||
name: role
|
name: role
|
||||||
required: true
|
required: true
|
||||||
@ -1173,29 +1208,29 @@ paths:
|
|||||||
- text/plain
|
- text/plain
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: User added successfully
|
description: Success Response
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
"400":
|
"400":
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"401":
|
"401":
|
||||||
description: Unauthorized
|
description: Unauthorized
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"403":
|
"403":
|
||||||
description: Forbidden
|
description: Forbidden
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"422":
|
"422":
|
||||||
description: 'Unprocessable Entity: creating user failed'
|
description: 'Unprocessable Entity: creating user failed'
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
"500":
|
"500":
|
||||||
description: Internal Server Error
|
description: Internal Server Error
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/api.ErrorResponse'
|
type: string
|
||||||
security:
|
security:
|
||||||
- ApiKeyAuth: []
|
- ApiKeyAuth: []
|
||||||
summary: Adds a new user
|
summary: Adds a new user
|
||||||
|
@ -741,14 +741,28 @@ const docTemplate = `{
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"enum": [
|
||||||
|
"admin",
|
||||||
|
"support",
|
||||||
|
"manager",
|
||||||
|
"user",
|
||||||
|
"api"
|
||||||
|
],
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Priority 1: Role to add, one of: [admin, support, manager, user, api]",
|
"description": "Priority 1: Role to add",
|
||||||
"name": "add-role",
|
"name": "add-role",
|
||||||
"in": "formData"
|
"in": "formData"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"enum": [
|
||||||
|
"admin",
|
||||||
|
"support",
|
||||||
|
"manager",
|
||||||
|
"user",
|
||||||
|
"api"
|
||||||
|
],
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Priority 2: Role to remove, one of: [admin, support, manager, user, api]",
|
"description": "Priority 2: Role to remove",
|
||||||
"name": "remove-role",
|
"name": "remove-role",
|
||||||
"in": "formData"
|
"in": "formData"
|
||||||
},
|
},
|
||||||
@ -767,7 +781,7 @@ const docTemplate = `{
|
|||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Task successful",
|
"description": "Success Response Message",
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
@ -775,31 +789,31 @@ const docTemplate = `{
|
|||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request",
|
"description": "Bad Request",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"401": {
|
"401": {
|
||||||
"description": "Unauthorized",
|
"description": "Unauthorized",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"403": {
|
"403": {
|
||||||
"description": "Forbidden",
|
"description": "Forbidden",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"422": {
|
"422": {
|
||||||
"description": "Unprocessable Entity: The user could not be updated",
|
"description": "Unprocessable Entity: The user could not be updated",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"500": {
|
"500": {
|
||||||
"description": "Internal Server Error",
|
"description": "Internal Server Error",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -813,9 +827,6 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Returns a JSON-encoded list of users.\nRequired query-parameter defines if all users or only users with additional special roles are returned.",
|
"description": "Returns a JSON-encoded list of users.\nRequired query-parameter defines if all users or only users with additional special roles are returned.",
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
"produces": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@ -834,33 +845,36 @@ const docTemplate = `{
|
|||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Users returned successfully",
|
"description": "List of users returned successfully",
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/api.ApiReturnedUser"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request",
|
"description": "Bad Request",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"401": {
|
"401": {
|
||||||
"description": "Unauthorized",
|
"description": "Unauthorized",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"403": {
|
"403": {
|
||||||
"description": "Forbidden",
|
"description": "Forbidden",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"500": {
|
"500": {
|
||||||
"description": "Internal Server Error",
|
"description": "Internal Server Error",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -898,8 +912,15 @@ const docTemplate = `{
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"enum": [
|
||||||
|
"admin",
|
||||||
|
"support",
|
||||||
|
"manager",
|
||||||
|
"user",
|
||||||
|
"api"
|
||||||
|
],
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "User role, one of: [admin, support, manager, user, api]",
|
"description": "User role",
|
||||||
"name": "role",
|
"name": "role",
|
||||||
"in": "formData",
|
"in": "formData",
|
||||||
"required": true
|
"required": true
|
||||||
@ -925,7 +946,7 @@ const docTemplate = `{
|
|||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "User added successfully",
|
"description": "Success Response",
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
@ -933,31 +954,31 @@ const docTemplate = `{
|
|||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request",
|
"description": "Bad Request",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"401": {
|
"401": {
|
||||||
"description": "Unauthorized",
|
"description": "Unauthorized",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"403": {
|
"403": {
|
||||||
"description": "Forbidden",
|
"description": "Forbidden",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"422": {
|
"422": {
|
||||||
"description": "Unprocessable Entity: creating user failed",
|
"description": "Unprocessable Entity: creating user failed",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"500": {
|
"500": {
|
||||||
"description": "Internal Server Error",
|
"description": "Internal Server Error",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -972,6 +993,9 @@ const docTemplate = `{
|
|||||||
"consumes": [
|
"consumes": [
|
||||||
"multipart/form-data"
|
"multipart/form-data"
|
||||||
],
|
],
|
||||||
|
"produces": [
|
||||||
|
"text/plain"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"remove"
|
"remove"
|
||||||
],
|
],
|
||||||
@ -992,31 +1016,31 @@ const docTemplate = `{
|
|||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request",
|
"description": "Bad Request",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"401": {
|
"401": {
|
||||||
"description": "Unauthorized",
|
"description": "Unauthorized",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"403": {
|
"403": {
|
||||||
"description": "Forbidden",
|
"description": "Forbidden",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"422": {
|
"422": {
|
||||||
"description": "Unprocessable Entity: deleting user failed",
|
"description": "Unprocessable Entity: deleting user failed",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"500": {
|
"500": {
|
||||||
"description": "Internal Server Error",
|
"description": "Internal Server Error",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/api.ErrorResponse"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1024,6 +1048,32 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
|
"api.ApiReturnedUser": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"email": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"projects": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"roles": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"username": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"api.ApiTag": {
|
"api.ApiTag": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -163,6 +163,14 @@ type JobMetricWithName struct {
|
|||||||
Metric *schema.JobMetric `json:"metric"`
|
Metric *schema.JobMetric `json:"metric"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ApiReturnedUser struct {
|
||||||
|
Username string `json:"username"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Roles []string `json:"roles"`
|
||||||
|
Email string `json:"email"`
|
||||||
|
Projects []string `json:"projects"`
|
||||||
|
}
|
||||||
|
|
||||||
func handleError(err error, statusCode int, rw http.ResponseWriter) {
|
func handleError(err error, statusCode int, rw http.ResponseWriter) {
|
||||||
log.Warnf("REST ERROR : %s", err.Error())
|
log.Warnf("REST ERROR : %s", err.Error())
|
||||||
rw.Header().Add("Content-Type", "application/json")
|
rw.Header().Add("Content-Type", "application/json")
|
||||||
@ -953,16 +961,16 @@ func (api *RestApi) getJobMetrics(rw http.ResponseWriter, r *http.Request) {
|
|||||||
// @produce plain
|
// @produce plain
|
||||||
// @param username formData string true "Unique user ID"
|
// @param username formData string true "Unique user ID"
|
||||||
// @param password formData string true "User password"
|
// @param password formData string true "User password"
|
||||||
// @param role formData string true "User role, one of: [admin, support, manager, user, api]"
|
// @param role formData string true "User role" Enums(admin, support, manager, user, api)
|
||||||
// @param project formData string false "Managed project, required for new manager role user"
|
// @param project formData string false "Managed project, required for new manager role user"
|
||||||
// @param name formData string false "Users name"
|
// @param name formData string false "Users name"
|
||||||
// @param email formData string false "Users email"
|
// @param email formData string false "Users email"
|
||||||
// @success 200 {string} string "User added successfully"
|
// @success 200 {string} string "Success Response"
|
||||||
// @failure 400 {object} api.ErrorResponse "Bad Request"
|
// @failure 400 {string} string "Bad Request"
|
||||||
// @failure 401 {object} api.ErrorResponse "Unauthorized"
|
// @failure 401 {string} string "Unauthorized"
|
||||||
// @failure 403 {object} api.ErrorResponse "Forbidden"
|
// @failure 403 {string} string "Forbidden"
|
||||||
// @failure 422 {object} api.ErrorResponse "Unprocessable Entity: creating user failed"
|
// @failure 422 {string} string "Unprocessable Entity: creating user failed"
|
||||||
// @failure 500 {object} api.ErrorResponse "Internal Server Error"
|
// @failure 500 {string} string "Internal Server Error"
|
||||||
// @security ApiKeyAuth
|
// @security ApiKeyAuth
|
||||||
// @router /users/ [post]
|
// @router /users/ [post]
|
||||||
func (api *RestApi) createUser(rw http.ResponseWriter, r *http.Request) {
|
func (api *RestApi) createUser(rw http.ResponseWriter, r *http.Request) {
|
||||||
@ -1017,13 +1025,14 @@ func (api *RestApi) createUser(rw http.ResponseWriter, r *http.Request) {
|
|||||||
// @tags remove
|
// @tags remove
|
||||||
// @description User defined by username in form data will be deleted from database.
|
// @description User defined by username in form data will be deleted from database.
|
||||||
// @accept mpfd
|
// @accept mpfd
|
||||||
// @param username formData string true "User ID to delete"
|
// @produce plain
|
||||||
|
// @param username formData string true "User ID to delete"
|
||||||
// @success 200 "User deleted successfully"
|
// @success 200 "User deleted successfully"
|
||||||
// @failure 400 {object} api.ErrorResponse "Bad Request"
|
// @failure 400 {string} string "Bad Request"
|
||||||
// @failure 401 {object} api.ErrorResponse "Unauthorized"
|
// @failure 401 {string} string "Unauthorized"
|
||||||
// @failure 403 {object} api.ErrorResponse "Forbidden"
|
// @failure 403 {string} string "Forbidden"
|
||||||
// @failure 422 {object} api.ErrorResponse "Unprocessable Entity: deleting user failed"
|
// @failure 422 {string} string "Unprocessable Entity: deleting user failed"
|
||||||
// @failure 500 {object} api.ErrorResponse "Internal Server Error"
|
// @failure 500 {string} string "Internal Server Error"
|
||||||
// @security ApiKeyAuth
|
// @security ApiKeyAuth
|
||||||
// @router /users/ [delete]
|
// @router /users/ [delete]
|
||||||
func (api *RestApi) deleteUser(rw http.ResponseWriter, r *http.Request) {
|
func (api *RestApi) deleteUser(rw http.ResponseWriter, r *http.Request) {
|
||||||
@ -1052,14 +1061,13 @@ func (api *RestApi) deleteUser(rw http.ResponseWriter, r *http.Request) {
|
|||||||
// @tags query
|
// @tags query
|
||||||
// @description Returns a JSON-encoded list of users.
|
// @description Returns a JSON-encoded list of users.
|
||||||
// @description Required query-parameter defines if all users or only users with additional special roles are returned.
|
// @description Required query-parameter defines if all users or only users with additional special roles are returned.
|
||||||
// @accept json
|
|
||||||
// @produce json
|
// @produce json
|
||||||
// @param not-just-user query bool true "If returned list should contain all users or only users with additional special roles"
|
// @param not-just-user query bool true "If returned list should contain all users or only users with additional special roles"
|
||||||
// @success 200 {string} json "Users returned successfully"
|
// @success 200 {array} api.ApiReturnedUser "List of users returned successfully"
|
||||||
// @failure 400 {object} api.ErrorResponse "Bad Request"
|
// @failure 400 {string} string "Bad Request"
|
||||||
// @failure 401 {object} api.ErrorResponse "Unauthorized"
|
// @failure 401 {string} string "Unauthorized"
|
||||||
// @failure 403 {object} api.ErrorResponse "Forbidden"
|
// @failure 403 {string} string "Forbidden"
|
||||||
// @failure 500 {object} api.ErrorResponse "Internal Server Error"
|
// @failure 500 {string} string "Internal Server Error"
|
||||||
// @security ApiKeyAuth
|
// @security ApiKeyAuth
|
||||||
// @router /users/ [get]
|
// @router /users/ [get]
|
||||||
func (api *RestApi) getUsers(rw http.ResponseWriter, r *http.Request) {
|
func (api *RestApi) getUsers(rw http.ResponseWriter, r *http.Request) {
|
||||||
@ -1090,17 +1098,17 @@ func (api *RestApi) getUsers(rw http.ResponseWriter, r *http.Request) {
|
|||||||
// @description If more than one formValue is set then only the highest priority field is used.
|
// @description If more than one formValue is set then only the highest priority field is used.
|
||||||
// @accept mpfd
|
// @accept mpfd
|
||||||
// @produce plain
|
// @produce plain
|
||||||
// @param id path string true "Database ID of User"
|
// @param id path string true "Database ID of User"
|
||||||
// @param add-role formData string false "Priority 1: Role to add, one of: [admin, support, manager, user, api]"
|
// @param add-role formData string false "Priority 1: Role to add" Enums(admin, support, manager, user, api)
|
||||||
// @param remove-role formData string false "Priority 2: Role to remove, one of: [admin, support, manager, user, api]"
|
// @param remove-role formData string false "Priority 2: Role to remove" Enums(admin, support, manager, user, api)
|
||||||
// @param add-project formData string false "Priority 3: Project to add"
|
// @param add-project formData string false "Priority 3: Project to add"
|
||||||
// @param remove-project formData string false "Priority 4: Project to remove"
|
// @param remove-project formData string false "Priority 4: Project to remove"
|
||||||
// @success 200 {string} string "Task successful"
|
// @success 200 {string} string "Success Response Message"
|
||||||
// @failure 400 {object} api.ErrorResponse "Bad Request"
|
// @failure 400 {string} string "Bad Request"
|
||||||
// @failure 401 {object} api.ErrorResponse "Unauthorized"
|
// @failure 401 {string} string "Unauthorized"
|
||||||
// @failure 403 {object} api.ErrorResponse "Forbidden"
|
// @failure 403 {string} string "Forbidden"
|
||||||
// @failure 422 {object} api.ErrorResponse "Unprocessable Entity: The user could not be updated"
|
// @failure 422 {string} string "Unprocessable Entity: The user could not be updated"
|
||||||
// @failure 500 {object} api.ErrorResponse "Internal Server Error"
|
// @failure 500 {string} string "Internal Server Error"
|
||||||
// @security ApiKeyAuth
|
// @security ApiKeyAuth
|
||||||
// @router /user/{id} [post]
|
// @router /user/{id} [post]
|
||||||
func (api *RestApi) updateUser(rw http.ResponseWriter, r *http.Request) {
|
func (api *RestApi) updateUser(rw http.ResponseWriter, r *http.Request) {
|
||||||
|
Loading…
Reference in New Issue
Block a user