apache / incubator-streampark

Make stream processing easier! Easy-to-use streaming application development framework and operation platform.
https://streampark.apache.org/
Apache License 2.0
3.89k stars 1.01k forks source link

[DISCUSSION] refactor v2 api use RESTful API #2565

Open lvshaokang opened 1 year ago

lvshaokang commented 1 year ago

Code of Conduct

Search before asking

Describe the proposal

AlertController

before after
[POST] /flink/alert/add [POST] /alert-configs/
[POST] /flink/alert/exists [GET] /alert-configs/{config-id}/check
[POST] /flink/alert/update [PUT] /alert-configs/{config-id}
[POST] /flink/alert/get [GET] /alert-configs/{config-id}
[POST] /flink/alert/list [GET] /alert-configs/
[POST] /flink/alert/listWithOutPage [GET] /alert-configs/
[DELETE] /flink/alert/delete [DELETE] /alert-configs/{config-id}
[POST] /flink/alert/send [POST] /alert-configs/{config-id}/send

ApplicationBuildPipelineController

before after
[POST] /flink/pipe/build [POST] /flink/applications/{app-id}/release
[POST] /flink/pipe/detail [GET] /flink/applications/{app-id}/release/pipeline

ApplicationController

before after
[POST] /flink/app/get [GET] /flink/applications/{app-id}
[POST] /flink/app/create [POST] /flink/applications/
[POST] /flink/app/copy [POST] /flink/applications/{app-id}/copy
[POST] /flink/app/update [PUT] /flink/applications/{app-id}
[POST] /flink/app/dashboard [POST] /team/{team-id}/flink/applications/dashboard
or /flink/applications/dashboard?team-id=
[POST] /flink/app/list [GET] /flink/applications/
[POST] /flink/app/mapping [POST] /flink/applications/mapping
[POST] /flink/app/revoke [POST] /flink/applications/{app-id}/revoke
[POST] /flink/app/start [POST] /flink/applications/{app-id}/start
[POST] /flink/app/cancel [POST] /flink/applications/{app-id}/cancel
[POST] /flink/app/clean [POST] -
[POST] /flink/app/forcedStop [POST] /flink/applications/{app-id}/force-stop
[POST] /flink/app/yarn [GET] /flink/applications/{app-id}/yarn-proxy
[POST] /flink/app/name [GET] /flink/applications/{app-id}/yarn-name
[POST] /flink/app/checkName [GET] /flink/applications/{app-id}/status
[POST] /flink/app/readConf [GET] /flink/applications/{app-id}/conf
[POST] /flink/app/main [GET] /flink/applications/{app-id}/main-class
[POST] /flink/app/rollback -
[POST] /flink/app/backups [GET] /flink/applications/backups
[POST] /flink/app/optionlog [GET] /flink/applications/{app-id}/option-logs
[POST] /flink/app/delete [DELETE] /flink/applications/{app-id}
[POST] /flink/app/deletebak [DELETE] /flink/applications/backups/{back-id}
[POST] /flink/app/checkjar -
[POST] /flink/app/upload [POST] /flink/applications/upload
[POST] /flink/app/verifySchema -
[POST] /flink/app/checkSavepointPath [POST] /flink/applications/{app-id}/savepoint-path
[POST] /flink/app/k8sStartLog [GET] /flink/applications/{app-id}/k8s-start-logs

ApplicationHistoryController

before after
[POST] /flink/history/uploadJars [GET] /histories/jars
[POST] /flink/history/k8sNamespaces [GET] /histories/k8s-namespaces
[POST] /flink/history/sessionClusterIds [GET] /histories/session-clusters
[POST] /flink/history/flinkBaseImages [GET] /histories/flink-base-images
[POST] /flink/history/flinkPodTemplates [GET] /histories/flink-pod-templates
[POST] /flink/history/flinkJmPodTemplates [GET] /histories/flink-jm-pod-templates
[POST] /flink/history/flinkTmPodTemplates [GET] /histories/flink-tm-pod-templates

ConfigController

before after
[POST] /flink/conf/get [GET] /configs/{config-id}
[POST] /flink/conf/template [GET] /configs/flink/conf-template
[POST] /flink/conf/list [GET] /flink/applications/{app-id}/configs
[POST] /flink/conf/history [GET] /flink/applications/{app-id}/configs/history
[POST] /flink/conf/delete [DELETE] /configs/flink/{config-id}
[POST] /flink/conf/sysHadoopConf [GET] /configs/system/hadoop-configs

ExternalLinkController

