Skip to content

Commit

Permalink
feat: impl of new internal api (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordenReuter authored May 21, 2024
1 parent d028355 commit 86a6b88
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,38 @@ h| Version
| tkit-quarkus-log-cdi
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-cdi.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
| 2.23.0
| tkit-quarkus-log-rs
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-rs.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
| 2.23.0
| tkit-quarkus-log-json
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-json.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
| 2.23.0
| tkit-quarkus-rest
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-rest.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link]
| 2.23.0
| tkit-quarkus-rest-context
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-rest-context.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link]
| 2.23.0
| tkit-quarkus-security
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-security.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link]
| 2.23.0
| quarkus-hibernate-validator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,52 +45,51 @@ public Response createAssignment(CreateAssignmentRequestDTO createAssignmentRequ
}

@Override
public Response grantAssignments(CreateProductAssignmentsRequestDTO createProductAssignmentsRequestDTO) {

//!! This is workaround for current UI

// app-id not null, take only first product from list
if (createProductAssignmentsRequestDTO.getAppId() != null && !createProductAssignmentsRequestDTO.getAppId().isEmpty()) {
int status = Response.Status.BAD_REQUEST.getStatusCode();
for (int i = 0; i < createProductAssignmentsRequestDTO.getProductNames().size(); i++) {
try (Response response = assignmentClient.grantRoleProductAssignments(
createProductAssignmentsRequestDTO.getRoleId(),
mapper.mapRoleProduct(createProductAssignmentsRequestDTO, i))) {
status = response.getStatus();
}
}
return Response.status(status).build();
public Response grantRoleAssignments(String roleId) {
try (Response response = assignmentClient.grantRoleAssignments(roleId)) {
return Response.status(response.getStatus()).build();
}
}

// list of product-names
try (Response response = assignmentClient.grantRoleProductsAssignments(
createProductAssignmentsRequestDTO.getRoleId(),
mapper.mapRoleProducts(createProductAssignmentsRequestDTO))) {
@Override
public Response grantRoleApplicationAssignments(String roleId,
CreateRoleApplicationAssignmentRequestDTO createRoleApplicationAssignmentRequestDTO) {
try (Response response = assignmentClient.grantRoleApplicationAssignments(roleId,
mapper.map(createRoleApplicationAssignmentRequestDTO))) {
return Response.status(response.getStatus()).build();
}
}

@Override
public Response grantRoleAssignments(String roleId) {
try (Response response = assignmentClient.grantRoleAssignments(roleId)) {
public Response grantRoleProductsAssignments(String roleId,
CreateRoleProductsAssignmentRequestDTO createRoleProductsAssignmentRequestDTO) {
try (Response response = assignmentClient.grantRoleProductsAssignments(roleId,
mapper.map(createRoleProductsAssignmentRequestDTO))) {
return Response.status(response.getStatus()).build();
}
}

@Override
public Response grantRoleProductAssignments(String roleId,
CreateRoleProductAssignmentRequestDTO createRoleProductAssignmentRequestDTO) {
try (Response response = assignmentClient.grantRoleProductAssignments(roleId,
mapper.map(createRoleProductAssignmentRequestDTO))) {
public Response revokeRoleApplicationAssignments(String roleId,
RevokeRoleApplicationAssignmentRequestDTO revokeRoleApplicationAssignmentRequestDTO) {
try (Response response = assignmentClient.revokeRoleApplicationAssignments(roleId,
mapper.map(revokeRoleApplicationAssignmentRequestDTO))) {
return Response.status(response.getStatus()).build();
}
}

@Override
public Response grantRoleProductsAssignments(String roleId,
CreateRoleProductsAssignmentRequestDTO createRoleProductsAssignmentRequestDTO) {
try (Response response = assignmentClient.grantRoleProductsAssignments(roleId,
mapper.map(createRoleProductsAssignmentRequestDTO))) {
public Response revokeRoleAssignments(String roleId) {
try (Response response = assignmentClient.revokeRoleAssignments(roleId)) {
return Response.status(response.getStatus()).build();
}
}

@Override
public Response revokeRoleProductsAssignments(String roleId,
RevokeRoleProductsAssignmentRequestDTO revokeRoleProductsAssignmentRequestDTO) {
try (Response response = assignmentClient.revokeRoleProductsAssignments(roleId,
mapper.map(revokeRoleProductsAssignmentRequestDTO))) {
return Response.status(response.getStatus()).build();
}
}
Expand All @@ -110,13 +109,6 @@ public Response getAssignment(String id) {
}
}

@Override
public Response revokeAssignments(RevokeAssignmentRequestDTO revokeAssignmentRequestDTO) {
try (Response response = assignmentClient.revokeAssignments(mapper.map(revokeAssignmentRequestDTO))) {
return Response.status(response.getStatus()).build();
}
}

@Override
public Response searchAssignments(AssignmentSearchCriteriaDTO assignmentSearchCriteriaDTO) {
try (Response response = assignmentClient.searchAssignments(mapper.map(assignmentSearchCriteriaDTO))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public interface AssignmentMapper {
@Mapping(target = "removeStreamItem", ignore = true)
AssignmentPageResultDTO map(AssignmentPageResult pageResult);

RevokeAssignmentRequest map(RevokeAssignmentRequestDTO revokeAssignmentRequestDTO);

CreateRoleProductsAssignmentRequest mapRoleProducts(CreateProductAssignmentsRequestDTO createProductAssignmentsRequestDTO);

default CreateRoleProductAssignmentRequest mapRoleProduct(
Expand All @@ -30,7 +28,11 @@ default CreateRoleProductAssignmentRequest mapRoleProduct(
.appId(createProductAssignmentsRequestDTO.getAppId());
}

CreateRoleProductAssignmentRequest map(CreateRoleProductAssignmentRequestDTO createRoleProductAssignmentRequestDTO);
CreateRoleProductAssignmentRequest map(CreateRoleApplicationAssignmentRequestDTO createRoleProductAssignmentRequestDTO);

CreateRoleProductsAssignmentRequest map(CreateRoleProductsAssignmentRequestDTO createRoleProductsAssignmentRequestDTO);

RevokeRoleProductAssignmentRequest map(RevokeRoleApplicationAssignmentRequestDTO revokeRoleApplicationAssignmentRequestDTO);

RevokeRoleProductsAssignmentRequest map(RevokeRoleProductsAssignmentRequestDTO revokeRoleProductsAssignmentRequestDTO);
}
139 changes: 85 additions & 54 deletions src/main/openapi/openapi-bff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -389,31 +389,6 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetailResponse'
/assignments/grant:
post:
x-onecx:
permissions:
assignment:
- write
tags:
- assignment
description: Create new assignments by criteria
operationId: grantAssignments
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateProductAssignmentsRequest'
responses:
201:
description: New assignments created
400:
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetailResponse'
/assignments/grant/{roleId}:
post:
tags:
Expand All @@ -431,12 +406,12 @@ paths:
description: New assignment created
404:
description: Data not found
/assignments/grant/{roleId}/product:
/assignments/grant/{roleId}/application:
post:
tags:
- assignment
description: Create new assignments for role and product
operationId: grantRoleProductAssignments
description: Create new assignments for role and application
operationId: grantRoleApplicationAssignments
parameters:
- name: roleId
in: path
Expand All @@ -448,7 +423,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateRoleProductAssignmentRequest'
$ref: '#/components/schemas/CreateRoleApplicationAssignmentRequest'
responses:
201:
description: New assignment created
Expand Down Expand Up @@ -489,25 +464,76 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetailResponse'
/assignments/revoke:
#
/assignments/revoke/{roleId}:
post:
x-onecx:
permissions:
assignment:
- delete
tags:
- assignment
description: delete assignments by criteria
operationId: revokeAssignments
description: Revoke assignments for role
operationId: revokeRoleAssignments
parameters:
- name: roleId
in: path
required: true
schema:
type: string
responses:
204:
description: assignment revoked
404:
description: Data not found
/assignments/revoke/{roleId}/application:
post:
tags:
- assignment
description: Revoke assignments for role and application
operationId: revokeRoleApplicationAssignments
parameters:
- name: roleId
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RevokeAssignmentRequest'
$ref: '#/components/schemas/RevokeRoleApplicationAssignmentRequest'
responses:
204:
description: revoked assignments
description: assignments revoked
404:
description: Data not found
400:
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetailResponse'
/assignments/revoke/{roleId}/products:
post:
tags:
- assignment
description: Revoke assignments for role and products
operationId: revokeRoleProductsAssignments
parameters:
- name: roleId
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RevokeRoleProductsAssignmentRequest'
responses:
204:
description: assignment revoked
404:
description: Data not found
400:
description: Bad request
content:
Expand Down Expand Up @@ -927,21 +953,6 @@ components:
type: array
items:
type: string
RevokeAssignmentRequest:
type: object
required:
- roleId
properties:
roleId:
type: string
appId:
type: string
permissionId:
type: string
productNames:
type: array
items:
type: string
Assignment:
type: object
properties:
Expand Down Expand Up @@ -1137,7 +1148,27 @@ components:
minItems: 1
items:
type: string
CreateRoleProductAssignmentRequest:
CreateRoleApplicationAssignmentRequest:
type: object
required:
- productName
- appId
properties:
appId:
type: string
productName:
type: string
RevokeRoleProductsAssignmentRequest:
type: object
required:
- productNames
properties:
productNames:
type: array
minItems: 1
items:
type: string
RevokeRoleApplicationAssignmentRequest:
type: object
required:
- productName
Expand Down
Loading

0 comments on commit 86a6b88

Please sign in to comment.