Skip to content

Commit

Permalink
feat: added assignment exim (#74)
Browse files Browse the repository at this point in the history
* feat: added assignment exim

* fix: swap assertion arguments
  • Loading branch information
JordenReuter authored Sep 18, 2024
1 parent 1bdc9db commit a8cc961
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ quarkus.openapi-generator.codegen.spec.onecx_permission_svc_yaml.return-response
quarkus.openapi-generator.codegen.spec.onecx_permission_svc_yaml.additional-api-type-annotations=@org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
quarkus.openapi-generator.codegen.spec.onecx_permission_svc_yaml.additional-model-type-annotations=@io.quarkus.runtime.annotations.RegisterForReflection;
quarkus.openapi-generator.codegen.spec.onecx_permission_svc_yaml.enable-security-generation=false
quarkus.openapi-generator.codegen.spec.onecx_permission_exim_svc_yaml.config-key=onecx_permission_svc
quarkus.openapi-generator.codegen.spec.onecx_permission_exim_svc_yaml.base-package=gen.org.tkit.onecx.permission.exim.client
quarkus.openapi-generator.codegen.spec.onecx_permission_exim_svc_yaml.return-response=true
quarkus.openapi-generator.codegen.spec.onecx_permission_exim_svc_yaml.additional-api-type-annotations=@org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
quarkus.openapi-generator.codegen.spec.onecx_permission_exim_svc_yaml.additional-model-type-annotations=@io.quarkus.runtime.annotations.RegisterForReflection;
quarkus.openapi-generator.codegen.spec.onecx_permission_exim_svc_yaml.enable-security-generation=false
quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_v1_yaml.config-key=onecx_workspace_svc
quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_v1_yaml.base-package=gen.org.tkit.onecx.permission.client
quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_v1_yaml.return-response=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,24 @@ h| Version

| https://quarkus.io/guides/rest[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-rest.adoc[Link]
| 3.13.3
| 3.14.4
| quarkus-smallrye-openapi
| https://quarkus.io/guides/openapi-swaggerui[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-smallrye-openapi.adoc[Link]
| 3.13.3
| 3.14.4
| quarkus-rest-jackson
| https://quarkus.io/guides/rest-json[Link]
|
| 3.13.3
| 3.14.4
| quarkus-smallrye-health
| https://quarkus.io/guides/smallrye-health[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-smallrye-health.adoc[Link]
| 3.13.3
| 3.14.4
| quarkus-openapi-generator
Expand All @@ -41,99 +40,98 @@ h| Version
| quarkus-rest-client-jackson
| https://quarkus.io/guides/rest-client[Link]
|
| 3.13.3
| 3.14.4
| 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.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
| 2.31.0
| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
| 2.32.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.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
| 2.31.0
| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
| 2.32.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.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
| 2.31.0
| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
| 2.32.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.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link]
| 2.31.0
| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link]
| 2.32.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.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link]
| 2.31.0
| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link]
| 2.32.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.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link]
| 2.31.0
| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link]
| 2.32.0
| quarkus-hibernate-validator
| https://quarkus.io/guides/validation[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-hibernate-validator.adoc[Link]
| 3.13.3
| 3.14.4
| onecx-permissions
| https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-permissions.html[Link]
| https://github.com/onecx/onecx-quarkus/blob/0.26.0/docs/modules/onecx-quarkus/pages/includes/onecx-permissions.adoc[Link]
| 0.26.0
| https://github.com/onecx/onecx-quarkus/blob/0.30.0/docs/modules/onecx-quarkus/pages/includes/onecx-permissions.adoc[Link]
| 0.30.0
| quarkus-oidc
| https://quarkus.io/guides/security-oidc-bearer-token-authentication-tutorial[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-oidc.adoc[Link]
| 3.13.3
| 3.14.4
| onecx-core
| https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-core.html[Link]
|
| 0.26.0
| 0.30.0
| quarkus-micrometer-registry-prometheus
| https://quarkus.io/guides/telemetry-micrometer[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-micrometer-registry-prometheus.adoc[Link]
| 3.13.3
| 3.14.4
| quarkus-opentelemetry
| https://quarkus.io/guides/opentelemetry[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-opentelemetry.adoc[Link]
| 3.13.3
| 3.14.4
| quarkus-arc
| https://quarkus.io/guides/cdi-reference[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-arc.adoc[Link]
| 3.13.3
| 3.14.4
| quarkus-container-image-docker
| https://quarkus.io/guides/container-image[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-container-image-docker.adoc[Link]
| 3.13.3
| 3.14.4
| quarkus-rest-client-oidc-filter
|
|
| 3.13.3
| 3.14.4
|===
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@
<skipCache>true</skipCache>
</configuration>
</execution>
<execution>
<id>permission-svc-exim</id>
<phase>generate-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://raw.githubusercontent.com/onecx/onecx-permission-svc/refs/heads/main/src/main/openapi/onecx-permission-exim-v1-openapi.yaml</url>
<outputDirectory>target/tmp/openapi</outputDirectory>
<outputFileName>onecx-permission-exim-svc.yaml</outputFileName>
<skipCache>true</skipCache>
</configuration>
</execution>
<execution>
<id>workspace-svc-external-v1</id>
<phase>generate-resources</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import gen.org.tkit.onecx.permission.client.api.AssignmentInternalApi;
import gen.org.tkit.onecx.permission.client.model.Assignment;
import gen.org.tkit.onecx.permission.client.model.AssignmentPageResult;
import gen.org.tkit.onecx.permission.exim.client.api.PermissionExportImportApi;
import gen.org.tkit.onecx.permission.exim.client.model.AssignmentSnapshot;

