mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-06-27 04:22:05 +00:00
Support followers for Database (#21169)
This commit is contained in:
parent
d4d1a16eaf
commit
829196f92b
@ -79,7 +79,7 @@ public class DatabaseResource extends EntityResource<Database, DatabaseRepositor
|
|||||||
public static final String COLLECTION_PATH = "v1/databases/";
|
public static final String COLLECTION_PATH = "v1/databases/";
|
||||||
private final DatabaseMapper mapper = new DatabaseMapper();
|
private final DatabaseMapper mapper = new DatabaseMapper();
|
||||||
static final String FIELDS =
|
static final String FIELDS =
|
||||||
"owners,databaseSchemas,usageSummary,location,tags,extension,domain,sourceHash";
|
"owners,databaseSchemas,usageSummary,location,tags,extension,domain,sourceHash,followers";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Database addHref(UriInfo uriInfo, Database db) {
|
public Database addHref(UriInfo uriInfo, Database db) {
|
||||||
@ -757,4 +757,65 @@ public class DatabaseResource extends EntityResource<Database, DatabaseRepositor
|
|||||||
Database database = repository.deleteDatabaseProfilerConfig(id);
|
Database database = repository.deleteDatabaseProfilerConfig(id);
|
||||||
return addHref(uriInfo, database);
|
return addHref(uriInfo, database);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("/{id}/followers")
|
||||||
|
@Operation(
|
||||||
|
operationId = "addFollowerToDatabase",
|
||||||
|
summary = "Add a follower",
|
||||||
|
description = "Add a user identified by `userId` as followed of this Database",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(
|
||||||
|
responseCode = "200",
|
||||||
|
description = "OK",
|
||||||
|
content =
|
||||||
|
@Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = ChangeEvent.class))),
|
||||||
|
@ApiResponse(responseCode = "404", description = "Database for instance {id} is not found")
|
||||||
|
})
|
||||||
|
public Response addFollower(
|
||||||
|
@Context UriInfo uriInfo,
|
||||||
|
@Context SecurityContext securityContext,
|
||||||
|
@Parameter(description = "Id of the Database", schema = @Schema(type = "UUID"))
|
||||||
|
@PathParam("id")
|
||||||
|
UUID id,
|
||||||
|
@Parameter(
|
||||||
|
description = "Id of the user to be added as follower",
|
||||||
|
schema = @Schema(type = "string"))
|
||||||
|
UUID userId) {
|
||||||
|
return repository
|
||||||
|
.addFollower(securityContext.getUserPrincipal().getName(), id, userId)
|
||||||
|
.toResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("/{id}/followers/{userId}")
|
||||||
|
@Operation(
|
||||||
|
operationId = "deleteFollower",
|
||||||
|
summary = "Remove a follower",
|
||||||
|
description = "Remove the user identified `userId` as a follower of the entity.",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(
|
||||||
|
responseCode = "200",
|
||||||
|
description = "OK",
|
||||||
|
content =
|
||||||
|
@Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = ChangeEvent.class)))
|
||||||
|
})
|
||||||
|
public Response deleteFollower(
|
||||||
|
@Context UriInfo uriInfo,
|
||||||
|
@Context SecurityContext securityContext,
|
||||||
|
@Parameter(description = "Id of the Entity", schema = @Schema(type = "UUID")) @PathParam("id")
|
||||||
|
UUID id,
|
||||||
|
@Parameter(
|
||||||
|
description = "Id of the user being removed as follower",
|
||||||
|
schema = @Schema(type = "string"))
|
||||||
|
@PathParam("userId")
|
||||||
|
String userId) {
|
||||||
|
return repository
|
||||||
|
.deleteFollower(securityContext.getUserPrincipal().getName(), id, UUID.fromString(userId))
|
||||||
|
.toResponse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ public class DatabaseResourceTest extends EntityResourceTest<Database, CreateDat
|
|||||||
database.getUsageSummary(),
|
database.getUsageSummary(),
|
||||||
database.getLocation());
|
database.getLocation());
|
||||||
|
|
||||||
fields = "owners,databaseSchemas,usageSummary,location,tags";
|
fields = "owners,databaseSchemas,usageSummary,location,tags,followers";
|
||||||
database =
|
database =
|
||||||
byName
|
byName
|
||||||
? getEntityByName(database.getFullyQualifiedName(), fields, ADMIN_AUTH_HEADERS)
|
? getEntityByName(database.getFullyQualifiedName(), fields, ADMIN_AUTH_HEADERS)
|
||||||
|
@ -128,6 +128,10 @@
|
|||||||
"certification": {
|
"certification": {
|
||||||
"$ref": "../../type/assetCertification.json"
|
"$ref": "../../type/assetCertification.json"
|
||||||
},
|
},
|
||||||
|
"followers": {
|
||||||
|
"description": "Followers of this entity.",
|
||||||
|
"$ref": "../../type/entityReferenceList.json"
|
||||||
|
},
|
||||||
"sourceHash": {
|
"sourceHash": {
|
||||||
"description": "Source hash of the entity",
|
"description": "Source hash of the entity",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -59,6 +59,10 @@ export interface Database {
|
|||||||
* Entity extension data with custom attributes added to the entity.
|
* Entity extension data with custom attributes added to the entity.
|
||||||
*/
|
*/
|
||||||
extension?: any;
|
extension?: any;
|
||||||
|
/**
|
||||||
|
* Followers of this entity.
|
||||||
|
*/
|
||||||
|
followers?: EntityReference[];
|
||||||
/**
|
/**
|
||||||
* Name that uniquely identifies a database in the format 'ServiceName.DatabaseName'.
|
* Name that uniquely identifies a database in the format 'ServiceName.DatabaseName'.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user