before after
[POST] /flink/externalLink/list [GET] /external-links
[POST] /flink/externalLink/render [GET] /flink/applications/{app-id}/external-links
[POST] /flink/externalLink/create [POST] /external-links
[POST] /flink/externalLink/update [PUT] /external-links/{link-id}
[POST] /flink/externalLink/delete [DELETE] /external-links/{link-id}

FlinkClusterController

before after
[POST] /flink/cluster/list [GET] /flink/clusters
[POST] /flink/cluster/remoteUrl [GET] /flink/clusters/{cluster-id}/remote-address
[POST] /flink/cluster/check [GET] /flink/clusters/{cluster-id}/status
[POST] /flink/cluster/create [POST] /flink/clusters
[POST] /flink/cluster/update [PUT] /flink/clusters/{cluster-id}
[POST] /flink/cluster/get [GET] /flink/clusters/{cluster-id}
[POST] /flink/cluster/start [POST] /flink/clusters/{cluster-id}/start
[POST] /flink/cluster/shutdown [POST] /flink/clusters/{cluster-id}/shutdown
[POST] /flink/cluster/delete [DELETE] /flink/clusters/{cluster-id}

FlinkEnvController

before after
[POST] /flink/env/list [GET] /flink/environments/
[POST] /flink/env/exists [GET] /flink/environments/verify
[POST] /flink/env/create [POST] /flink/environments
[POST] /flink/env/get [GET] /flink/environments/{env-id}
[POST] /flink/env/sync [PUT] /flink/environments/{env-id}/sync
[POST] /flink/env/update [PUT] /flink/environments/{env-id}
[POST] /flink/env/default [PATCH] /flink/environments/{env-id}

FlinkPodTemplateController

before after
[POST] /flink/podtmpl/sysHosts [GET] /flink/pod-templates/hosts
[POST] /flink/podtmpl/init [GET] /flink/pod-templates/init
[POST] /flink/podtmpl/compHostAlias [POST] /flink/pod-templates/host-alias/complete
[POST] /flink/podtmpl/extractHostAlias [POST] /flink/pod-templates/host-alias/extract
[POST] /flink/podtmpl/previewHostAlias [POST] /flink/pod-templates/host-alias/preview

FlinkSqlController

before after
[POST] /flink/sql/verify [POST] /flink/sql/verify
[POST] /flink/sql/list [GET] /flink/applications/{app-id}/sql
[POST] /flink/sql/delete [DELETE] /flink/sql/{sql-id}
[POST] /flink/sql/get [GET] /flink/sql?id=1,2
[POST] /flink/sql/history [GET] /flink/applications/{app-id}/sql/history
[POST] /flink/sql/sqlComplete [POST] /flink/sql/complete

ProjectController

before after
[POST] /flink/project/create [POST] /projects
[POST] /flink/project/update [PUT] /projects/{project-id}
[POST] /flink/project/get [GET] /projects/{project-id}
[POST] /flink/project/build [POST] /projects/{project-id}/build
[POST] /flink/project/buildlog [GET] /projects/{project-id}/build-logs
[POST] /flink/project/list [GET] /projects
[POST] /flink/project/branches [GET] /projects/{project-id}/git/branches
[POST] /flink/project/delete [DELETE] /projects/{project-id}
[POST] /flink/project/gitcheck [POST] /projects/{project-id}/git/auth
[POST] /flink/project/exists [POST] /projects/{project-id}/check
[POST] /flink/project/modules [GET] /projects/{project-id}/modules
[POST] /flink/project/jars [GET] /projects/{project-id}/jars
[POST] /flink/project/listconf [GET] /projects/{project-id}/configurations
[POST] /flink/project/select [GET] /teams/{team-id}/projects
or /projects?team-id=?

SavePointController

before after
[POST] /flink/savepoint/latest [GET] /flink/applications/{app-id}/savepoints/latest
[POST] /flink/savepoint/history [GET] /flink/applications/{app-id}/savepoints/history
[POST] /flink/savepoint/delete [DELETE] /savepoints/{savepoint-id}
[POST] /flink/savepoint/trigger [POST] /flink/applications/{app-id}/savepoints

SettingController

before after
[POST] /flink/setting/all [GET] /settings
[POST] /flink/setting/get [GET] /settings/{setting-key}
[POST] /flink/setting/weburl [GET] /settings/streampark/address
[POST] /flink/setting/update [PUT] /settings/{setting-key}
[PUT] /flink/setting/checkHadoop [GET] /settings/hadoop/status

VariableController

before after
[POST] /variable/page [GET] /variables
[POST] /variable/list [GET] /variables
[POST] /variable/dependApps [GET] /projects/{project-id}
[POST] /variable/post [POST] /variables/
[PUT] /variable/update [PUT] /variables/{variable-id}
[POST] /variable/showOriginal [GET] /variables/{variable-id}
[DELETE] /variable/delete [DELETE] /variables/{variable-id}
[POST] /variable/check/code [GET] /variables/validate

