use of com.sequenceiq.authorization.annotation.ResourceCrn in project cloudbreak by hortonworks.
the class UserV1Controller method getUserSyncState.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public EnvironmentUserSyncState getUserSyncState(@ResourceCrn @TenantAwareParam @NotEmpty String environmentCrn) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
Crn envCrn = Crn.safeFromString(environmentCrn);
return environmentUserSyncStateCalculator.calculateEnvironmentUserSyncState(accountId, envCrn);
}
use of com.sequenceiq.authorization.annotation.ResourceCrn in project cloudbreak by hortonworks.
the class CDPStructuredEventV1Controller method getAuditEventsZipResponse.
private Response getAuditEventsZipResponse(Collection<CDPStructuredNotificationEvent> events, String resourceCrn) {
StreamingOutput streamingOutput = output -> {
try (ZipOutputStream zipOutputStream = new ZipOutputStream(output)) {
zipOutputStream.putNextEntry(new ZipEntry("struct-events.json"));
zipOutputStream.write(JsonUtil.writeValueAsString(events).getBytes());
zipOutputStream.closeEntry();
}
};
String resourceType = Crn.safeFromString(resourceCrn).getResourceType().getName();
String fileName = String.format("audit-%s.zip", resourceType);
return Response.ok(streamingOutput).header("content-disposition", String.format("attachment; filename = %s", fileName)).build();
}
use of com.sequenceiq.authorization.annotation.ResourceCrn in project cloudbreak by hortonworks.
the class EnvironmentPlatformResourceController method getPrivateDnsZones.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformPrivateDnsZonesResponse getPrivateDnsZones(@ResourceCrn String environmentCrn, String platformVariant) {
String accountId = getAccountId();
validateEnvironmentCrnPattern(environmentCrn);
PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, platformVariant, null);
LOGGER.debug("Get /platform_resources/private_dns_zones, request: {}", request);
CloudPrivateDnsZones privateDnsZones = platformParameterService.getPrivateDnsZones(request);
List<PlatformPrivateDnsZoneResponse> platformPrivateDnsZones = privateDnsZones.getPrivateDnsZones().stream().map(pdz -> new PlatformPrivateDnsZoneResponse(pdz.getPrivateDnsZoneId())).collect(Collectors.toList());
PlatformPrivateDnsZonesResponse response = new PlatformPrivateDnsZonesResponse(platformPrivateDnsZones);
LOGGER.debug("Resp /platform_resources/private_dns_zones, request: {}, privateDnsZones: {}, response: {}", request, privateDnsZones, response);
return response;
}
use of com.sequenceiq.authorization.annotation.ResourceCrn in project cloudbreak by hortonworks.
the class EnvironmentPlatformResourceController method getResourceGroups.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformResourceGroupsResponse getResourceGroups(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone) {
String accountId = getAccountId();
validateEnvironmentCrnPattern(environmentCrn);
PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, null);
LOGGER.info("Get /platform_resources/resource_groups, request: {}", request);
CloudResourceGroups resourceGroups = platformParameterService.getResourceGroups(request);
List<PlatformResourceGroupResponse> platformResourceGroups = resourceGroups.getResourceGroups().stream().map(rg -> new PlatformResourceGroupResponse(rg.getName())).collect(Collectors.toList());
PlatformResourceGroupsResponse response = new PlatformResourceGroupsResponse(platformResourceGroups);
LOGGER.info("Resp /platform_resources/resource_groups, request: {}, resourceGroups: {}, response: {}", request, resourceGroups, response);
return response;
}
use of com.sequenceiq.authorization.annotation.ResourceCrn in project cloudbreak by hortonworks.
the class UserV1Controller method getLastSyncOperationStatus.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.GET_OPERATION_STATUS)
public SyncOperationStatus getLastSyncOperationStatus(@ResourceCrn @TenantAwareParam @NotEmpty String environmentCrn) {
Crn envCrn = Crn.safeFromString(environmentCrn);
EnvironmentUserSyncState userSyncState = environmentUserSyncStateCalculator.calculateEnvironmentUserSyncState(envCrn.getAccountId(), envCrn);
return operationToSyncOperationStatus.convert(operationService.getOperationForAccountIdAndOperationId(envCrn.getAccountId(), userSyncState.getLastUserSyncOperationId()));
}
Aggregations