-
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
Showing
12 changed files
with
111 additions
and
23 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
32 changes: 32 additions & 0 deletions
32
webapi/src/main/scala/org/knora/webapi/slice/admin/api/GroupsEndpoints.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,32 @@ | ||
/* | ||
* Copyright © 2021 - 2024 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.groupsmessages.GroupsGetResponseADM | ||
import org.knora.webapi.messages.admin.responder.usersmessages.UsersADMJsonProtocol.groupsGetResponseADMFormat | ||
import org.knora.webapi.slice.common.api.BaseEndpoints | ||
|
||
final case class GroupsEndpoints(baseEndpoints: BaseEndpoints) { | ||
private val base = "admin" / "groups" | ||
private val tags = List("Groups", "Admin API") | ||
|
||
val getGroups = baseEndpoints.publicEndpoint.get | ||
.in(base) | ||
.out(sprayJsonBody[GroupsGetResponseADM]) | ||
.description("Returns all groups.") | ||
.tags(tags) | ||
|
||
val endpoints: Seq[AnyEndpoint] = Seq(getGroups) | ||
} | ||
|
||
object GroupsEndpoints { | ||
val layer = ZLayer.derive[GroupsEndpoints] | ||
} |
30 changes: 30 additions & 0 deletions
30
webapi/src/main/scala/org/knora/webapi/slice/admin/api/GroupsEndpointsHandler.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,30 @@ | ||
/* | ||
* Copyright © 2021 - 2024 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.slice.admin.api.service.GroupsRestService | ||
import org.knora.webapi.slice.common.api.EndpointAndZioHandler | ||
import org.knora.webapi.slice.common.api.HandlerMapper | ||
|
||
case class GroupsEndpointsHandler( | ||
endpoints: GroupsEndpoints, | ||
restService: GroupsRestService, | ||
mapper: HandlerMapper | ||
) { | ||
private val getGroupsHandler = | ||
EndpointAndZioHandler( | ||
endpoints.getGroups, | ||
(_: Unit) => restService.getAllGroups | ||
) | ||
|
||
val handlers = List(getGroupsHandler).map(mapper.mapEndpointAndHandler(_)) | ||
} | ||
|
||
object GroupsEndpointsHandler { | ||
val layer = ZLayer.derive[GroupsEndpointsHandler] | ||
} |
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
27 changes: 27 additions & 0 deletions
27
webapi/src/main/scala/org/knora/webapi/slice/admin/api/service/GroupsRestService.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,27 @@ | ||
/* | ||
* Copyright © 2021 - 2024 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.groupsmessages.GroupsGetResponseADM | ||
import org.knora.webapi.responders.admin.GroupsResponderADM | ||
|
||
@accessible | ||
trait GroupsRestService { | ||
def getAllGroups: Task[GroupsGetResponseADM] | ||
} | ||
|
||
final case class GroupsRestServiceLive( | ||
responder: GroupsResponderADM | ||
) extends GroupsRestService { | ||
override def getAllGroups: Task[GroupsGetResponseADM] = responder.groupsGetRequestADM | ||
} | ||
|
||
object GroupsRestServiceLive { | ||
val layer = ZLayer.derive[GroupsRestServiceLive] | ||
} |
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