-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
60 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/scala/org/broadinstitute/dsde/workbench/sam/api/UserRoutesV1.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.broadinstitute.dsde.workbench.sam.api | ||
|
||
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ | ||
import akka.http.scaladsl.model.StatusCodes | ||
import akka.http.scaladsl.server | ||
import akka.http.scaladsl.server.Directives._ | ||
import org.broadinstitute.dsde.workbench.model._ | ||
import org.broadinstitute.dsde.workbench.sam.model.api.SamJsonSupport._ | ||
import org.broadinstitute.dsde.workbench.sam.model.api.SamUser | ||
import org.broadinstitute.dsde.workbench.sam.service.UserService | ||
import org.broadinstitute.dsde.workbench.sam.util.SamRequestContext | ||
|
||
trait UserRoutesV1 extends SamUserDirectives with SamRequestContextDirectives { | ||
val userService: UserService | ||
|
||
def userRoutesV1(samUser: SamUser, samRequestContext: SamRequestContext): server.Route = pathPrefix("users") { | ||
pathPrefix("v1") { | ||
get { | ||
path(Segment) { email => | ||
pathEnd { | ||
complete { | ||
userService.getUserIdInfoFromEmail(WorkbenchEmail(email), samRequestContext).map { | ||
case Left(_) => StatusCodes.NotFound -> None | ||
case Right(None) => StatusCodes.NoContent -> None | ||
case Right(Some(userIdInfo)) => StatusCodes.OK -> Some(userIdInfo) | ||
} | ||
} | ||
} | ||
} | ||
} ~ | ||
pathPrefix("invite") { | ||
post { | ||
path(Segment) { inviteeEmail => | ||
complete { | ||
userService | ||
.inviteUser(WorkbenchEmail(inviteeEmail.trim), samRequestContext) | ||
.map(userStatus => StatusCodes.Created -> userStatus) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters