@Override public String params(String param) { return delegate.params(param); }
@Override public Map<String, String> params() { return delegate.params(); }
private String requiredParam(final Request req, final String name) { String value = req.params(name); if (StringUtils.isBlank(value)) { throw HaltApiResponses.haltBecauseRequiredParamMissing(name); } return value; }
private String findPipelineGroupName(Request request) { String groupName = request.params("group_name"); if (StringUtils.isBlank(groupName)) { groupName = goConfigService.findGroupNameByPipeline(getPipelineNameFromRequest(request)); } return groupName; }
private PipelineConfig pipelineConfigFromRequest(Request req) { final String pipelineName = req.params("pipeline_name"); PipelineConfig pipeline = configService.editablePipelineConfigNamed(pipelineName); if (null == pipeline) { throw new RecordNotFoundException(format("Cannot locate pipeline config with name: %s", pipelineName)); } return pipeline; }
private CaseInsensitiveString getPipelineNameFromRequest(Request request) { String pipelineName = request.params("pipeline_name"); if (StringUtils.isBlank(pipelineName)) { pipelineName = request.queryParams("pipeline_name"); } return new CaseInsensitiveString(pipelineName); }
private ConfigRepoConfig repoFromRequest(Request req) { ConfigRepoConfig repo = service.getConfigRepo(req.params(":id")); if (null == repo) { throw HaltApiResponses.haltBecauseNotFound(); } return repo; }
public String deleteAgent(Request request, Response response) throws IOException { final HttpOperationResult result = new HttpOperationResult(); agentService.deleteAgents(currentUsername(), result, singletonList(request.params("uuid"))); return renderHTTPOperationResult(result, request, response); }
public String usages(Request request, Response response) { final String elasticProfileId = StringUtils.stripToEmpty(request.params(PROFILE_ID_PARAM)); final Collection<ElasticProfileUsage> jobsUsingElasticProfile = elasticProfileService.getUsageInformation(elasticProfileId); return ElasticProfileUsageRepresenter.toJSON(jobsUsingElasticProfile); } }
public String schedule(Request req, Response res) throws IOException { HttpOperationResult result = new HttpOperationResult(); String pipelineName = req.params("pipeline_name"); pipelineTriggerService.schedule(pipelineName, getScheduleOptions(req), currentUsername(), result); return renderHTTPOperationResult(result, req, res); }
public String destroy(Request req, Response res) throws IOException { Role role = fetchEntityFromConfig(req.params("role_name")); HttpLocalizedOperationResult result = new HttpLocalizedOperationResult(); roleConfigService.delete(SessionUtils.currentUsername(), role, result); return renderHTTPOperationResult(result, req, res); }
public void checkViewAccessToTemplateAnd403(Request request, Response response) { if (!securityService.isSecurityEnabled() || securityService.isUserAdmin(currentUsername())) { return; } String templateName = request.params("template_name"); if (StringUtils.isNotBlank(templateName) && !securityService.isAuthorizedToViewTemplate(new CaseInsensitiveString(templateName), currentUsername())) { throw renderForbiddenResponse(); } if (StringUtils.isBlank(templateName) && !securityService.isAuthorizedToViewTemplates(currentUsername())) { throw renderForbiddenResponse(); } }
public String triggerOptions(Request request, Response response) throws IOException { String pipelineName = request.params("pipeline_name"); EnvironmentVariablesConfig variables = goConfigService.variablesFor(pipelineName); PipelineInstanceModel pipelineInstanceModel = pipelineHistoryService.latest(pipelineName, currentUsername()); TriggerOptions triggerOptions = new TriggerOptions(variables, pipelineInstanceModel); return writerForTopLevelObject(request, response, writer -> TriggerWithOptionsViewRepresenter.toJSON(writer, triggerOptions)); }
public String show(Request req, Response res) throws IOException { PipelineTemplateConfig templateConfig = fetchEntityFromConfig(req.params("template_name")); if (isGetOrHeadRequestFresh(req, templateConfig)) { return notModified(res); } else { setEtagHeader(templateConfig, res); return writerForTopLevelObject(req, res, writer -> TemplateConfigRepresenter.toJSON(writer, templateConfig)); } }
private ConfigRepoWithResult repoWithResultFromRequest(Request req) { ConfigRepoConfig repo = service.getConfigRepo(req.params(":id")); if (null == repo) { throw HaltApiResponses.haltBecauseNotFound(); } PartialConfigParseResult result = dataSource.getLastParseResult(repo.getMaterialConfig()); return new ConfigRepoWithResult(repo, result, isMaterialUpdateInProgress(repo)); }
public String destroy(Request req, Response res) throws IOException { PipelineConfig existingPipelineConfig = fetchEntityFromConfig(req.params("pipeline_name")); haltIfPipelineIsDefinedRemotely(existingPipelineConfig); HttpLocalizedOperationResult result = new HttpLocalizedOperationResult(); pipelineConfigService.deletePipelineConfig(SessionUtils.currentUsername(), existingPipelineConfig, result); return renderHTTPOperationResult(result, req, res); }
public String show(Request req, Response res) throws IOException { PipelineConfig pipelineConfig = fetchEntityFromConfig(req.params("pipeline_name")); if (isGetOrHeadRequestFresh(req, pipelineConfig)) { return notModified(res); } else { setEtagHeader(pipelineConfig, res); return writerForTopLevelObject(req, res, writer -> PipelineConfigRepresenter.toJSON(writer, pipelineConfig)); } }
String deleteRepo(Request req, Response res) { ConfigRepoConfig repo = fetchEntityFromConfig(req.params(":id")); HttpLocalizedOperationResult result = new HttpLocalizedOperationResult(); service.deleteConfigRepo(repo.getId(), currentUsername(), result); return handleSimpleMessageResponse(res, result); }
public String show(Request req, Response res) throws IOException { PipelineConfigs pipelineConfigs = fetchEntityFromConfig(req.params("group_name")); if (isGetOrHeadRequestFresh(req, pipelineConfigs)) { return notModified(res); } else { setEtagHeader(pipelineConfigs, res); return writerForTopLevelObject(req, res, writer -> PipelineGroupRepresenter.toJSON(writer, pipelineConfigs)); } }
public String show(Request req, Response res) throws Exception { User user = userService.findUserByName(req.params("login_name")); if (user.equals(new NullUser())) { throw new RecordNotFoundException(); } UserToRepresent toRepresent = getUserToRepresent(user, roleConfigService.getRolesForUser(Collections.singletonList(user.getUsername()))); return writerForTopLevelObject(req, res, writer -> UserRepresenter.toJSON(writer, toRepresent)); }