我正在尝试获取SnapshotCapacityGb
关系数据类型。这是我所拥有的:
package main
import (
"fmt"
"github.com/softlayer/softlayer-go/session"
"github.com/softlayer/softlayer-go/services"
"github.com/softlayer/softlayer-go/filter"
"encoding/json"
)
func main() {
sess := session.New("XXXXXXXX", "XXXXXX")
accountService := services.GetAccountService(sess)
filters := filter.New(
filter.Path("networkStorage.id").Eq(39283541),
)
result, err := accountService.Mask("id;capacityGb;snapshotCapacityGb").Filter(filters.Build()).GetNetworkStorage()
fmt.Println(err)
// Following helps to print the result in json format.
jsonFormat, jsonErr := json.MarshalIndent(result,""," ")
if jsonErr != nil {
fmt.Println(jsonErr)
return
}
fmt.Println(string(jsonFormat))
}
但这会打印所有默认属性(id,capacityGB),并跳过关系数据类型(snapshotCapacityGb)。为什么看不到关系数据类型?
当我使用rest api时同样有效
https://{{sluser}}:{{slkey}}@api.softlayer.com/rest/v3.1/SoftLayer_Account/getNetworkStorage/39283541/getObject?objectMask=id;snapshotCapacityGb;capacityGb
我正在使用Ubuntu VERSION =“ 14.04.5 LTS,Trusty Tahr”
答案 0 :(得分:1)
某些网络存储设备没有快照,因此响应中不存在 snapshotCapacityGb 值,或者该值为空。由于您可以使用REST检索该值,因此go-client可能正在使用XML-RPC端点,因此我建议尝试使用REST端点:
endpoint := "https://api.softlayer.com/rest/v3"
sess := session.New(username, apikey, endpoint)