package com.hubspot.singularity.resources;

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

import com.google.common.base.Optional;
import com.google.inject.Inject;
import com.hubspot.singularity.SingularityService;
import com.hubspot.singularity.SingularityUserSettings;
import com.hubspot.singularity.data.UserManager;
import com.wordnik.swagger.annotations.ApiParam;

@Path(UserResource.PATH)
@Produces({ MediaType.APPLICATION_JSON })
public class UserResource {
  public static final String PATH = SingularityService.API_BASE_PATH + "/users";

  private final UserManager userManager;

  @Inject
  public UserResource(UserManager userManager) {
    this.userManager = userManager;
  }

  @GET
  @Path("/settings")
  public Optional<SingularityUserSettings> getUserSettings(
      @ApiParam("The user id to use") @QueryParam("userId") String userId) {
    return userManager.getUserSettings(userId);
  }

  @POST
  @Path("/settings")
  public void setUserSettings(
      @ApiParam("The user id to use") @QueryParam("userId") String userId,
      @ApiParam("The new settings") SingularityUserSettings settings) {
    userManager.updateUserSettings(userId, settings);
  }
}

@@ -37,16 +37,43 @@
 urces;%0A%0A
+import javax.ws.rs.DELETE;%0A
 import j
@@ -1101,39 +1101,32 @@
 setUserSettings(
-%0A      
 @ApiParam(%22The u
@@ -1128,68 +1128,467 @@
 The 
-user id to use%22) @QueryParam(%22userId%22) String userId,%0A      
+new settings%22) SingularityUserSettings settings) %7B%0A    userManager.updateUserSettings(settings.getUserId(), settings);%0A  %7D%0A%0A  @POST%0A  @Path(%22/settings/starred-requests%22)%0A  public void addStarredRequests(@ApiParam(%22The new starred requests%22) SingularityUserSettings settings) %7B%0A    userManager.addStarredRequestIds(settings.getUserId(), settings.getStarredRequestIds());%0A  %7D%0A%0A  @DELETE%0A  @Path(%22/settings/starred-requests%22)%0A  public void deleteStarredRequests(
 @Api
@@ -1595,38 +1595,46 @@
 Param(%22The new s
-etting
+tarred request
 s%22) SingularityU
@@ -1677,33 +1677,52 @@
 ger.
-updateUserS
+deleteStarredRequestIds(s
 ettings
-(u
+.getU
 serId
+()
 , se
@@ -1723,21 +1723,44 @@
 (), settings
+.getStarredRequestIds()
 );%0A  %7D%0A%7D%0A

Add add/delete starred requests to UserResource