快照容量未由softlayer-go对象掩码获取

时间:2018-08-22 10:13:22

标签: ibm-cloud-infrastructure

我正在尝试获取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”

1 个答案:

答案 0 :(得分:1)

某些网络存储设备没有快照,因此响应中不存在 snapshotCapacityGb 值,或者该值为空。由于您可以使用REST检索该值,因此go-client可能正在使用XML-RPC端点,因此我建议尝试使用REST端点:

endpoint := "https://api.softlayer.com/rest/v3"

sess := session.New(username, apikey, endpoint)