Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dds 1861 - new v3 version to fix endpoints - fix the files endpoints #1505

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
99b5a30
added new files
rv0lt Jan 18, 2024
95d20c2
adapted tests
rv0lt Jan 18, 2024
fcaf512
define new version of api
rv0lt Jan 18, 2024
e291d42
prettier
rv0lt Jan 18, 2024
eddd5d2
init
rv0lt Jan 18, 2024
6f9dba3
check for both versions
rv0lt Jan 25, 2024
3fca063
black and sprintlog
rv0lt Jan 25, 2024
324adde
last changes
rv0lt Jan 25, 2024
4391375
black
rv0lt Jan 25, 2024
482fd74
increase coverage
rv0lt Jan 25, 2024
03d2158
black and coverage
rv0lt Jan 25, 2024
dcb35b1
100 coverage
rv0lt Jan 29, 2024
051d4d6
Merge branch 'dev' into DDS-1861-Fix-the-Files-endpoints-according-to…
rv0lt Jan 30, 2024
1bee728
black
rv0lt Jan 30, 2024
bad60b8
Merge branch 'dev' into DDS-1861-Fix-the-Files-endpoints-according-to…
rv0lt Jan 30, 2024
7a18458
not needed files deleted
rv0lt Jan 30, 2024
eef6729
Merge branch 'dev' into DDS-1861-Fix-the-Files-endpoints-according-to…
rv0lt Jan 30, 2024
fa05a23
Merge branch 'dev' into DDS-1861-Fix-the-Files-endpoints-according-to…
rv0lt Jan 31, 2024
d4a4496
more info
rv0lt Jan 31, 2024
827bad2
prettier
rv0lt Jan 31, 2024
4a3c89e
description more presentable
rv0lt Jan 31, 2024
2fc3fb6
add more information and betterrepresentation of output
rv0lt Jan 31, 2024
e2affed
yammlint
rv0lt Jan 31, 2024
a1703cf
last changes
rv0lt Feb 1, 2024
0af874e
black
rv0lt Feb 1, 2024
ec8c14a
Update dds_web/static/swagger.yaml
rv0lt Feb 21, 2024
b287431
Update dds_web/static/swagger.yaml
rv0lt Feb 21, 2024
654cacb
feedback comments
rv0lt Feb 21, 2024
be1fa53
feedback
rv0lt Feb 21, 2024
6821e24
prettier
rv0lt Feb 21, 2024
0ba2d54
Merge branch 'dev' into DDS-1861-Fix-the-Files-endpoints-according-to…
rv0lt Feb 26, 2024
660113a
better explanation of s3 keys operation on files
rv0lt Feb 29, 2024
61b4362
Merge branch 'DDS-1861-Fix-the-Files-endpoints-according-to-the-OpenA…
rv0lt Feb 29, 2024
5822156
Merge branch 'dev' into DDS-1861-Fix-the-Files-endpoints-according-to…
rv0lt Feb 29, 2024
6354702
Update dds_web/static/swagger.yaml
rv0lt Mar 4, 2024
379cc7d
Update dds_web/static/swagger.yaml
rv0lt Mar 4, 2024
efc8a75
Update dds_web/static/swagger.yaml
rv0lt Mar 4, 2024
92df4b3
Update dds_web/static/swaggerv3.yaml
rv0lt Mar 4, 2024
624ac2b
Update dds_web/static/swagger.yaml
rv0lt Mar 4, 2024
db0faed
Update dds_web/static/swaggerv3.yaml
rv0lt Mar 4, 2024
f7faf7c
run prettier on sugested changes
rv0lt Mar 4, 2024
0961f1d
tests for db tools
rv0lt Mar 4, 2024
82212e1
Revert "tests for db tools"
rv0lt Mar 4, 2024
044bbc4
better explanation for api usage
rv0lt Mar 4, 2024
0354a75
checked operation IDs tags
rv0lt Mar 5, 2024
c834273
Update dds_web/static/swagger.yaml
rv0lt Mar 6, 2024
6a66a32
prettierç
rv0lt Mar 6, 2024
afbb089
rm trailing spaces
rv0lt Mar 6, 2024
6642d98
Update SPRINTLOG.md
rv0lt Mar 13, 2024
845f776
sprintlog
rv0lt Mar 13, 2024
db50f17
Merge branch 'dev' into DDS-1861-Fix-the-Files-endpoints-according-to…
rv0lt Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions SPRINTLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ _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))

