diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/AppRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/AppRepository.java index e5ea4bf5341..c636a869133 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/AppRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/AppRepository.java @@ -140,6 +140,10 @@ public class AppRepository extends EntityRepository { return null; } + public List listAllAppsReference() { + return daoCollection.applicationDAO().listAppsRef(); + } + @Override public void storeEntity(App entity, boolean update) { List ownerRefs = entity.getOwners(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java index 4c7022f06cc..1d7a94ccee1 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java @@ -16,6 +16,7 @@ package org.openmetadata.service.jdbi3; import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty; import static org.openmetadata.schema.type.Relationship.CONTAINS; import static org.openmetadata.schema.type.Relationship.MENTIONED_IN; +import static org.openmetadata.service.Entity.APPLICATION; import static org.openmetadata.service.Entity.GLOSSARY_TERM; import static org.openmetadata.service.Entity.ORGANIZATION_NAME; import static org.openmetadata.service.Entity.QUERY; @@ -2583,6 +2584,22 @@ public interface CollectionDAO { default Class getEntityClass() { return App.class; } + + @SqlQuery("SELECT id, name from installed_apps") + @RegisterRowMapper(AppEntityReferenceMapper.class) + List listAppsRef(); + + class AppEntityReferenceMapper implements RowMapper { + @Override + public EntityReference map(ResultSet rs, StatementContext ctx) throws SQLException { + String fqn = rs.getString("name"); + return new EntityReference() + .withId(UUID.fromString(rs.getString("id"))) + .withName(fqn) + .withFullyQualifiedName(fqn) + .withType(APPLICATION); + } + } } interface ApplicationMarketPlaceDAO extends EntityDAO { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/apps/AppResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/apps/AppResource.java index 3887c7de2f3..1a73adaf9ab 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/apps/AppResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/apps/AppResource.java @@ -170,6 +170,10 @@ public class AppResource extends EntityResource { /* Required for serde */ } + public static class AppRefList extends ResultList { + /* Required for serde */ + } + public static class AppRunList extends ResultList { /* Required for serde */ } @@ -239,6 +243,26 @@ public class AppResource extends EntityResource { uriInfo, securityContext, fieldsParam, filter, limitParam, before, after); } + @GET + @Path("/installed") + @Operation( + operationId = "listInstalledAppsInformation", + summary = "List Entity Reference for installed application", + description = "Get a list of applications ", + responses = { + @ApiResponse( + responseCode = "200", + description = "List of Installed Applications Entity Reference", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = AppRefList.class))) + }) + public List list( + @Context UriInfo uriInfo, @Context SecurityContext securityContext) { + return repository.listAllAppsReference(); + } + @GET @Path("/name/{name}/status") @Operation(