@ApplicationScoped
@Transactional(value = Transactional.TxType.NOT_SUPPORTED)
Expand All @@ -29,6 +31,10 @@ public class AssignmentRestController implements AssignmentApiService {
@Inject
AssignmentInternalApi assignmentClient;

@RestClient
@Inject
PermissionExportImportApi assignmentEximClient;

@Inject
AssignmentMapper mapper;

Expand Down Expand Up @@ -69,6 +75,13 @@ public Response grantRoleProductsAssignments(String roleId,
}
}

@Override
public Response importAssignments(Object dto) {
try (Response response = assignmentEximClient.importAssignments(mapper.createSnapshot(dto))) {
return Response.status(response.getStatus()).build();
}
}

@Override
public Response revokeRoleApplicationAssignments(String roleId,
RevokeRoleApplicationAssignmentRequestDTO revokeRoleApplicationAssignmentRequestDTO) {
Expand Down Expand Up @@ -101,6 +114,15 @@ public Response deleteAssignment(String id) {
}
}

@Override
public Response exportAssignments(ExportAssignmentsRequestDTO exportAssignmentsRequestDTO) {
try (Response response = assignmentEximClient.exportAssignments(mapper.map(exportAssignmentsRequestDTO))) {
return Response.status(response.getStatus())
.entity(response.readEntity(AssignmentSnapshot.class))
.build();
}
}

