Only supply "rules" if at least one rule is present.
diff --git a/openstack/cdn/v1/services/results.go b/openstack/cdn/v1/services/results.go
index 18d4fc1..7d6878c 100644
--- a/openstack/cdn/v1/services/results.go
+++ b/openstack/cdn/v1/services/results.go
@@ -57,11 +57,13 @@
r["origin"] = o.Origin
r["port"] = o.Port
r["ssl"] = o.SSL
- r["rules"] = make([]map[string]interface{}, len(o.Rules))
- for index, rule := range o.Rules {
- submap := r["rules"].([]map[string]interface{})[index]
- submap["name"] = rule.Name
- submap["request_url"] = rule.RequestURL
+ if len(o.Rules) > 0 {
+ r["rules"] = make([]map[string]interface{}, len(o.Rules))
+ for index, rule := range o.Rules {
+ submap := r["rules"].([]map[string]interface{})[index]
+ submap["name"] = rule.Name
+ submap["request_url"] = rule.RequestURL
+ }
}
return r
}