From 309f614e32f140b5bc7fc055b472be0b7e4957f4 Mon Sep 17 00:00:00 2001 From: rv0lt Date: Mon, 22 Jan 2024 14:03:26 +0100 Subject: [PATCH 1/8] endpoints --- dds_web/static/swagger.yaml | 393 +++++++++++++++++++++++++++++++++++- 1 file changed, 391 insertions(+), 2 deletions(-) diff --git a/dds_web/static/swagger.yaml b/dds_web/static/swagger.yaml index fe8e9e6bf..e8800e52b 100644 --- a/dds_web/static/swagger.yaml +++ b/dds_web/static/swagger.yaml @@ -16,8 +16,8 @@ servers: - url: https://dds-dev.dckube3.scilifelab.se/api/v1 description: Endpoint for the development enviroment # Uncomment when local testing -# - url: http://localhost:5000/api/v1 -# description: Local enviroment + - url: http://localhost:5000/api/v1 + description: Local enviroment tags: - name: authentication description: Authorization and authentication operations @@ -467,6 +467,323 @@ paths: requestBody: $ref: "#/components/requestBodies/Token" + ### SUPERADMIN OPERATIONS ######### + /maintenance: + put: + tags: + - superadmin + summary: Change the maintenance mode of the system + operationId: maintenanceMode + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: string + example: "{message: maintenance set.}" + requestBody: + content: + application/json: + schema: + type: object + properties: + state: + type: string + enum: [on, off] + /unit/info/all: + get: + tags: + - superadmin + summary: Get unit info. + operationId: allUnits + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/UnitsInfo" + /motd: + post: + tags: + - superadmin + summary: Add a Message of the Day. + operationId: addMOTD + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: string + example: "{message: The MOTD was added to the database.}" + requestBody: + content: + application/json: + schema: + type: object + properties: + message: + type: string + example: "This is a message of the day" + get: + tags: + - superadmin + summary: Return list of all active MOTDs to super admin. + operationId: allUnits + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/MotdInfo" + put: + tags: + - superadmin + summary: Deactivate MOTD. + operationId: deactivateMOTD + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: string + example: "{message: The MOTD was deactivated in the database.}" + requestBody: + content: + application/json: + schema: + type: object + properties: + motd_id: + type: integer + example: 1 + /motd/send: + post: + tags: + - superadmin + summary: Send MOTD as email to users. + operationId: sendMOTD + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: string + example: "{message: MOTD has been sent to the users.}" + requestBody: + content: + application/json: + schema: + type: object + properties: + motd_id: + type: integer + example: 1 + /user/find: + get: + tags: + - superadmin + summary: Get all users or check if there is a specific user in the database CHECK METHOD + description: This method requires the data + to be passed in the request body instead of the query. + Since this does not comply with the openAPI standards, swagger cannot document it properly, + therefore we need to change/remove it in the future. + deprecated: true + operationId: findUser + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: string + example: "{Exists: true}" + /user/totp/deactivate: + put: + tags: + - superadmin + summary: Deactivate TOTP and activate HOTP for other user, e.g. if phone lost + operationId: resetTwoFactor + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: string + example: "{message: TOTP has been deactivated. + They can now use 2FA via email during authentication}" + requestBody: + content: + application/json: + schema: + type: object + properties: + username: + type: string + example: unituser1 + /proj/busy/any: + get: + tags: + - superadmin + summary: Check if any project are busy CHECK METHOD + description: This method requires the data + to be passed in the request body instead of the query. + Since this does not comply with the openAPI standards, swagger cannot document it properly, + therefore we need to change/remove it in the future. + deprecated: true + operationId: anyProjectBusy + parameters: + - $ref: "#/components/parameters/defaultHeader" + - in: query + name: list + schema: + type: boolean + required: false + description: Check if user is listing the busy projects. + Otherwise just returns the number of busy projects. + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: object + properties: + num: + type: integer + example: 0 + /stats: + get: + tags: + - superadmin + summary: Collect rows from reporting table and return them. + operationId: stats + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + $ref: "#/components/schemas/Reporting" + /user/emails: + get: + tags: + - superadmin + summary: Get emails for Unit Admins and Unit Personnel. + operationId: unitUsersEmails + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: array + items: + type: string + example: + [ + unitadmin1@mailtrap.io, + unitadmin2@mailtrap.io, + unitadmin3@mailtrap.io, + unituser1@mailtrap.io, + unituser2@mailtrap.io, + ] components: # define reusable parameters: parameters: @@ -631,6 +948,78 @@ components: checksum: type: string example: cheksum + UnitsInfo: + type: object + properties: + Name: + type: string + example: Unit 1 + Contact Email: + type: string + example: support@example.com + Days In Available: + type: integer + example: 90 + Days In Expired: + type: integer + example: 30 + External Display Name: + type: string + example: Unit 1 + Public ID: + type: string + example: unit_1 + Safespring Endpoint: + type: string + Size: + type: integer + format: int64 + example: 1000 + MotdInfo: + type: object + properties: + MOTD ID: + type: integer + example: 1 + Message: + type: string + example: This is a message of the day + Created: + type: string + example: 2021-01-01 00:00:00 + Reporting: + type: object + properties: + Active projects: + type: integer + Data Now (TB): + type: integer + Data Uploaded (TB): + type: integer + Date: + type: string + Inactive projects: + type: integer + Project Owners: + type: integer + Researchers: + type: integer + Super Admins: + type: integer + TBHours Last Month: + type: integer + TBHours Total: + type: integer + Total projects: + type: integer + Total users: + type: integer + Unit Admins: + type: integer + Unit Personnel: + type: integer + Units: + type: integer Token: type: object properties: From 0157c802932d76a77571474fd952b4a43fabfcf8 Mon Sep 17 00:00:00 2001 From: rv0lt Date: Mon, 22 Jan 2024 14:06:30 +0100 Subject: [PATCH 2/8] sprintlog --- SPRINTLOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SPRINTLOG.md b/SPRINTLOG.md index b6cd625ba..98e7460b5 100644 --- a/SPRINTLOG.md +++ b/SPRINTLOG.md @@ -343,3 +343,7 @@ _Nothing merged in CLI during this sprint_ - Minor update jinja2 package to address cve ([#1503](https://github.com/ScilifelabDataCentre/dds_web/pull/1503)) - Minor update jwcrypto package to address cve ([#1504](https://github.com/ScilifelabDataCentre/dds_web/pull/1504)) + +# 2024-01-15 - 2024-01-26 + +- Document Superadmin endpoints ([#1507](https://github.com/ScilifelabDataCentre/dds_web/pull/1507)) From b91ad529108065c08385721e688a5a028621c712 Mon Sep 17 00:00:00 2001 From: rv0lt Date: Tue, 23 Jan 2024 13:43:19 +0100 Subject: [PATCH 3/8] last changes --- dds_web/static/swagger.yaml | 98 +++++++++++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 21 deletions(-) diff --git a/dds_web/static/swagger.yaml b/dds_web/static/swagger.yaml index e8800e52b..20545fa34 100644 --- a/dds_web/static/swagger.yaml +++ b/dds_web/static/swagger.yaml @@ -16,8 +16,8 @@ servers: - url: https://dds-dev.dckube3.scilifelab.se/api/v1 description: Endpoint for the development enviroment # Uncomment when local testing - - url: http://localhost:5000/api/v1 - description: Local enviroment +# - url: http://localhost:5000/api/v1 +# description: Local enviroment tags: - name: authentication description: Authorization and authentication operations @@ -503,7 +503,7 @@ paths: get: tags: - superadmin - summary: Get unit info. + summary: Get units info. operationId: allUnits parameters: - $ref: "#/components/parameters/defaultHeader" @@ -519,9 +519,27 @@ paths: content: application/json: schema: - type: array - items: - $ref: "#/components/schemas/UnitsInfo" + type: object + properties: + units: + type: array + items: + $ref: "#/components/schemas/UnitsInfo" + keys: + type: array + items: + type: string + example: + [ + Name, + Contact Email, + Days In Available, + Days In Expired, + External Display Name, + Public ID, + Safespring Endpoint, + Size, + ] /motd: post: tags: @@ -572,9 +590,17 @@ paths: content: application/json: schema: - type: array - items: - $ref: "#/components/schemas/MotdInfo" + type: object + properties: + motds: + type: array + items: + $ref: "#/components/schemas/MotdInfo" + keys: + type: array + items: + type: string + example: [MOTD ID, Message, Created] put: tags: - superadmin @@ -752,7 +778,34 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Reporting" + type: object + properties: + stats: + type: array + items: + $ref: "#/components/schemas/Reporting" + columns: + type: array + items: + type: string + example: + [ + Active projects, + Data Now (TB), + Data Uploaded (TB), + Date, + Inactive projects, + Project Owners, + Researchers, + Super Admins, + TBHours Last Month, + TBHours Total, + Total projects, + Total users, + Unit Admins, + Unit Personnel, + Units, + ] /user/emails: get: tags: @@ -773,17 +826,20 @@ paths: content: application/json: schema: - type: array - items: - type: string - example: - [ - unitadmin1@mailtrap.io, - unitadmin2@mailtrap.io, - unitadmin3@mailtrap.io, - unituser1@mailtrap.io, - unituser2@mailtrap.io, - ] + type: object + properties: + emails: + type: array + items: + type: string + example: + [ + unitadmin1@mailtrap.io, + unitadmin2@mailtrap.io, + unitadmin3@mailtrap.io, + unituser1@mailtrap.io, + unituser2@mailtrap.io, + ] components: # define reusable parameters: parameters: From 1e5bc9c5e534ef48df3f2d336f6a443be9ffc5cb Mon Sep 17 00:00:00 2001 From: rv0lt Date: Mon, 29 Jan 2024 12:10:59 +0100 Subject: [PATCH 4/8] feedback --- dds_web/static/swagger.yaml | 45 ++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/dds_web/static/swagger.yaml b/dds_web/static/swagger.yaml index 20545fa34..3278b4c3a 100644 --- a/dds_web/static/swagger.yaml +++ b/dds_web/static/swagger.yaml @@ -16,8 +16,8 @@ servers: - url: https://dds-dev.dckube3.scilifelab.se/api/v1 description: Endpoint for the development enviroment # Uncomment when local testing -# - url: http://localhost:5000/api/v1 -# description: Local enviroment + - url: http://localhost:5000/api/v1 + description: Local enviroment tags: - name: authentication description: Authorization and authentication operations @@ -489,7 +489,7 @@ paths: application/json: schema: type: string - example: "{message: maintenance set.}" + example: "{message: Maintenance mode is set to: ON}" requestBody: content: application/json: @@ -499,6 +499,27 @@ paths: state: type: string enum: [on, off] + get: + tags: + - superadmin + summary: Return current Maintenance mode + operationId: maintenanceModeGet + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: string + example: "{message: Maintenance mode is set to: ON}" /unit/info/all: get: tags: @@ -561,7 +582,8 @@ paths: application/json: schema: type: string - example: "{message: The MOTD was added to the database.}" + example: "{message: The MOTD was successfuly + added to the database.}" requestBody: content: application/json: @@ -621,7 +643,8 @@ paths: application/json: schema: type: string - example: "{message: The MOTD was deactivated in the database.}" + example: "{message: The MOTD was successfuly + deactivated in the database.}" requestBody: content: application/json: @@ -652,7 +675,7 @@ paths: application/json: schema: type: string - example: "{message: MOTD has been sent to the users.}" + example: "{message: MOTD 1 has been sent to the users.}" requestBody: content: application/json: @@ -710,7 +733,7 @@ paths: application/json: schema: type: string - example: "{message: TOTP has been deactivated. + example: "{message: TOTP has been deactivated for user unituser1. They can now use 2FA via email during authentication}" requestBody: content: @@ -780,10 +803,6 @@ paths: schema: type: object properties: - stats: - type: array - items: - $ref: "#/components/schemas/Reporting" columns: type: array items: @@ -806,6 +825,10 @@ paths: Unit Personnel, Units, ] + stats: + type: array + items: + $ref: "#/components/schemas/Reporting" /user/emails: get: tags: From c839225363d94fb4ec208c88e72d69c4815475e4 Mon Sep 17 00:00:00 2001 From: rv0lt Date: Tue, 30 Jan 2024 11:01:13 +0100 Subject: [PATCH 5/8] sync with dev --- dds_web/static/swagger.yaml | 435 ++++++++++++++++++++++++++++++++++++ 1 file changed, 435 insertions(+) diff --git a/dds_web/static/swagger.yaml b/dds_web/static/swagger.yaml index 3278b4c3a..bcba0367e 100644 --- a/dds_web/static/swagger.yaml +++ b/dds_web/static/swagger.yaml @@ -467,6 +467,338 @@ paths: requestBody: $ref: "#/components/requestBodies/Token" + ### USER OPERATIONS ######### + /user/info: + get: + tags: + - user + summary: Return own info when required + operationId: retrieveUserInfo + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + $ref: "#/components/schemas/UserInfo" + /user/add: + post: + tags: + - user + summary: Associate existing users or unanswered invites with projects or create invites + operationId: addUser + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/projectID" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: object + properties: + email: + type: string + example: researcher1@mailtrap.io + errors: + type: object + message: + type: string + example: Pending invite was successful + status: + type: integer + example: 200 + requestBody: + $ref: "#/components/requestBodies/User" + /user/delete: + delete: + tags: + - user + summary: Delete user or invite in the DDS. Unit Admins can delete Unit Admins and Unit Personnel. + Super admins can delete any user CHECK METHOD + description: This method requires the data + to be passed in the request body instead of the query. + Since this does not comply with the openAPI standards, swagger cannot document it properly, + therefore we need to change/remove it in the future. + deprecated: true + operationId: deleteUser + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/email" + - $ref: "#/components/parameters/is_invite" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: successful operation + content: + application/json: + schema: + type: string + example: "{message: You successfully deleted the account.}" + /user/delete_self: + delete: + tags: + - user + summary: Endpoint to initiate user self removal from the system. + Every user can self-delete the own account with an e-mail confirmation + operationId: deleteUserSelf + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: successful operation + content: + application/json: + schema: + type: string + example: "{message: Requested account deletion initiated. + An e-mail with a confirmation link has been sent to your address}" + /user/access/revoke: + post: + tags: + - user + summary: Remove an user from a project + operationId: removeUserAssociation + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/projectID" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: successful operation + content: + application/json: + schema: + type: string + example: "{message: User with email email@example.com no longer + associated with exmple_project.}" + requestBody: + content: + application/json: + schema: + type: object + properties: + email: + type: string + example: researcher1@mailtrap.io + /user/activation: + post: + tags: + - user + summary: Unit Admins can reactivate/deactivate unitusers. Super admins can reactivate/deactivate any user. + operationId: userActivation + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: successful operation + content: + application/json: + schema: + type: string + example: "{message: You successfully reactivated the account}" + requestBody: + content: + application/json: + schema: + type: object + properties: + email: + type: string + example: researcher1@mailtrap.io + action: + type: string + enum: + - reactivate + - deactivate + /user/hotp/activate: + post: + tags: + - user + summary: Request to switch from TOTP to HOTP for second factor authentication. + operationId: requestHOTPActivation + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: successful operation + content: + application/json: + schema: + type: string + example: "{message: Please check your email and follow the attached link to activate two-factor with email}" # yamllint disable-line + security: + - encryptedToken: [] + /user/totp/activate: + post: + tags: + - user + summary: Request to switch from HOTP to TOTP for second factor authentication. + operationId: requestTOTPActivation + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: successful operation + content: + application/json: + schema: + type: string + example: "{message: Please check your email and follow the attached link to activate two-factor with autenticator app}" # yamllint disable-line + /users: + get: + tags: + - user + summary: List unit users within the unit the current user is connected to, or the one defined by a superadmin. + CHECK METHOD FOR SUPERADMINS + description: TODO - for superadmin, it can be passed a unit, currently in body, needs to be in query. + deprecated: true + operationId: getUsers + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: successful operation + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/UserList" + /user/invites: + get: + tags: + - user + summary: Provides a list of invited users. + Superadmins see all invites, unitusers the invites to their projects and units. + description: The Unit field is only returned when authenticated as a superadmin. + operationId: getInvites + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: successful operation + content: + application/json: + schema: + type: object + properties: + invites: + type: array + items: + $ref: "#/components/schemas/InvitesList" + keys: + type: array + items: + type: string + example: [Email, Role, Projects, Created, Unit] + /usage: + get: + tags: + - user + - project + summary: Calculate and display the amount of GB hours and the total cost. + Only unit accounts can get invoicing information + operationId: showUsage + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: successful operation + content: + application/json: + schema: + type: object + properties: + project_usage: + type: object + properties: + project_1: + type: object + properties: + gbhours: + type: number + example: 0.00000000000000000000 + cost: + type: number + example: 0.00000000000000000000 + total_usage: + type: object + properties: + gbhours: + type: number + example: 0.00000000000000000000 + cost: + type: number + example: 0.00000000000000000000 + ### SUPERADMIN OPERATIONS ######### /maintenance: put: @@ -879,6 +1211,18 @@ components: schema: type: string description: project id to query + email: + name: email + in: query + schema: + type: string + description: email of the user/invite to query + is_invite: + name: is_invite + in: query + schema: + type: string + description: flag to mark if the user to query is an invite # Define common request bodies: requestBodies: Files: @@ -894,6 +1238,11 @@ components: properties: filename: $ref: "#/components/schemas/FailedFiles" + User: + content: + application/json: + schema: + $ref: "#/components/schemas/User" Token: content: application/json: @@ -1027,6 +1376,92 @@ components: checksum: type: string example: cheksum + User: + type: object + required: + - role + - unit + - email + properties: + role: + type: string + example: Researcher + unit: + type: string + example: UnitA + email: + type: string + example: researcher1@mailtrap.io + send_email: + type: boolean + example: true + UserInfo: + type: object + properties: + info: + type: object + properties: + email_primary: + type: string + example: unitadmin1@mailtrap.io + emails_all: + type: array + items: + type: string + is_admin: + type: boolean + example: true + name: + type: string + example: Unit Admin 1 + role: + type: string + example: Unit Admin + username: + type: string + example: unitadmin_1 + UserList: + type: object + properties: + active: + type: boolean + example: true + name: + type: string + example: Unit Admin 1 + role: + type: string + example: Unit Admin + username: + type: string + example: unitadmin_1 + email: + type: string + example: unitadmin1@mailtrap.io + InvitesList: + type: object + required: + - Created + - Email + - Role + properties: + Created: + type: string + format: date-time + Email: + type: string + example: researcher1@mailtrap.io + Role: + type: string + example: Researcher + Projects: + type: array + items: + type: string + example: [project1] + Unit: + type: string + example: "" UnitsInfo: type: object properties: From 0689849e5ab22b31b61eeaabfd75c30da9b965c7 Mon Sep 17 00:00:00 2001 From: rv0lt Date: Tue, 30 Jan 2024 11:06:51 +0100 Subject: [PATCH 6/8] prettier --- dds_web/static/swagger.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dds_web/static/swagger.yaml b/dds_web/static/swagger.yaml index 1860d07ec..bcba0367e 100644 --- a/dds_web/static/swagger.yaml +++ b/dds_web/static/swagger.yaml @@ -799,7 +799,7 @@ paths: type: number example: 0.00000000000000000000 -### SUPERADMIN OPERATIONS ######### + ### SUPERADMIN OPERATIONS ######### /maintenance: put: tags: From 802d66dd86189730ff7506fd986e130e419031be Mon Sep 17 00:00:00 2001 From: rv0lt Date: Tue, 30 Jan 2024 14:16:37 +0100 Subject: [PATCH 7/8] sync with dev --- dds_web/static/swagger.yaml | 467 ++++++++++++++++++++++++++++++++++++ 1 file changed, 467 insertions(+) diff --git a/dds_web/static/swagger.yaml b/dds_web/static/swagger.yaml index bcba0367e..1528563c4 100644 --- a/dds_web/static/swagger.yaml +++ b/dds_web/static/swagger.yaml @@ -799,6 +799,396 @@ paths: type: number example: 0.00000000000000000000 + ### PROJECT OPERATIONS ######### + /proj/list: + get: + tags: + - project + summary: Get info regarding all projects which user is involved in + operationId: userProjects + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + $ref: "#/components/schemas/ProjListInfo" + /proj/rm: + delete: + tags: + - project + summary: Remove project contents + operationId: removeContents + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/projectID" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: string + example: "{removed: true}" + /proj/public: + get: + tags: + - project + summary: Gets the public key beloning to the current project + operationId: getPublic + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/projectID" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: object + properties: + public: + type: string + example: public_key + /proj/private: + get: + tags: + - project + summary: Gets the private key beloning to the current project + operationId: getPublic + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/projectID" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: object + properties: + private: + type: string + example: private + /proj/create: + post: + tags: + - project + summary: Create a new project + operationId: createProject + parameters: + - $ref: "#/components/parameters/defaultHeader" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: object + properties: + status: + type: integer + example: 200 + message: + type: string + example: Added new project project_title + project_id: + type: string + example: project_id + user_addition_statuses: + type: array + items: + type: object + properties: + status: + type: string + example: User added + requestBody: + content: + application/json: + schema: + type: object + required: + - title + - description + - pi + properties: + forced: + type: boolean + example: false + description: Verify enough number of Unit Admins + title: + type: string + example: project_title + description: + type: string + example: project_description + pi: + type: string + example: pi@example.com + non_sensitive: + type: boolean + example: False + description: If has non-sensitive data + users_to_add: + type: array + items: + type: object + properties: + email: + type: string + example: researcheruser@mailtrap.io + role: + type: string + example: Researcher + description: List of users (outside the unit) to add to the project. Can be empty. + /proj/users: + get: + tags: + - project + summary: Get all users in a project + operationId: projectUsers + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/projectID" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: object + properties: + research_users: + type: array + items: + type: object + properties: + Primary email: + type: string + User name: + type: string + Role: + type: string + /proj/status: + get: + tags: + - project + summary: Get current project status and optionally entire status history CHECK METHOD + description: This method requires some data + to be passed in the request body instead of the query. + Since this does not comply with the openAPI standards, swagger cannot document it properly, + therefore we need to change/remove it in the future. + deprecated: true + operationId: projectStatusGet + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/projectID" + - name: history + in: query + required: false + schema: + type: boolean + example: true + description: If true, return entire status history + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: object + properties: + current_status: + type: string + example: In progress + post: + tags: + - project + summary: Update project status + operationId: projectStatusPost + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/projectID" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: object + properties: + message: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + new_status: + type: string + example: Available + send_email: + type: boolean + example: true + deadline: + type: integer + example: 30 + is_aborted: + type: boolean + example: false + /proj/access: + post: + tags: + - project + summary: Give access to user + operationId: projectAccess + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/projectID" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: string + example: "{message: Project Access updated + for user user_primeary_email.}" + requestBody: + content: + application/json: + schema: + type: object + properties: + email: + type: string + /proj/info: + get: + tags: + - project + summary: Display Project information + operationId: projectInfo + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/projectID" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + $ref: "#/components/schemas/ProjInfo" + put: + tags: + - project + summary: Update Project information + operationId: projectInfoUpdate + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/projectID" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: object + properties: + message: + type: string + example: Project_id info was successfuly updated + title: + type: string + example: new_title + description: + type: string + example: new_description + pi: + type: string + example: new_pi@example.org + requestBody: + content: + application/json: + schema: + type: object + properties: + title: + type: string + new_description: + type: string + new_pi: + type: string + ### SUPERADMIN OPERATIONS ######### /maintenance: put: @@ -1462,6 +1852,83 @@ components: Unit: type: string example: "" + ProjListInfo: + type: object + properties: + always_show: + type: boolean + example: true + project_info: + type: array + items: + type: object + properties: + Access: + type: boolean + example: true + Created By: + type: string + example: user + Last Updated: + type: string + example: 2020-01-01 00:00:00 + PI: + type: string + example: support@example.org + Project ID: + type: string + example: project_id + Size: + type: integer + example: 1000 + Status: + type: string + example: In progress + Title: + type: string + example: project_title + total_size: + type: integer + example: 1000 + tota_usage: + type: object + properties: + cost: + type: integer + example: 0 + usage: + type: integer + example: 1000 + ProjInfo: + type: object + properties: + project_info: + type: object + properties: + Created By: + type: string + example: user + Last Updated: + type: string + example: 2020-01-01 00:00:00 + PI: + type: string + example: support@example.org + Project ID: + type: string + example: project_id + Status: + type: string + example: In progress + Size: + type: integer + example: 1000 + Title: + type: string + example: project_title + Description: + type: string + example: project_description UnitsInfo: type: object properties: From 368cb92bc00aadf9bc5798ec8a55b3953d3c2dd4 Mon Sep 17 00:00:00 2001 From: rv0lt Date: Tue, 30 Jan 2024 14:52:24 +0100 Subject: [PATCH 8/8] sync with dev --- dds_web/static/swagger.yaml | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/dds_web/static/swagger.yaml b/dds_web/static/swagger.yaml index 1528563c4..e940596c5 100644 --- a/dds_web/static/swagger.yaml +++ b/dds_web/static/swagger.yaml @@ -1585,6 +1585,48 @@ paths: unituser1@mailtrap.io, unituser2@mailtrap.io, ] + ### S3 OPERATIONS ######### + /s3/proj: + get: + tags: + - s3 + summary: Get the project S3 keys + operationId: retrieveUserInfo + parameters: + - $ref: "#/components/parameters/defaultHeader" + - $ref: "#/components/parameters/projectID" + responses: + "401": + $ref: "#/components/responses/UnauthorizedToken" + "400": + $ref: "#/components/responses/BadRequest" + "500": + $ref: "#/components/responses/InternalServerlError" + "200": + description: succesful operation + content: + application/json: + schema: + type: object + properties: + safespring_project: + type: string + example: sfsp_proj + url: + type: string + example: url + keys: + type: object + properties: + access_key: + type: string + example: access_key + secret_key: + type: string + example: secret_key + bucket: + type: string + example: bucketname components: # define reusable parameters: parameters: