use of com.sequenceiq.cloudbreak.tag.request.CDPTagMergeRequest in project cloudbreak by hortonworks.
the class EnvironmentTagProvider method getTags.
public Map<String, String> getTags(EnvironmentDto environmentDto, String resourceCrn) {
Map<String, String> userDefinedTags = environmentDto.getTags().getUserDefinedTags();
Map<String, String> accountTags = getAccountTags(environmentDto.getAccountId());
Map<String, String> defaultTags = getDefaultTags(environmentDto, userDefinedTags, accountTags, resourceCrn);
CDPTagMergeRequest mergeRequest = CDPTagMergeRequest.Builder.builder().withEnvironmentTags(environmentDto.getTags().getUserDefinedTags()).withPlatform(environmentDto.getCloudPlatform()).withRequestTags(defaultTags).build();
return costTagging.mergeTags(mergeRequest);
}
use of com.sequenceiq.cloudbreak.tag.request.CDPTagMergeRequest in project cloudbreak by hortonworks.
the class StackV4RequestToStackConverter method getTags.
private Json getTags(StackV4Request source, DetailedEnvironmentResponse environment) {
try {
TagsV4Request tags = source.getTags();
if (tags == null) {
Map<String, String> userDefined = environment == null || environment.getTags() == null ? new HashMap<>() : environment.getTags().getUserDefined();
return new Json(new StackTags(userDefined, new HashMap<>(), new HashMap<>()));
}
Map<String, String> userDefined = new HashMap<>();
if (environment != null && environment.getTags() != null && environment.getTags().getUserDefined() != null && !environment.getTags().getUserDefined().isEmpty()) {
userDefined = environment.getTags().getUserDefined();
}
CDPTagMergeRequest request = CDPTagMergeRequest.Builder.builder().withPlatform(source.getCloudPlatform().name()).withRequestTags(tags.getUserDefined() != null ? tags.getUserDefined() : Maps.newHashMap()).withEnvironmentTags(userDefined).build();
return new Json(new StackTags(costTagging.mergeTags(request), tags.getApplication(), new HashMap<>()));
} catch (Exception e) {
throw new BadRequestException("Failed to convert dynamic tags. " + e.getMessage(), e);
}
}
Aggregations