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
feat: Expose GET /admin/projects/iri/{iriUrlEncoded} as zio-http route #2355
Conversation
lastFile:webapi/src/main/scala/org/knora/webapi/core/HttpServerWithZIOHttp.scala
Codecov ReportBase: 86.68% // Head: 86.45% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #2355 +/- ##
==========================================
- Coverage 86.68% 86.45% -0.23%
==========================================
Files 250 271 +21
Lines 28252 28270 +18
==========================================
- Hits 24490 24441 -49
- Misses 3762 3829 +67
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
b16f9cc
to
5600a18
Compare
5600a18
to
ba8ca55
Compare
…, and remove new needless implicit class tag
55a5348
to
ad5b367
Compare
…e.getSingleProjectADMRequest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice to have the authenticator separated out like this!
Some questions/remarks:
- Why did you rename
ProjectsService
toRestProjectsService
? What are our naming conventions in this regard? - Maybe I'm overlooking something... but I think the addition of
HealthRouteZ
is not reflected in the PR title/description. - Otherwise, some comments in the files directly.
webapi/src/main/scala/org/knora/webapi/http/status/ApiStatusCodesZ.scala
Outdated
Show resolved
Hide resolved
webapi/src/main/scala/org/knora/webapi/responders/admin/ProjectsResponderADM.scala
Show resolved
Hide resolved
webapi/src/main/scala/org/knora/webapi/responders/admin/RestProjectsService.scala
Show resolved
Hide resolved
webapi/src/main/scala/org/knora/webapi/routing/RouteUtilZ.scala
Outdated
Show resolved
Hide resolved
webapi/src/main/scala/org/knora/webapi/routing/admin/ProjectsRouteZ.scala
Outdated
Show resolved
Hide resolved
val layer: URLayer[ProjectsService with AppConfig, ProjectsRouteZ] = ZLayer.fromFunction(ProjectsRouteZ.apply _) | ||
val layer: ZLayer[AppConfig with RestProjectsService, Nothing, ProjectsRouteZ] = | ||
ZLayer.fromFunction(ProjectsRouteZ.apply _) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not keep URLayer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to apply my suggestions - mainly Docstrings improvements.
* The possible values for the HTTP status code that is returned as part of each Knora API v2 response. | ||
* migrated from [[org.knora.webapi.http.status.ApiStatusCodes]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* migrated from [[org.knora.webapi.http.status.ApiStatusCodes]] | |
* Migrated from [[org.knora.webapi.http.status.ApiStatusCodes]] |
webapi/src/main/scala/org/knora/webapi/routing/HealthRouteZ.scala
Outdated
Show resolved
Hide resolved
webapi/src/main/scala/org/knora/webapi/routing/HealthRouteZ.scala
Outdated
Show resolved
Hide resolved
webapi/src/main/scala/org/knora/webapi/routing/HealthRouteZ.scala
Outdated
Show resolved
Hide resolved
* @param name ??? | ||
* @param severity ??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some minor remarks
webapi/src/main/scala/org/knora/webapi/routing/RouteUtilZ.scala
Outdated
Show resolved
Hide resolved
* | ||
* ```failure``` A [[BadRequestException]] with the `errorMsg` | ||
*/ | ||
def urlDecode(value: String, errorMsg: String = ""): Task[String] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need the second parameter errorMsg
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, different Routes might want create their own error messages in the BadRequestException
. In this PR it is "Failed to url decode IRI parameter." in the route. I did not want to hardcode that particular message into the RouteUtil as it should not assume that all encoded params are IRIs.
// Returns a single project identified by an urlencoded IRI | ||
case Method.GET -> !! / "admin" / "projects" / "iri" / iriUrlEncoded => | ||
RouteUtilZ | ||
.urlDecode(iriUrlEncoded, "Failed to url decode IRI parameter.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.urlDecode(iriUrlEncoded, "Failed to url decode IRI parameter.") | |
.urlDecode(iriUrlEncoded, s"Failed to URL decode IRI from parameter: ${iriUrlEncoded}.") |
.of[ProjectGetResponseADM] | ||
.apply(Assertion.equalTo(expectedRequest), Expectation.value(expectedResponse)) | ||
|
||
private val expectNoInteraction = ActorToZioBridgeMock.empty | ||
private val systemUnderTest = ZIO.service[RestProjectsService] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private val systemUnderTest = ZIO.service[RestProjectsService] | |
private val serviceUnderTest = ZIO.service[RestProjectsService] |
webapi/src/test/scala/org/knora/webapi/routing/RouteUtilZSpec.scala
Outdated
Show resolved
Hide resolved
actual <- RouteUtilZ.urlDecode("http%3A%2F%2Frdfh.ch%2Fprojects%2FLw3FC39BSzCwvmdOaTyLqQ") | ||
} yield assertTrue(actual == "http://rdfh.ch/projects/Lw3FC39BSzCwvmdOaTyLqQ") | ||
}, | ||
test("given an empty value should return BadRequestException") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test("given an empty value should return BadRequestException") { | |
test("given an empty valu, return BadRequestException") { |
webapi/src/test/scala/org/knora/webapi/routing/RouteUtilZSpec.scala
Outdated
Show resolved
Hide resolved
final case class RestProjectsService(bridge: ActorToZioBridge) { | ||
|
||
/** | ||
* Finds the project by its [[ProjectIdentifierADM]] and returns the information as a [[ProjectGetResponseADM]]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Finds the project by its [[ProjectIdentifierADM]] and returns the information as a [[ProjectGetResponseADM]]. | |
* Finds the project by its [[IRI]] and returns the information as a [[ProjectGetResponseADM]]. |
…desZ.scala Co-authored-by: Balduin Landolt <33053745+BalduinLandolt@users.noreply.github.com>
Co-authored-by: irinaschubert <irina.schubert@dasch.swiss>
Co-authored-by: Marcin Procyk <marcin.procyk@dasch.swiss>
Co-authored-by: Marcin Procyk <marcin.procyk@dasch.swiss>
Co-authored-by: Marcin Procyk <marcin.procyk@dasch.swiss>
…scala Co-authored-by: irinaschubert <irina.schubert@dasch.swiss>
…scala Co-authored-by: irinaschubert <irina.schubert@dasch.swiss>
Pull Request Checklist
Task Description/Number
Picking up from the last
mob/main
session I have finalised the changes from that branch.Changes include:
GET /admin/projects/iri/{iriUrlEncoded}
as zio-http route.requestingUser
field fromProjectGetRequestADM
.AuthenticatorService
- a zio service for interaction withAuthenticator
as a preparation for other routes.Basic Requirements
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Does this PR change client-test-data?