Skip to content

Commit

Permalink
[AMORO-3038] Unify the API set for dashboard and open API
Browse files Browse the repository at this point in the history
  • Loading branch information
mansonliwh committed Oct 12, 2024
1 parent 0ffdec2 commit 9f2aaed
Show file tree
Hide file tree
Showing 23 changed files with 231 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,13 @@ public EndpointGroup endpoints() {

// for dashboard api
path(
"/ams/v1",
"/api/ams/v1",
() -> {
// login controller
get("/login/current", loginController::getCurrent);
post("/login", loginController::login);
post("/logout", loginController::logout);
});
path("ams/v1", apiGroup());

// for open api
path("/api/ams/v1", apiGroup());
Expand Down Expand Up @@ -355,7 +354,8 @@ private EndpointGroup apiGroup() {

public void preHandleRequest(Context ctx) {
String uriPath = ctx.path();
if (needApiKeyCheck(uriPath)) {
String requestSource = ctx.header("X-Request-Source");
if (needApiKeyCheck(uriPath) && !"frontend".equals(requestSource)) {
if (AUTH_TYPE_BASIC.equalsIgnoreCase(authType)) {
BasicAuthCredentials cred = ctx.basicAuthCredentials();
if (!(basicAuthUser.equals(cred.component1())
Expand Down Expand Up @@ -391,10 +391,10 @@ public void handleException(Exception e, Context ctx) {
}

private static final String[] urlWhiteList = {
"/ams/v1/versionInfo",
"/ams/v1/login",
"/ams/v1/health/status",
"/ams/v1/login/current",
"/api/ams/v1/versionInfo",
"/api/ams/v1/login",
"/api/ams/v1/health/status",
"/api/ams/v1/login/current",
"/",
"/overview",
"/introduce",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ public void deleteCatalog(Context ctx) {
/** Construct a url */
private String constructCatalogConfigFileUrl(String catalogName, String type, String key) {
return String.format(
"/ams/v1/catalogs/%s/config/%s/%s", catalogName, type, key.replaceAll("\\.", "-"));
"/api/ams/v1/catalogs/%s/config/%s/%s", catalogName, type, key.replaceAll("\\.", "-"));
}

/** Get the config file content uri("/catalogs/{catalogName}/config/{type}/{key} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void uploadFile(Context ctx) throws IOException {
Integer fid = platformFileInfoService.addFile(name, content);
Map<String, String> result = new HashMap<>();
result.put("id", String.valueOf(fid));
result.put("url", "/ams/v1/files/" + fid);
result.put("url", "/api/ams/v1/files/" + fid);
ctx.json(OkResponse.of(result));
}

Expand Down
26 changes: 13 additions & 13 deletions amoro-web/mock/modules/catalogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

export default [
{
url: '/mock/ams/v1/catalogs',
url: '/mock/api/ams/v1/catalogs',
method: 'get',
response: () => ({
"message": "success",
Expand Down Expand Up @@ -56,27 +56,27 @@ export default [
}),
},
{
url: '/mock/ams/v1/catalogs',
url: '/mock/api/ams/v1/catalogs',
method: 'post',
response: () => ({"message":"success","code":200,"result":""}),
},

{
url: '/mock/ams/v1/catalogs/test_catalog/databases',
url: '/mock/api/ams/v1/catalogs/test_catalog/databases',
method: 'get',
response: () => {
return { "message": "success", "code": 200, "result": ["db", "test", "acc"] }
},
},
{
url: '/mock/ams/v1/catalogs/test_catalog/databases/db/tables',
url: '/mock/api/ams/v1/catalogs/test_catalog/databases/db/tables',
method: 'get',
response: () => {
return { "message": "success", "code": 200, "result": [{ "name": "user", "type": "ICEBERG" },{ "name": "wf", "type": "ICEBERG" }, { "name": "xcvz", "type": "ICEBERG" }] };
},
},
{
url: '/mock/ams/v1/catalogs/:id',
url: '/mock/api/ams/v1/catalogs/:id',
method: 'get',
response: () => ({
"message": "success",
Expand All @@ -92,15 +92,15 @@ export default [
"storage.type": "Hadoop",
"hive.site": {
"fileName": "hive-site.xml",
"fileUrl": "/ams/v1/catalogs/test_catalog/config/storage-config/hive-site"
"fileUrl": "/api/ams/v1/catalogs/test_catalog/config/storage-config/hive-site"
},
"hadoop.core.site": {
"fileName": "core-site.xml",
"fileUrl": "/ams/v1/catalogs/test_catalog/config/storage-config/hadoop-core-site"
"fileUrl": "/api/ams/v1/catalogs/test_catalog/config/storage-config/hadoop-core-site"
},
"hadoop.hdfs.site": {
"fileName": "hdfs-site.xml",
"fileUrl": "/ams/v1/catalogs/test_catalog/config/storage-config/hadoop-hdfs-site"
"fileUrl": "/api/ams/v1/catalogs/test_catalog/config/storage-config/hadoop-hdfs-site"
}
},
"authConfig": {
Expand All @@ -116,22 +116,22 @@ export default [
}),
},
{
url: '/mock/ams/v1/catalogs/:id',
url: '/mock/api/ams/v1/catalogs/:id',
method: 'put',
response: () => ({ "message": "success", "code": 200, "result": null }),
},
{
url: '/mock/ams/v1/catalogs/:id',
url: '/mock/api/ams/v1/catalogs/:id',
method: 'delete',
response: () => ({ "message": "success", "code": 200, "result": true }),
},
{
url: '/mock/ams/v1/catalogs/:id/delete/check',
url: '/mock/api/ams/v1/catalogs/:id/delete/check',
method: 'get',
response: () => ({ "message": "success", "code": 200, "result": true }),
},
{
url: '/mock/ams/v1/catalogs/metastore/types',
url: '/mock/api/ams/v1/catalogs/metastore/types',
method: 'get',
response: () => ({
"message": "success",
Expand Down Expand Up @@ -161,7 +161,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/tables/catalogs/:catalog/dbs/:dbId/tables/:tableName/optimizing-processes/:processesId/tasks',
url: '/mock/api/ams/v1/tables/catalogs/:catalog/dbs/:dbId/tables/:tableName/optimizing-processes/:processesId/tasks',
method: 'get',
response: () => ({
"message": "success",
Expand Down
10 changes: 5 additions & 5 deletions amoro-web/mock/modules/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

export default [
{
url: '/mock/ams/v1/login/current',
url: '/mock/api/ams/v1/login/current',
method: 'get',
response: () => ({
code: 200,
Expand All @@ -30,7 +30,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/login',
url: '/mock/api/ams/v1/login',
method: 'post',
response: () => ({
code: 200,
Expand All @@ -39,7 +39,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/versionInfo',
url: '/mock/api/ams/v1/versionInfo',
method: 'get',
response: () => ({
code: 200,
Expand All @@ -51,7 +51,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/upgrade/properties',
url: '/mock/api/ams/v1/upgrade/properties',
method: 'get',
response: () => ({
code: 200,
Expand All @@ -63,7 +63,7 @@ export default [
})
},
{
url: '/mock/ams/v1/logout',
url: '/mock/api/ams/v1/logout',
method: 'post',
response: () => ({
code: 200,
Expand Down
29 changes: 19 additions & 10 deletions amoro-web/mock/modules/optimize.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

export default [
{
url: '/mock/ams/v1/optimize/resourceGroups/get',
url: '/mock/api/ams/v1/optimize/resourceGroups/get',
method: 'get',
response: () => ({
code: 200,
Expand All @@ -29,7 +29,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/optimize/containers/get',
url: '/mock/api/ams/v1/optimize/containers/get',
method: 'get',
response: () => ({
code: 200,
Expand All @@ -38,7 +38,16 @@ export default [
}),
},
{
url: '/mock/ams/v1/optimize/optimizerGroups/:groups/tables',
url: '/mock/api/ams/v1/optimize/actions',
method: 'get',
response: () => ({
code: 200,
msg: 'success',
result: ['major', 'minor', 'clean', 'idle', 'pending']
}),
},
{
url: '/mock/api/ams/v1/optimize/optimizerGroups/:groups/tables',
method: 'get',
response: () => ({
"message": "success",
Expand Down Expand Up @@ -76,12 +85,12 @@ export default [
}),
},
{
url: '/mock/ams/v1/optimize/optimizerGroups/local/optimizers',
url: '/mock/api/ams/v1/optimize/optimizerGroups/local/optimizers',
method: 'post',
response: () => ({ "message": "success", "code": 200, "result": "success to scaleOut optimizer" }),
},
{
url: '/mock/ams/v1/optimize/resourceGroups',
url: '/mock/api/ams/v1/optimize/resourceGroups',
method: 'get',
response: () => ({
"message": "success",
Expand Down Expand Up @@ -124,7 +133,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/optimize/resourceGroups',
url: '/mock/api/ams/v1/optimize/resourceGroups',
method: 'put',
response: () => ({
"message": "success",
Expand All @@ -133,7 +142,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/optimize/resourceGroups',
url: '/mock/api/ams/v1/optimize/resourceGroups',
method: 'post',
response: () => ({
"message": "success",
Expand All @@ -142,12 +151,12 @@ export default [
}),
},
{
url: '/mock/ams/v1/optimize/resourceGroups/:id/delete/check',
url: '/mock/api/ams/v1/optimize/resourceGroups/:id/delete/check',
method: 'get',
response: () => ({ "message": "success", "code": 200, "result": true }),
},
{
url: '/mock/ams/v1/optimize/resourceGroups/:id',
url: '/mock/api/ams/v1/optimize/resourceGroups/:id',
method: 'delete',
response: () => ({
"message": "success",
Expand All @@ -156,7 +165,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/optimize/optimizerGroups/all/optimizers',
url: '/mock/api/ams/v1/optimize/optimizerGroups/all/optimizers',
method: 'get',
response: () => ({
"message": "success",
Expand Down
10 changes: 5 additions & 5 deletions amoro-web/mock/modules/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

export default [
{
url: '/mock/ams/v1/overview/summary',
url: '/mock/api/ams/v1/overview/summary',
method: 'get',
response: () => ({
code: 200,
Expand All @@ -33,7 +33,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/overview/optimizing',
url: '/mock/api/ams/v1/overview/optimizing',
method: 'get',
response: () => ({
code: 200,
Expand All @@ -48,7 +48,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/overview/top',
url: '/mock/api/ams/v1/overview/top',
method: 'get',
response: () => ({
code: 200,
Expand All @@ -68,7 +68,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/overview/resource',
url: '/mock/api/ams/v1/overview/resource',
method: 'get',
response: () => ({
code: 200,
Expand Down Expand Up @@ -97,7 +97,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/overview/dataSize',
url: '/mock/api/ams/v1/overview/dataSize',
method: 'get',
response: () => ({
code: 200,
Expand Down
4 changes: 2 additions & 2 deletions amoro-web/mock/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

export default [
{
url: '/mock/ams/v1/settings/system',
url: '/mock/api/ams/v1/settings/system',
method: 'get',
response: () => ({
code: 200,
Expand All @@ -30,7 +30,7 @@ export default [
}),
},
{
url: '/mock/ams/v1/settings/containers',
url: '/mock/api/ams/v1/settings/containers',
method: 'get',
response: () => ({
code: 200,
Expand Down
Loading

0 comments on commit 9f2aaed

Please sign in to comment.