-
Notifications
You must be signed in to change notification settings - Fork 1
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
BI-2374 Add delete catch-all to deltabreed brapi controller #427
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
|
||
package org.breedinginsight.brapi.v2; | ||
|
||
import io.micronaut.context.annotation.Value; | ||
davedrp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import io.micronaut.http.HttpRequest; | ||
import io.micronaut.http.HttpResponse; | ||
import io.micronaut.http.HttpStatus; | ||
|
@@ -186,6 +187,15 @@ public HttpResponse<?> getCatchall(@PathVariable("path") String path, @PathVaria | |
return executeRequest(path, programId, request, "GET"); | ||
} | ||
|
||
@Delete("/${micronaut.bi.api.version}/programs/{programId}" + BrapiVersion.BRAPI_V2 + "/{+path}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the delete pass through is overridden by specific implementations in future cards, is the plan to use the DeltaBreed external reference id rather than the DbId of the brapi service? |
||
@Produces(MediaType.APPLICATION_JSON) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we discussed in standup, this currently won't delete the associated dataset and that should be captured in the the experiment delete endpoint implementation. |
||
@ProgramSecured(roleGroups = {ProgramSecuredRoleGroup.PROGRAM_SCOPED_ROLES}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this something only a program or system admin should be allowed to do? Wondering if we should make a new role group that is system admin and program admin without readonly. |
||
public HttpResponse<?> deleteCatchall(@PathVariable("path") String path, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When testing I could do |
||
@PathVariable("programId") UUID programId, | ||
HttpRequest<Void> request) { | ||
return executeDeleteRequest(path, programId, request); | ||
} | ||
|
||
@Post("/${micronaut.bi.api.version}/programs/{programId}" + BrapiVersion.BRAPI_V2 + "/{+path}") | ||
@Consumes(MediaType.ALL) | ||
@Produces(MediaType.APPLICATION_JSON) | ||
|
@@ -241,6 +251,22 @@ private HttpResponse<String> executeRequest(String path, UUID programId, HttpReq | |
throw new HttpStatusException(HttpStatus.UNAUTHORIZED, "Unauthorized BrAPI Request"); | ||
} | ||
|
||
private HttpResponse<String> executeDeleteRequest(String path, UUID programId, HttpRequest<?> request) { | ||
AuthenticatedUser actingUser = securityService.getUser(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actingUser isn't used |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe should add a |
||
if (programId != null) { | ||
HttpUrl requestUrl = getUrl(programId, path, request); | ||
|
||
var brapiRequest = new Request.Builder().url(requestUrl) | ||
.method("DELETE", null) | ||
.build(); | ||
|
||
return makeCall(brapiRequest); | ||
} | ||
|
||
throw new HttpStatusException(HttpStatus.UNAUTHORIZED, "Unauthorized BrAPI Request"); | ||
} | ||
|
||
private HttpResponse<String> makeCall(Request brapiRequest) { | ||
// TODO: use config parameter for timeout | ||
OkHttpClient client = new OkHttpClient.Builder() | ||
|
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.
What was the reason for this change? Should we be using the value defined in application.yml
brapi.server.reference-source