Search in sources :

Example 21 with CheckPermissionByAccount

use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.

the class SdxInternalController method create.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_DATALAKE)
public SdxClusterResponse create(String name, @Valid SdxInternalClusterRequest createSdxClusterRequest) {
    String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
    Pair<SdxCluster, FlowIdentifier> result = sdxService.createSdx(userCrn, name, createSdxClusterRequest, createSdxClusterRequest.getStackV4Request());
    SdxCluster sdxCluster = result.getLeft();
    metricService.incrementMetricCounter(MetricType.INTERNAL_SDX_REQUESTED, sdxCluster);
    SdxClusterResponse sdxClusterResponse = sdxClusterConverter.sdxClusterToResponse(sdxCluster);
    sdxClusterResponse.setName(sdxCluster.getClusterName());
    sdxClusterResponse.setFlowIdentifier(result.getRight());
    return sdxClusterResponse;
}
Also used : SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 22 with CheckPermissionByAccount

use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.

the class SdxController method create.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_DATALAKE)
public SdxClusterResponse create(String name, @Valid SdxCustomClusterRequest createSdxClusterRequest) {
    String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
    Pair<SdxCluster, FlowIdentifier> result = sdxService.createSdx(userCrn, name, createSdxClusterRequest);
    SdxCluster sdxCluster = result.getLeft();
    metricService.incrementMetricCounter(MetricType.CUSTOM_SDX_REQUESTED, sdxCluster);
    SdxClusterResponse sdxClusterResponse = sdxClusterConverter.sdxClusterToResponse(sdxCluster);
    sdxClusterResponse.setName(sdxCluster.getClusterName());
    sdxClusterResponse.setFlowIdentifier(result.getRight());
    return sdxClusterResponse;
}
Also used : SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 23 with CheckPermissionByAccount

use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.

the class AccountTelemetryController method testRulePattern.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
public TestAnonymizationRuleResponse testRulePattern(TestAnonymizationRuleRequest request) {
    TestAnonymizationRuleResponse response = new TestAnonymizationRuleResponse();
    response.setOutput(accountTelemetryService.testRulePatterns(request.getRules(), request.getInput()));
    return response;
}
Also used : TestAnonymizationRuleResponse(com.sequenceiq.environment.api.v1.telemetry.model.response.TestAnonymizationRuleResponse) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 24 with CheckPermissionByAccount

use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.

the class EventV4Controller method getPagedCloudbreakEventListByCrn.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
public List<CloudbreakEventV4Response> getPagedCloudbreakEventListByCrn(@TenantAwareParam String crn, Integer page, Integer size, boolean onlyAlive) {
    PageRequest pageable = PageRequest.of(page, size, Sort.by("timestamp").descending());
    StackView stackView;
    if (onlyAlive) {
        stackView = getStackViewByCrnIfAvailable(crn);
    } else {
        stackView = getStackViewByCrn(crn);
    }
    return cloudbreakEventsFacade.retrieveEventsByStack(stackView.getId(), stackView.getType(), pageable).getContent();
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 25 with CheckPermissionByAccount

use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.

the class ImageCatalogV4Controller method create.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_IMAGE_CATALOG)
public ImageCatalogV4Response create(Long workspaceId, ImageCatalogV4Request request) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    String creator = ThreadBasedUserCrnProvider.getUserCrn();
    ImageCatalog catalogToSave = imageCatalogV4RequestToImageCatalogConverter.convert(request);
    ImageCatalog imageCatalog = imageCatalogService.createForLoggedInUser(catalogToSave, restRequestThreadLocalService.getRequestedWorkspaceId(), accountId, creator);
    notify(ResourceEvent.IMAGE_CATALOG_CREATED);
    return imageCatalogToImageCatalogV4ResponseConverter.convert(imageCatalog);
}
Also used : ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Aggregations

CheckPermissionByAccount (com.sequenceiq.authorization.annotation.CheckPermissionByAccount)33 Credential (com.sequenceiq.environment.credential.domain.Credential)8 ProxyConfig (com.sequenceiq.environment.proxy.domain.ProxyConfig)4 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)3 SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)3 PageRequest (org.springframework.data.domain.PageRequest)3 AuthorizationResourceAction (com.sequenceiq.authorization.resource.AuthorizationResourceAction)2 AccountId (com.sequenceiq.cloudbreak.auth.security.internal.AccountId)2 TenantAwareParam (com.sequenceiq.cloudbreak.auth.security.internal.TenantAwareParam)2 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)2 ProxyResponse (com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse)2 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)2 Controller (org.springframework.stereotype.Controller)2 CheckPermissionByRequestProperty (com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty)1 EventV4Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v4.events.EventV4Endpoint)1 CloudbreakEventV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response)1 CloudbreakEventV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Responses)1 ResourceEventResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ResourceEventResponse)1