-
Notifications
You must be signed in to change notification settings - Fork 359
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
25 changed files
with
270 additions
and
664 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
21 changes: 21 additions & 0 deletions
21
engine/src/main/scala/cromwell/webservice/routes/wes/RunListResponse.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,21 @@ | ||
package cromwell.webservice.routes.wes | ||
|
||
import akka.http.scaladsl.model.StatusCodes | ||
import cromwell.services.metadata.MetadataService | ||
import cromwell.services.metadata.MetadataService.{WorkflowQueryFailure, WorkflowQuerySuccess} | ||
import cromwell.webservice.routes.wes.WesState.fromStatusString | ||
import cromwell.webservice.WebServiceUtils._ | ||
|
||
case class RunListResponse(runs: List[WesRunStatus], next_page_token: String) | ||
|
||
object RunListResponse { | ||
def fromMetadataQueryResponse(response: MetadataService.MetadataQueryResponse): WesResponse = { | ||
|
||
response match { | ||
case w: WorkflowQuerySuccess => | ||
val runs = w.response.results.toList.map(x => WesRunStatus(x.id, fromStatusString(x.status))) | ||
WesResponseRunList(runs) | ||
case f: WorkflowQueryFailure => WesErrorResponse(f.reason.errorRequest(StatusCodes.BadRequest).toString, StatusCodes.BadRequest.intValue) | ||
} | ||
} | ||
} |
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
61 changes: 61 additions & 0 deletions
61
engine/src/main/scala/cromwell/webservice/routes/wes/WesRunRoutes.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,61 @@ | ||
package cromwell.webservice.routes.wes | ||
|
||
import akka.actor.ActorRef | ||
import akka.http.scaladsl.model.StatusCodes | ||
import akka.http.scaladsl.server.Directives._ | ||
import akka.http.scaladsl.server.Route | ||
import akka.http.scaladsl.server.directives.RouteDirectives.complete | ||
import WesRunRoutes._ | ||
import com.typesafe.config.ConfigFactory | ||
|
||
import cromwell.webservice.routes.MetadataRouteSupport.metadataQueryRequest | ||
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.concurrent.Future | ||
import scala.util.{Failure, Success} | ||
|
||
trait WesRunRoutes { | ||
|
||
val serviceRegistryActor: ActorRef | ||
|
||
lazy val runRoutes: Route = | ||
pathPrefix("ga4gh" / "wes" / "v1") { | ||
pathPrefix("runs") { | ||
pathEnd { | ||
get { | ||
parameters(("page_size".as[Int].?, "page_token".?)) { (pageSize, pageToken) => | ||
completeCromwellResponse(listRuns(pageSize, pageToken, serviceRegistryActor)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
object WesRunRoutes { | ||
|
||
import akka.util.Timeout | ||
import scala.concurrent.duration.FiniteDuration | ||
import net.ceedubs.ficus.Ficus._ | ||
|
||
implicit lazy val duration: FiniteDuration = ConfigFactory.load().as[FiniteDuration]("akka.http.server.request-timeout") | ||
implicit lazy val timeout: Timeout = duration | ||
|
||
def completeCromwellResponse(future: => Future[WesResponse]): Route = { | ||
|
||
import WesResponseJsonSupport.WesResponseErrorFormat | ||
import cromwell.webservice.routes.wes.WesResponseJsonSupport.WesResponseFormat | ||
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ | ||
|
||
onComplete(future) { | ||
case Success(response: WesResponse) => complete(response) | ||
case Failure(e) => complete(WesErrorResponse(e.getMessage, StatusCodes.InternalServerError.intValue)) | ||
} | ||
} | ||
|
||
def listRuns(pageSize: Option[Int], pageToken: Option[String], serviceRegistryActor: ActorRef): Future[WesResponse] = { | ||
// FIXME: to handle - page_size, page_token | ||
// FIXME: How to handle next_page_token in response? | ||
metadataQueryRequest(Seq.empty[(String, String)], serviceRegistryActor).map(RunListResponse.fromMetadataQueryResponse) | ||
} | ||
} |
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
Oops, something went wrong.