@GET public List<ImageBean> getImagesByAppname( @QueryParam("app") Optional<String> appName, @QueryParam("start") Optional<Integer> start, @QueryParam("size") Optional<Integer> size) throws Exception { return imageDAO.getImages(appName.orNull(), start.or(1), size.or(DEFAULT_PAGE_SIZE)); }
@GET @Path("/{id : [a-zA-Z0-9\\-_]+}") public ImageBean getImageById(@PathParam("id") String id) throws Exception { if (StringUtils.isEmpty(id)) { throw new TeletaanInternalException( Response.Status.BAD_REQUEST, "Require image id for the request."); } return imageDAO.getById(id); }
@POST public void publish(@Context SecurityContext sc, @Valid ImageBean amiBean) throws Exception { authorizer.authorize(sc, new Resource(Resource.ALL, Resource.Type.SYSTEM), Role.OPERATOR); if (amiBean.getPublish_date() == null) { amiBean.setPublish_date(System.currentTimeMillis()); } amiBean.setQualified(false); imageDAO.insertOrUpdate(amiBean); LOG.info("Publish new ami {} for app {}", amiBean.getId(), amiBean.getApp_name()); HealthCheckBean healthCheckBean = new HealthCheckBean(); healthCheckBean.setType(HealthCheckType.AMI_TRIGGERED); healthCheckBean.setAmi_id(amiBean.getId()); List<String> healthCheckIds = healthCheckHandler.createHealthCheck(healthCheckBean); LOG.info("Add new health checks, ids: {}", Joiner.on(",").join(healthCheckIds)); }
@GET @Path("/appnames") public List<String> getApplicationNames() throws Exception { return imageDAO.getAppNames(); }