package com.hubspot.singularity.resources;

import java.util.List;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.google.inject.Inject;
import com.hubspot.singularity.SingularityCreateResult;
import com.hubspot.singularity.SingularityDeleteResult;
import com.hubspot.singularity.SingularityRequestHistory;
import com.hubspot.singularity.SingularityService;
import com.hubspot.singularity.SingularityTaskHistoryUpdate;
import com.hubspot.singularity.SingularityWebhook;
import com.hubspot.singularity.data.WebhookManager;

@Path(SingularityService.API_BASE_PATH + "/webhooks")
@Produces({ MediaType.APPLICATION_JSON })
public class WebhookResource {

  private final WebhookManager webhookManager;

  @Inject
  public WebhookResource(WebhookManager webhookManager) {
    this.webhookManager = webhookManager;
  }

  @GET
  public List<SingularityWebhook> getActiveWebhooks() {
    return webhookManager.getActiveWebhooks();
  }

  @POST
  public SingularityCreateResult addWebhook(SingularityWebhook webhook) {
    return webhookManager.addWebhook(webhook);
  }

  @DELETE
  @Path("/{webhookId}")
  public SingularityDeleteResult deleteWebhook(@PathParam("webhookId") String webhookId) {
    return webhookManager.deleteWebhook(webhookId);
  }

//  @GET
//  @Path("/deploy/{webhookId}")
//  public List<SingularityTaskHistoryUpdate> getQueuedTaskUpdates(@PathParam("webhookId") String webhookId) {
//    return webhookManager.getQueuedTaskUpdatesForHook(webhookId);
//  }
//
  
  @GET
  @Path("/request/{webhookId}")
  public List<SingularityRequestHistory> getQueuedRequestUpdates(@PathParam("webhookId") String webhookId) {
    return webhookManager.getQueuedRequestHistoryForHook(webhookId);
  }
  
  @GET
  @Path("/task/{webhookId}")
  public List<SingularityTaskHistoryUpdate> getQueuedTaskUpdates(@PathParam("webhookId") String webhookId) {
    return webhookManager.getQueuedTaskUpdatesForHook(webhookId);
  }

}

@@ -394,32 +394,89 @@
 tyDeleteResult;%0A
+import com.hubspot.singularity.SingularityDeployWebhook;%0A
 import com.hubsp
@@ -1459,19 +1459,15 @@
  %7D%0A%0A
-//
   @GET%0A
-//
   @P
@@ -1493,18 +1493,16 @@
 okId%7D%22)%0A
-//
   public
@@ -1518,33 +1518,29 @@
 gularity
-TaskHistoryUpdate
+DeployWebhook
 %3E getQue
@@ -1534,36 +1534,38 @@
 bhook%3E getQueued
-Task
+Deploy
 Updates(@PathPar
@@ -1600,18 +1600,16 @@
 okId) %7B%0A
-//
     retu
@@ -1627,36 +1627,38 @@
 anager.getQueued
-Task
+Deploy
 UpdatesForHook(w
@@ -1672,17 +1672,12 @@
 d);%0A
-//
   %7D%0A
-//%0A
   %0A 

add deploy updates endpoint