use of com.ctrip.framework.apollo.common.dto.GrayReleaseRuleDTO in project apollo by ctripcorp.
the class OpenApiBeanUtils method transformToGrayReleaseRuleDTO.
public static GrayReleaseRuleDTO transformToGrayReleaseRuleDTO(OpenGrayReleaseRuleDTO openGrayReleaseRuleDTO) {
Preconditions.checkArgument(openGrayReleaseRuleDTO != null);
String appId = openGrayReleaseRuleDTO.getAppId();
String branchName = openGrayReleaseRuleDTO.getBranchName();
String clusterName = openGrayReleaseRuleDTO.getClusterName();
String namespaceName = openGrayReleaseRuleDTO.getNamespaceName();
GrayReleaseRuleDTO grayReleaseRuleDTO = new GrayReleaseRuleDTO(appId, clusterName, namespaceName, branchName);
Set<OpenGrayReleaseRuleItemDTO> openGrayReleaseRuleItemDTOSet = openGrayReleaseRuleDTO.getRuleItems();
openGrayReleaseRuleItemDTOSet.forEach(openGrayReleaseRuleItemDTO -> {
String clientAppId = openGrayReleaseRuleItemDTO.getClientAppId();
Set<String> clientIpList = openGrayReleaseRuleItemDTO.getClientIpList();
Set<String> clientLabelList = openGrayReleaseRuleItemDTO.getClientLabelList();
GrayReleaseRuleItemDTO ruleItem = new GrayReleaseRuleItemDTO(clientAppId, clientIpList, clientLabelList);
grayReleaseRuleDTO.addRuleItem(ruleItem);
});
return grayReleaseRuleDTO;
}
use of com.ctrip.framework.apollo.common.dto.GrayReleaseRuleDTO in project apollo by ctripcorp.
the class NamespaceBranchController method updateBranchRules.
@PreAuthorize(value = "@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)")
@PutMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules")
public void updateBranchRules(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String branchName, @RequestBody OpenGrayReleaseRuleDTO rules, @RequestParam("operator") String operator, HttpServletRequest request) {
RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(operator), "operator can not be empty");
if (userService.findByUserId(operator) == null) {
throw new BadRequestException("operator " + operator + " not exists");
}
rules.setAppId(appId);
rules.setClusterName(clusterName);
rules.setNamespaceName(namespaceName);
rules.setBranchName(branchName);
GrayReleaseRuleDTO grayReleaseRuleDTO = OpenApiBeanUtils.transformToGrayReleaseRuleDTO(rules);
namespaceBranchService.updateBranchGrayRules(appId, Env.valueOf(env.toUpperCase()), clusterName, namespaceName, branchName, grayReleaseRuleDTO, operator);
}
use of com.ctrip.framework.apollo.common.dto.GrayReleaseRuleDTO in project apollo by ctripcorp.
the class NamespaceBranchController method findBranchGrayRules.
@GetMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules")
public GrayReleaseRuleDTO findBranchGrayRules(@PathVariable String appId, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String branchName) {
checkBranch(appId, clusterName, namespaceName, branchName);
GrayReleaseRule rules = namespaceBranchService.findBranchGrayRules(appId, clusterName, namespaceName, branchName);
if (rules == null) {
return null;
}
GrayReleaseRuleDTO ruleDTO = new GrayReleaseRuleDTO(rules.getAppId(), rules.getClusterName(), rules.getNamespaceName(), rules.getBranchName());
ruleDTO.setReleaseId(rules.getReleaseId());
ruleDTO.setRuleItems(GrayReleaseRuleItemTransformer.batchTransformFromJSON(rules.getRules()));
return ruleDTO;
}
Aggregations