Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Migrate GET /version and /health to tapir (DEV-3286, DEV-3287) #3110

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import sbt.Keys.version

import scala.language.postfixOps
import scala.sys.process.*

import org.knora.Dependencies
import org.knora.LocalSettings

import java.time.Instant

//////////////////////////////////////
// GLOBAL SETTINGS
//////////////////////////////////////
Expand All @@ -34,6 +35,9 @@ val gitVersion = ("git describe --tag --dirty --abbrev=7 --always " !!).trim +

ThisBuild / version := gitVersion

lazy val buildCommit = ("git rev-parse --short HEAD" !!).trim
lazy val buildTime = Instant.now.toString

lazy val aggregatedProjects: Seq[ProjectReference] = Seq(webapi, sipi, integration)

lazy val buildSettings = Seq(
Expand Down Expand Up @@ -253,9 +257,11 @@ lazy val webapi: Project = Project(id = "webapi", base = file("webapi"))
buildInfoKeys ++= Seq[BuildInfoKey](
name,
version,
"sipi" -> Dependencies.sipiImage,
"fuseki" -> Dependencies.fusekiImage,
"pekkoHttp" -> Dependencies.pekkoHttp,
"sipi" -> Dependencies.sipiImage,
"fuseki" -> Dependencies.fusekiImage,
"pekkoHttp" -> Dependencies.pekkoHttp,
"buildCommit" -> buildCommit,
"buildTime" -> buildTime,
),
buildInfoPackage := "org.knora.webapi.http.version",
)
Expand Down
38 changes: 15 additions & 23 deletions docs/03-endpoints/api-util/version.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,29 @@

# Version

The version endpoint provides the versions of the used components in the Knora-stack.
The response has the type `application/json` and contains the following information:

1. name: has the value "version"

2. version numbers for the following components:
- pekkoHttp
- gdbFree
- gdbSE
- sbt
- scala
- sipi
- webapi

The version endpoint provides all versions of used components in the DSP stack.

## Example request

`GET /version`


## Example response

