-
Notifications
You must be signed in to change notification settings - Fork 14
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
Feature/1693 api v3 schema etc #2052
Conversation
…e contours, empty DatasetControllerV3 to test
- login allowed at /api/login & /api-v3/login - v2/v3 BaseRestApiTest distinquished
…der and no content -> IT updated
…version, includes a sample CR)
…st and post-import + IT to prove correct behavior
…mport + IT to prove correct behavior - fix with common location processing with segment stripping (+normalization)
… GET datasets/{name}/{version}
…/audit-trail added
…ion} now works for # or 'latest' (IT = regression test)
…{name}/{version} and /{name}/latest - improved
…- supports latest for as version-expression, impl for datasets improved by actual existence checking + IT test cases for non-existing/non-latest queries
…properties - supports latest for as version-expression; get impl is unvalidated, put impl checks validity - login is now common, under /api/login for both v2 and v3 (did not work previously)
…properties - supports latest for as version-expression; get impl is unvalidated, put impl checks validity - extended for different validation cases - login is now common, under /api/login for both v2 and v3 (did not work previously)
…ture -> CompletableFuture (mistake reverted)
… added. IT mostly adjusted, but there are todos - DatasetServiceV3 introduced to carry difference in behavior to DatasetService. original entity validation has been divided into create-validation and regular-entity validation. - buildfix for VersionedModelServiceTest
…sion}` in proper validations
…asets/dsName/version/rules, GET datasets/dsName/version/rules/# + IT
- v2 ignores this added information - needs
…api-v3-schema-etc
…api-v3-schema-etc
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.
I did not upload schema yet otherwise I think I check all the user facing paths.
...i/src/main/scala/za/co/absa/enceladus/rest_api/controllers/v3/MappingTableControllerV3.scala
Show resolved
Hide resolved
...i/src/main/scala/za/co/absa/enceladus/rest_api/controllers/v3/MappingTableControllerV3.scala
Outdated
Show resolved
Hide resolved
...i/src/main/scala/za/co/absa/enceladus/rest_api/controllers/v3/MappingTableControllerV3.scala
Outdated
Show resolved
Hide resolved
current.setDescription(update.description).asInstanceOf[Schema] | ||
} | ||
|
||
/** final - override `updateWithFields` if needed */ |
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 is updateWithFields
? I only see updateWithFieldsReplace
or updateFields
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.
Thanks for noticing, updateFields
was previously named updateWithFields
and this reference was not correctly affected by the change. Fixed.
… removed, some ITs and comments added
…rt mapping removed -> reflected in IT; small updates
… removed, some ITs and comments added
…api-v3-schema-etc
rest-api/src/main/scala/za/co/absa/enceladus/rest_api/controllers/SchemaController.scala
Show resolved
Hide resolved
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
@GetMapping(path = Array("/{name}/{version}/defaults")) |
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.
Sorry for my ignorance. Why we need dedicated endpoint for mapping table defaults? Isn't it enough to be part of the mapping table entity?
Maybe more a question to @Zejnilovic, as I see it in the proposal doc too.
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.
For GET - because spark-jobs pull that data on the run of the conformance rule, in the middle of the job.
For POST - so you do not have to always update the whole thing.
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, the proposal contained it.
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.
GET - 👍
PUT - Why is this different from other partial properties? (Minor, can stay 😉 )
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.
Sort of explained in person, the gist is: a special approach is warranted due to the fact that defaults are added in now. But true that the whole endpoint may not be strictly necessary for V3 API.
Since it was designed like this, I'd like to keep it, but removal should be quite easy. 😏
|
||
@PutMapping(path = Array("/{name}/{version}/defaults")) | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@PreAuthorize("@authConstants.hasAdminRole(authentication)") |
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 the admin authorization requirement (multiple places)?
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.
This is a mistake I plan on fixing in #2055, because there are other changes to the admin authorization that need to be done (In short: I have moved the admin-auth to VersionedModelController, but it wrong as only the PropDefs should be admin-controlled)
I have fixed this in this PR already, there will be just touchups in #2055.
for { | ||
existingMtOpt <- forVersionExpression(name, version)(mappingTableService.getVersion) | ||
existingMt = existingMtOpt.getOrElse(throw notFound()) | ||
updatedMtAndValidationOpt <- mappingTableService.addDefault(user.getUsername, name, existingMt.version, newDefault) | ||
(updatedMt, validation) = updatedMtAndValidationOpt.getOrElse(throw notFound()) | ||
response = createdWithNameVersionLocationBuilder(name, updatedMt.version, request, | ||
stripLastSegments = 3, suffix = s"/defaults").body(validation) // stripping: /{name}/{version}/defaults | ||
} yield response |
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.
Seems like the same code as above?
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.
🤷 Up to you, sorry I missed the difference. On the other hand it suggests similarity. Counter argument is, if the code can be logically distilled not just some forced sub-function.
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.
Ok, I have actually created a subfunction that seems to make sense. Hope you find it a tad better, @benedeki.
class PropertyDefinitionControllerV3 @Autowired()(propertyDefService: PropertyDefinitionService) | ||
extends VersionedModelControllerV3(propertyDefService) | ||
|
||
// super-class implementation is sufficient |
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.
Appreciate the comment 😎
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.
Glad you liked it, but I actually had to redo it
import za.co.absa.enceladus.rest_api.models.rest.exceptions.SchemaParsingException | ||
import za.co.absa.enceladus.rest_api.repositories.RefCollection | ||
import za.co.absa.enceladus.rest_api.services.v3.SchemaServiceV3 | ||
import za.co.absa.enceladus.rest_api.services.{AttachmentService, SchemaRegistryService, SchemaService} |
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.
SchemaService
is not used
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.
True, thanks, removed.
rest-api/src/main/scala/za/co/absa/enceladus/rest_api/controllers/v3/SchemaControllerV3.scala
Outdated
Show resolved
Hide resolved
rest-api/src/main/scala/za/co/absa/enceladus/rest_api/services/v3/MappingTableServiceV3.scala
Show resolved
Hide resolved
…authentication)")` is now limited to changing endpoints of PropertyDefinitionControllerV3 (previously it was incorrectly used for all changing endpoints. IT updated. And specific check for the adminRole have been added to PropertyDefinitionControllerV3IntegrationSuite.
…g `dev` or not.
…api-v3-schema-etc
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.
Just read the code. Comments are not blocking.
rest-api/src/main/scala/za/co/absa/enceladus/rest_api/controllers/SchemaController.scala
Show resolved
Hide resolved
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
@GetMapping(path = Array("/{name}/{version}/defaults")) |
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.
GET - 👍
PUT - Why is this different from other partial properties? (Minor, can stay 😉 )
for { | ||
existingMtOpt <- forVersionExpression(name, version)(mappingTableService.getVersion) | ||
existingMt = existingMtOpt.getOrElse(throw notFound()) | ||
updatedMtAndValidationOpt <- mappingTableService.addDefault(user.getUsername, name, existingMt.version, newDefault) | ||
(updatedMt, validation) = updatedMtAndValidationOpt.getOrElse(throw notFound()) | ||
response = createdWithNameVersionLocationBuilder(name, updatedMt.version, request, | ||
stripLastSegments = 3, suffix = s"/defaults").body(validation) // stripping: /{name}/{version}/defaults | ||
} yield response |
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.
🤷 Up to you, sorry I missed the difference. On the other hand it suggests similarity. Counter argument is, if the code can be logically distilled not just some forced sub-function.
… with `MappingTableControllerV3.withMappingTableToResponse`
% Conflicts: % rest-api/src/main/scala/za/co/absa/enceladus/rest_api/controllers/SchemaController.scala % rest-api/src/main/scala/za/co/absa/enceladus/rest_api/controllers/v3/VersionedModelControllerV3.scala % rest-api/src/main/scala/za/co/absa/enceladus/rest_api/services/SchemaService.scala % rest-api/src/main/scala/za/co/absa/enceladus/rest_api/services/VersionedModelService.scala % rest-api/src/test/scala/za/co/absa/enceladus/rest_api/integration/controllers/v3/DatasetControllerV3IntegrationSuite.scala
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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.
Tested the endpoints.
Code reviewed
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.
Looks good
Continuation of PR #2046
implements V3 API for MappingTables, Schemas, and PropDefs.
introduces Admin-level authorization for changing endpoints (POST/PUT/DELETE)
IT extended to support ⬆️ and also the test cases with incorrect auth-level (resulting with 403s)
Future work (not covered in this PR) = delete test cases (relies on assuring that the disable workflow works as expected) and used-in
Partially implements #1693
Release notes suggestion
/api-v3/{datasets|schemas|mapping-tables|property-defintions}/
Rest API V3 added. Includes checks on entities and is to be used externally. Schema is now updatable via entity payload as well (outside of attachment upload).