Implement filtering for APIs and tenants
diff --git a/api-gateway-config/scripts/lua/lib/utils.lua b/api-gateway-config/scripts/lua/lib/utils.lua
index e50f56b..0db0201 100644
--- a/api-gateway-config/scripts/lua/lib/utils.lua
+++ b/api-gateway-config/scripts/lua/lib/utils.lua
@@ -50,12 +50,12 @@
       first = false
     end
     if type(k) == 'string' then
-      tt[#tt+1] = concatStrings({tostring(k), ' = '})
+      tt[#tt+1] = _Utils.concatStrings({tostring(k), ' = '})
     end
     if type(v) == 'table' then
-      tt[#tt+1] = serializeTable(v)
+      tt[#tt+1] = _Utils.serializeTable(v)
     elseif type(v) == 'string' then
-      tt[#tt+1] = concatStrings({'"', tostring(v), '"'})
+      tt[#tt+1] = _Utils.concatStrings({'"', tostring(v), '"'})
     else
       tt[#tt+1] = tostring(v)
     end
diff --git a/api-gateway-config/scripts/lua/management/apis.lua b/api-gateway-config/scripts/lua/management/apis.lua
index 484e9a5..7144ac0 100644
--- a/api-gateway-config/scripts/lua/management/apis.lua
+++ b/api-gateway-config/scripts/lua/management/apis.lua
@@ -245,6 +245,7 @@
 -- GET /v1/apis
 function _M.getAPIs()
   local uri = string.gsub(ngx.var.request_uri, "?.*", "")
+  local queryParams = ngx.req.get_uri_args()
   local id
   local index = 1
   local tenantQuery = false
@@ -261,7 +262,7 @@
     index = index + 1
   end
   if id == nil then
-    getAllAPIs()
+    getAllAPIs(queryParams)
   else
     if tenantQuery == false then
       getAPI(id)
@@ -272,21 +273,53 @@
 end
 
 --- Get all APIs in redis
-function getAllAPIs()
+-- @param queryParams object containing optional query parameters
+function getAllAPIs(queryParams)
   local red = redis.init(REDIS_HOST, REDIS_PORT, REDIS_PASS, 10000)
-  local res = redis.getAllAPIs(red)
+  local apis = redis.getAllAPIs(red)
   redis.close(red)
-  local apiList = {}
-  for k, v in pairs(res) do
-    if k%2 == 0 then
-      apiList[#apiList+1] = cjson.decode(v)
-    end
+  local apiList
+  if next(queryParams) ~= nil then
+    apiList = filterAPIs(apis, queryParams);
   end
-  apiList = cjson.encode(apiList)
+  if apiList == nil then
+    apiList = {}
+    for k, v in pairs(apis) do
+      if k%2 == 0 then
+        apiList[#apiList+1] = cjson.decode(v)
+      end
+    end
+    apiList = cjson.encode(apiList)
+  end
   ngx.header.content_type = "application/json; charset=utf-8"
   request.success(200, apiList)
 end
 
+--- Filter APIs based on query parameters
+-- @param apis list of apis
+-- @param queryParams query parameters to filter tenants
+function filterAPIs(apis, queryParams)
+  local basePath = queryParams['filter[where][basePath]']
+  local name = queryParams['filter[where][name]']
+  -- missing or invalid query parameters
+  if (basePath == nil and name == nil) then
+    return nil
+  end
+  -- filter tenants
+  local apiList = {}
+  for k, v in pairs(apis) do
+    if k%2 == 0 then
+      local api = cjson.decode(v)
+      if (basePath ~= nil and name == nil and api.basePath == basePath) or
+              (name ~= nil and basePath == nil and api.name == name) or
+              (basePath ~= nil and name ~= nil and api.basePath == basePath and api.name == name) then
+        apiList[#apiList+1] = api
+      end
+    end
+  end
+  return cjson.encode(apiList)
+end
+
 --- Get API by its id
 -- @param id of API
 function getAPI(id)
diff --git a/api-gateway-config/scripts/lua/management/subscriptions.lua b/api-gateway-config/scripts/lua/management/subscriptions.lua
index 7c8e80f..e87af10 100644
--- a/api-gateway-config/scripts/lua/management/subscriptions.lua
+++ b/api-gateway-config/scripts/lua/management/subscriptions.lua
@@ -33,7 +33,7 @@
 local _M = {}
 
 --- Add an apikey/subscription to redis
--- PUT /subscriptions
+-- PUT /v1/subscriptions
 -- Body:
 -- {
 --    key: *(String) key for tenant/api/resource
@@ -54,7 +54,7 @@
 end
 
 --- Delete apikey/subscription from redis
--- DELETE /subscriptions
+-- DELETE /v1/subscriptions
 -- Body:
 -- {
 --    key: *(String) key for tenant/api/resource
diff --git a/api-gateway-config/scripts/lua/management/tenants.lua b/api-gateway-config/scripts/lua/management/tenants.lua
index bab2986..f2f798d 100644
--- a/api-gateway-config/scripts/lua/management/tenants.lua
+++ b/api-gateway-config/scripts/lua/management/tenants.lua
@@ -160,8 +160,8 @@
 -- @param tenants list of tenants
 -- @param queryParams query parameters to filter tenants
 function filterTenants(tenants, queryParams)
-  local namespace = queryParams.namespace
-  local instance = queryParams.instance
+  local namespace = queryParams['filter[where][namespace]']
+  local instance = queryParams['filter[where][instance]']
   -- missing or invalid query parameters
   if (namespace == nil and instance == nil) or (instance ~= nil and namespace == nil) then
     return nil
@@ -223,8 +223,8 @@
 --- Filter apis based on query paramters
 -- @param queryParams query parameters to filter apis
 function filterTenantAPIs(id, apis, queryParams)
-  local basePath = queryParams.basePath
-  local name = queryParams.name
+  local basePath = queryParams['filter[where][basePath]']
+  local name = queryParams['filter[where][name]']
   -- missing query parameters
   if (basePath == nil and name == nil)then
     return nil