```json
HTTP/1.1 200 OK
Content-Length: 247
Content-Type: application/json
Date: Mon, 11 Mar 2024 17:40:32 GMT
Server: webapi/v30.9.0

{
"pekkoHttp": "10.1.7",
"gdbFree": "8.10.0-free",
"gdbSE": "8.5.0-se",
"name": "version",
"sbt": "1.2.8",
"scala": "2.12.8",
"sipi": "v2.0.1",
"webapi": "10.0.0-7-gc5a72b3-SNAPSHOT"
"buildCommit": "bbb0e65c7",
"buildTime": "2024-03-11T17:40:17.322491Z",
"fuseki": "2.1.5",
"pekkoHttp": "1.0.1",
"scala": "2.13.13",
"sipi": "3.9.0",
"webapi": "v30.9.0"
}

```
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import org.knora.webapi.slice.admin.repo.service.KnoraProjectRepoLive
import org.knora.webapi.slice.admin.repo.service.KnoraUserRepoLive
import org.knora.webapi.slice.common.api.*
import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper
import org.knora.webapi.slice.infrastructure.api.ManagementEndpoints
import org.knora.webapi.slice.infrastructure.api.ManagementRoutes
import org.knora.webapi.slice.ontology.api.service.RestCardinalityService
import org.knora.webapi.slice.ontology.api.service.RestCardinalityServiceLive
import org.knora.webapi.slice.ontology.domain.service.CardinalityService
Expand Down Expand Up @@ -181,10 +183,11 @@ object LayersTest {
InferenceOptimizationService.layer,
IriConverter.layer,
IriService.layer,
KnoraGroupRepoLive.layer,
KnoraProjectRepoLive.layer,
KnoraResponseRenderer.layer,
KnoraGroupRepoLive.layer,
KnoraUserRepoLive.layer,
KnoraUserService.layer,
KnoraUserToUserConverter.layer,
ListRestService.layer,
ListsEndpoints.layer,
Expand All @@ -195,6 +198,7 @@ object LayersTest {
MaintenanceEndpointsHandlers.layer,
MaintenanceRestService.layer,
MaintenanceServiceLive.layer,
ManagementRoutes.layer,
MessageRelayLive.layer,
OntologyCacheLive.layer,
OntologyHelpersLive.layer,
Expand Down Expand Up @@ -235,13 +239,13 @@ object LayersTest {
TapirToPekkoInterpreter.layer,
TestClientService.layer,
TriplestoreServiceLive.layer,
KnoraUserService.layer,
UserService.layer,
UsersEndpoints.layer,
UsersEndpointsHandler.layer,
UsersResponder.layer,
UsersRestService.layer,
ValuesResponderV2Live.layer,
ManagementEndpoints.layer,
)

private val fusekiAndSipiTestcontainers =
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import org.knora.webapi.slice.admin.repo.service.KnoraProjectRepoLive
import org.knora.webapi.slice.admin.repo.service.KnoraUserRepoLive
import org.knora.webapi.slice.common.api.*
import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper
import org.knora.webapi.slice.infrastructure.api.ManagementEndpoints
import org.knora.webapi.slice.infrastructure.api.ManagementRoutes
import org.knora.webapi.slice.ontology.api.service.RestCardinalityService
import org.knora.webapi.slice.ontology.api.service.RestCardinalityServiceLive
import org.knora.webapi.slice.ontology.domain.service.CardinalityService
Expand Down Expand Up @@ -124,9 +126,9 @@ object LayersLive {
IriConverter.layer,
IriService.layer,
JwtServiceLive.layer,
KnoraGroupRepoLive.layer,
KnoraProjectRepoLive.layer,
KnoraResponseRenderer.layer,
KnoraGroupRepoLive.layer,
KnoraUserRepoLive.layer,
KnoraUserService.layer,
KnoraUserToUserConverter.layer,
Expand All @@ -139,6 +141,7 @@ object LayersLive {
MaintenanceEndpointsHandlers.layer,
MaintenanceRestService.layer,
MaintenanceServiceLive.layer,
ManagementRoutes.layer,
MessageRelayLive.layer,
OntologyCacheLive.layer,
OntologyHelpersLive.layer,
Expand Down Expand Up @@ -186,5 +189,6 @@ object LayersLive {
UsersResponder.layer,
UsersRestService.layer,
ValuesResponderV2Live.layer,
ManagementEndpoints.layer,
)
}
22 changes: 16 additions & 6 deletions webapi/src/main/scala/org/knora/webapi/routing/ApiRoutes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.knora.webapi.slice.admin.domain.service.KnoraProjectRepo
import org.knora.webapi.slice.admin.domain.service.UserService
import org.knora.webapi.slice.common.api.AuthorizationRestService
import org.knora.webapi.slice.infrastructure.api.ManagementRoutes
import org.knora.webapi.slice.ontology.api.service.RestCardinalityService
import org.knora.webapi.slice.resourceinfo.api.ResourceInfoRoutes
import org.knora.webapi.slice.resourceinfo.api.service.RestResourceInfoService
Expand All @@ -48,7 +49,7 @@
* All routes composed together.
*/
val layer: URLayer[
ActorSystem & AuthorizationRestService & AdminApiRoutes & AppConfig & AppRouter & core.State & IriConverter & KnoraProjectRepo & MessageRelay & ProjectADMRestService & ProjectsEndpointsHandler & ResourceInfoRoutes & RestCardinalityService & RestResourceInfoService & routing.Authenticator & SearchApiRoutes & SearchResponderV2 & SipiService & StringFormatter & UserService & ValuesResponderV2,
ActorSystem & AuthorizationRestService & AdminApiRoutes & AppConfig & AppRouter & core.State & IriConverter & KnoraProjectRepo & MessageRelay & ManagementRoutes & ProjectADMRestService & ProjectsEndpointsHandler & ResourceInfoRoutes & RestCardinalityService & RestResourceInfoService & routing.Authenticator & SearchApiRoutes & SearchResponderV2 & SipiService & StringFormatter & UserService & ValuesResponderV2,
ApiRoutes,
] =
ZLayer {
Expand All @@ -59,12 +60,21 @@
adminApiRoutes <- ZIO.service[AdminApiRoutes]
resourceInfoRoutes <- ZIO.service[ResourceInfoRoutes]
searchApiRoutes <- ZIO.service[SearchApiRoutes]
managementRoutes <- ZIO.service[ManagementRoutes]

Check warning on line 63 in webapi/src/main/scala/org/knora/webapi/routing/ApiRoutes.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/routing/ApiRoutes.scala#L63

Added line #L63 was not covered by tests
routeData <- ZIO.succeed(KnoraRouteData(sys.system, router.ref, appConfig))
runtime <-
ZIO.runtime[
AppConfig & AuthorizationRestService & core.State & IriConverter & KnoraProjectRepo & MessageRelay & ProjectADMRestService & RestCardinalityService & RestResourceInfoService & routing.Authenticator & SearchApiRoutes & SearchResponderV2 & SipiService & StringFormatter & UserService & ValuesResponderV2,
]
} yield ApiRoutesImpl(routeData, adminApiRoutes, resourceInfoRoutes, searchApiRoutes, appConfig, runtime)
} yield ApiRoutesImpl(

Check warning on line 69 in webapi/src/main/scala/org/knora/webapi/routing/ApiRoutes.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/routing/ApiRoutes.scala#L69

Added line #L69 was not covered by tests
routeData,
adminApiRoutes,
resourceInfoRoutes,
searchApiRoutes,
managementRoutes,
appConfig,
runtime,
)
}
}

Expand All @@ -80,6 +90,7 @@
adminApiRoutes: AdminApiRoutes,
resourceInfoRoutes: ResourceInfoRoutes,
searchApiRoutes: SearchApiRoutes,
managementRoutes: ManagementRoutes,
appConfig: AppConfig,
implicit val runtime: Runtime[
AppConfig & AuthorizationRestService & core.State & IriConverter & KnoraProjectRepo & MessageRelay & ProjectADMRestService & RestCardinalityService & RestResourceInfoService & routing.Authenticator & SearchResponderV2 & SipiService & StringFormatter & UserService & ValuesResponderV2,
Expand All @@ -98,15 +109,14 @@
.withAllowedMethods(List(GET, PUT, POST, DELETE, PATCH, HEAD, OPTIONS)),
) {
DSPApiDirectives.handleErrors(appConfig) {
(adminApiRoutes.routes ++ resourceInfoRoutes.routes ++ searchApiRoutes.routes).reduce(_ ~ _) ~
(adminApiRoutes.routes ++ resourceInfoRoutes.routes ++ searchApiRoutes.routes ++ managementRoutes.routes)
.reduce(_ ~ _) ~

Check warning on line 113 in webapi/src/main/scala/org/knora/webapi/routing/ApiRoutes.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/routing/ApiRoutes.scala#L112-L113

Added lines #L112 - L113 were not covered by tests
AuthenticationRouteV2().makeRoute ~
HealthRoute().makeRoute ~
ListsRouteV2().makeRoute ~
OntologiesRouteV2().makeRoute ~
ResourcesRouteV2(appConfig).makeRoute ~
StandoffRouteV2().makeRoute ~
ValuesRouteV2().makeRoute ~
VersionRoute().makeRoute
ValuesRouteV2().makeRoute

Check warning on line 119 in webapi/src/main/scala/org/knora/webapi/routing/ApiRoutes.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/routing/ApiRoutes.scala#L119

Added line #L119 was not covered by tests
}
}
}
Expand Down
Loading
Loading