Exemple #1
0
 @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));
 }
Exemple #2
0
  @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);
  }
Exemple #3
0
  @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));
  }
Exemple #4
0
 @GET
 @Path("/appnames")
 public List<String> getApplicationNames() throws Exception {
   return imageDAO.getAppNames();
 }