@Override
public Response getAssignment(String id) {
try (Response response = assignmentClient.getAssignment(id)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,60 @@
package org.tkit.onecx.permission.bff.rs.mappers;

import jakarta.inject.Inject;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper;

import com.fasterxml.jackson.databind.ObjectMapper;

import gen.org.tkit.onecx.permission.bff.rs.internal.model.*;
import gen.org.tkit.onecx.permission.client.model.*;
import gen.org.tkit.onecx.permission.exim.client.model.AssignmentSnapshot;
import gen.org.tkit.onecx.permission.exim.client.model.ExportAssignmentsRequest;

@Mapper(uses = { OffsetDateTimeMapper.class })
public interface AssignmentMapper {
CreateAssignmentRequest map(CreateAssignmentRequestDTO createAssignmentRequestDTO);
public abstract class AssignmentMapper {

@Inject
ObjectMapper mapper;

public abstract CreateAssignmentRequest map(CreateAssignmentRequestDTO createAssignmentRequestDTO);

AssignmentDTO map(Assignment assignment);
public abstract AssignmentDTO map(Assignment assignment);

@Mapping(target = "appIds", source = "appIds")
AssignmentSearchCriteria map(AssignmentSearchCriteriaDTO assignmentSearchCriteriaDTO);
public abstract AssignmentSearchCriteria map(AssignmentSearchCriteriaDTO assignmentSearchCriteriaDTO);

@Mapping(target = "removeStreamItem", ignore = true)
AssignmentPageResultDTO map(AssignmentPageResult pageResult);
public abstract AssignmentPageResultDTO map(AssignmentPageResult pageResult);

CreateRoleProductsAssignmentRequest mapRoleProducts(CreateProductAssignmentsRequestDTO createProductAssignmentsRequestDTO);
public abstract CreateRoleProductsAssignmentRequest mapRoleProducts(
CreateProductAssignmentsRequestDTO createProductAssignmentsRequestDTO);

default CreateRoleProductAssignmentRequest mapRoleProduct(
public CreateRoleProductAssignmentRequest mapRoleProduct(
CreateProductAssignmentsRequestDTO createProductAssignmentsRequestDTO, int productIndex) {
return new CreateRoleProductAssignmentRequest()
.productName(createProductAssignmentsRequestDTO.getProductNames().get(productIndex))
.appId(createProductAssignmentsRequestDTO.getAppId());
}

CreateRoleProductAssignmentRequest map(CreateRoleApplicationAssignmentRequestDTO createRoleProductAssignmentRequestDTO);
public abstract CreateRoleProductAssignmentRequest map(
CreateRoleApplicationAssignmentRequestDTO createRoleProductAssignmentRequestDTO);

CreateRoleProductsAssignmentRequest map(CreateRoleProductsAssignmentRequestDTO createRoleProductsAssignmentRequestDTO);
public abstract CreateRoleProductsAssignmentRequest map(
CreateRoleProductsAssignmentRequestDTO createRoleProductsAssignmentRequestDTO);

public abstract RevokeRoleProductAssignmentRequest map(
RevokeRoleApplicationAssignmentRequestDTO revokeRoleApplicationAssignmentRequestDTO);

public abstract RevokeRoleProductsAssignmentRequest map(
RevokeRoleProductsAssignmentRequestDTO revokeRoleProductsAssignmentRequestDTO);

public AssignmentSnapshot createSnapshot(Object object) {
return mapper.convertValue(object, AssignmentSnapshot.class);
}

RevokeRoleProductAssignmentRequest map(RevokeRoleApplicationAssignmentRequestDTO revokeRoleApplicationAssignmentRequestDTO);
public abstract ExportAssignmentsRequest map(ExportAssignmentsRequestDTO exportAssignmentsRequestDTO);

RevokeRoleProductsAssignmentRequest map(RevokeRoleProductsAssignmentRequestDTO revokeRoleProductsAssignmentRequestDTO);
}
58 changes: 58 additions & 0 deletions src/main/openapi/openapi-bff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,56 @@ paths:
responses:
204:
description: Assignment deleted
/assignments/export:
x-onecx:
permissions:
assignment:
- read
post:
tags:
- assignment
description: Export assignments
operationId: exportAssignments
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ExportAssignmentsRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
"404":
description: No themes founds
/assignments/import:
x-onecx:
permissions:
assignment:
- write
post:
tags:
- assignment
description: Import assignments
operationId: importAssignments
requestBody:
required: true
content:
application/json:
schema:
type: object
responses:
"200":
description: Import successful
"400":
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetailResponse'
/applications/search:
post:
x-onecx:
Expand Down Expand Up @@ -728,6 +778,14 @@ paths:
$ref: '#/components/schemas/UserAssignmentPageResult'
components:
schemas:
ExportAssignmentsRequest:
type: object
properties:
productNames:
type: array
uniqueItems: true
items:
type: string
UserCriteria:
type: object
properties:
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ quarkus.openapi-generator.codegen.spec.onecx_permission_svc_yaml.additional-api-
quarkus.openapi-generator.codegen.spec.onecx_permission_svc_yaml.additional-model-type-annotations=@io.quarkus.runtime.annotations.RegisterForReflection;
quarkus.openapi-generator.codegen.spec.onecx_permission_svc_yaml.enable-security-generation=false

# permission exim client
quarkus.openapi-generator.codegen.spec.onecx_permission_exim_svc_yaml.config-key=onecx_permission_svc
quarkus.openapi-generator.codegen.spec.onecx_permission_exim_svc_yaml.base-package=gen.org.tkit.onecx.permission.exim.client
quarkus.openapi-generator.codegen.spec.onecx_permission_exim_svc_yaml.return-response=true
quarkus.openapi-generator.codegen.spec.onecx_permission_exim_svc_yaml.additional-api-type-annotations=@org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
quarkus.openapi-generator.codegen.spec.onecx_permission_exim_svc_yaml.additional-model-type-annotations=@io.quarkus.runtime.annotations.RegisterForReflection;
quarkus.openapi-generator.codegen.spec.onecx_permission_exim_svc_yaml.enable-security-generation=false

# workspace client
quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_v1_yaml.config-key=onecx_workspace_svc
quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_v1_yaml.base-package=gen.org.tkit.onecx.permission.client
Expand Down
Loading

0 comments on commit a8cc961

Please sign in to comment.