use of com.sequenceiq.cloudbreak.service.secret.model.SecretResponse in project cloudbreak by hortonworks.
the class CredentialService method convertToCredential.
private Credential convertToCredential(CredentialResponse credentialResponse) {
SecretResponse secretResponse = credentialResponse.getAttributes();
String attributes = secretService.getByResponse(secretResponse);
return new Credential(credentialResponse.getCloudPlatform(), credentialResponse.getName(), attributes, credentialResponse.getCrn(), credentialResponse.getAccountId());
}
use of com.sequenceiq.cloudbreak.service.secret.model.SecretResponse in project cloudbreak by hortonworks.
the class CredentialService method getCredentialByEnvCrn.
public Credential getCredentialByEnvCrn(String envCrn) {
CredentialResponse credentialResponse = null;
try {
credentialResponse = credentialEndpoint.getByEnvironmentCrn(envCrn);
} catch (ClientErrorException e) {
try (Response response = e.getResponse()) {
if (Response.Status.NOT_FOUND.getStatusCode() == response.getStatus()) {
throw new BadRequestException(String.format("Credential not found by environment CRN: %s", envCrn), e);
}
String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
throw new CloudbreakServiceException(String.format("Failed to get credential: %s", errorMessage), e);
}
}
SecretResponse secretResponse = credentialResponse.getAttributes();
String attributes = secretService.getByResponse(secretResponse);
return new Credential(credentialResponse.getCloudPlatform(), credentialResponse.getName(), attributes, credentialResponse.getCrn(), credentialResponse.getAccountId());
}
Aggregations