Skip to content

Commit 8314fdf

Browse files
Adds followers to services and database schema (#21017)
* Adds followers to services and database schema * Add delete and followers fields * Add missing fields * Fix failing test for get entity with different fields * Fix ingestion test case failure
1 parent 7cd798b commit 8314fdf

45 files changed

Lines changed: 833 additions & 37 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/DatabaseSchemaResource.java

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public class DatabaseSchemaResource
7777
extends EntityResource<DatabaseSchema, DatabaseSchemaRepository> {
7878
private final DatabaseSchemaMapper mapper = new DatabaseSchemaMapper();
7979
public static final String COLLECTION_PATH = "v1/databaseSchemas/";
80-
static final String FIELDS = "owners,tables,usageSummary,tags,extension,domain,sourceHash";
80+
static final String FIELDS =
81+
"owners,tables,usageSummary,tags,extension,domain,sourceHash,followers";
8182

8283
@Override
8384
public DatabaseSchema addHref(UriInfo uriInfo, DatabaseSchema schema) {
@@ -315,6 +316,69 @@ public Response create(
315316
return create(uriInfo, securityContext, schema);
316317
}
317318

319+
@PUT
320+
@Path("/{id}/followers")
321+
@Operation(
322+
operationId = "addFollowerToDatabaseSchema",
323+
summary = "Add a follower",
324+
description = "Add a user identified by `userId` as followed of this Database Schema",
325+
responses = {
326+
@ApiResponse(
327+
responseCode = "200",
328+
description = "OK",
329+
content =
330+
@Content(
331+
mediaType = "application/json",
332+
schema = @Schema(implementation = ChangeEvent.class))),
333+
@ApiResponse(
334+
responseCode = "404",
335+
description = "Dashboard Service for instance {id} is not found")
336+
})
337+
public Response addFollower(
338+
@Context UriInfo uriInfo,
339+
@Context SecurityContext securityContext,
340+
@Parameter(description = "Id of the Database Schema", schema = @Schema(type = "UUID"))
341+
@PathParam("id")
342+
UUID id,
343+
@Parameter(
344+
description = "Id of the user to be added as follower",
345+
schema = @Schema(type = "string"))
346+
UUID userId) {
347+
return repository
348+
.addFollower(securityContext.getUserPrincipal().getName(), id, userId)
349+
.toResponse();
350+
}
351+
352+
@DELETE
353+
@Path("/{id}/followers/{userId}")
354+
@Operation(
355+
operationId = "deleteFollower",
356+
summary = "Remove a follower",
357+
description = "Remove the user identified `userId` as a follower of the entity.",
358+
responses = {
359+
@ApiResponse(
360+
responseCode = "200",
361+
description = "OK",
362+
content =
363+
@Content(
364+
mediaType = "application/json",
365+
schema = @Schema(implementation = ChangeEvent.class)))
366+
})
367+
public Response deleteFollower(
368+
@Context UriInfo uriInfo,
369+
@Context SecurityContext securityContext,
370+
@Parameter(description = "Id of the Entity", schema = @Schema(type = "UUID")) @PathParam("id")
371+
UUID id,
372+
@Parameter(
373+
description = "Id of the user being removed as follower",
374+
schema = @Schema(type = "string"))
375+
@PathParam("userId")
376+
String userId) {
377+
return repository
378+
.deleteFollower(securityContext.getUserPrincipal().getName(), id, UUID.fromString(userId))
379+
.toResponse();
380+
}
381+
318382
@PATCH
319383
@Path("/{id}")
320384
@Operation(

openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/TableResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ public Table deleteColumnCustomMetric(
12941294
@Operation(
12951295
operationId = "deleteFollower",
12961296
summary = "Remove a follower",
1297-
description = "Remove the user identified `userId` as a follower of the table.",
1297+
description = "Remove the user identified `userId` as a follower of the entity.",
12981298
responses = {
12991299
@ApiResponse(
13001300
responseCode = "200",
@@ -1307,7 +1307,7 @@ public Table deleteColumnCustomMetric(
13071307
public Response deleteFollower(
13081308
@Context UriInfo uriInfo,
13091309
@Context SecurityContext securityContext,
1310-
@Parameter(description = "Id of the table", schema = @Schema(type = "UUID")) @PathParam("id")
1310+
@Parameter(description = "Id of the Entity", schema = @Schema(type = "UUID")) @PathParam("id")
13111311
UUID id,
13121312
@Parameter(
13131313
description = "Id of the user being removed as follower",

openmetadata-service/src/main/java/org/openmetadata/service/resources/services/apiservices/APIServiceResource.java

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.openmetadata.schema.entity.services.ServiceType;
5353
import org.openmetadata.schema.entity.services.connections.TestConnectionResult;
5454
import org.openmetadata.schema.type.ApiConnection;
55+
import org.openmetadata.schema.type.ChangeEvent;
5556
import org.openmetadata.schema.type.EntityHistory;
5657
import org.openmetadata.schema.type.Include;
5758
import org.openmetadata.schema.type.MetadataOperation;
@@ -78,7 +79,7 @@ public class APIServiceResource
7879
extends ServiceEntityResource<ApiService, APIServiceRepository, ApiConnection> {
7980
private final APIServiceMapper mapper = new APIServiceMapper();
8081
public static final String COLLECTION_PATH = "v1/services/apiServices/";
81-
static final String FIELDS = "pipelines,owners,tags,domain";
82+
public static final String FIELDS = "pipelines,owners,tags,domain,followers";
8283

8384
@Override
8485
public ApiService addHref(UriInfo uriInfo, ApiService service) {
@@ -524,6 +525,69 @@ public Response delete(
524525
uriInfo, securityContext, EntityInterfaceUtil.quoteName(fqn), recursive, hardDelete);
525526
}
526527

528+
@PUT
529+
@Path("/{id}/followers")
530+
@Operation(
531+
operationId = "addFollowerToApiService",
532+
summary = "Add a follower",
533+
description = "Add a user identified by `userId` as followed of this api service",
534+
responses = {
535+
@ApiResponse(
536+
responseCode = "200",
537+
description = "OK",
538+
content =
539+
@Content(
540+
mediaType = "application/json",
541+
schema = @Schema(implementation = ChangeEvent.class))),
542+
@ApiResponse(
543+
responseCode = "404",
544+
description = "Api Service for instance {id} is not found")
545+
})
546+
public Response addFollower(
547+
@Context UriInfo uriInfo,
548+
@Context SecurityContext securityContext,
549+
@Parameter(description = "Id of the Api Service", schema = @Schema(type = "UUID"))
550+
@PathParam("id")
551+
UUID id,
552+
@Parameter(
553+
description = "Id of the user to be added as follower",
554+
schema = @Schema(type = "string"))
555+
UUID userId) {
556+
return repository
557+
.addFollower(securityContext.getUserPrincipal().getName(), id, userId)
558+
.toResponse();
559+
}
560+
561+
@DELETE
562+
@Path("/{id}/followers/{userId}")
563+
@Operation(
564+
operationId = "deleteFollower",
565+
summary = "Remove a follower",
566+
description = "Remove the user identified `userId` as a follower of the entity.",
567+
responses = {
568+
@ApiResponse(
569+
responseCode = "200",
570+
description = "OK",
571+
content =
572+
@Content(
573+
mediaType = "application/json",
574+
schema = @Schema(implementation = ChangeEvent.class)))
575+
})
576+
public Response deleteFollower(
577+
@Context UriInfo uriInfo,
578+
@Context SecurityContext securityContext,
579+
@Parameter(description = "Id of the Entity", schema = @Schema(type = "UUID")) @PathParam("id")
580+
UUID id,
581+
@Parameter(
582+
description = "Id of the user being removed as follower",
583+
schema = @Schema(type = "string"))
584+
@PathParam("userId")
585+
String userId) {
586+
return repository
587+
.deleteFollower(securityContext.getUserPrincipal().getName(), id, UUID.fromString(userId))
588+
.toResponse();
589+
}
590+
527591
@PUT
528592
@Path("/restore")
529593
@Operation(

openmetadata-service/src/main/java/org/openmetadata/service/resources/services/dashboard/DashboardServiceResource.java

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.openmetadata.schema.entity.services.DashboardService;
5151
import org.openmetadata.schema.entity.services.ServiceType;
5252
import org.openmetadata.schema.entity.services.connections.TestConnectionResult;
53+
import org.openmetadata.schema.type.ChangeEvent;
5354
import org.openmetadata.schema.type.DashboardConnection;
5455
import org.openmetadata.schema.type.EntityHistory;
5556
import org.openmetadata.schema.type.Include;
@@ -74,7 +75,7 @@ public class DashboardServiceResource
7475
DashboardService, DashboardServiceRepository, DashboardConnection> {
7576
private final DashboardServiceMapper mapper = new DashboardServiceMapper();
7677
public static final String COLLECTION_PATH = "v1/services/dashboardServices";
77-
static final String FIELDS = "owners,domain";
78+
public static final String FIELDS = "owners,domain,followers";
7879

7980
public DashboardServiceResource(Authorizer authorizer, Limits limits) {
8081
super(Entity.DASHBOARD_SERVICE, authorizer, limits, ServiceType.DASHBOARD);
@@ -173,6 +174,69 @@ public DashboardService get(
173174
return decryptOrNullify(securityContext, dashboardService);
174175
}
175176

177+
@PUT
178+
@Path("/{id}/followers")
179+
@Operation(
180+
operationId = "addFollowerToDashboardService",
181+
summary = "Add a follower",
182+
description = "Add a user identified by `userId` as followed of this Dashboard service",
183+
responses = {
184+
@ApiResponse(
185+
responseCode = "200",
186+
description = "OK",
187+
content =
188+
@Content(
189+
mediaType = "application/json",
190+
schema = @Schema(implementation = ChangeEvent.class))),
191+
@ApiResponse(
192+
responseCode = "404",
193+
description = "Dashboard Service for instance {id} is not found")
194+
})
195+
public Response addFollower(
196+
@Context UriInfo uriInfo,
197+
@Context SecurityContext securityContext,
198+
@Parameter(description = "Id of the Dashboard Service", schema = @Schema(type = "UUID"))
199+
@PathParam("id")
200+
UUID id,
201+
@Parameter(
202+
description = "Id of the user to be added as follower",
203+
schema = @Schema(type = "string"))
204+
UUID userId) {
205+
return repository
206+
.addFollower(securityContext.getUserPrincipal().getName(), id, userId)
207+
.toResponse();
208+
}
209+
210+
@DELETE
211+
@Path("/{id}/followers/{userId}")
212+
@Operation(
213+
operationId = "deleteFollower",
214+
summary = "Remove a follower",
215+
description = "Remove the user identified `userId` as a follower of the entity.",
216+
responses = {
217+
@ApiResponse(
218+
responseCode = "200",
219+
description = "OK",
220+
content =
221+
@Content(
222+
mediaType = "application/json",
223+
schema = @Schema(implementation = ChangeEvent.class)))
224+
})
225+
public Response deleteFollower(
226+
@Context UriInfo uriInfo,
227+
@Context SecurityContext securityContext,
228+
@Parameter(description = "Id of the Entity", schema = @Schema(type = "UUID")) @PathParam("id")
229+
UUID id,
230+
@Parameter(
231+
description = "Id of the user being removed as follower",
232+
schema = @Schema(type = "string"))
233+
@PathParam("userId")
234+
String userId) {
235+
return repository
236+
.deleteFollower(securityContext.getUserPrincipal().getName(), id, UUID.fromString(userId))
237+
.toResponse();
238+
}
239+
176240
@GET
177241
@Path("/name/{name}")
178242
@Operation(

openmetadata-service/src/main/java/org/openmetadata/service/resources/services/database/DatabaseServiceResource.java

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.openmetadata.schema.entity.services.DatabaseService;
5454
import org.openmetadata.schema.entity.services.ServiceType;
5555
import org.openmetadata.schema.entity.services.connections.TestConnectionResult;
56+
import org.openmetadata.schema.type.ChangeEvent;
5657
import org.openmetadata.schema.type.EntityHistory;
5758
import org.openmetadata.schema.type.Include;
5859
import org.openmetadata.schema.type.MetadataOperation;
@@ -82,7 +83,7 @@ public class DatabaseServiceResource
8283
extends ServiceEntityResource<DatabaseService, DatabaseServiceRepository, DatabaseConnection> {
8384
private final DatabaseServiceMapper mapper = new DatabaseServiceMapper();
8485
public static final String COLLECTION_PATH = "v1/services/databaseServices/";
85-
static final String FIELDS = "pipelines,owners,tags,domain";
86+
public static final String FIELDS = "pipelines,owners,tags,domain,followers";
8687

8788
@Override
8889
public DatabaseService addHref(UriInfo uriInfo, DatabaseService service) {
@@ -386,6 +387,69 @@ public Response createOrUpdate(
386387
return response;
387388
}
388389

390+
@PUT
391+
@Path("/{id}/followers")
392+
@Operation(
393+
operationId = "addFollowerToDatabaseService",
394+
summary = "Add a follower",
395+
description = "Add a user identified by `userId` as followed of this database service",
396+
responses = {
397+
@ApiResponse(
398+
responseCode = "200",
399+
description = "OK",
400+
content =
401+
@Content(
402+
mediaType = "application/json",
403+
schema = @Schema(implementation = ChangeEvent.class))),
404+
@ApiResponse(
405+
responseCode = "404",
406+
description = "Database Service for instance {id} is not found")
407+
})
408+
public Response addFollower(
409+
@Context UriInfo uriInfo,
410+
@Context SecurityContext securityContext,
411+
@Parameter(description = "Id of the Database Service", schema = @Schema(type = "UUID"))
412+
@PathParam("id")
413+
UUID id,
414+
@Parameter(
415+
description = "Id of the user to be added as follower",
416+
schema = @Schema(type = "string"))
417+
UUID userId) {
418+
return repository
419+
.addFollower(securityContext.getUserPrincipal().getName(), id, userId)
420+
.toResponse();
421+
}
422+
423+
@DELETE
424+
@Path("/{id}/followers/{userId}")
425+
@Operation(
426+
operationId = "deleteFollower",
427+
summary = "Remove a follower",
428+
description = "Remove the user identified `userId` as a follower of the entity.",
429+
responses = {
430+
@ApiResponse(
431+
responseCode = "200",
432+
description = "OK",
433+
content =
434+
@Content(
435+
mediaType = "application/json",
436+
schema = @Schema(implementation = ChangeEvent.class)))
437+
})
438+
public Response deleteFollower(
439+
@Context UriInfo uriInfo,
440+
@Context SecurityContext securityContext,
441+
@Parameter(description = "Id of the Entity", schema = @Schema(type = "UUID")) @PathParam("id")
442+
UUID id,
443+
@Parameter(
444+
description = "Id of the user being removed as follower",
445+
schema = @Schema(type = "string"))
446+
@PathParam("userId")
447+
String userId) {
448+
return repository
449+
.deleteFollower(securityContext.getUserPrincipal().getName(), id, UUID.fromString(userId))
450+
.toResponse();
451+
}
452+
389453
@PATCH
390454
@Path("/{id}")
391455
@Operation(

0 commit comments

Comments
 (0)