use of com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateRequest in project cloudbreak by hortonworks.
the class CloudStorageValidator method validate.
public void validate(CloudStorageRequest cloudStorageRequest, DetailedEnvironmentResponse environment, ValidationResult.ValidationResultBuilder validationResultBuilder) {
if (CloudStorageValidation.DISABLED.equals(environment.getCloudStorageValidation())) {
LOGGER.info("Due to cloud storage validation not being enabled, not validating cloudStorageRequest: {}", JsonUtil.writeValueAsStringSilent(cloudStorageRequest));
return;
}
String accountId = ThreadBasedUserCrnProvider.getAccountId();
if (!entitlementService.cloudStorageValidationEnabled(accountId)) {
LOGGER.info("Cloud storage validation entitlement is missing, not validating cloudStorageRequest: {}", JsonUtil.writeValueAsStringSilent(cloudStorageRequest));
return;
}
LOGGER.info("Validating cloudStorageRequest: {}", JsonUtil.writeValueAsStringSilent(cloudStorageRequest));
if (cloudStorageRequest != null) {
Credential credential = getCredential(environment);
CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential);
ObjectStorageValidateRequest request = createObjectStorageValidateRequest(cloudCredential, cloudStorageRequest, environment);
ObjectStorageValidateResponse response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> cloudProviderServicesV4Endpoint.validateObjectStorage(request));
LOGGER.info("ValidateObjectStorage: request: {}, response: {}", AnonymizerUtil.anonymize(JsonUtil.writeValueAsStringSilent(request)), JsonUtil.writeValueAsStringSilent(response));
if (ResponseStatus.ERROR.equals(response.getStatus())) {
validationResultBuilder.error(response.getError());
} else if (StringUtils.isNotBlank(response.getError())) {
validationResultBuilder.warning(response.getError());
}
}
}
Aggregations