diff --git a/service/common/src/main/java/org/apache/polaris/service/admin/PolarisServiceImpl.java b/service/common/src/main/java/org/apache/polaris/service/admin/PolarisServiceImpl.java index 8670b1aebe..09e6a4f4fa 100644 --- a/service/common/src/main/java/org/apache/polaris/service/admin/PolarisServiceImpl.java +++ b/service/common/src/main/java/org/apache/polaris/service/admin/PolarisServiceImpl.java @@ -78,6 +78,71 @@ import org.apache.polaris.service.admin.api.PolarisPrincipalRolesApiService; import org.apache.polaris.service.admin.api.PolarisPrincipalsApiService; import org.apache.polaris.service.config.ReservedProperties; +import org.apache.polaris.service.events.AfterAddGrantToCatalogRoleEvent; +import org.apache.polaris.service.events.AfterAssignPrincipalRoleEvent; +import org.apache.polaris.service.events.AfterCatalogCreatedEvent; +import org.apache.polaris.service.events.AfterCatalogDeletedEvent; +import org.apache.polaris.service.events.AfterCatalogGetEvent; +import org.apache.polaris.service.events.AfterCatalogListEvent; +import org.apache.polaris.service.events.AfterCatalogRoleAssignToPrincipalRoleEvent; +import org.apache.polaris.service.events.AfterCatalogRoleCreateEvent; +import org.apache.polaris.service.events.AfterCatalogRoleDeleteEvent; +import org.apache.polaris.service.events.AfterCatalogRoleGetEvent; +import org.apache.polaris.service.events.AfterCatalogRoleRevokeFromPrincipalRoleEvent; +import org.apache.polaris.service.events.AfterCatalogRoleUpdateEvent; +import org.apache.polaris.service.events.AfterCatalogRolesListEvent; +import org.apache.polaris.service.events.AfterCatalogUpdatedEvent; +import org.apache.polaris.service.events.AfterCredentialsRotateEvent; +import org.apache.polaris.service.events.AfterListAssigneePrincipalRolesForCatalogRoleEvent; +import org.apache.polaris.service.events.AfterListAssigneePrincipalsForPrincipalRoleEvent; +import org.apache.polaris.service.events.AfterListCatalogRolesForPrincipalRoleEvent; +import org.apache.polaris.service.events.AfterListGrantsForCatalogRoleEvent; +import org.apache.polaris.service.events.AfterPrincipalCreateEvent; +import org.apache.polaris.service.events.AfterPrincipalDeleteEvent; +import org.apache.polaris.service.events.AfterPrincipalGetEvent; +import org.apache.polaris.service.events.AfterPrincipalRoleCreateEvent; +import org.apache.polaris.service.events.AfterPrincipalRoleDeleteEvent; +import org.apache.polaris.service.events.AfterPrincipalRoleGetEvent; +import org.apache.polaris.service.events.AfterPrincipalRoleUpdateEvent; +import org.apache.polaris.service.events.AfterPrincipalRolesAssignedListEvent; +import org.apache.polaris.service.events.AfterPrincipalRolesListEvent; +import org.apache.polaris.service.events.AfterPrincipalUpdateEvent; +import org.apache.polaris.service.events.AfterPrincipalsListEvent; +import org.apache.polaris.service.events.AfterRevokeGrantFromCatalogRoleEvent; +import org.apache.polaris.service.events.AfterRevokePrincipalRoleEvent; +import org.apache.polaris.service.events.BeforeAddGrantToCatalogRoleEvent; +import org.apache.polaris.service.events.BeforeAssignPrincipalRoleEvent; +import org.apache.polaris.service.events.BeforeCatalogCreatedEvent; +import org.apache.polaris.service.events.BeforeCatalogDeletedEvent; +import org.apache.polaris.service.events.BeforeCatalogGetEvent; +import org.apache.polaris.service.events.BeforeCatalogListEvent; +import org.apache.polaris.service.events.BeforeCatalogRoleAssignToPrincipalRoleEvent; +import org.apache.polaris.service.events.BeforeCatalogRoleCreateEvent; +import org.apache.polaris.service.events.BeforeCatalogRoleDeleteEvent; +import org.apache.polaris.service.events.BeforeCatalogRoleGetEvent; +import org.apache.polaris.service.events.BeforeCatalogRoleRevokeFromPrincipalRoleEvent; +import org.apache.polaris.service.events.BeforeCatalogRoleUpdateEvent; +import org.apache.polaris.service.events.BeforeCatalogRolesListEvent; +import org.apache.polaris.service.events.BeforeCatalogUpdatedEvent; +import org.apache.polaris.service.events.BeforeCredentialsRotateEvent; +import org.apache.polaris.service.events.BeforeListAssigneePrincipalRolesForCatalogRoleEvent; +import org.apache.polaris.service.events.BeforeListAssigneePrincipalsForPrincipalRoleEvent; +import org.apache.polaris.service.events.BeforeListCatalogRolesForPrincipalRoleEvent; +import org.apache.polaris.service.events.BeforeListGrantsForCatalogRoleEvent; +import org.apache.polaris.service.events.BeforePrincipalCreateEvent; +import org.apache.polaris.service.events.BeforePrincipalDeleteEvent; +import org.apache.polaris.service.events.BeforePrincipalGetEvent; +import org.apache.polaris.service.events.BeforePrincipalRoleCreateEvent; +import org.apache.polaris.service.events.BeforePrincipalRoleDeleteEvent; +import org.apache.polaris.service.events.BeforePrincipalRoleGetEvent; +import org.apache.polaris.service.events.BeforePrincipalRoleUpdateEvent; +import org.apache.polaris.service.events.BeforePrincipalRolesAssignedListEvent; +import org.apache.polaris.service.events.BeforePrincipalRolesListEvent; +import org.apache.polaris.service.events.BeforePrincipalUpdateEvent; +import org.apache.polaris.service.events.BeforePrincipalsListEvent; +import org.apache.polaris.service.events.BeforeRevokeGrantFromCatalogRoleEvent; +import org.apache.polaris.service.events.BeforeRevokePrincipalRoleEvent; +import org.apache.polaris.service.events.PolarisEventListener; import org.apache.polaris.service.types.PolicyIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -95,6 +160,7 @@ public class PolarisServiceImpl private final UserSecretsManagerFactory userSecretsManagerFactory; private final CallContext callContext; private final ReservedProperties reservedProperties; + private final PolarisEventListener polarisEventListener; @Inject public PolarisServiceImpl( @@ -103,13 +169,15 @@ public PolarisServiceImpl( UserSecretsManagerFactory userSecretsManagerFactory, PolarisAuthorizer polarisAuthorizer, CallContext callContext, - ReservedProperties reservedProperties) { + ReservedProperties reservedProperties, + PolarisEventListener polarisEventListener) { this.resolutionManifestFactory = resolutionManifestFactory; this.metaStoreManagerFactory = metaStoreManagerFactory; this.userSecretsManagerFactory = userSecretsManagerFactory; this.polarisAuthorizer = polarisAuthorizer; this.callContext = callContext; this.reservedProperties = reservedProperties; + this.polarisEventListener = polarisEventListener; } private PolarisAdminService newAdminService( @@ -138,12 +206,15 @@ private PolarisAdminService newAdminService( @Override public Response createCatalog( CreateCatalogRequest request, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforeCatalogCreated( + new BeforeCatalogCreatedEvent(request.getCatalog().getName())); PolarisAdminService adminService = newAdminService(realmContext, securityContext); Catalog catalog = request.getCatalog(); validateStorageConfig(catalog.getStorageConfigInfo()); validateExternalCatalog(catalog); Catalog newCatalog = new CatalogEntity(adminService.createCatalog(request)).asCatalog(); LOGGER.info("Created new catalog {}", newCatalog); + polarisEventListener.onAfterCatalogCreated(new AfterCatalogCreatedEvent(newCatalog)); return Response.status(Response.Status.CREATED).build(); } @@ -208,8 +279,10 @@ private void validateAuthenticationParameters(AuthenticationParameters authentic @Override public Response deleteCatalog( String catalogName, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforeCatalogDeleted(new BeforeCatalogDeletedEvent(catalogName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); adminService.deleteCatalog(catalogName); + polarisEventListener.onAfterCatalogDeleted(new AfterCatalogDeletedEvent(catalogName)); return Response.status(Response.Status.NO_CONTENT).build(); } @@ -217,8 +290,12 @@ public Response deleteCatalog( @Override public Response getCatalog( String catalogName, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforeCatalogGet(new BeforeCatalogGetEvent(catalogName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); - return Response.ok(adminService.getCatalog(catalogName).asCatalog()).build(); + Catalog catalog = adminService.getCatalog(catalogName).asCatalog(); + Response resp = Response.ok(catalog).build(); + polarisEventListener.onAfterCatalogGet(new AfterCatalogGetEvent(catalog)); + return resp; } /** From PolarisCatalogsApiService */ @@ -228,16 +305,21 @@ public Response updateCatalog( UpdateCatalogRequest updateRequest, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforeCatalogUpdated( + new BeforeCatalogUpdatedEvent(catalogName, updateRequest)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); if (updateRequest.getStorageConfigInfo() != null) { validateStorageConfig(updateRequest.getStorageConfigInfo()); } - return Response.ok(adminService.updateCatalog(catalogName, updateRequest).asCatalog()).build(); + Catalog catalog = adminService.updateCatalog(catalogName, updateRequest).asCatalog(); + polarisEventListener.onAfterCatalogUpdated(new AfterCatalogUpdatedEvent(catalog)); + return Response.ok(catalog).build(); } /** From PolarisCatalogsApiService */ @Override public Response listCatalogs(RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforeCatalogList(new BeforeCatalogListEvent()); PolarisAdminService adminService = newAdminService(realmContext, securityContext); List catalogList = adminService.listCatalogs().stream() @@ -246,6 +328,7 @@ public Response listCatalogs(RealmContext realmContext, SecurityContext security .toList(); Catalogs catalogs = new Catalogs(catalogList); LOGGER.debug("listCatalogs returning: {}", catalogs); + polarisEventListener.onAfterCatalogList(new AfterCatalogListEvent()); return Response.ok(catalogs).build(); } @@ -253,6 +336,8 @@ public Response listCatalogs(RealmContext realmContext, SecurityContext security @Override public Response createPrincipal( CreatePrincipalRequest request, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforePrincipalCreate( + new BeforePrincipalCreateEvent(request.getPrincipal().getName())); PolarisAdminService adminService = newAdminService(realmContext, securityContext); PrincipalEntity principal = new PrincipalEntity.Builder() @@ -267,6 +352,8 @@ public Response createPrincipal( } PrincipalWithCredentials createdPrincipal = adminService.createPrincipal(principal); LOGGER.info("Created new principal {}", createdPrincipal); + polarisEventListener.onAfterPrincipalCreate( + new AfterPrincipalCreateEvent(createdPrincipal.getPrincipal())); return Response.status(Response.Status.CREATED).entity(createdPrincipal).build(); } @@ -274,8 +361,10 @@ public Response createPrincipal( @Override public Response deletePrincipal( String principalName, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforePrincipalDelete(new BeforePrincipalDeleteEvent(principalName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); adminService.deletePrincipal(principalName); + polarisEventListener.onAfterPrincipalDelete(new AfterPrincipalDeleteEvent(principalName)); return Response.status(Response.Status.NO_CONTENT).build(); } @@ -283,8 +372,12 @@ public Response deletePrincipal( @Override public Response getPrincipal( String principalName, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforePrincipalGet(new BeforePrincipalGetEvent(principalName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); - return Response.ok(adminService.getPrincipal(principalName).asPrincipal()).build(); + Principal principal = adminService.getPrincipal(principalName).asPrincipal(); + Response resp = Response.ok(principal).build(); + polarisEventListener.onAfterPrincipalGet(new AfterPrincipalGetEvent(principal)); + return resp; } /** From PolarisPrincipalsApiService */ @@ -294,22 +387,31 @@ public Response updatePrincipal( UpdatePrincipalRequest updateRequest, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforePrincipalUpdate( + new BeforePrincipalUpdateEvent(principalName, updateRequest)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); - return Response.ok(adminService.updatePrincipal(principalName, updateRequest).asPrincipal()) - .build(); + Principal updatedPrincipal = + adminService.updatePrincipal(principalName, updateRequest).asPrincipal(); + polarisEventListener.onAfterPrincipalUpdate(new AfterPrincipalUpdateEvent(updatedPrincipal)); + return Response.ok(updatedPrincipal).build(); } /** From PolarisPrincipalsApiService */ @Override public Response rotateCredentials( String principalName, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforeCredentialsRotate(new BeforeCredentialsRotateEvent(principalName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); - return Response.ok(adminService.rotateCredentials(principalName)).build(); + PrincipalWithCredentials rotatedPrincipal = adminService.rotateCredentials(principalName); + polarisEventListener.onAfterCredentialsRotate( + new AfterCredentialsRotateEvent(rotatedPrincipal.getPrincipal())); + return Response.ok(rotatedPrincipal).build(); } /** From PolarisPrincipalsApiService */ @Override public Response listPrincipals(RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforePrincipalsList(new BeforePrincipalsListEvent()); PolarisAdminService adminService = newAdminService(realmContext, securityContext); List principalList = adminService.listPrincipals().stream() @@ -318,6 +420,7 @@ public Response listPrincipals(RealmContext realmContext, SecurityContext securi .toList(); Principals principals = new Principals(principalList); LOGGER.debug("listPrincipals returning: {}", principals); + polarisEventListener.onAfterPrincipalsList(new AfterPrincipalsListEvent()); return Response.ok(principals).build(); } @@ -327,6 +430,7 @@ public Response createPrincipalRole( CreatePrincipalRoleRequest request, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforePrincipalRoleCreate(new BeforePrincipalRoleCreateEvent(request)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); PrincipalRoleEntity entity = new PrincipalRoleEntity.Builder() @@ -338,6 +442,8 @@ public Response createPrincipalRole( PrincipalRole newPrincipalRole = new PrincipalRoleEntity(adminService.createPrincipalRole(entity)).asPrincipalRole(); LOGGER.info("Created new principalRole {}", newPrincipalRole); + polarisEventListener.onAfterPrincipalRoleCreate( + new AfterPrincipalRoleCreateEvent(newPrincipalRole)); return Response.status(Response.Status.CREATED).build(); } @@ -345,8 +451,12 @@ public Response createPrincipalRole( @Override public Response deletePrincipalRole( String principalRoleName, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforePrincipalRoleDelete( + new BeforePrincipalRoleDeleteEvent(principalRoleName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); adminService.deletePrincipalRole(principalRoleName); + polarisEventListener.onAfterPrincipalRoleDelete( + new AfterPrincipalRoleDeleteEvent(principalRoleName)); return Response.status(Response.Status.NO_CONTENT).build(); } @@ -354,8 +464,13 @@ public Response deletePrincipalRole( @Override public Response getPrincipalRole( String principalRoleName, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforePrincipalRoleGet( + new BeforePrincipalRoleGetEvent(principalRoleName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); - return Response.ok(adminService.getPrincipalRole(principalRoleName).asPrincipalRole()).build(); + PrincipalRole principalRole = + adminService.getPrincipalRole(principalRoleName).asPrincipalRole(); + polarisEventListener.onAfterPrincipalRoleGet(new AfterPrincipalRoleGetEvent(principalRole)); + return Response.ok(principalRole).build(); } /** From PolarisPrincipalRolesApiService */ @@ -365,15 +480,20 @@ public Response updatePrincipalRole( UpdatePrincipalRoleRequest updateRequest, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforePrincipalRoleUpdate( + new BeforePrincipalRoleUpdateEvent(principalRoleName, updateRequest)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); - return Response.ok( - adminService.updatePrincipalRole(principalRoleName, updateRequest).asPrincipalRole()) - .build(); + PrincipalRole updatedPrincipalRole = + adminService.updatePrincipalRole(principalRoleName, updateRequest).asPrincipalRole(); + polarisEventListener.onAfterPrincipalRoleUpdate( + new AfterPrincipalRoleUpdateEvent(updatedPrincipalRole)); + return Response.ok(updatedPrincipalRole).build(); } /** From PolarisPrincipalRolesApiService */ @Override public Response listPrincipalRoles(RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforePrincipalRolesList(new BeforePrincipalRolesListEvent()); PolarisAdminService adminService = newAdminService(realmContext, securityContext); List principalRoleList = adminService.listPrincipalRoles().stream() @@ -382,6 +502,7 @@ public Response listPrincipalRoles(RealmContext realmContext, SecurityContext se .toList(); PrincipalRoles principalRoles = new PrincipalRoles(principalRoleList); LOGGER.debug("listPrincipalRoles returning: {}", principalRoles); + polarisEventListener.onAfterPrincipalRolesList(new AfterPrincipalRolesListEvent()); return Response.ok(principalRoles).build(); } @@ -392,6 +513,8 @@ public Response createCatalogRole( CreateCatalogRoleRequest request, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforeCatalogRoleCreate( + new BeforeCatalogRoleCreateEvent(catalogName, request.getCatalogRole().getName())); PolarisAdminService adminService = newAdminService(realmContext, securityContext); CatalogRoleEntity entity = new CatalogRoleEntity.Builder() @@ -403,6 +526,8 @@ public Response createCatalogRole( CatalogRole newCatalogRole = new CatalogRoleEntity(adminService.createCatalogRole(catalogName, entity)).asCatalogRole(); LOGGER.info("Created new catalogRole {}", newCatalogRole); + polarisEventListener.onAfterCatalogRoleCreate( + new AfterCatalogRoleCreateEvent(catalogName, newCatalogRole)); return Response.status(Response.Status.CREATED).build(); } @@ -413,8 +538,12 @@ public Response deleteCatalogRole( String catalogRoleName, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforeCatalogRoleDelete( + new BeforeCatalogRoleDeleteEvent(catalogName, catalogRoleName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); adminService.deleteCatalogRole(catalogName, catalogRoleName); + polarisEventListener.onAfterCatalogRoleDelete( + new AfterCatalogRoleDeleteEvent(catalogName, catalogRoleName)); return Response.status(Response.Status.NO_CONTENT).build(); } @@ -425,9 +554,15 @@ public Response getCatalogRole( String catalogRoleName, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforeCatalogRoleGet( + new BeforeCatalogRoleGetEvent(catalogName, catalogRoleName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); - return Response.ok(adminService.getCatalogRole(catalogName, catalogRoleName).asCatalogRole()) - .build(); + CatalogRole catalogRole = + adminService.getCatalogRole(catalogName, catalogRoleName).asCatalogRole(); + Response resp = Response.ok(catalogRole).build(); + polarisEventListener.onAfterCatalogRoleGet( + new AfterCatalogRoleGetEvent(catalogName, catalogRole)); + return resp; } /** From PolarisCatalogsApiService */ @@ -438,18 +573,22 @@ public Response updateCatalogRole( UpdateCatalogRoleRequest updateRequest, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforeCatalogRoleUpdate( + new BeforeCatalogRoleUpdateEvent(catalogName, catalogRoleName, updateRequest)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); - return Response.ok( - adminService - .updateCatalogRole(catalogName, catalogRoleName, updateRequest) - .asCatalogRole()) - .build(); + CatalogRole updatedCatalogRole = + adminService.updateCatalogRole(catalogName, catalogRoleName, updateRequest).asCatalogRole(); + polarisEventListener.onAfterCatalogRoleUpdate( + new AfterCatalogRoleUpdateEvent(catalogName, updatedCatalogRole)); + return Response.ok(updatedCatalogRole).build(); } /** From PolarisCatalogsApiService */ @Override public Response listCatalogRoles( String catalogName, RealmContext realmContext, SecurityContext securityContext) { + LOGGER.info("Listing catalog roles for catalog {}", catalogName); + polarisEventListener.onBeforeCatalogRolesList(new BeforeCatalogRolesListEvent(catalogName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); List catalogRoleList = adminService.listCatalogRoles(catalogName).stream() @@ -457,6 +596,7 @@ public Response listCatalogRoles( .map(CatalogRoleEntity::asCatalogRole) .toList(); CatalogRoles catalogRoles = new CatalogRoles(catalogRoleList); + polarisEventListener.onAfterCatalogRolesList(new AfterCatalogRolesListEvent(catalogName)); LOGGER.debug("listCatalogRoles returning: {}", catalogRoles); return Response.ok(catalogRoles).build(); } @@ -472,8 +612,12 @@ public Response assignPrincipalRole( "Assigning principalRole {} to principal {}", request.getPrincipalRole().getName(), principalName); + polarisEventListener.onBeforeAssignPrincipalRole( + new BeforeAssignPrincipalRoleEvent(principalName, request.getPrincipalRole())); PolarisAdminService adminService = newAdminService(realmContext, securityContext); adminService.assignPrincipalRole(principalName, request.getPrincipalRole().getName()); + polarisEventListener.onAfterAssignPrincipalRole( + new AfterAssignPrincipalRoleEvent(principalName, request.getPrincipalRole())); return Response.status(Response.Status.CREATED).build(); } @@ -485,8 +629,12 @@ public Response revokePrincipalRole( RealmContext realmContext, SecurityContext securityContext) { LOGGER.info("Revoking principalRole {} from principal {}", principalRoleName, principalName); + polarisEventListener.onBeforeRevokePrincipalRole( + new BeforeRevokePrincipalRoleEvent(principalName, principalRoleName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); adminService.revokePrincipalRole(principalName, principalRoleName); + polarisEventListener.onAfterRevokePrincipalRole( + new AfterRevokePrincipalRoleEvent(principalName, principalRoleName)); return Response.status(Response.Status.NO_CONTENT).build(); } @@ -494,6 +642,8 @@ public Response revokePrincipalRole( @Override public Response listPrincipalRolesAssigned( String principalName, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforePrincipalRolesAssignedList( + new BeforePrincipalRolesAssignedListEvent(principalName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); List principalRoleList = adminService.listPrincipalRolesAssigned(principalName).stream() @@ -502,6 +652,8 @@ public Response listPrincipalRolesAssigned( .toList(); PrincipalRoles principalRoles = new PrincipalRoles(principalRoleList); LOGGER.debug("listPrincipalRolesAssigned returning: {}", principalRoles); + polarisEventListener.onAfterPrincipalRolesAssignedList( + new AfterPrincipalRolesAssignedListEvent(principalName)); return Response.ok(principalRoles).build(); } @@ -513,6 +665,9 @@ public Response assignCatalogRoleToPrincipalRole( GrantCatalogRoleRequest request, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforeCatalogRoleAssignToPrincipalRole( + new BeforeCatalogRoleAssignToPrincipalRoleEvent( + principalRoleName, catalogName, request.getCatalogRole())); LOGGER.info( "Assigning catalogRole {} in catalog {} to principalRole {}", request.getCatalogRole().getName(), @@ -521,6 +676,9 @@ public Response assignCatalogRoleToPrincipalRole( PolarisAdminService adminService = newAdminService(realmContext, securityContext); adminService.assignCatalogRoleToPrincipalRole( principalRoleName, catalogName, request.getCatalogRole().getName()); + polarisEventListener.onAfterCatalogRoleAssignToPrincipalRole( + new AfterCatalogRoleAssignToPrincipalRoleEvent( + principalRoleName, catalogName, request.getCatalogRole().getName())); return Response.status(Response.Status.CREATED).build(); } @@ -532,6 +690,9 @@ public Response revokeCatalogRoleFromPrincipalRole( String catalogRoleName, RealmContext realmContext, SecurityContext securityContext) { + polarisEventListener.onBeforeCatalogRoleRevokeFromPrincipalRole( + new BeforeCatalogRoleRevokeFromPrincipalRoleEvent( + principalRoleName, catalogName, catalogRoleName)); LOGGER.info( "Revoking catalogRole {} in catalog {} from principalRole {}", catalogRoleName, @@ -540,6 +701,9 @@ public Response revokeCatalogRoleFromPrincipalRole( PolarisAdminService adminService = newAdminService(realmContext, securityContext); adminService.revokeCatalogRoleFromPrincipalRole( principalRoleName, catalogName, catalogRoleName); + polarisEventListener.onAfterCatalogRoleRevokeFromPrincipalRole( + new AfterCatalogRoleRevokeFromPrincipalRoleEvent( + principalRoleName, catalogName, catalogRoleName)); return Response.status(Response.Status.NO_CONTENT).build(); } @@ -547,6 +711,9 @@ public Response revokeCatalogRoleFromPrincipalRole( @Override public Response listAssigneePrincipalsForPrincipalRole( String principalRoleName, RealmContext realmContext, SecurityContext securityContext) { + LOGGER.info("Listing assignee principals for principalRole {}", principalRoleName); + polarisEventListener.onBeforeListAssigneePrincipalsForPrincipalRole( + new BeforeListAssigneePrincipalsForPrincipalRoleEvent(principalRoleName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); List principalList = adminService.listAssigneePrincipalsForPrincipalRole(principalRoleName).stream() @@ -554,6 +721,8 @@ public Response listAssigneePrincipalsForPrincipalRole( .map(PrincipalEntity::asPrincipal) .toList(); Principals principals = new Principals(principalList); + polarisEventListener.onAfterListAssigneePrincipalsForPrincipalRole( + new AfterListAssigneePrincipalsForPrincipalRoleEvent(principalRoleName)); LOGGER.debug("listAssigneePrincipalsForPrincipalRole returning: {}", principals); return Response.ok(principals).build(); } @@ -565,6 +734,10 @@ public Response listCatalogRolesForPrincipalRole( String catalogName, RealmContext realmContext, SecurityContext securityContext) { + LOGGER.info( + "Listing catalog roles for principalRole {} in catalog {}", principalRoleName, catalogName); + polarisEventListener.onBeforeListCatalogRolesForPrincipalRole( + new BeforeListCatalogRolesForPrincipalRoleEvent(principalRoleName, catalogName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); List catalogRoleList = adminService.listCatalogRolesForPrincipalRole(principalRoleName, catalogName).stream() @@ -572,6 +745,8 @@ public Response listCatalogRolesForPrincipalRole( .map(CatalogRoleEntity::asCatalogRole) .toList(); CatalogRoles catalogRoles = new CatalogRoles(catalogRoleList); + polarisEventListener.onAfterListCatalogRolesForPrincipalRole( + new AfterListCatalogRolesForPrincipalRoleEvent(principalRoleName, catalogName)); LOGGER.debug("listCatalogRolesForPrincipalRole returning: {}", catalogRoles); return Response.ok(catalogRoles).build(); } @@ -589,14 +764,16 @@ public Response addGrantToCatalogRole( grantRequest, catalogRoleName, catalogName); + polarisEventListener.onBeforeAddGrantToCatalogRole( + new BeforeAddGrantToCatalogRoleEvent(catalogName, catalogRoleName, grantRequest)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); + PolarisPrivilege privilege; switch (grantRequest.getGrant()) { // The per-securable-type Privilege enums must be exact String match for a subset of all // PolarisPrivilege values. case ViewGrant viewGrant: { - PolarisPrivilege privilege = - PolarisPrivilege.valueOf(viewGrant.getPrivilege().toString()); + privilege = PolarisPrivilege.valueOf(viewGrant.getPrivilege().toString()); String viewName = viewGrant.getViewName(); String[] namespaceParts = viewGrant.getNamespace().toArray(new String[0]); adminService.grantPrivilegeOnViewToRole( @@ -608,8 +785,7 @@ public Response addGrantToCatalogRole( } case TableGrant tableGrant: { - PolarisPrivilege privilege = - PolarisPrivilege.valueOf(tableGrant.getPrivilege().toString()); + privilege = PolarisPrivilege.valueOf(tableGrant.getPrivilege().toString()); String tableName = tableGrant.getTableName(); String[] namespaceParts = tableGrant.getNamespace().toArray(new String[0]); adminService.grantPrivilegeOnTableToRole( @@ -621,8 +797,7 @@ public Response addGrantToCatalogRole( } case NamespaceGrant namespaceGrant: { - PolarisPrivilege privilege = - PolarisPrivilege.valueOf(namespaceGrant.getPrivilege().toString()); + privilege = PolarisPrivilege.valueOf(namespaceGrant.getPrivilege().toString()); String[] namespaceParts = namespaceGrant.getNamespace().toArray(new String[0]); adminService.grantPrivilegeOnNamespaceToRole( catalogName, catalogRoleName, Namespace.of(namespaceParts), privilege); @@ -630,15 +805,13 @@ public Response addGrantToCatalogRole( } case CatalogGrant catalogGrant: { - PolarisPrivilege privilege = - PolarisPrivilege.valueOf(catalogGrant.getPrivilege().toString()); + privilege = PolarisPrivilege.valueOf(catalogGrant.getPrivilege().toString()); adminService.grantPrivilegeOnCatalogToRole(catalogName, catalogRoleName, privilege); break; } case PolicyGrant policyGrant: { - PolarisPrivilege privilege = - PolarisPrivilege.valueOf(policyGrant.getPrivilege().toString()); + privilege = PolarisPrivilege.valueOf(policyGrant.getPrivilege().toString()); String policyName = policyGrant.getPolicyName(); String[] namespaceParts = policyGrant.getNamespace().toArray(new String[0]); adminService.grantPrivilegeOnPolicyToRole( @@ -656,6 +829,9 @@ public Response addGrantToCatalogRole( .log("Don't know how to handle privilege grant: {}", grantRequest); return Response.status(Response.Status.BAD_REQUEST).build(); } + polarisEventListener.onAfterAddGrantToCatalogRole( + new AfterAddGrantToCatalogRoleEvent( + catalogName, catalogRoleName, privilege, grantRequest.getGrant())); return Response.status(Response.Status.CREATED).build(); } @@ -673,19 +849,22 @@ public Response revokeGrantFromCatalogRole( grantRequest, catalogRoleName, catalogName); + polarisEventListener.onBeforeRevokeGrantFromCatalogRole( + new BeforeRevokeGrantFromCatalogRoleEvent( + catalogName, catalogRoleName, grantRequest, cascade)); if (cascade != null && cascade) { LOGGER.warn("Tried to use unimplemented 'cascade' feature when revoking grants."); return Response.status(501).build(); // not implemented } PolarisAdminService adminService = newAdminService(realmContext, securityContext); + PolarisPrivilege privilege; switch (grantRequest.getGrant()) { // The per-securable-type Privilege enums must be exact String match for a subset of all // PolarisPrivilege values. case ViewGrant viewGrant: { - PolarisPrivilege privilege = - PolarisPrivilege.valueOf(viewGrant.getPrivilege().toString()); + privilege = PolarisPrivilege.valueOf(viewGrant.getPrivilege().toString()); String viewName = viewGrant.getViewName(); String[] namespaceParts = viewGrant.getNamespace().toArray(new String[0]); adminService.revokePrivilegeOnViewFromRole( @@ -697,8 +876,7 @@ public Response revokeGrantFromCatalogRole( } case TableGrant tableGrant: { - PolarisPrivilege privilege = - PolarisPrivilege.valueOf(tableGrant.getPrivilege().toString()); + privilege = PolarisPrivilege.valueOf(tableGrant.getPrivilege().toString()); String tableName = tableGrant.getTableName(); String[] namespaceParts = tableGrant.getNamespace().toArray(new String[0]); adminService.revokePrivilegeOnTableFromRole( @@ -710,8 +888,7 @@ public Response revokeGrantFromCatalogRole( } case NamespaceGrant namespaceGrant: { - PolarisPrivilege privilege = - PolarisPrivilege.valueOf(namespaceGrant.getPrivilege().toString()); + privilege = PolarisPrivilege.valueOf(namespaceGrant.getPrivilege().toString()); String[] namespaceParts = namespaceGrant.getNamespace().toArray(new String[0]); adminService.revokePrivilegeOnNamespaceFromRole( catalogName, catalogRoleName, Namespace.of(namespaceParts), privilege); @@ -719,15 +896,13 @@ public Response revokeGrantFromCatalogRole( } case CatalogGrant catalogGrant: { - PolarisPrivilege privilege = - PolarisPrivilege.valueOf(catalogGrant.getPrivilege().toString()); + privilege = PolarisPrivilege.valueOf(catalogGrant.getPrivilege().toString()); adminService.revokePrivilegeOnCatalogFromRole(catalogName, catalogRoleName, privilege); break; } case PolicyGrant policyGrant: { - PolarisPrivilege privilege = - PolarisPrivilege.valueOf(policyGrant.getPrivilege().toString()); + privilege = PolarisPrivilege.valueOf(policyGrant.getPrivilege().toString()); String policyName = policyGrant.getPolicyName(); String[] namespaceParts = policyGrant.getNamespace().toArray(new String[0]); adminService.revokePrivilegeOnPolicyFromRole( @@ -745,6 +920,9 @@ public Response revokeGrantFromCatalogRole( .log("Don't know how to handle privilege revocation: {}", grantRequest); return Response.status(Response.Status.BAD_REQUEST).build(); } + polarisEventListener.onAfterRevokeGrantFromCatalogRole( + new AfterRevokeGrantFromCatalogRoleEvent( + catalogName, catalogRoleName, privilege, grantRequest.getGrant(), cascade)); return Response.status(Response.Status.CREATED).build(); } @@ -755,6 +933,12 @@ public Response listAssigneePrincipalRolesForCatalogRole( String catalogRoleName, RealmContext realmContext, SecurityContext securityContext) { + LOGGER.info( + "Listing assignee principal roles for catalog role {} in catalog {}", + catalogRoleName, + catalogName); + polarisEventListener.onBeforeListAssigneePrincipalRolesForCatalogRole( + new BeforeListAssigneePrincipalRolesForCatalogRoleEvent(catalogName, catalogRoleName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); List principalRoleList = adminService.listAssigneePrincipalRolesForCatalogRole(catalogName, catalogRoleName).stream() @@ -763,6 +947,8 @@ public Response listAssigneePrincipalRolesForCatalogRole( .toList(); PrincipalRoles principalRoles = new PrincipalRoles(principalRoleList); LOGGER.debug("listAssigneePrincipalRolesForCatalogRole returning: {}", principalRoles); + polarisEventListener.onAfterListAssigneePrincipalRolesForCatalogRole( + new AfterListAssigneePrincipalRolesForCatalogRoleEvent(catalogName, catalogRoleName)); return Response.ok(principalRoles).build(); } @@ -773,10 +959,16 @@ public Response listGrantsForCatalogRole( String catalogRoleName, RealmContext realmContext, SecurityContext securityContext) { + LOGGER.info("Listing grants for catalog role {} in catalog {}", catalogRoleName, catalogName); + polarisEventListener.onBeforeListGrantsForCatalogRole( + new BeforeListGrantsForCatalogRoleEvent(catalogName, catalogRoleName)); PolarisAdminService adminService = newAdminService(realmContext, securityContext); List grantList = adminService.listGrantsForCatalogRole(catalogName, catalogRoleName); GrantResources grantResources = new GrantResources(grantList); + LOGGER.debug("listGrantsForCatalogRole returning: {}", grantResources); + polarisEventListener.onAfterListGrantsForCatalogRole( + new AfterListGrantsForCatalogRoleEvent(catalogName, catalogRoleName)); return Response.ok(grantResources).build(); } } diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterAddGrantToCatalogRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterAddGrantToCatalogRoleEvent.java new file mode 100644 index 0000000000..22442f69e3 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterAddGrantToCatalogRoleEvent.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.GrantResource; +import org.apache.polaris.core.entity.PolarisPrivilege; + +/** + * Event fired after a grant is added to a catalog role in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role + * @param privilege the privilege granted + * @param grantResource the grant resource + */ +public record AfterAddGrantToCatalogRoleEvent( + String catalogName, + String catalogRoleName, + PolarisPrivilege privilege, + GrantResource grantResource) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterAssignPrincipalRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterAssignPrincipalRoleEvent.java new file mode 100644 index 0000000000..6efbc8b6fd --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterAssignPrincipalRoleEvent.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.PrincipalRole; + +/** + * Event fired after a principal role is assigned to a principal in Polaris. + * + * @param principalName the name of the principal + * @param principalRole the principal role assigned + */ +public record AfterAssignPrincipalRoleEvent(String principalName, PrincipalRole principalRole) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogCreatedEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogCreatedEvent.java new file mode 100644 index 0000000000..0a7c4e70ea --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogCreatedEvent.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.Catalog; + +/** Emitted when Polaris intends to create a table. */ +public record AfterCatalogCreatedEvent(Catalog catalog) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogDeletedEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogDeletedEvent.java new file mode 100644 index 0000000000..8d17b4279c --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogDeletedEvent.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** Emitted when Polaris deletes a catalog. */ +public record AfterCatalogDeletedEvent(String catalogName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogGetEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogGetEvent.java new file mode 100644 index 0000000000..3173944a5d --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogGetEvent.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.Catalog; + +/** Emitted when Polaris retrieves a catalog. */ +public record AfterCatalogGetEvent(Catalog catalog) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogListEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogListEvent.java new file mode 100644 index 0000000000..46cbe23430 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogListEvent.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** Emitted when Polaris lists all catalogs. */ +public record AfterCatalogListEvent() implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleAssignToPrincipalRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleAssignToPrincipalRoleEvent.java new file mode 100644 index 0000000000..1c05590246 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleAssignToPrincipalRoleEvent.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired after a catalog role is assigned to a principal role in Polaris. + * + * @param principalRoleName the name of the principal role + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role assigned + */ +public record AfterCatalogRoleAssignToPrincipalRoleEvent( + String principalRoleName, String catalogName, String catalogRoleName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleCreateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleCreateEvent.java new file mode 100644 index 0000000000..a67997e89b --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleCreateEvent.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.CatalogRole; + +/** + * Event fired after a catalog role is created in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRole the catalog role that was created + */ +public record AfterCatalogRoleCreateEvent(String catalogName, CatalogRole catalogRole) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleDeleteEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleDeleteEvent.java new file mode 100644 index 0000000000..2725bff03a --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleDeleteEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired after a catalog role is deleted in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role that was deleted + */ +public record AfterCatalogRoleDeleteEvent(String catalogName, String catalogRoleName) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleGetEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleGetEvent.java new file mode 100644 index 0000000000..83b3d97e1d --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleGetEvent.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.CatalogRole; + +/** + * Event fired after a catalog role is retrieved in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRole the catalog role that was retrieved + */ +public record AfterCatalogRoleGetEvent(String catalogName, CatalogRole catalogRole) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleRevokeFromPrincipalRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleRevokeFromPrincipalRoleEvent.java new file mode 100644 index 0000000000..398079e591 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleRevokeFromPrincipalRoleEvent.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired after a catalog role is revoked from a principal role in Polaris. + * + * @param principalRoleName the name of the principal role + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role that was revoked + */ +public record AfterCatalogRoleRevokeFromPrincipalRoleEvent( + String principalRoleName, String catalogName, String catalogRoleName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleUpdateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleUpdateEvent.java new file mode 100644 index 0000000000..4e854ec4a9 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRoleUpdateEvent.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.CatalogRole; + +/** + * Event fired after a catalog role is updated in Polaris. + * + * @param catalogName the name of the catalog + * @param updatedCatalogRole the updated catalog role object + */ +public record AfterCatalogRoleUpdateEvent(String catalogName, CatalogRole updatedCatalogRole) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRolesListEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRolesListEvent.java new file mode 100644 index 0000000000..3f5ed4fda3 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogRolesListEvent.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired after the list of catalog roles is retrieved in Polaris. + * + * @param catalogName the name of the catalog + */ +public record AfterCatalogRolesListEvent(String catalogName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogUpdatedEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogUpdatedEvent.java new file mode 100644 index 0000000000..aec78cd14f --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogUpdatedEvent.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.Catalog; + +/** Emitted when Polaris updates a catalog. */ +public record AfterCatalogUpdatedEvent(Catalog catalog) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterCredentialsRotateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterCredentialsRotateEvent.java new file mode 100644 index 0000000000..ee7e63e37c --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterCredentialsRotateEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.Principal; + +/** + * Event fired after credentials are rotated for a principal in Polaris. + * + * @param rotatedPrincipal the updated principal with new credentials + */ +public record AfterCredentialsRotateEvent(Principal rotatedPrincipal) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterListAssigneePrincipalRolesForCatalogRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterListAssigneePrincipalRolesForCatalogRoleEvent.java new file mode 100644 index 0000000000..0aa49877b2 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterListAssigneePrincipalRolesForCatalogRoleEvent.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired after the list of assignee principal roles for a catalog role is retrieved in + * Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role + */ +public record AfterListAssigneePrincipalRolesForCatalogRoleEvent( + String catalogName, String catalogRoleName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterListAssigneePrincipalsForPrincipalRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterListAssigneePrincipalsForPrincipalRoleEvent.java new file mode 100644 index 0000000000..4c1de61867 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterListAssigneePrincipalsForPrincipalRoleEvent.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired after the list of assignee principals for a principal role is retrieved in Polaris. + * + * @param principalRoleName the name of the principal role + */ +public record AfterListAssigneePrincipalsForPrincipalRoleEvent(String principalRoleName) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterListCatalogRolesForPrincipalRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterListCatalogRolesForPrincipalRoleEvent.java new file mode 100644 index 0000000000..758f9fb385 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterListCatalogRolesForPrincipalRoleEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired after the list of catalog roles for a principal role is retrieved in Polaris. + * + * @param principalRoleName the name of the principal role + * @param catalogName the name of the catalog + */ +public record AfterListCatalogRolesForPrincipalRoleEvent( + String principalRoleName, String catalogName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterListGrantsForCatalogRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterListGrantsForCatalogRoleEvent.java new file mode 100644 index 0000000000..c04d6ef895 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterListGrantsForCatalogRoleEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired after the list of grants for a catalog role is retrieved in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role + */ +public record AfterListGrantsForCatalogRoleEvent(String catalogName, String catalogRoleName) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalCreateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalCreateEvent.java new file mode 100644 index 0000000000..0a7d66f051 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalCreateEvent.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.Principal; + +/** Emitted after a principal is created in Polaris. */ +public record AfterPrincipalCreateEvent(Principal principal) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalDeleteEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalDeleteEvent.java new file mode 100644 index 0000000000..5d19d5b9ab --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalDeleteEvent.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired after a principal is deleted in Polaris. + * + * @param principalName the name of the principal that was deleted + */ +public record AfterPrincipalDeleteEvent(String principalName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalGetEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalGetEvent.java new file mode 100644 index 0000000000..244a0adf36 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalGetEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.Principal; + +/** + * Event fired after a principal is retrieved in Polaris. + * + * @param principal the principal that was retrieved + */ +public record AfterPrincipalGetEvent(Principal principal) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRoleCreateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRoleCreateEvent.java new file mode 100644 index 0000000000..6f382a29db --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRoleCreateEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.PrincipalRole; + +/** + * Event fired after a principal role is created in Polaris. + * + * @param principalRole the new Principal Role entity created + */ +public record AfterPrincipalRoleCreateEvent(PrincipalRole principalRole) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRoleDeleteEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRoleDeleteEvent.java new file mode 100644 index 0000000000..2792d79525 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRoleDeleteEvent.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired after a principal role is deleted in Polaris. + * + * @param principalRoleName the name of the principal role that was deleted + */ +public record AfterPrincipalRoleDeleteEvent(String principalRoleName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRoleGetEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRoleGetEvent.java new file mode 100644 index 0000000000..afd8331d5c --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRoleGetEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.PrincipalRole; + +/** + * Event fired after a principal role is retrieved in Polaris. + * + * @param principalRole the principal role that was retrieved + */ +public record AfterPrincipalRoleGetEvent(PrincipalRole principalRole) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRoleUpdateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRoleUpdateEvent.java new file mode 100644 index 0000000000..62437359d1 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRoleUpdateEvent.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.PrincipalRole; + +/** + * Event fired after a principal role is updated in Polaris. + * + * @param updatedPrincipalRole the updated principal role object + */ +public record AfterPrincipalRoleUpdateEvent(PrincipalRole updatedPrincipalRole) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRolesAssignedListEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRolesAssignedListEvent.java new file mode 100644 index 0000000000..5b19aac111 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRolesAssignedListEvent.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired after the list of principal roles assigned to a principal is retrieved in Polaris. + * + * @param principalName the name of the principal + */ +public record AfterPrincipalRolesAssignedListEvent(String principalName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRolesListEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRolesListEvent.java new file mode 100644 index 0000000000..abb7b94412 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalRolesListEvent.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** Event fired after the list of principal roles is retrieved in Polaris. */ +public record AfterPrincipalRolesListEvent() implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalUpdateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalUpdateEvent.java new file mode 100644 index 0000000000..59c87d51bc --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalUpdateEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.Principal; + +/** + * Event fired after a principal is updated in Polaris. + * + * @param updatedPrincipal the updated principal object + */ +public record AfterPrincipalUpdateEvent(Principal updatedPrincipal) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalsListEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalsListEvent.java new file mode 100644 index 0000000000..8ebdbcc917 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterPrincipalsListEvent.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** Event fired after the list of principals is retrieved in Polaris. */ +public record AfterPrincipalsListEvent() implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterRevokeGrantFromCatalogRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterRevokeGrantFromCatalogRoleEvent.java new file mode 100644 index 0000000000..29047708d8 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterRevokeGrantFromCatalogRoleEvent.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.GrantResource; +import org.apache.polaris.core.entity.PolarisPrivilege; + +/** + * Event fired after a grant is revoked from a catalog role in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role + * @param privilege the privilege revoked + * @param grantResource the revoke grant resource + * @param cascade whether to cascade the revocation + */ +public record AfterRevokeGrantFromCatalogRoleEvent( + String catalogName, + String catalogRoleName, + PolarisPrivilege privilege, + GrantResource grantResource, + Boolean cascade) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/AfterRevokePrincipalRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/AfterRevokePrincipalRoleEvent.java new file mode 100644 index 0000000000..137c67169c --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/AfterRevokePrincipalRoleEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired after a principal role is revoked from a principal in Polaris. + * + * @param principalName the name of the principal + * @param principalRoleName the name of the principal role that was revoked + */ +public record AfterRevokePrincipalRoleEvent(String principalName, String principalRoleName) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeAddGrantToCatalogRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeAddGrantToCatalogRoleEvent.java new file mode 100644 index 0000000000..020dd44532 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeAddGrantToCatalogRoleEvent.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.AddGrantRequest; + +/** + * Event fired before a grant is added to a catalog role in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role + * @param grantRequest the grant request + */ +public record BeforeAddGrantToCatalogRoleEvent( + String catalogName, String catalogRoleName, AddGrantRequest grantRequest) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeAssignPrincipalRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeAssignPrincipalRoleEvent.java new file mode 100644 index 0000000000..1a0fd973ac --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeAssignPrincipalRoleEvent.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.PrincipalRole; + +/** + * Event fired before a principal role is assigned to a principal in Polaris. + * + * @param principalName the name of the principal + * @param principalRole the principal role to be assigned + */ +public record BeforeAssignPrincipalRoleEvent(String principalName, PrincipalRole principalRole) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogCreatedEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogCreatedEvent.java new file mode 100644 index 0000000000..3becd35fa8 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogCreatedEvent.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** Emitted when Polaris intends to create a catalog. */ +public record BeforeCatalogCreatedEvent(String catalogName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogDeletedEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogDeletedEvent.java new file mode 100644 index 0000000000..f5bf13cf89 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogDeletedEvent.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** Emitted when Polaris intends to delete a catalog. */ +public record BeforeCatalogDeletedEvent(String catalogName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogGetEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogGetEvent.java new file mode 100644 index 0000000000..3a98e263fd --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogGetEvent.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** Emitted when Polaris intends to get a catalog. */ +public record BeforeCatalogGetEvent(String catalogName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogListEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogListEvent.java new file mode 100644 index 0000000000..4d2f36da39 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogListEvent.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** Emitted when Polaris intends to list all catalogs. */ +public record BeforeCatalogListEvent() implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleAssignToPrincipalRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleAssignToPrincipalRoleEvent.java new file mode 100644 index 0000000000..6a86fe470a --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleAssignToPrincipalRoleEvent.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.CatalogRole; + +/** + * Event fired before a catalog role is assigned to a principal role in Polaris. + * + * @param principalRoleName the name of the principal role + * @param catalogName the name of the catalog + * @param catalogRole the catalog role to be assigned + */ +public record BeforeCatalogRoleAssignToPrincipalRoleEvent( + String principalRoleName, String catalogName, CatalogRole catalogRole) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleCreateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleCreateEvent.java new file mode 100644 index 0000000000..dff9f5e675 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleCreateEvent.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.service.events; + +/** + * Event fired before a catalog role is created in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role to be created + */ +public record BeforeCatalogRoleCreateEvent(String catalogName, String catalogRoleName) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleDeleteEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleDeleteEvent.java new file mode 100644 index 0000000000..bf92eee21e --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleDeleteEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired before a catalog role is deleted in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role to be deleted + */ +public record BeforeCatalogRoleDeleteEvent(String catalogName, String catalogRoleName) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleGetEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleGetEvent.java new file mode 100644 index 0000000000..3d0aff17cd --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleGetEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired before a catalog role is retrieved in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role to be retrieved + */ +public record BeforeCatalogRoleGetEvent(String catalogName, String catalogRoleName) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleRevokeFromPrincipalRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleRevokeFromPrincipalRoleEvent.java new file mode 100644 index 0000000000..b270cab2e0 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleRevokeFromPrincipalRoleEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.service.events; + +/** + * Event fired before a catalog role is revoked from a principal role in Polaris. + * + * @param principalRoleName the name of the principal role + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role to be revoked + */ +public record BeforeCatalogRoleRevokeFromPrincipalRoleEvent( + String principalRoleName, String catalogName, String catalogRoleName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleUpdateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleUpdateEvent.java new file mode 100644 index 0000000000..32e7c08637 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRoleUpdateEvent.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.UpdateCatalogRoleRequest; + +/** + * Event fired before a catalog role is updated in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role to be updated + * @param updateRequest the update request object + */ +public record BeforeCatalogRoleUpdateEvent( + String catalogName, String catalogRoleName, UpdateCatalogRoleRequest updateRequest) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRolesListEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRolesListEvent.java new file mode 100644 index 0000000000..f7d5ee77e8 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogRolesListEvent.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired before the list of catalog roles is retrieved in Polaris. + * + * @param catalogName the name of the catalog + */ +public record BeforeCatalogRolesListEvent(String catalogName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogUpdatedEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogUpdatedEvent.java new file mode 100644 index 0000000000..1c25b7fbd3 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCatalogUpdatedEvent.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.UpdateCatalogRequest; + +/** Emitted when Polaris intends to update a catalog. */ +public record BeforeCatalogUpdatedEvent(String catalogName, UpdateCatalogRequest updateRequest) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeCredentialsRotateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCredentialsRotateEvent.java new file mode 100644 index 0000000000..8184eeeed3 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeCredentialsRotateEvent.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired before credentials are rotated for a principal in Polaris. + * + * @param principalName the name of the principal whose credentials will be rotated + */ +public record BeforeCredentialsRotateEvent(String principalName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeListAssigneePrincipalRolesForCatalogRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeListAssigneePrincipalRolesForCatalogRoleEvent.java new file mode 100644 index 0000000000..1d26d87159 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeListAssigneePrincipalRolesForCatalogRoleEvent.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired before the list of assignee principal roles for a catalog role is retrieved in + * Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role + */ +public record BeforeListAssigneePrincipalRolesForCatalogRoleEvent( + String catalogName, String catalogRoleName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeListAssigneePrincipalsForPrincipalRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeListAssigneePrincipalsForPrincipalRoleEvent.java new file mode 100644 index 0000000000..d2d96abe68 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeListAssigneePrincipalsForPrincipalRoleEvent.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired before the list of assignee principals for a principal role is retrieved in Polaris. + * + * @param principalRoleName the name of the principal role + */ +public record BeforeListAssigneePrincipalsForPrincipalRoleEvent(String principalRoleName) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeListCatalogRolesForPrincipalRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeListCatalogRolesForPrincipalRoleEvent.java new file mode 100644 index 0000000000..1e38284df2 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeListCatalogRolesForPrincipalRoleEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired before the list of catalog roles for a principal role is retrieved in Polaris. + * + * @param principalRoleName the name of the principal role + * @param catalogName the name of the catalog + */ +public record BeforeListCatalogRolesForPrincipalRoleEvent( + String principalRoleName, String catalogName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeListGrantsForCatalogRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeListGrantsForCatalogRoleEvent.java new file mode 100644 index 0000000000..f2f4b7ce93 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeListGrantsForCatalogRoleEvent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired before the list of grants for a catalog role is retrieved in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role + */ +public record BeforeListGrantsForCatalogRoleEvent(String catalogName, String catalogRoleName) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalCreateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalCreateEvent.java new file mode 100644 index 0000000000..c578f6a5fe --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalCreateEvent.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** Emitted before a principal is created in Polaris. */ +public record BeforePrincipalCreateEvent(String principalName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalDeleteEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalDeleteEvent.java new file mode 100644 index 0000000000..e3ab3bacac --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalDeleteEvent.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired before a principal is deleted in Polaris. + * + * @param principalName the name of the principal to be deleted + */ +public record BeforePrincipalDeleteEvent(String principalName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalGetEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalGetEvent.java new file mode 100644 index 0000000000..97da76154d --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalGetEvent.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +/** + * Event fired before a principal is retrieved in Polaris. + * + * @param principalName the name of the principal to be retrieved + */ +public record BeforePrincipalGetEvent(String principalName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRoleCreateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRoleCreateEvent.java new file mode 100644 index 0000000000..fa57954c12 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRoleCreateEvent.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.CreatePrincipalRoleRequest; + +/** + * Event fired before a principal role is created in Polaris. + * + * @param createPrincipalRoleRequest the principal role requested to be created + */ +public record BeforePrincipalRoleCreateEvent(CreatePrincipalRoleRequest createPrincipalRoleRequest) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRoleDeleteEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRoleDeleteEvent.java new file mode 100644 index 0000000000..cc066b743b --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRoleDeleteEvent.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.service.events; + +/** + * Event fired before a principal role is deleted in Polaris. + * + * @param principalRoleName the name of the principal role to be deleted + */ +public record BeforePrincipalRoleDeleteEvent(String principalRoleName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRoleGetEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRoleGetEvent.java new file mode 100644 index 0000000000..c6e126723e --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRoleGetEvent.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.service.events; + +/** + * Event fired before a principal role is retrieved in Polaris. + * + * @param principalRoleName the name of the principal role to be retrieved + */ +public record BeforePrincipalRoleGetEvent(String principalRoleName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRoleUpdateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRoleUpdateEvent.java new file mode 100644 index 0000000000..c51c82caaa --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRoleUpdateEvent.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.UpdatePrincipalRoleRequest; + +/** + * Event fired before a principal role is updated in Polaris. + * + * @param principalRoleName the name of the principal role to be updated + * @param updateRequest the update request object + */ +public record BeforePrincipalRoleUpdateEvent( + String principalRoleName, UpdatePrincipalRoleRequest updateRequest) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRolesAssignedListEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRolesAssignedListEvent.java new file mode 100644 index 0000000000..497624a63c --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRolesAssignedListEvent.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.service.events; + +/** + * Event fired before the list of principal roles assigned to a principal is retrieved in Polaris. + * + * @param principalName the name of the principal + */ +public record BeforePrincipalRolesAssignedListEvent(String principalName) implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRolesListEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRolesListEvent.java new file mode 100644 index 0000000000..ba2cc89cd1 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalRolesListEvent.java @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.service.events; + +/** Event fired before the list of principal roles is retrieved in Polaris. */ +public record BeforePrincipalRolesListEvent() implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalUpdateEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalUpdateEvent.java new file mode 100644 index 0000000000..e6f79d652d --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalUpdateEvent.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.UpdatePrincipalRequest; + +/** + * Event fired before a principal is updated in Polaris. + * + * @param principalName the name of the principal to be updated + * @param updateRequest the update request object + */ +public record BeforePrincipalUpdateEvent(String principalName, UpdatePrincipalRequest updateRequest) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalsListEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalsListEvent.java new file mode 100644 index 0000000000..539fe32534 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforePrincipalsListEvent.java @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.service.events; + +/** Event fired before the list of principals is retrieved in Polaris. */ +public record BeforePrincipalsListEvent() implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeRevokeGrantFromCatalogRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeRevokeGrantFromCatalogRoleEvent.java new file mode 100644 index 0000000000..f5476bd761 --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeRevokeGrantFromCatalogRoleEvent.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.service.events; + +import org.apache.polaris.core.admin.model.RevokeGrantRequest; + +/** + * Event fired before a grant is revoked from a catalog role in Polaris. + * + * @param catalogName the name of the catalog + * @param catalogRoleName the name of the catalog role + * @param grantRequest the revoke grant request + * @param cascade whether the revoke is cascading + */ +public record BeforeRevokeGrantFromCatalogRoleEvent( + String catalogName, String catalogRoleName, RevokeGrantRequest grantRequest, Boolean cascade) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/BeforeRevokePrincipalRoleEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/BeforeRevokePrincipalRoleEvent.java new file mode 100644 index 0000000000..3eab21354b --- /dev/null +++ b/service/common/src/main/java/org/apache/polaris/service/events/BeforeRevokePrincipalRoleEvent.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.service.events; + +/** + * Event fired before a principal role is revoked from a principal in Polaris. + * + * @param principalName the name of the principal + * @param principalRoleName the name of the principal role to be revoked + */ +public record BeforeRevokePrincipalRoleEvent(String principalName, String principalRoleName) + implements PolarisEvent {} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/PolarisEvent.java b/service/common/src/main/java/org/apache/polaris/service/events/PolarisEvent.java index 4922c02f4c..671ab9bf6f 100644 --- a/service/common/src/main/java/org/apache/polaris/service/events/PolarisEvent.java +++ b/service/common/src/main/java/org/apache/polaris/service/events/PolarisEvent.java @@ -18,8 +18,14 @@ */ package org.apache.polaris.service.events; +import java.util.UUID; + /** * Represents an event emitted by Polaris. Currently there's no common data across events so this is * just a marker interface. * */ -public interface PolarisEvent {} +public interface PolarisEvent { + static String createEventId() { + return UUID.randomUUID().toString(); + } +} diff --git a/service/common/src/main/java/org/apache/polaris/service/events/PolarisEventListener.java b/service/common/src/main/java/org/apache/polaris/service/events/PolarisEventListener.java index 485766bb24..b9c1f50ff9 100644 --- a/service/common/src/main/java/org/apache/polaris/service/events/PolarisEventListener.java +++ b/service/common/src/main/java/org/apache/polaris/service/events/PolarisEventListener.java @@ -55,4 +55,198 @@ public void onBeforeTaskAttempted(BeforeTaskAttemptedEvent event) {} /** {@link AfterTaskAttemptedEvent} */ public void onAfterTaskAttempted(AfterTaskAttemptedEvent event) {} + + /** {@link BeforeCatalogCreatedEvent} */ + public void onBeforeCatalogCreated(BeforeCatalogCreatedEvent event) {} + + /** {@link AfterCatalogCreatedEvent} */ + public void onAfterCatalogCreated(AfterCatalogCreatedEvent event) {} + + public void onBeforeCatalogDeleted(BeforeCatalogDeletedEvent event) {} + + public void onAfterCatalogDeleted(AfterCatalogDeletedEvent event) {} + + public void onBeforeCatalogGet(BeforeCatalogGetEvent event) {} + + public void onAfterCatalogGet(AfterCatalogGetEvent event) {} + + public void onBeforeCatalogUpdated(BeforeCatalogUpdatedEvent event) {} + + public void onAfterCatalogUpdated(AfterCatalogUpdatedEvent event) {} + + public void onBeforeCatalogList(BeforeCatalogListEvent event) {} + + public void onAfterCatalogList(AfterCatalogListEvent event) {} + + /** {@link BeforePrincipalCreateEvent} */ + public void onBeforePrincipalCreate(BeforePrincipalCreateEvent event) {} + + /** {@link AfterPrincipalCreateEvent} */ + public void onAfterPrincipalCreate(AfterPrincipalCreateEvent event) {} + + /** {@link BeforePrincipalDeleteEvent} */ + public void onBeforePrincipalDelete(BeforePrincipalDeleteEvent event) {} + + /** {@link AfterPrincipalDeleteEvent} */ + public void onAfterPrincipalDelete(AfterPrincipalDeleteEvent event) {} + + /** {@link BeforePrincipalGetEvent} */ + public void onBeforePrincipalGet(BeforePrincipalGetEvent event) {} + + /** {@link AfterPrincipalGetEvent} */ + public void onAfterPrincipalGet(AfterPrincipalGetEvent event) {} + + /** {@link BeforePrincipalUpdateEvent} */ + public void onBeforePrincipalUpdate(BeforePrincipalUpdateEvent event) {} + + /** {@link AfterPrincipalUpdateEvent} */ + public void onAfterPrincipalUpdate(AfterPrincipalUpdateEvent event) {} + + /** {@link BeforeCredentialsRotateEvent} */ + public void onBeforeCredentialsRotate(BeforeCredentialsRotateEvent event) {} + + /** {@link AfterCredentialsRotateEvent} */ + public void onAfterCredentialsRotate(AfterCredentialsRotateEvent event) {} + + /** {@link BeforePrincipalsListEvent} */ + public void onBeforePrincipalsList(BeforePrincipalsListEvent event) {} + + /** {@link AfterPrincipalsListEvent} */ + public void onAfterPrincipalsList(AfterPrincipalsListEvent event) {} + + /** {@link BeforePrincipalRoleCreateEvent} */ + public void onBeforePrincipalRoleCreate(BeforePrincipalRoleCreateEvent event) {} + + /** {@link AfterPrincipalRoleCreateEvent} */ + public void onAfterPrincipalRoleCreate(AfterPrincipalRoleCreateEvent event) {} + + /** {@link BeforePrincipalRoleDeleteEvent} */ + public void onBeforePrincipalRoleDelete(BeforePrincipalRoleDeleteEvent event) {} + + /** {@link AfterPrincipalRoleDeleteEvent} */ + public void onAfterPrincipalRoleDelete(AfterPrincipalRoleDeleteEvent event) {} + + /** {@link BeforePrincipalRoleGetEvent} */ + public void onBeforePrincipalRoleGet(BeforePrincipalRoleGetEvent event) {} + + /** {@link AfterPrincipalRoleGetEvent} */ + public void onAfterPrincipalRoleGet(AfterPrincipalRoleGetEvent event) {} + + /** {@link BeforePrincipalRoleUpdateEvent} */ + public void onBeforePrincipalRoleUpdate(BeforePrincipalRoleUpdateEvent event) {} + + /** {@link AfterPrincipalRoleUpdateEvent} */ + public void onAfterPrincipalRoleUpdate(AfterPrincipalRoleUpdateEvent event) {} + + /** {@link BeforePrincipalRolesListEvent} */ + public void onBeforePrincipalRolesList(BeforePrincipalRolesListEvent event) {} + + /** {@link AfterPrincipalRolesListEvent} */ + public void onAfterPrincipalRolesList(AfterPrincipalRolesListEvent event) {} + + /** {@link BeforeCatalogRoleCreateEvent} */ + public void onBeforeCatalogRoleCreate(BeforeCatalogRoleCreateEvent event) {} + + /** {@link AfterCatalogRoleCreateEvent} */ + public void onAfterCatalogRoleCreate(AfterCatalogRoleCreateEvent event) {} + + /** {@link BeforeCatalogRoleDeleteEvent} */ + public void onBeforeCatalogRoleDelete(BeforeCatalogRoleDeleteEvent event) {} + + /** {@link AfterCatalogRoleDeleteEvent} */ + public void onAfterCatalogRoleDelete(AfterCatalogRoleDeleteEvent event) {} + + /** {@link BeforeCatalogRoleGetEvent} */ + public void onBeforeCatalogRoleGet(BeforeCatalogRoleGetEvent event) {} + + /** {@link AfterCatalogRoleGetEvent} */ + public void onAfterCatalogRoleGet(AfterCatalogRoleGetEvent event) {} + + /** {@link BeforeCatalogRoleUpdateEvent} */ + public void onBeforeCatalogRoleUpdate(BeforeCatalogRoleUpdateEvent event) {} + + /** {@link AfterCatalogRoleUpdateEvent} */ + public void onAfterCatalogRoleUpdate(AfterCatalogRoleUpdateEvent event) {} + + /** {@link BeforeCatalogRolesListEvent} */ + public void onBeforeCatalogRolesList(BeforeCatalogRolesListEvent event) {} + + /** {@link AfterCatalogRolesListEvent} */ + public void onAfterCatalogRolesList(AfterCatalogRolesListEvent event) {} + + /** {@link BeforeAssignPrincipalRoleEvent} */ + public void onBeforeAssignPrincipalRole(BeforeAssignPrincipalRoleEvent event) {} + + /** {@link AfterAssignPrincipalRoleEvent} */ + public void onAfterAssignPrincipalRole(AfterAssignPrincipalRoleEvent event) {} + + /** {@link BeforeRevokePrincipalRoleEvent} */ + public void onBeforeRevokePrincipalRole(BeforeRevokePrincipalRoleEvent event) {} + + /** {@link AfterRevokePrincipalRoleEvent} */ + public void onAfterRevokePrincipalRole(AfterRevokePrincipalRoleEvent event) {} + + /** {@link BeforePrincipalRolesAssignedListEvent} */ + public void onBeforePrincipalRolesAssignedList(BeforePrincipalRolesAssignedListEvent event) {} + + /** {@link AfterPrincipalRolesAssignedListEvent} */ + public void onAfterPrincipalRolesAssignedList(AfterPrincipalRolesAssignedListEvent event) {} + + /** {@link BeforeCatalogRoleAssignToPrincipalRoleEvent} */ + public void onBeforeCatalogRoleAssignToPrincipalRole( + BeforeCatalogRoleAssignToPrincipalRoleEvent event) {} + + /** {@link AfterCatalogRoleAssignToPrincipalRoleEvent} */ + public void onAfterCatalogRoleAssignToPrincipalRole( + AfterCatalogRoleAssignToPrincipalRoleEvent event) {} + + /** {@link BeforeCatalogRoleRevokeFromPrincipalRoleEvent} */ + public void onBeforeCatalogRoleRevokeFromPrincipalRole( + BeforeCatalogRoleRevokeFromPrincipalRoleEvent event) {} + + /** {@link AfterCatalogRoleRevokeFromPrincipalRoleEvent} */ + public void onAfterCatalogRoleRevokeFromPrincipalRole( + AfterCatalogRoleRevokeFromPrincipalRoleEvent event) {} + + /** {@link BeforeListAssigneePrincipalsForPrincipalRoleEvent} */ + public void onBeforeListAssigneePrincipalsForPrincipalRole( + BeforeListAssigneePrincipalsForPrincipalRoleEvent event) {} + + /** {@link AfterListAssigneePrincipalsForPrincipalRoleEvent} */ + public void onAfterListAssigneePrincipalsForPrincipalRole( + AfterListAssigneePrincipalsForPrincipalRoleEvent event) {} + + /** {@link BeforeListCatalogRolesForPrincipalRoleEvent} */ + public void onBeforeListCatalogRolesForPrincipalRole( + BeforeListCatalogRolesForPrincipalRoleEvent event) {} + + /** {@link AfterListCatalogRolesForPrincipalRoleEvent} */ + public void onAfterListCatalogRolesForPrincipalRole( + AfterListCatalogRolesForPrincipalRoleEvent event) {} + + /** {@link BeforeAddGrantToCatalogRoleEvent} */ + public void onBeforeAddGrantToCatalogRole(BeforeAddGrantToCatalogRoleEvent event) {} + + /** {@link AfterAddGrantToCatalogRoleEvent} */ + public void onAfterAddGrantToCatalogRole(AfterAddGrantToCatalogRoleEvent event) {} + + /** {@link BeforeRevokeGrantFromCatalogRoleEvent} */ + public void onBeforeRevokeGrantFromCatalogRole(BeforeRevokeGrantFromCatalogRoleEvent event) {} + + /** {@link AfterRevokeGrantFromCatalogRoleEvent} */ + public void onAfterRevokeGrantFromCatalogRole(AfterRevokeGrantFromCatalogRoleEvent event) {} + + /** {@link BeforeListAssigneePrincipalRolesForCatalogRoleEvent} */ + public void onBeforeListAssigneePrincipalRolesForCatalogRole( + BeforeListAssigneePrincipalRolesForCatalogRoleEvent event) {} + + /** {@link AfterListAssigneePrincipalRolesForCatalogRoleEvent} */ + public void onAfterListAssigneePrincipalRolesForCatalogRole( + AfterListAssigneePrincipalRolesForCatalogRoleEvent event) {} + + /** {@link BeforeListGrantsForCatalogRoleEvent} */ + public void onBeforeListGrantsForCatalogRole(BeforeListGrantsForCatalogRoleEvent event) {} + + /** {@link AfterListGrantsForCatalogRoleEvent} */ + public void onAfterListGrantsForCatalogRole(AfterListGrantsForCatalogRoleEvent event) {} } diff --git a/service/common/src/test/java/org/apache/polaris/service/admin/PolarisServiceImplTest.java b/service/common/src/test/java/org/apache/polaris/service/admin/PolarisServiceImplTest.java index 75adb59f5b..e0a205eb45 100644 --- a/service/common/src/test/java/org/apache/polaris/service/admin/PolarisServiceImplTest.java +++ b/service/common/src/test/java/org/apache/polaris/service/admin/PolarisServiceImplTest.java @@ -40,6 +40,7 @@ import org.apache.polaris.core.persistence.resolver.ResolutionManifestFactory; import org.apache.polaris.core.secrets.UserSecretsManagerFactory; import org.apache.polaris.service.config.ReservedProperties; +import org.apache.polaris.service.events.NoOpPolarisEventListener; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -80,7 +81,8 @@ void setUp() { userSecretsManagerFactory, polarisAuthorizer, callContext, - reservedProperties); + reservedProperties, + new NoOpPolarisEventListener()); } @Test diff --git a/service/common/src/testFixtures/java/org/apache/polaris/service/TestServices.java b/service/common/src/testFixtures/java/org/apache/polaris/service/TestServices.java index 8bd031bfd7..2280bbcceb 100644 --- a/service/common/src/testFixtures/java/org/apache/polaris/service/TestServices.java +++ b/service/common/src/testFixtures/java/org/apache/polaris/service/TestServices.java @@ -277,7 +277,8 @@ public String getAuthenticationScheme() { userSecretsManagerFactory, authorizer, callContext, - reservedProperties)); + reservedProperties, + polarisEventListener)); return new TestServices( catalogsApi,