From 43163273fa3b7fea631c06b4662bb55d2f143c34 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Mon, 17 Feb 2025 07:40:24 +0100 Subject: [PATCH] api: remove IsAdmin from required attributes (#366) --- docs/documentation/rest-api/swagger.yaml | 1 - .../app/api/core/assets/doc/v0_swagger.json | 62 +++++++++++++++++++ .../app/api/core/assets/doc/v0_swagger.yaml | 42 +++++++++++++ .../app/api/core/assets/doc/v1_swagger.json | 3 +- .../app/api/core/assets/doc/v1_swagger.yaml | 1 - internal/app/api/v1/models/models_user.go | 2 +- 6 files changed, 106 insertions(+), 5 deletions(-) diff --git a/docs/documentation/rest-api/swagger.yaml b/docs/documentation/rest-api/swagger.yaml index 25b4327..f0189fc 100644 --- a/docs/documentation/rest-api/swagger.yaml +++ b/docs/documentation/rest-api/swagger.yaml @@ -549,7 +549,6 @@ definitions: type: string required: - Identifier - - IsAdmin type: object models.UserInformation: properties: diff --git a/internal/app/api/core/assets/doc/v0_swagger.json b/internal/app/api/core/assets/doc/v0_swagger.json index b37f2cf..8137d9e 100644 --- a/internal/app/api/core/assets/doc/v0_swagger.json +++ b/internal/app/api/core/assets/doc/v0_swagger.json @@ -1363,6 +1363,50 @@ } } }, + "/user/{id}/interfaces": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Users" + ], + "summary": "Get interfaces for the given user. Returns an empty list if self provisioning is disabled.", + "operationId": "users_handleInterfacesGet", + "parameters": [ + { + "type": "string", + "description": "The user identifier", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/model.Interface" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/model.Error" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/model.Error" + } + } + } + } + }, "/user/{id}/peers": { "get": { "produces": [ @@ -1373,6 +1417,15 @@ ], "summary": "Get peers for the given user.", "operationId": "users_handlePeersGet", + "parameters": [ + { + "type": "string", + "description": "The user identifier", + "name": "id", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -1408,6 +1461,15 @@ ], "summary": "Get peer stats for the given user.", "operationId": "users_handleStatsGet", + "parameters": [ + { + "type": "string", + "description": "The user identifier", + "name": "id", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", diff --git a/internal/app/api/core/assets/doc/v0_swagger.yaml b/internal/app/api/core/assets/doc/v0_swagger.yaml index ee870dc..96046e9 100644 --- a/internal/app/api/core/assets/doc/v0_swagger.yaml +++ b/internal/app/api/core/assets/doc/v0_swagger.yaml @@ -1262,9 +1262,45 @@ paths: summary: Enable the REST API for the given user. tags: - Users + /user/{id}/interfaces: + get: + operationId: users_handleInterfacesGet + parameters: + - description: The user identifier + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/model.Interface' + type: array + "400": + description: Bad Request + schema: + $ref: '#/definitions/model.Error' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/model.Error' + summary: Get interfaces for the given user. Returns an empty list if self provisioning + is disabled. + tags: + - Users /user/{id}/peers: get: operationId: users_handlePeersGet + parameters: + - description: The user identifier + in: path + name: id + required: true + type: string produces: - application/json responses: @@ -1288,6 +1324,12 @@ paths: /user/{id}/stats: get: operationId: users_handleStatsGet + parameters: + - description: The user identifier + in: path + name: id + required: true + type: string produces: - application/json responses: diff --git a/internal/app/api/core/assets/doc/v1_swagger.json b/internal/app/api/core/assets/doc/v1_swagger.json index 80d01cd..03ead44 100644 --- a/internal/app/api/core/assets/doc/v1_swagger.json +++ b/internal/app/api/core/assets/doc/v1_swagger.json @@ -1998,8 +1998,7 @@ "models.User": { "type": "object", "required": [ - "Identifier", - "IsAdmin" + "Identifier" ], "properties": { "ApiEnabled": { diff --git a/internal/app/api/core/assets/doc/v1_swagger.yaml b/internal/app/api/core/assets/doc/v1_swagger.yaml index 2f092b7..cc374b7 100644 --- a/internal/app/api/core/assets/doc/v1_swagger.yaml +++ b/internal/app/api/core/assets/doc/v1_swagger.yaml @@ -549,7 +549,6 @@ definitions: type: string required: - Identifier - - IsAdmin type: object models.UserInformation: properties: diff --git a/internal/app/api/v1/models/models_user.go b/internal/app/api/v1/models/models_user.go index d809595..552d615 100644 --- a/internal/app/api/v1/models/models_user.go +++ b/internal/app/api/v1/models/models_user.go @@ -17,7 +17,7 @@ type User struct { // The name of the authentication provider. This field is read-only. ProviderName string `json:"ProviderName,omitempty" readonly:"true" example:""` // If this field is set, the user is an admin. - IsAdmin bool `json:"IsAdmin" binding:"required" example:"false"` + IsAdmin bool `json:"IsAdmin" example:"false"` // The first name of the user. This field is optional. Firstname string `json:"Firstname" example:"Max"`