# 2023-01-15 - 2024-01-25
rv0lt marked this conversation as resolved.
Show resolved Hide resolved

# 2024-01-15 - 2024-01-26

- Document Superadmin endpoints ([#1507](https://github.com/ScilifelabDataCentre/dds_web/pull/1507))
Expand All @@ -367,4 +369,8 @@ _Nothing merged in CLI during this sprint_

- Add link in footer for new User Agreement and Privacy Policy ([#1516](https://github.com/ScilifelabDataCentre/dds_web/pull/1516))
- New extra release, outside maintenance window, version 2.6.3 ([#1518](https://github.com/ScilifelabDataCentre/dds_web/pull/1518))

# 2024-03-11 - 2024-03-22

- Fix the files endpoints according to the openAPI standards, providing new endpoint version that co-exists with the current one ([#1505](https://github.com/ScilifelabDataCentre/dds_web/pull/1505))
- Added email to troubleshouting webpage, with obfuscation ([#1520](https://github.com/ScilifelabDataCentre/dds_web/pull/1520))
40 changes: 30 additions & 10 deletions dds_web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ def prepare():
# Verify cli version compatible
if "api/v1" in flask.request.path:
verify_cli_version(version_cli=flask.request.headers.get("X-Cli-Version"))
elif "api/v3" in flask.request.path: # experimental v3 version
# If version api is not provided, it gets the data from the __version__ file
# When v3 is finallized, this should be removed and the __version__ file should be updated
pass

# Get message of the day
flask.g.motd = get_active_motds()
Expand Down Expand Up @@ -309,28 +313,44 @@ def dds_version_filter(_):
import dds_web.security.auth

# Register blueprints
from dds_web.api import api_blueprint
from dds_web.api import api_blueprint, api_blueprint_v3
from dds_web.web.root import pages
from dds_web.web.user import auth_blueprint
from flask_swagger_ui import get_swaggerui_blueprint

# url for the documentation
SWAGGER_URL = "/documentation"
# path where the swagger file is localted in the repository
API_URL = "/static/swagger.yaml"
# base url for the api documentation
SWAGGER_URL_1 = "/api/documentation/v1"
SWAGGER_URL_3 = "/api/documentation/v3"

# register blueprint for the documentation
swagger_ui_blueprint = get_swaggerui_blueprint(
SWAGGER_URL,
API_URL,
# path where the swagger file(s) are localted in the repository
API_URL_V1 = "/static/swagger.yaml"
API_URL_V3 = "/static/swaggerv3.yaml"

# register blueprint(s) for the documentation
swagger_ui_blueprint_v1 = get_swaggerui_blueprint(
SWAGGER_URL_1,
API_URL_V1,
config={
"app_name": "DDS API Documentation",
"defaultModelsExpandDepth": -1,
"layout": "BaseLayout",
},
)
swagger_ui_blueprint_v3 = get_swaggerui_blueprint(
SWAGGER_URL_3,
API_URL_V3,
config={
"app_name": "DDS API Documentation",
"defaultModelsExpandDepth": -1,
"layout": "BaseLayout",
},
)
app.register_blueprint(swagger_ui_blueprint, url_prefix=SWAGGER_URL)

# two documentation and api versions, v3 will contain the new endpoints fixed
app.register_blueprint(swagger_ui_blueprint_v1, url_prefix=SWAGGER_URL_1, name="v1")
app.register_blueprint(swagger_ui_blueprint_v3, url_prefix=SWAGGER_URL_3, name="v3")
app.register_blueprint(api_blueprint, url_prefix="/api/v1")
app.register_blueprint(api_blueprint_v3, url_prefix="/api/v3")
app.register_blueprint(pages, url_prefix="")
app.register_blueprint(auth_blueprint, url_prefix="")

Expand Down
138 changes: 75 additions & 63 deletions dds_web/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
api_blueprint = flask.Blueprint("api_blueprint", __name__)
api = flask_restful.Api(api_blueprint)

api_blueprint_v3 = flask.Blueprint("api_blueprint_v3", __name__)
api_v3 = flask_restful.Api(api_blueprint_v3)


@api.representation("application/json")
@api_v3.representation("application/json")
def output_json(data, code, headers=None):
resp = flask.make_response(flask.json.dumps(data), code)
resp.headers.extend(headers or {})
Expand All @@ -33,66 +37,74 @@ def output_json(data, code, headers=None):
####################################################################################################
# RESOURCES ############################################################################ RESOURCES #
####################################################################################################

# Login/access ###################################################################### Login/access #
api.add_resource(user.EncryptedToken, "/user/encrypted_token", endpoint="encrypted_token")
api.add_resource(user.SecondFactor, "/user/second_factor", endpoint="second_factor")

# S3 ########################################################################################## S3 #
api.add_resource(s3.S3Info, "/s3/proj", endpoint="proj_s3_info")

# Files #################################################################################### Files #
api.add_resource(files.NewFile, "/file/new", endpoint="new_file")
api.add_resource(files.MatchFiles, "/file/match", endpoint="match_files")
api.add_resource(files.ListFiles, "/files/list", endpoint="list_files")
api.add_resource(files.RemoveFile, "/file/rm", endpoint="remove_file")
api.add_resource(files.RemoveDir, "/file/rmdir", endpoint="remove_dir")
api.add_resource(files.FileInfo, "/file/info", endpoint="file_info")
api.add_resource(files.FileInfoAll, "/file/all/info", endpoint="all_file_info")
api.add_resource(files.UpdateFile, "/file/update", endpoint="update_file")
api.add_resource(files.AddFailedFiles, "/file/failed/add", endpoint="add_failed_files")

# Projects ############################################################################## Projects #
api.add_resource(project.UserProjects, "/proj/list", endpoint="list_projects")
api.add_resource(project.RemoveContents, "/proj/rm", endpoint="remove_contents")
api.add_resource(project.GetPublic, "/proj/public", endpoint="public_key")
api.add_resource(project.GetPrivate, "/proj/private", endpoint="private_key")
api.add_resource(project.CreateProject, "/proj/create", endpoint="create_project")
api.add_resource(project.ProjectUsers, "/proj/users", endpoint="list_project_users")
api.add_resource(project.ProjectStatus, "/proj/status", endpoint="project_status")
api.add_resource(project.ProjectAccess, "/proj/access", endpoint="project_access")
api.add_resource(project.ProjectBusy, "/proj/busy", endpoint="project_busy")
api.add_resource(project.ProjectInfo, "/proj/info", endpoint="project_info")

# User management ################################################################ User management #
api.add_resource(user.RetrieveUserInfo, "/user/info", endpoint="user_info")
api.add_resource(user.AddUser, "/user/add", endpoint="add_user")
api.add_resource(user.DeleteUser, "/user/delete", endpoint="delete_user")
api.add_resource(user.DeleteUserSelf, "/user/delete_self", endpoint="delete_user_self")
api.add_resource(user.RemoveUserAssociation, "/user/access/revoke", endpoint="revoke_from_project")
api.add_resource(user.UserActivation, "/user/activation", endpoint="user_activation")
api.add_resource(
user.RequestHOTPActivation, "/user/hotp/activate", endpoint="request_hotp_activation"
)
api.add_resource(
user.RequestTOTPActivation, "/user/totp/activate", endpoint="request_totp_activation"
)
api.add_resource(user.Users, "/users", endpoint="users")
api.add_resource(user.InvitedUsers, "/user/invites", endpoint="list_invites")

# Super Admins ###################################################################### Super Admins #

api.add_resource(superadmin_only.MaintenanceMode, "/maintenance", endpoint="maintenance")
api.add_resource(superadmin_only.AllUnits, "/unit/info/all", endpoint="all_units")
api.add_resource(superadmin_only.MOTD, "/motd", endpoint="motd")
api.add_resource(superadmin_only.SendMOTD, "/motd/send", endpoint="send_motd")
api.add_resource(superadmin_only.FindUser, "/user/find", endpoint="find_user")
api.add_resource(
superadmin_only.ResetTwoFactor, "/user/totp/deactivate", endpoint="reset_user_hotp"
)
api.add_resource(superadmin_only.AnyProjectsBusy, "/proj/busy/any", endpoint="projects_busy_any")
api.add_resource(superadmin_only.Statistics, "/stats", endpoint="stats")
api.add_resource(superadmin_only.UnitUserEmails, "/user/emails", endpoint="user_emails")

# Invoicing ############################################################################ Invoicing #
api.add_resource(user.ShowUsage, "/usage", endpoint="usage")
def add_resources(api):
# Login/access ###################################################################### Login/access #
api.add_resource(user.EncryptedToken, "/user/encrypted_token", endpoint="encrypted_token")
api.add_resource(user.SecondFactor, "/user/second_factor", endpoint="second_factor")

# S3 ########################################################################################## S3 #
api.add_resource(s3.S3Info, "/s3/proj", endpoint="proj_s3_info")

# Files #################################################################################### Files #
api.add_resource(files.NewFile, "/file/new", endpoint="new_file")
api.add_resource(files.MatchFiles, "/file/match", endpoint="match_files")
api.add_resource(files.ListFiles, "/files/list", endpoint="list_files")
api.add_resource(files.RemoveFile, "/file/rm", endpoint="remove_file")
api.add_resource(files.RemoveDir, "/file/rmdir", endpoint="remove_dir")
api.add_resource(files.FileInfo, "/file/info", endpoint="file_info")
api.add_resource(files.FileInfoAll, "/file/all/info", endpoint="all_file_info")
api.add_resource(files.UpdateFile, "/file/update", endpoint="update_file")
api.add_resource(files.AddFailedFiles, "/file/failed/add", endpoint="add_failed_files")

# Projects ############################################################################## Projects #
api.add_resource(project.UserProjects, "/proj/list", endpoint="list_projects")
api.add_resource(project.RemoveContents, "/proj/rm", endpoint="remove_contents")
api.add_resource(project.GetPublic, "/proj/public", endpoint="public_key")
api.add_resource(project.GetPrivate, "/proj/private", endpoint="private_key")
api.add_resource(project.CreateProject, "/proj/create", endpoint="create_project")
api.add_resource(project.ProjectUsers, "/proj/users", endpoint="list_project_users")
api.add_resource(project.ProjectStatus, "/proj/status", endpoint="project_status")
api.add_resource(project.ProjectAccess, "/proj/access", endpoint="project_access")
api.add_resource(project.ProjectBusy, "/proj/busy", endpoint="project_busy")
api.add_resource(project.ProjectInfo, "/proj/info", endpoint="project_info")

# User management ################################################################ User management #
api.add_resource(user.RetrieveUserInfo, "/user/info", endpoint="user_info")
api.add_resource(user.AddUser, "/user/add", endpoint="add_user")
api.add_resource(user.DeleteUser, "/user/delete", endpoint="delete_user")
api.add_resource(user.DeleteUserSelf, "/user/delete_self", endpoint="delete_user_self")
api.add_resource(
user.RemoveUserAssociation, "/user/access/revoke", endpoint="revoke_from_project"
)
api.add_resource(user.UserActivation, "/user/activation", endpoint="user_activation")
api.add_resource(
user.RequestHOTPActivation, "/user/hotp/activate", endpoint="request_hotp_activation"
)
api.add_resource(
user.RequestTOTPActivation, "/user/totp/activate", endpoint="request_totp_activation"
)
api.add_resource(user.Users, "/users", endpoint="users")
api.add_resource(user.InvitedUsers, "/user/invites", endpoint="list_invites")

# Super Admins ###################################################################### Super Admins #

api.add_resource(superadmin_only.MaintenanceMode, "/maintenance", endpoint="maintenance")
api.add_resource(superadmin_only.AllUnits, "/unit/info/all", endpoint="all_units")
api.add_resource(superadmin_only.MOTD, "/motd", endpoint="motd")
api.add_resource(superadmin_only.SendMOTD, "/motd/send", endpoint="send_motd")
api.add_resource(superadmin_only.FindUser, "/user/find", endpoint="find_user")
api.add_resource(
superadmin_only.ResetTwoFactor, "/user/totp/deactivate", endpoint="reset_user_hotp"
)
api.add_resource(
superadmin_only.AnyProjectsBusy, "/proj/busy/any", endpoint="projects_busy_any"
)
api.add_resource(superadmin_only.Statistics, "/stats", endpoint="stats")
api.add_resource(superadmin_only.UnitUserEmails, "/user/emails", endpoint="user_emails")

# Invoicing ############################################################################ Invoicing #
api.add_resource(user.ShowUsage, "/usage", endpoint="usage")


add_resources(api)
add_resources(api_v3)
Loading
Loading