use of com.sequenceiq.environment.api.v1.tags.model.response.GeneratedAccountTagResponse in project cloudbreak by hortonworks.
the class AccountTagController method generate.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
public GeneratedAccountTagResponses generate(@ResourceName String environmentName, @ResourceCrn @TenantAwareParam String environmentCrn) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
EnvironmentDto environmentDto = null;
if (!Strings.isNullOrEmpty(environmentCrn)) {
environmentDto = environmentService.getByCrnAndAccountId(environmentCrn, accountId);
} else if (!Strings.isNullOrEmpty(environmentName)) {
environmentDto = environmentService.getByNameAndAccountId(environmentName, accountId);
}
Map<String, String> accountTagsMap = new HashMap<>();
if (environmentDto != null) {
accountTagsMap = accountTagService.generate(accountId, environmentDto);
}
Set<GeneratedAccountTagResponse> accountTags = new HashSet<>();
for (Map.Entry<String, String> entry : accountTagsMap.entrySet()) {
GeneratedAccountTagResponse accountTag = new GeneratedAccountTagResponse();
accountTag.setKey(entry.getKey());
accountTag.setValue(entry.getValue());
accountTags.add(accountTag);
}
return new GeneratedAccountTagResponses(accountTags);
}
Aggregations