You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2018/04/25 14:57:09 UTC
[cloudstack-cloudmonkey] 01/06: cache: add API response keys in API
cache for filter options
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack-cloudmonkey.git
commit 1a06716e10b732f0c28b38535fe57a33f021653b
Author: Rohit Yadav <ro...@apache.org>
AuthorDate: Sun Apr 22 20:57:19 2018 +0530
cache: add API response keys in API cache for filter options
Signed-off-by: Rohit Yadav <ro...@apache.org>
---
config/cache.go | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/config/cache.go b/config/cache.go
index a037a95..8fc9089 100644
--- a/config/cache.go
+++ b/config/cache.go
@@ -26,6 +26,8 @@ import (
"unicode"
)
+const FAKE = "fake"
+
// APIArg are the args passable to an API
type APIArg struct {
Name string
@@ -46,7 +48,7 @@ type API struct {
Related []string
Async bool
Description string
- ResponseName string
+ ResponseKeys []string
}
var apiCache map[string]*API
@@ -138,10 +140,24 @@ func (c *Config) UpdateCache(response map[string]interface{}) interface{} {
})
}
+ // Add filter arg
+ apiArgs = append(apiArgs, &APIArg{
+ Name: "filter=",
+ Type: FAKE,
+ Description: "cloudmonkey specific response key filtering",
+ })
+
sort.Slice(apiArgs, func(i, j int) bool {
return apiArgs[i].Name < apiArgs[j].Name
})
+ var responseKeys []string
+ for _, respNode := range api["response"].([]interface{}) {
+ if resp, ok := respNode.(map[string]interface{}); ok {
+ responseKeys = append(responseKeys, fmt.Sprintf("%v,", resp["name"]))
+ }
+ }
+
var requiredArgs []string
for _, arg := range apiArgs {
if arg.Required {
@@ -157,6 +173,7 @@ func (c *Config) UpdateCache(response map[string]interface{}) interface{} {
RequiredArgs: requiredArgs,
Async: isAsync,
Description: description,
+ ResponseKeys: responseKeys,
}
}
return count
--
To stop receiving notification emails like this one, please contact
rohit@apache.org.