use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesAPI method createBridge.
@APIResponses(value = { @APIResponse(description = "Accepted.", responseCode = "202", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = BridgeResponse.class))), @APIResponse(description = "Bad request.", responseCode = "400", content = @Content(mediaType = MediaType.APPLICATION_JSON)), @APIResponse(description = "Unauthorized.", responseCode = "401"), @APIResponse(description = "Forbidden.", responseCode = "403"), @APIResponse(description = "Internal error.", responseCode = "500", content = @Content(mediaType = MediaType.APPLICATION_JSON)) })
@Operation(summary = "Create a Bridge instance", description = "Create a Bridge instance for the authenticated user.")
@POST
public Response createBridge(@Valid BridgeRequest bridgeRequest) {
String customerId = identityResolver.resolve(jwt);
String organisationId = identityResolver.resolveOrganisationId(jwt);
String owner = identityResolver.resolveOwner(jwt);
Bridge bridge = bridgesService.createBridge(customerId, organisationId, owner, bridgeRequest);
return Response.accepted(bridgesService.toResponse(bridge)).build();
}
use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesServiceImpl method deleteBridge.
@Override
@Transactional
public void deleteBridge(String id, String customerId) {
Long processorsCount = processorService.getProcessorsCount(id, customerId);
ListResult<Processor> hiddenProcessors = processorService.getHiddenProcessors(id, customerId);
if (processorsCount != hiddenProcessors.getTotal()) {
// See https://issues.redhat.com/browse/MGDOBR-43
throw new BridgeLifecycleException("It is not possible to delete a Bridge instance with active Processors.");
}
Bridge bridge = findByIdAndCustomerId(id, customerId);
if (!isBridgeDeletable(bridge)) {
throw new BridgeLifecycleException("Bridge could only be deleted if its in READY/FAILED state.");
}
hiddenProcessors.getItems().forEach(p -> processorService.deleteProcessor(id, p.getId(), customerId));
LOGGER.info("Bridge with id '{}' for customer '{}' has been marked for deletion", bridge.getId(), bridge.getCustomerId());
// Bridge deletion and related Work creation should always be in the same transaction
bridge.setStatus(ManagedResourceStatus.DEPROVISION);
bridge.setDeletionRequestedAt(ZonedDateTime.now());
workManager.schedule(bridge);
metricsService.onOperationStart(bridge, MetricsOperation.DELETE);
LOGGER.info("Bridge with id '{}' for customer '{}' has been marked for deletion", bridge.getId(), bridge.getCustomerId());
}
use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesServiceImpl method updateBridge.
@Transactional
@Override
public Bridge updateBridge(BridgeDTO bridgeDTO) {
Bridge bridge = getBridge(bridgeDTO.getId(), bridgeDTO.getCustomerId());
bridge.setStatus(bridgeDTO.getStatus());
bridge.setEndpoint(bridgeDTO.getEndpoint());
bridge.setModifiedAt(ZonedDateTime.now());
if (bridgeDTO.getStatus().equals(ManagedResourceStatus.DELETED)) {
bridgeDAO.deleteById(bridge.getId());
metricsService.onOperationComplete(bridge, MetricsOperation.DELETE);
} else if (bridgeDTO.getStatus().equals(ManagedResourceStatus.READY)) {
if (Objects.isNull(bridge.getPublishedAt())) {
bridge.setPublishedAt(ZonedDateTime.now());
metricsService.onOperationComplete(bridge, MetricsOperation.PROVISION);
}
}
LOGGER.info("Bridge with id '{}' has been updated for customer '{}'", bridge.getId(), bridge.getCustomerId());
return bridge;
}
use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceImpl method createErrorHandlerProcessor.
@Override
@Transactional
public Processor createErrorHandlerProcessor(String bridgeId, String customerId, String owner, ProcessorRequest processorRequest) {
Bridge bridge = bridgesService.getBridge(bridgeId, customerId);
ProcessorType processorType = processorRequest.getType();
if (processorType != ProcessorType.SINK) {
throw new InternalPlatformException("Unable to configure error handler");
}
return doCreateProcessor(bridge, customerId, owner, ProcessorType.ERROR_HANDLER, processorRequest);
}
use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeDAO method findByCustomerId.
public ListResult<Bridge> findByCustomerId(String customerId, QueryResourceInfo queryInfo) {
Parameters parameters = Parameters.with("customerId", customerId);
PanacheQuery<Bridge> query = find("#BRIDGE.findByCustomerId", parameters);
String filterName = queryInfo.getFilterInfo().getFilterName();
Set<ManagedResourceStatus> filterStatus = queryInfo.getFilterInfo().getFilterStatus();
if (Objects.nonNull(filterName)) {
query.filter("byName", Parameters.with("name", filterName + "%"));
}
if (Objects.nonNull(filterStatus) && !filterStatus.isEmpty()) {
query.filter("byStatus", Parameters.with("status", filterStatus));
}
long total = query.count();
List<Bridge> bridges = query.page(queryInfo.getPageNumber(), queryInfo.getPageSize()).list();
return new ListResult<>(bridges, queryInfo.getPageNumber(), total);
}
Aggregations