mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-07-25 18:30:00 +00:00
Added Webhook type filter in list api (#7221)
* added webhook type filter in list api * added webhook type filter in list api
This commit is contained in:
parent
cecd3ca342
commit
fe8fb625e2
@ -43,6 +43,7 @@ public class ListFilter {
|
||||
condition = addCondition(condition, getParentCondition(tableName));
|
||||
condition = addCondition(condition, getCategoryCondition(tableName));
|
||||
condition = addCondition(condition, getWebhookCondition(tableName));
|
||||
condition = addCondition(condition, getWebhookTypeCondition(tableName));
|
||||
return condition.isEmpty() ? "WHERE TRUE" : "WHERE " + condition;
|
||||
}
|
||||
|
||||
@ -82,12 +83,23 @@ public class ListFilter {
|
||||
return webhookStatus == null ? "" : getStatusPrefixCondition(tableName, escape(webhookStatus));
|
||||
}
|
||||
|
||||
public String getWebhookTypeCondition(String tableName) {
|
||||
String webhookType = queryParams.get("webhookType");
|
||||
return webhookType == null ? "" : getWebhookTypePrefixCondition(tableName, escape(webhookType));
|
||||
}
|
||||
|
||||
private String getFqnPrefixCondition(String tableName, String fqnPrefix) {
|
||||
return tableName == null
|
||||
? String.format("fullyQualifiedName LIKE '%s%s%%'", fqnPrefix, Entity.SEPARATOR)
|
||||
: String.format("%s.fullyQualifiedName LIKE '%s%s%%'", tableName, fqnPrefix, Entity.SEPARATOR);
|
||||
}
|
||||
|
||||
private String getWebhookTypePrefixCondition(String tableName, String typePrefix) {
|
||||
return tableName == null
|
||||
? String.format("webhookType LIKE '%s%%'", typePrefix)
|
||||
: String.format("%s.webhookType LIKE '%s%%'", tableName, typePrefix);
|
||||
}
|
||||
|
||||
private String getCategoryPrefixCondition(String tableName, String category) {
|
||||
return tableName == null
|
||||
? String.format("category LIKE '%s%s%%'", category, "")
|
||||
|
@ -120,6 +120,11 @@ public class WebhookResource extends EntityResource<Webhook, WebhookRepository>
|
||||
@Parameter(description = "Filter webhooks by status", schema = @Schema(type = "string", example = "active"))
|
||||
@QueryParam("status")
|
||||
String statusParam,
|
||||
@Parameter(
|
||||
description = "Filter webhooks by type",
|
||||
schema = @Schema(type = "string", example = "generic, slack, msteams"))
|
||||
@QueryParam("webhookType")
|
||||
String typeParam,
|
||||
@Parameter(description = "Limit the number webhooks returned. (1 to 1000000, default = " + "10) ")
|
||||
@DefaultValue("10")
|
||||
@Min(0)
|
||||
@ -139,7 +144,8 @@ public class WebhookResource extends EntityResource<Webhook, WebhookRepository>
|
||||
@DefaultValue("non-deleted")
|
||||
Include include)
|
||||
throws IOException {
|
||||
ListFilter filter = new ListFilter(Include.ALL).addQueryParam("status", statusParam);
|
||||
ListFilter filter =
|
||||
new ListFilter(Include.ALL).addQueryParam("status", statusParam).addQueryParam("webhookType", typeParam);
|
||||
return listInternal(uriInfo, securityContext, "", filter, limitParam, before, after);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user