-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate jans-config-api client from multiple swagger specs #426
- Loading branch information
Showing
5 changed files
with
141 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"inputs": [ | ||
{ | ||
"inputURL": "https://raw.githubusercontent.com/JanssenProject/jans/main/jans-config-api/docs/jans-config-api-swagger-auto.yaml" | ||
}, | ||
{ | ||
"inputURL": "https://raw.githubusercontent.com/JanssenProject/jans/main/jans-config-api/plugins/docs/jans-admin-ui-plugin-swagger.yaml" | ||
}, | ||
{ | ||
"inputURL": "https://raw.githubusercontent.com/JanssenProject/jans/main/jans-config-api/plugins/docs/user-mgt-plugin-swagger.yaml" | ||
} | ||
], | ||
"output": "./configApiSpecs.yaml" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { handleResponse } from 'Utils/ApiUtils' | ||
|
||
export default class MappingApi { | ||
constructor(api) { | ||
this.api = api | ||
} | ||
getMappings = () => { | ||
return new Promise((resolve, reject) => { | ||
this.api.getAdminuiRolePermissions((error, data) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
updateMapping = (data) => { | ||
const options = {} | ||
options['rolePermissionMapping'] = data | ||
return new Promise((resolve, reject) => { | ||
this.api.mapPermissionsToRole(options, (error, options) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
addMapping = (data) => { | ||
const options = {} | ||
options['rolePermissionMapping'] = data | ||
return new Promise((resolve, reject) => { | ||
this.api.mapPermissionsToRole(options, (error, options) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
deleteMapping = (data) => { | ||
return new Promise((resolve, reject) => { | ||
this.api.removeRolePermissionsPermission(data.role, (error, options) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
admin-ui/plugins/admin/components/Permissions/PermissionApi.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { handleResponse } from 'Utils/ApiUtils' | ||
|
||
export default class PermissionApi { | ||
constructor(api) { | ||
this.api = api | ||
} | ||
getPermissions = () => { | ||
return new Promise((resolve, reject) => { | ||
this.api.getAdminuiPermissions((error, data) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
addPermission = (data) => { | ||
const options = {} | ||
options['adminPermission'] = data | ||
return new Promise((resolve, reject) => { | ||
this.api.addAdminuiPermission(options, (error, data) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
editPermission = (data) => { | ||
const options = {} | ||
options['adminPermission'] = data | ||
return new Promise((resolve, reject) => { | ||
this.api.editAdminuiPermission(options, (error, data) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
deletePermission = async (data) => { | ||
return new Promise((resolve, reject) => { | ||
this.api.deleteAdminuiPermission(data.permission, (error, data) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { handleResponse } from 'Utils/ApiUtils' | ||
|
||
export default class RoleApi { | ||
constructor(api) { | ||
this.api = api | ||
} | ||
getRoles = () => { | ||
return new Promise((resolve, reject) => { | ||
this.api.getAdminuiRoles((error, data) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
addRole = (data) => { | ||
const options = {} | ||
options['adminRole'] = data | ||
return new Promise((resolve, reject) => { | ||
this.api.addAdminuiRole(options, (error, data) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
editRole = (data) => { | ||
const options = {} | ||
options['adminRole'] = data | ||
return new Promise((resolve, reject) => { | ||
this.api.editAdminuiRole(options, (error, data) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
deleteRole = async (data) => { | ||
return new Promise((resolve, reject) => { | ||
this.api.deleteAdminuiRole(data.role, (error, data) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
} |