Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions restapi/api_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,18 @@ func (obj *APIObject) readObject() error {

searchKey := obj.readSearch["search_key"]
searchValue := obj.readSearch["search_value"]
idAttribute := obj.readSearch["id_attribute"]
if idAttribute != "" {
obj.idAttribute = idAttribute
if obj.debug {
log.Printf("api_object.go: idAttribute set to '%s'", obj.idAttribute)
}
}

if searchKey != "" && searchValue != "" {

obj.searchPath = strings.Replace(obj.getPath, "{id}", obj.id, -1)
searchValue = strings.Replace(searchValue, "{id}", obj.id, -1)

queryString := obj.readSearch["query_string"]
if obj.queryString != "" {
Expand All @@ -388,6 +396,20 @@ func (obj *APIObject) readObject() error {
obj.id = ""
return nil
}
// Strip null values from the object if they are unset in the input data
for k, v := range objFound {
_, hasKey := obj.data[k]
if v == nil && !hasKey {
delete(objFound, k)
}
}
objectWrap := obj.readSearch["object_wrap"]
if objectWrap != "" {
if obj.debug {
log.Printf("api_object.go: Wrapping object in '%s'", objectWrap)
}
objFound = map[string]interface{}{objectWrap: objFound}
}
objFoundString, _ := json.Marshal(objFound)
return obj.updateState(string(objFoundString))
}
Expand Down
4 changes: 3 additions & 1 deletion restapi/delta_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ func _descendIgnoreList(descendPath string, ignoreList []string) []string {
newIgnoreList := make([]string, len(ignoreList))

for _, ignorePath := range ignoreList {
pathComponents := strings.Split(ignorePath, ".")
pathComponents := strings.FieldsFunc(ignorePath, func(r rune) bool {
return r == '.' || r == '/'
})
// If this ignorePath starts with the descendPath, remove the first component and keep the rest
if pathComponents[0] == descendPath {
modifiedPath := strings.Join(pathComponents[1:], ".")
Expand Down