@POST("/jolokia/environment/{environmentId}/pod/{podName}/{path:(.*|^$)}") public void jolokiaProxyPost(int environmentId, String podName, String path, Req req) { genericJolokiaProxy(environmentId, podName, path, req); }
uri = ((POST) ann).uri();
@POST("/jolokia/environment/{environmentId}/pod/{podName}") public void jolokiaProxyPost(int environmentId, String podName, Req req) { genericJolokiaProxy(environmentId, podName, "", req); }
@Administrator @POST("/deployment-roles/add-user") public void addUserToDeploymentRole(String userEmail, int deploymentRoleId, Req req) { deploymentRoleDao.addUserToDeploymentRole(userEmail, deploymentRoleId); assignJsonResponseToReq(req, HttpStatus.CREATED, "ok"); }
@Administrator @POST("/deployment-roles/add-deployment-permission") public void addDeploymentPermissionToDeploymentRole(int deploymentRoleId, int deploymentPermissionId, Req req) { deploymentRoleDao.addDeploymentPermissionToDeploymentRole(deploymentRoleId, deploymentPermissionId); assignJsonResponseToReq(req, HttpStatus.CREATED, "ok"); }
@Administrator @POST("/blocker-definition/override/user") public void addBlockerDefinitionUserOverride(String userEmail, int blockerId, Req req) { blockerDefinitionDao.addUserToBlockerOverride(userEmail, blockerId); assignJsonResponseToReq(req, HttpStatus.CREATED, "ok"); }
@LoggedIn @POST("/environments-stack/environment") public void addEnvironmentToStack(int environmentId, int stackId, Req req) { environmentsStackDao.addEnvironmentToStack(environmentId, stackId); assignJsonResponseToReq(req, HttpStatus.CREATED, getEnvironmentsStack(stackId)); }
@LoggedIn @POST("/deployment") public void addDeployment(String environmentIdsCsv, String serviceIdsCsv, int deployableVersionId, String deploymentMessage, String groupName, Req req) { Iterable<String> environmentIds = Splitter.on(IDS_DELIMITER).omitEmptyStrings().trimResults().split(environmentIdsCsv);
@LoggedIn @POST("/notification") public void addNotification(String name, String environmentId, String serviceId, NotificationType type, String notificationJsonConfiguration, Req req) { 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 notification = new Notification(); notification.setName(name); notification.setEnvironmentId(environmentIdParsed); notification.setServiceId(serviceIdParsed); notification.setType(type); notification.setNotificationJsonConfiguration(notificationJsonConfiguration); notificationDao.addNotification(notification); assignJsonResponseToReq(req, HttpStatus.CREATED, notification); }
@Administrator @POST("/deployment-roles") public void addDeploymentRole(String name, Req req) { DeploymentRole newDeploymentRole = new DeploymentRole(); newDeploymentRole.setName(name); deploymentRoleDao.addDeploymentRole(newDeploymentRole); assignJsonResponseToReq(req, HttpStatus.CREATED, newDeploymentRole); }
@Administrator @POST("/deployment-permission") public void addDeploymentPermission(String name, String serviceId, String environmentId, DeploymentPermission.PermissionType permissionType, Req req) { DeploymentPermission newDeploymentPermission = new DeploymentPermission(); newDeploymentPermission.setName(name); // This is how rapidoid represent nulls. also has to be string to not have a NumberFormatException if (serviceId.equals("null") && environmentId.equals("null")) { req.response().code(HttpStatus.BAD_REQUEST); req.response().json("One of serviceId or environmentId must be present!"); } else { if (!serviceId.equals("null")) { newDeploymentPermission.setServiceId(Integer.parseInt(serviceId)); } if (!environmentId.equals("null")) { newDeploymentPermission.setEnvironmentId(Integer.parseInt(environmentId)); } } newDeploymentPermission.setPermissionType(permissionType); deploymentPermissionDao.addDeploymentPermission(newDeploymentPermission); assignJsonResponseToReq(req, HttpStatus.CREATED, newDeploymentPermission); }
@Administrator @POST("/blocker-definition") public void addBlockerDefinition(String name, String environmentId, String serviceId, Boolean isActive, String blockerTypeName, String blockerJsonConfiguration, Req req) { if (!blockerService.getBlockerTypeBinding(blockerTypeName).isPresent()) { logger.warn("Could not find proper class that annotated with {}", blockerTypeName); assignJsonResponseToReq(req, HttpStatus.BAD_REQUEST, "There is no implementation for blocker with name " + blockerTypeName); 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 blockerDefinition = new BlockerDefinition(); blockerDefinition.setName(name); blockerDefinition.setEnvironmentId(environmentIdParsed); blockerDefinition.setServiceId(serviceIdParsed); blockerDefinition.setBlockerTypeName(blockerTypeName); blockerDefinition.setBlockerJsonConfiguration(blockerJsonConfiguration); blockerDefinition.setActive(isActive); blockerDefinitionDao.addBlockerDefinition(blockerDefinition); assignJsonResponseToReq(req, HttpStatus.CREATED, blockerDefinition); }
@LoggedIn @Transactional @POST("/environments-stack") public void addEnvironmentsStack(String name, boolean isEnabled, String environmentsCsv, Req req) { List<Integer> environmentsIds = StringParser.splitCsvToIntegerList(environmentsCsv); EnvironmentsStack environmentsStack = new EnvironmentsStack(name, isEnabled); stackDao.addStack(environmentsStack); if (environmentsIds.size() > 0) { environmentsStackDao.addEnvironmentsToStack(environmentsIds, environmentsStack.getId()); } assignJsonResponseToReq(req, HttpStatus.CREATED, getEnvironmentsStack(environmentsStack.getId())); }
@LoggedIn @Transactional @POST("/services-stack/service") public void addServiceToStack(int serviceId, int stackId, Req req) { if (serviceDao.getService(serviceId).getIsPartOfGroup()) { assignJsonResponseToReq(req, HttpStatus.BAD_REQUEST, "Can't add to stack service that is part of a group"); return; } servicesStackDao.addServiceToStack(serviceId, stackId); assignJsonResponseToReq(req, HttpStatus.CREATED, getServicesStack(stackId)); }
@LoggedIn @POST("/deployment-groups") public void addDeployment(int environmentId, int serviceId, int deployableVersionId, String groupIdsCsv, String deploymentMessage, Req req) throws NumberFormatException {
@LoggedIn @Transactional @POST("/services-stack") public void addServicesStack(String name, boolean isEnabled, String servicesCsv, Req req) { List<Integer> servicesIds = StringParser.splitCsvToIntegerList(servicesCsv); ServicesStack servicesStack = new ServicesStack(name, isEnabled); stackDao.addStack(servicesStack); if (servicesIds.size() > 0) { servicesIds.forEach(id -> { if (serviceDao.getService(id).getIsPartOfGroup()) { assignJsonResponseToReq(req, HttpStatus.BAD_REQUEST, "Can't add to stack service that is part of a group"); return; } }); servicesStackDao.addServicesToStack(servicesIds, servicesStack.getId()); } assignJsonResponseToReq(req, HttpStatus.CREATED, getServicesStack(servicesStack.getId())); }
@LoggedIn @POST("/service") public void addService(String name, String deploymentYaml, String serviceYaml, String ingressYaml, Boolean isPartOfGroup, Req req) { Service newService = new Service(); newService.setName(name); newService.setDeploymentYaml(deploymentYaml); newService.setServiceYaml(serviceYaml); newService.setIngressYaml(ingressYaml); newService.setIsPartOfGroup(isPartOfGroup); serviceDao.addService(newService); assignJsonResponseToReq(req, HttpStatus.CREATED, newService); }
@LoggedIn @POST("/group") public void addGroup(String name, int serviceId, int environmentId, int scalingFactor, String jsonParams, Req req) { Group newGroup = new Group(); newGroup.setName(name); newGroup.setServiceId(serviceId); newGroup.setEnvironmentId(environmentId); newGroup.setScalingFactor(scalingFactor); newGroup.setJsonParams(jsonParams); groupDao.addGroup(newGroup); assignJsonResponseToReq(req, HttpStatus.CREATED, newGroup); }
@LoggedIn @POST("/k8s/pod/restart") public void restartPod(int environmentId, String podName, Req req) { Environment environment = environmentDao.getEnvironment(environmentId); if (environment == null) { ControllerCommon.assignJsonResponseToReq(req, HttpStatus.BAD_REQUEST, "Environment " + environmentId + " does not exists"); return; } try { kubernetesHandlerStore.getOrCreateKubernetesHandler(environment).restartPod(podName); } catch (ApolloKubernetesException e) { ControllerCommon.assignJsonResponseToReq(req, HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage()); return; } ControllerCommon.assignJsonResponseToReq(req, HttpStatus.OK, "Ok"); }
@Administrator @POST("/signup") public User addUser(String userEmail, String firstName, String lastName, String password) { // TODO: validate input User newUser = new User(); newUser.setUserEmail(userEmail); newUser.setFirstName(firstName); newUser.setLastName(lastName); newUser.setHashedPassword(PasswordManager.encryptPassword(password)); newUser.setAdmin(false); newUser.setEnabled(true); userDao.addUser(newUser); return newUser; }