Skip to content

Commit

Permalink
Added sttp docs and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
hnaderi committed Sep 26, 2022
1 parent 44f40fa commit 687a72b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The following integrations are currently available:
libraryDependencies ++= Seq(
"dev.hnaderi" %% "scala-k8s-http4s" % "@VERSION@", // JVM, JS, Native ; http4s and fs2 integration
"dev.hnaderi" %% "scala-k8s-zio" % "@VERSION@", // JVM ; ZIO native integration using zio-http and zio-json
"dev.hnaderi" %% "scala-k8s-sttp" % "@VERSION@", // JVM, JS, Native ; sttp integration using jawn parser
"dev.hnaderi" %% "scala-k8s-circe" % "@VERSION@", // JVM, JS ; circe integration
"dev.hnaderi" %% "scala-k8s-json4s" % "@VERSION@", // JVM, JS, Native; json4s integration
"dev.hnaderi" %% "scala-k8s-spray-json" % "@VERSION@", // JVM ; spray-json integration
Expand All @@ -68,6 +69,6 @@ visit [project site](https://projects.hnaderi.dev/scala-k8s) to see more tutoria
see [this project](https://github.com/hnaderi/sbt-k8s)

## Future plans
- more integrations (ZIO, sttp, akka-http)!
- more integrations (akka-http, ...)!
- more requests and options
- direct TLS support
5 changes: 3 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,11 @@ lazy val docs = project
"Jawn" -> url("https://github.com/typelevel/jawn")
),
libraryDependencies ++= Seq(
"org.http4s" %%% "http4s-circe" % "0.23.16"
"org.http4s" %%% "http4s-circe" % "0.23.16",
"com.softwaremill.sttp.client3" %%% "circe" % "3.8.0"
)
)
.dependsOn(http4s.jvm, circe.jvm, manifests.jvm)
.dependsOn(http4s.jvm, sttp.jvm, circe.jvm, manifests.jvm)

lazy val unidocs = project
.in(file("unidocs"))
Expand Down
21 changes: 21 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The following integrations are currently available:
libraryDependencies ++= Seq(
"dev.hnaderi" %% "scala-k8s-http4s" % "@VERSION@", // JVM, JS, Native ; http4s and fs2 integration
"dev.hnaderi" %% "scala-k8s-zio" % "@VERSION@", // JVM ; ZIO native integration using zio-http and zio-json
"dev.hnaderi" %% "scala-k8s-sttp" % "@VERSION@", // JVM, JS, Native ; sttp integration using jawn parser
"dev.hnaderi" %% "scala-k8s-circe" % "@VERSION@", // JVM, JS ; circe integration
"dev.hnaderi" %% "scala-k8s-json4s" % "@VERSION@", // JVM, JS, Native; json4s integration
"dev.hnaderi" %% "scala-k8s-spray-json" % "@VERSION@", // JVM ; spray-json integration
Expand Down Expand Up @@ -213,6 +214,26 @@ val client = ZIOKubernetesClient.make("http://localhost:8001")
val nodes = ZIOKubernetesClient.send(APIs.nodes.list())
```

### Sttp based client
```scala mdoc:compile-only
import dev.hnaderi.k8s.circe._
import dev.hnaderi.k8s.client.APIs
import dev.hnaderi.k8s.client.SttpKubernetesClient
import io.circe.Json
import sttp.client3._
import sttp.client3.circe._

val simpleBackend = HttpURLConnectionBackend()

val client = new SttpKubernetesClient[Identity, Json](
"http://localhost:8001",
simpleBackend
)

val nodes = APIs.nodes.list().send(client)
nodes.body.items.flatMap(_.metadata).flatMap(_.name).foreach(println)
```

### Working with requests
Requests are plain data, so you can manipulate or pass them like any normal data

Expand Down

0 comments on commit 687a72b

Please sign in to comment.