@@ -63,6 +63,14 @@ var mapRequireList = map[string]map[string]bool{
6363 },
6464}
6565
66+ // nestedResponse is a prefilled map with the list of endpoints
67+ // that responses fields are nested in a parent object. The map value
68+ // gives the object field name.
69+ var nestedResponse = map [string ]string {
70+ "getUploadParamsForTemplate" : "getuploadparams" ,
71+ "getUploadParamsForVolume" : "getuploadparams" ,
72+ }
73+
6674// We prefill this one value to make sure it is not
6775// created twice, as this is also a top level type.
6876var typeNames = map [string ]bool {"Nic" : true }
@@ -1479,10 +1487,21 @@ func (s *service) generateNewAPICallFunc(a *API) {
14791487 pn (" }" )
14801488 pn ("" )
14811489 }
1482- pn (" var r %s" , strings .TrimPrefix (n , "Configure" )+ "Response" )
1483- pn (" if err := json.Unmarshal(resp, &r); err != nil {" )
1484- pn (" return nil, err" )
1485- pn (" }" )
1490+
1491+ if field , isNested := nestedResponse [a .Name ]; isNested {
1492+ pn (" var nested struct {" )
1493+ pn (" Response %sResponse `json:\" %s\" `" , strings .TrimPrefix (n , "Configure" ), field )
1494+ pn (" }" )
1495+ pn (" if err := json.Unmarshal(resp, &nested); err != nil {" )
1496+ pn (" return nil, err" )
1497+ pn (" }" )
1498+ pn (" r := nested.Response" )
1499+ } else {
1500+ pn (" var r %sResponse" , strings .TrimPrefix (n , "Configure" ))
1501+ pn (" if err := json.Unmarshal(resp, &r); err != nil {" )
1502+ pn (" return nil, err" )
1503+ pn (" }" )
1504+ }
14861505 pn ("" )
14871506 if a .Isasync {
14881507 pn (" // If we have a async client, we need to wait for the async result" )
0 commit comments