@PUT("/jolokia/environment/{environmentId}/pod/{podName}/{path:(.*|^$)}") public void jolokiaProxyPut(int environmentId, String podName, String path, Req req) { genericJolokiaProxy(environmentId, podName, path, req); }
uri = ((PUT) ann).uri();
@PUT("/blocker-definition/{id}/active/{active}") public void updateBlockerDefinitionActiveness(int id, String active, Req req) { BlockerDefinition blockerDefinition = blockerDefinitionDao.getBlockerDefinition(id); if (blockerDefinition == null) { Map<String, String> message = ImmutableMap.of("message", "Blocker not found"); assignJsonResponseToReq(req, HttpStatus.NOT_FOUND, message); return; } try { blockerDefinition.setActive(Boolean.valueOf(active)); } catch (Exception e) { assignJsonResponseToReq(req, HttpStatus.BAD_REQUEST, blockerDefinition); return; } blockerDefinitionDao.updateBlockerDefinition(blockerDefinition); assignJsonResponseToReq(req, HttpStatus.OK, blockerDefinition); } }
@LoggedIn @PUT("/notification/{id}") public void updateNotification(int id, String name, String environmentId, String serviceId, NotificationType type, String notificationJsonConfiguration, Req req) { Notification notification = notificationDao.getNotification(id); if (notification == null) { Map<String, String> message = ImmutableMap.of("message", "Notification not found"); assignJsonResponseToReq(req, HttpStatus.NOT_FOUND, message); return; } Integer environmentIdParsed = null; Integer serviceIdParsed = null; if (environmentId != null && !environmentId.equals("null")) environmentIdParsed = Integer.parseInt(environmentId); if (serviceId != null && !serviceId.equals("null")) serviceIdParsed = Integer.parseInt(serviceId); notification.setName(name); notification.setEnvironmentId(environmentIdParsed); notification.setServiceId(serviceIdParsed); notification.setType(type); notification.setNotificationJsonConfiguration(notificationJsonConfiguration); notificationDao.updateNotification(notification); assignJsonResponseToReq(req, HttpStatus.OK, notification); }
@Administrator @PUT("/blocker-definition/{id}") public void updateBlockerDefinition(int id, String name, String environmentId, String serviceId, Boolean isActive, String blockerTypeName, String blockerJsonConfiguration, Req req) { BlockerDefinition blockerDefinition = blockerDefinitionDao.getBlockerDefinition(id); if (blockerDefinition == null) { Map<String, String> message = ImmutableMap.of("message", "Blocker not found"); assignJsonResponseToReq(req, HttpStatus.NOT_FOUND, message); return; } Integer environmentIdParsed = null; Integer serviceIdParsed = null; if (environmentId != null && !environmentId.equals("null")) environmentIdParsed = Integer.parseInt(environmentId); if (serviceId != null && !serviceId.equals("null")) serviceIdParsed = Integer.parseInt(serviceId); blockerDefinition.setName(name); blockerDefinition.setEnvironmentId(environmentIdParsed); blockerDefinition.setServiceId(serviceIdParsed); blockerDefinition.setBlockerTypeName(blockerTypeName); blockerDefinition.setBlockerJsonConfiguration(blockerJsonConfiguration); blockerDefinition.setActive(isActive); blockerDefinitionDao.updateBlockerDefinition(blockerDefinition); assignJsonResponseToReq(req, HttpStatus.OK, blockerDefinition); }
@LoggedIn @Transactional @PUT("/environments-stack") public void updateEnvironmentsStack(int id, String name, boolean isEnabled, String environmentsCsv, Req req) { List<Integer> environmentsIds = StringParser.splitCsvToIntegerList(environmentsCsv); if (environmentsIds.size() <= 0) { assignJsonResponseToReq(req, HttpStatus.BAD_REQUEST, "The EnvironmentsStack you asked to update has an empty environments list"); return; } EnvironmentsStack environmentsStack = new EnvironmentsStack(id, name, isEnabled); stackDao.updateStack(environmentsStack); environmentsStackDao.clearEnvironmentsStack(id); environmentsStackDao.addEnvironmentsToStack(environmentsIds, id); assignJsonResponseToReq(req, HttpStatus.OK, getEnvironmentsStack(id)); }
@LoggedIn @PUT("/group/{id}") public void updateGroup(int id, String name, int serviceId, int environmentId, int scalingFactor, String jsonParams, Req req) { Group group = groupDao.getGroup(id); if (group == null) { Map<String, String> message = ImmutableMap.of("message", "Group not found"); assignJsonResponseToReq(req, HttpStatus.NOT_FOUND, message); return; } group.setName(name); group.setServiceId(serviceId); group.setEnvironmentId(environmentId); group.setScalingFactor(scalingFactor); group.setJsonParams(jsonParams); groupDao.updateGroup(group); assignJsonResponseToReq(req, HttpStatus.OK, group); }
@LoggedIn @PUT("/service/{id}") public void updateService(int id, String name, String deploymentYaml, String serviceYaml, String ingressYaml, Boolean isPartOfGroup, Req req) { Service service = serviceDao.getService(id); if (service == null) { Map<String, String> message = ImmutableMap.of("message", "Service not found"); assignJsonResponseToReq(req, HttpStatus.NOT_FOUND, message); return; } service.setName(name); service.setDeploymentYaml(deploymentYaml); service.setServiceYaml(serviceYaml); service.setIngressYaml(ingressYaml); service.setIsPartOfGroup(isPartOfGroup); serviceDao.updateService(service); assignJsonResponseToReq(req, HttpStatus.OK, service); } }
@LoggedIn @Transactional @PUT("/services-stack") public void updateServicesStack(int id, String name, boolean isEnabled, String servicesCsv, Req req) { List<Integer> servicesIds = StringParser.splitCsvToIntegerList(servicesCsv); if (servicesIds.size() <= 0) { assignJsonResponseToReq(req, HttpStatus.BAD_REQUEST, "The ServicesStack you asked to update has an empty services list"); return; } servicesIds.forEach(serviceId -> { if (serviceDao.getService(id).getIsPartOfGroup()) { assignJsonResponseToReq(req, HttpStatus.BAD_REQUEST, "Can't add to stack service that is part of a group"); return; } }); ServicesStack servicesStack = new ServicesStack(id, name, isEnabled); stackDao.updateStack(servicesStack); servicesStackDao.clearServicesStack(id); servicesStackDao.addServicesToStack(servicesIds, id); assignJsonResponseToReq(req, HttpStatus.OK, getServicesStack(id)); }
@LoggedIn @PUT("/scaling/{groupId}") public void updateScalingFactor(int groupId, int scalingFactor, Req req) { Group group = groupDao.getGroup(groupId); if (group == null) { assignJsonResponseToReq(req, HttpStatus.NOT_FOUND, groupId); return; } if (group.getScalingStatus() == Group.ScalingStatus.BLOCKED) { assignJsonResponseToReq(req, HttpStatus.FORBIDDEN, groupId); return; } group.setScalingFactor(scalingFactor); group.setScalingStatus(Group.ScalingStatus.PENDING); groupDao.updateGroup(group); assignJsonResponseToReq(req, HttpStatus.OK, group); } }
@Administrator @PUT("/users") public User updateUser(String userEmail, String firstName, String lastName, String password, Boolean isAdmin, Boolean isEnabled) { User user = getUser(userEmail); user.setUserEmail(userEmail); user.setFirstName(firstName); user.setLastName(lastName); user.setHashedPassword(PasswordManager.encryptPassword(password)); user.setAdmin(isAdmin); user.setEnabled(isEnabled); userDao.updateUser(user); return user; }