Created
September 7, 2018 15:00
-
-
Save danbills/1c12901a6781d1c644e6fa857ed66626 to your computer and use it in GitHub Desktop.
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
import $ivy.`org.http4s::http4s-dsl:0.18.17` | |
import $ivy.`org.http4s::http4s-blaze-server:0.18.17` | |
import $ivy.`org.http4s::http4s-blaze-client:0.18.17` | |
import $ivy.`io.circe::circe-core:0.9.3` | |
import $ivy.`io.circe::circe-parser:0.9.3` | |
import $ivy.`io.circe::circe-generic:0.9.3` | |
import io.circe._, io.circe.parser._ | |
import io.circe.generic.auto._ | |
import org.http4s.client.blaze._ | |
import org.http4s.client._ | |
import org.http4s.client.dsl.io._ | |
import org.http4s.headers._ | |
import org.http4s.MediaType._ | |
import org.http4s.Uri | |
import org.http4s._ | |
import org.http4s.Method._ | |
import cats.effect._ | |
import cats.syntax.option._ | |
import cats.syntax.either._ | |
val httpClient = Http1Client[IO]().unsafeRunSync | |
val wfId = "499f2b8b-7190-4a25-8195-0b8a534af450" | |
val request = GET( | |
Uri.uri("http://localhost:8000/api/workflows/v1/499f2b8b-7190-4a25-8195-0b8a534af450/metadata?expandSubWorkflows=false"), | |
Accept(`application/json`) | |
) | |
case class Event(startTime: String, description: String, endTime: String) | |
case class Call(executionEvents: Array[Event]) | |
println{ | |
val text = httpClient.expect[String](request).unsafeRunSync | |
val json = parse(text).getOrElse(throw new RuntimeException("boom!")).hcursor.downField("calls") | |
for { | |
key <- json.keys.toList.flatten | |
out <- json.downField(key).as[Array[Call]].getOrElse(throw new RuntimeException("boom")).toList | |
} yield out | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment