-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
2d3d4c4
commit 3684b91
Showing
13 changed files
with
130 additions
and
33 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
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
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
33 changes: 33 additions & 0 deletions
33
webapi/src/main/scala/org/knora/webapi/slice/admin/api/UsersEndpoints.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,33 @@ | ||
/* | ||
* Copyright © 2021 - 2023 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.knora.webapi.slice.admin.api | ||
|
||
import sttp.tapir.* | ||
import sttp.tapir.generic.auto.* | ||
import sttp.tapir.json.spray.jsonBody as sprayJsonBody | ||
import zio.* | ||
|
||
import org.knora.webapi.messages.admin.responder.usersmessages.UsersADMJsonProtocol.* | ||
import org.knora.webapi.messages.admin.responder.usersmessages.UsersGetResponseADM | ||
import org.knora.webapi.slice.common.api.BaseEndpoints | ||
|
||
final case class UsersEndpoints(baseEndpoints: BaseEndpoints) { | ||
|
||
private val projectsBase = "admin" / "users" | ||
|
||
private val tags = List("Users", "Admin API") | ||
|
||
val getUsers = baseEndpoints.securedEndpoint.get | ||
.in(projectsBase) | ||
.out(sprayJsonBody[UsersGetResponseADM]) | ||
.description("Returns all users.") | ||
.tags(tags) | ||
|
||
} | ||
|
||
object UsersEndpoints { | ||
val layer = ZLayer.derive[UsersEndpoints] | ||
} |
35 changes: 35 additions & 0 deletions
35
webapi/src/main/scala/org/knora/webapi/slice/admin/api/UsersEndpointsHandler.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,35 @@ | ||
/* | ||
* Copyright © 2021 - 2023 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.knora.webapi.slice.admin.api | ||
|
||
import zio.ZLayer | ||
|
||
import org.knora.webapi.messages.admin.responder.usersmessages.UsersGetResponseADM | ||
import org.knora.webapi.slice.admin.api.service.UsersADMRestService | ||
import org.knora.webapi.slice.common.api.HandlerMapper | ||
import org.knora.webapi.slice.common.api.SecuredEndpointAndZioHandler | ||
|
||
case class UsersEndpointsHandler( | ||
usersEndpoints: UsersEndpoints, | ||
restService: UsersADMRestService, | ||
mapper: HandlerMapper | ||
) { | ||
|
||
val getUsersHandler = | ||
SecuredEndpointAndZioHandler[ | ||
Unit, | ||
UsersGetResponseADM | ||
](usersEndpoints.getUsers, user => { case (_: Unit) => restService.listAllUsers(user) }) | ||
|
||
// private val handlers = List().map(mapper.mapEndpointAndHandler) | ||
private val securedHandlers = List(getUsersHandler).map(mapper.mapEndpointAndHandler(_)) | ||
|
||
val allHanders = /* handlers ++ */ securedHandlers | ||
} | ||
|
||
object UsersEndpointsHandler { | ||
val layer = ZLayer.derive[UsersEndpointsHandler] | ||
} |
31 changes: 31 additions & 0 deletions
31
webapi/src/main/scala/org/knora/webapi/slice/admin/api/service/UsersADMRestService.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,31 @@ | ||
/* | ||
* Copyright © 2021 - 2023 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.knora.webapi.slice.admin.api.service | ||
|
||
import zio.* | ||
import zio.macros.accessible | ||
|
||
import org.knora.webapi.messages.admin.responder.usersmessages.UserADM | ||
import org.knora.webapi.messages.admin.responder.usersmessages.UsersGetResponseADM | ||
import org.knora.webapi.responders.admin.UsersResponderADM | ||
|
||
@accessible | ||
trait UsersADMRestService { | ||
|
||
def listAllUsers(user: UserADM): Task[UsersGetResponseADM] | ||
} | ||
|
||
final case class UsersADMRestServiceLive( | ||
responder: UsersResponderADM | ||
) extends UsersADMRestService { | ||
|
||
override def listAllUsers(user: UserADM): Task[UsersGetResponseADM] = | ||
responder.getAllUserADMRequest(user) | ||
} | ||
|
||
object UsersADMRestServiceLive { | ||
val layer = ZLayer.derive[UsersADMRestServiceLive] | ||
} |