AccessTokenController

before after
[POST] /token/create [POST] /tokens
[POST] /token/check [GET] /tokens/current/status
[POST] /token/list [GET] /tokens
[POST] /token/toggle [PATCH] /tokens/{token-id}/toggle
[POST] /token/delete [DELETE] /tokens/{token-id}
[POST] /token/curl -

MemberController

before after
[POST] /member/list [POST] /members
[POST] /member/candidateUsers [GET] /teams/{team-id}/users
[POST] /member/teams [GET] /members/{user-id}/teams
[POST] /member/check/user [GET] /teams/{team-id}/members/{username}/check
[POST] /member/post [POST] /members
[DELETE] /member/delete [DELETE] /members/{member-id}
[PUT] /member/update [PUT] /members/{member-id}

MenuController

before after
[POST] /menu/router [GET] /teams/{team-id}/users/current/menu-routes
/users/current/menu-routes?team-id=?
[POST] /menu/list [GET] /menus
[POST] /menu/post [POST] /menus
[DELETE] /menu/delete [DELETE] /menus
[PUT] /menu/update [PUT] /menus/{menu-id}

PassportController

before after
[POST] /passport/signin [POST] /passport/signin
[POST] /passport/signout [POST] /passport/signout

RoleController

before after
[POST] /role/list [GET] /roles
[POST] /role/check/name [GET] /roles/{role-name}/check
[POST] /role/menu [POST] /roles/{role-id}/menus
[POST] /role/post [POST] /roles
[DELETE] /role/delete [DELETE] /roles/{role-id}
[PUT] /role/update [PUT] /roles/{role-id}

TeamController

before after
[POST] /team/list [GET] /teams
[POST] /team/check/name [GET] /teams/{team-name}/check
[POST] /team/post [POST] /teams
[DELETE] /team/update [DELETE] /teams/{team-id}
[PUT] /team/update [PUT] /teams/{team-id}

UserController

before after
[POST] /user/detail [GET] /users/{username}
[POST] /user/list [GET] /users
[POST] /user/post [POST] /users
[PUT] /user/update [PUT] /users/{user-id}
[DELETE] /user/delete [DELETE] /users/{user-id}
[PUT] /user/profile [PUT] /users/{user-id}
[POST] /user/avatar [PATCH] /users/{username}
[POST] /user/getNoTokenUser [GET] /users?has_token=true
[POST] /user/check/name [POST] /users/{username}/check
[POST] /user/check/password [POST] /users/{username}/verify
[PUT] /user/password [PATCH] /users/{username}/password
[PUT] /user/password/reset [POST] /users/{username}/reset-password
[POST] /user/types [GET] /user-types
[POST] /user/initTeam [POST] /users/{user-id}/teams
[POST] /user/setTeam [POST] /users/current/teams
[POST] /user/appOwners [POST] /teams/{team-id}/users

Task list

TODO

Are you willing to submit PR?

wolfboys commented 1 year ago

Great proposal, some resturls, we need to discuss

GOODBOY008 commented 1 year ago

@lvshaokang @wolfboys We should change post data with json instead of form. With this issue merged ,I will carry on replace enum type issue.

GOODBOY008 commented 1 year ago

Like this front end pass only one param,but back end receive with Application entity is too heavy and make us confused. So we should discuss use DTO instead of entity to pass params. 229964842-85a4b442-bee5-4dc9-97f1-4c1e1e134322 229964850-e5b2ceb7-3bdd-440c-a496-eb6e6e55feb0

GOODBOY008 commented 1 year ago

Backend controller add param validation , most of endpionts are missing param validation.

lvshaokang commented 1 year ago

@lvshaokang @wolfboys We should change post data with json instead of form. With this issue merged ,I will carry on replace enum type issue.

@GOODBOY008 Right. Some controller methods is redundant, but for one or two fields of the method whether to also use json entity, may need to consider it. Some times we can use path variable or query variable to pass parameters, like, [DELETE] /alert-configs/{config-id} [GET] /alert-configs?a=b&c=d

GOODBOY008 commented 1 year ago

Like this front end pass only one param,but back end receive with Application entity is too heavy and make us confused. So we should discuss use DTO instead of entity to pass params. 229964842-85a4b442-bee5-4dc9-97f1-4c1e1e134322 229964850-e5b2ceb7-3bdd-440c-a496-eb6e6e55feb0

@lvshaokang According to the specific conditions , we should think different :)