Search in sources :

Example 1 with ProxyConfig

use of com.sequenceiq.environment.proxy.domain.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyConfigService method deleteByNameInAccount.

public ProxyConfig deleteByNameInAccount(String name, String accountId) {
    ProxyConfig proxyConfig = proxyConfigRepository.findByNameInAccount(name, accountId).orElseThrow(notFound("Proxy config with name:", name));
    MDCBuilder.buildMdcContext(proxyConfig);
    proxyConfigRepository.delete(proxyConfig);
    return proxyConfig;
}
Also used : ProxyConfig(com.sequenceiq.environment.proxy.domain.ProxyConfig)

Example 2 with ProxyConfig

use of com.sequenceiq.environment.proxy.domain.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyConfigService method deleteByCrnInAccount.

public ProxyConfig deleteByCrnInAccount(String crn, String accountId) {
    ProxyConfig proxyConfig = proxyConfigRepository.findByResourceCrnInAccount(crn, accountId).orElseThrow(notFound("Proxy config with crn:", crn));
    MDCBuilder.buildMdcContext(proxyConfig);
    proxyConfigRepository.delete(proxyConfig);
    return proxyConfig;
}
Also used : ProxyConfig(com.sequenceiq.environment.proxy.domain.ProxyConfig)

Example 3 with ProxyConfig

use of com.sequenceiq.environment.proxy.domain.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyController method getByResourceCrn.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
public ProxyResponse getByResourceCrn(@TenantAwareParam String crn) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    ProxyConfig config = proxyConfigService.getByCrnForAccountId(crn, accountId);
    return proxyConfigToProxyResponseConverter.convert(config);
}
Also used : ProxyConfig(com.sequenceiq.environment.proxy.domain.ProxyConfig) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 4 with ProxyConfig

use of com.sequenceiq.environment.proxy.domain.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyController method getByEnvironmentCrn.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
public ProxyResponse getByEnvironmentCrn(@TenantAwareParam String environmentCrn) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    ProxyConfig proxyConfig = proxyConfigService.getByEnvironmentCrnAndAccountId(environmentCrn, accountId);
    return proxyConfigToProxyResponseConverter.convert(proxyConfig);
}
Also used : ProxyConfig(com.sequenceiq.environment.proxy.domain.ProxyConfig) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 5 with ProxyConfig

use of com.sequenceiq.environment.proxy.domain.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyConfigServiceTest method testDeleteMultipleInAccountHasAllResult.

@Test
public void testDeleteMultipleInAccountHasAllResult() {
    String name1 = ProxyTestSource.NAME;
    String name2 = "another";
    Set<String> names = Set.of(name1, name2);
    ProxyConfig proxyConfig1 = ProxyTestSource.getProxyConfig();
    ProxyConfig proxyConfig2 = ProxyTestSource.getProxyConfig();
    proxyConfig2.setName(name2);
    proxyConfig2.setId(2L);
    Set<ProxyConfig> proxyConfigs = Set.of(proxyConfig2, proxyConfig1);
    when(proxyConfigRepository.findByNameOrResourceCrnInAccount(names, ACCOUNT_ID)).thenReturn(proxyConfigs);
    Assertions.assertEquals(proxyConfigs, underTestProxyConfigService.deleteMultipleInAccount(names, ACCOUNT_ID));
}
Also used : ProxyConfig(com.sequenceiq.environment.proxy.domain.ProxyConfig) Test(org.junit.jupiter.api.Test)

Aggregations

ProxyConfig (com.sequenceiq.environment.proxy.domain.ProxyConfig)12 CheckPermissionByAccount (com.sequenceiq.authorization.annotation.CheckPermissionByAccount)4 Test (org.junit.jupiter.api.Test)2 ProxyRequest (com.sequenceiq.environment.api.v1.proxy.model.request.ProxyRequest)1 ProxyResponse (com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse)1 Credential (com.sequenceiq.environment.credential.domain.Credential)1 Environment (com.sequenceiq.environment.environment.domain.Environment)1 ProxyTestSource.getProxyConfig (com.sequenceiq.environment.proxy.v1.ProxyTestSource.getProxyConfig)1 ProxyTestSource.getProxyRequest (com.sequenceiq.environment.proxy.v1.ProxyTestSource.getProxyRequest)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1