-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pollux): schema registry lookup and verification policies REST A…
…PI ATL-1334 (#168) * feat(pollux): implement schema-registry in-memory using Tapir * feat(pollux) Add pagination request for VC Schema + Specs * feat(pollux) Add VerificationPolicy entity and REST API
- Loading branch information
1 parent
d6d7224
commit d75b36b
Showing
22 changed files
with
1,032 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ import sbtghpackages.GitHubPackagesPlugin.autoImport._ | |
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._ | ||
|
||
// Custom keys | ||
val apiBaseDirectory = settingKey[File]("The base directory for PrismAgent API specifications") | ||
val apiBaseDirectory = | ||
settingKey[File]("The base directory for PrismAgent API specifications") | ||
|
||
inThisBuild( | ||
Seq( | ||
|
@@ -53,8 +54,13 @@ lazy val server = project | |
Compile / sourceGenerators += openApiGenerateClasses, | ||
openApiGeneratorSpec := apiBaseDirectory.value / "http/prism-agent-openapi-spec.yaml", | ||
openApiGeneratorConfig := baseDirectory.value / "openapi/generator-config/config.yaml", | ||
openApiGeneratorImportMapping := Seq("DidOperationType", "DidOperationStatus") | ||
.map(model => (model, s"io.iohk.atala.agent.server.http.model.OASModelPatches.$model")) | ||
openApiGeneratorImportMapping := Seq( | ||
"DidOperationType", | ||
"DidOperationStatus" | ||
) | ||
.map(model => | ||
(model, s"io.iohk.atala.agent.server.http.model.OASModelPatches.$model") | ||
) | ||
.toMap, | ||
Docker / maintainer := "[email protected]", | ||
Docker / dockerUsername := Some("input-output-hk"), | ||
|
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
37 changes: 37 additions & 0 deletions
37
prism-agent/service/server/src/main/scala/io/iohk/atala/api/http/codec/OrderCodec.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,37 @@ | ||
package io.iohk.atala.api.http.codec | ||
|
||
import io.iohk.atala.api.http.model.Order | ||
import io.iohk.atala.api.http.model.Order.Direction | ||
import sttp.tapir.Codec.PlainCodec | ||
import sttp.tapir.{Codec, DecodeResult} | ||
|
||
import java.util.Base64 | ||
|
||
object OrderCodec { | ||
implicit def orderCodec: PlainCodec[Order] = { | ||
def decode(s: String): DecodeResult[Order] = | ||
try { | ||
val s2 = new String(Base64.getDecoder.decode(s)) | ||
val order = s2.split(".", 2) match { | ||
case Array() => Order.empty | ||
case Array(field) => Order(field) | ||
case Array(field, "") => Order(field) | ||
case Array(field, direction) => | ||
Order(field, Some(Direction.valueOf(direction))) | ||
case _ => sys.error("impossible") | ||
} | ||
DecodeResult.Value(order) | ||
} catch { | ||
case e: Exception => DecodeResult.Error(s, e) | ||
} | ||
|
||
def encode(order: Order): String = | ||
Base64.getEncoder | ||
.encodeToString( | ||
s"${order.field}.${order.direction.getOrElse(Order.DefaultDirection).toString}" | ||
.getBytes("UTF-8") | ||
) | ||
|
||
Codec.string.mapDecode(decode)(encode) | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
prism-agent/service/server/src/main/scala/io/iohk/atala/api/http/model/Order.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,20 @@ | ||
package io.iohk.atala.api.http.model | ||
|
||
import sttp.tapir.Codec.PlainCodec | ||
import sttp.tapir.generic.auto.* | ||
import sttp.tapir.{Codec, DecodeResult, Schema} | ||
|
||
import java.util.Base64 | ||
|
||
case class Order(field: String, direction: Option[Order.Direction] = None) | ||
|
||
object Order { | ||
val DefaultDirection = Direction.Ascending | ||
val empty = Order("") | ||
|
||
enum Direction(kind: String): | ||
case Ascending extends Direction("asc") | ||
case Descending extends Direction("desc") | ||
|
||
import io.iohk.atala.api.http.codec.OrderCodec.orderCodec | ||
} |
15 changes: 15 additions & 0 deletions
15
prism-agent/service/server/src/main/scala/io/iohk/atala/api/http/model/Pagination.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,15 @@ | ||
package io.iohk.atala.api.http.model | ||
|
||
import sttp.tapir.Codec.PlainCodec | ||
import sttp.tapir.generic.auto.* | ||
import sttp.tapir.{Codec, DecodeResult, Schema} | ||
import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder} | ||
|
||
import java.time.ZonedDateTime | ||
import java.util.{Base64, UUID} | ||
import scala.util.Try | ||
|
||
case class Pagination( | ||
offset: Option[Int] = Some(0), | ||
limit: Option[Int] = Some(10) | ||
) |
66 changes: 0 additions & 66 deletions
66
prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/Models.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.