Update ApiGw route filters

It adds filter for method, endpoint which was renamed from query, and fixes route filter which filters by ID.
This commit is contained in:
Vivek Patel
2022-10-12 17:18:06 +05:30
parent 0996f80dbe
commit 99da9719de
4 changed files with 20 additions and 11 deletions
+10 -4
View File
@@ -226,10 +226,16 @@ func ApigwRouteFilter(f systemType.ApigwRouteFilter) (ee []goqu.Expression, _ sy
ee = append(ee, expr)
}
if f.Query != "" {
ee = append(ee, goqu.Or(
goqu.C("endpoint").ILike("%"+f.Query+"%"),
))
if val := strings.TrimSpace(f.Route); len(val) > 0 {
ee = append(ee, goqu.C("id").Eq(f.Route))
}
if val := strings.TrimSpace(f.Endpoint); len(val) > 0 {
ee = append(ee, goqu.C("endpoint").Eq(f.Endpoint))
}
if val := strings.TrimSpace(f.Method); len(val) > 0 {
ee = append(ee, goqu.C("method").Eq(f.Method))
}
return ee, f, err
+4 -3
View File
@@ -55,14 +55,15 @@ apigw_route: {
filter: {
struct: {
route: {}
query: {goType: "string"}
route: {goType: "string", storeIdent: "id"}
endpoint: {goType: "string"}
method: {goType: "string"}
deleted: {goType: "filter.State", storeIdent: "deleted_at"}
disabled: {goType: "filter.State", storeIdent: "enabled"}
}
query: ["endpoint"]
byValue: ["route", "endpoint", "method"]
byNilState: ["deleted"]
byFalseState: ["disabled"]
}
+3 -2
View File
@@ -58,8 +58,9 @@ func (ctrl *ApigwRoute) List(ctx context.Context, r *request.ApigwRouteList) (in
var (
err error
f = types.ApigwRouteFilter{
Query: r.Query,
Deleted: filter.State(r.Deleted),
// todo: this should renamed to r.Endpoint after UI is aligned with this
Endpoint: r.Query,
Deleted: filter.State(r.Deleted),
// todo: this should dynamic as Delete
// but making it default to `1`, until UI is aligned with this
+3 -2
View File
@@ -32,8 +32,9 @@ type (
}
ApigwRouteFilter struct {
Route string `json:"route"`
Query string `json:"query"`
Route string `json:"route"`
Endpoint string `json:"endpoint"`
Method string `json:"method"`
Deleted filter.State `json:"deleted"`
Disabled filter.State `json:"disabled"`