问题描述
func getPrivateVlan(env string) (string, error) {
// 1. Create a session
sess := session.New(user, pass)
// 2. Get a service
accountService := services.GetAccountService(sess)
// 3. Invoke a method:
vlans, err := accountService.GetNetworkVlans()
vlan := vlans[0]
log.Println(*vlan.Name) //works
log.Println(*vlan.PrimaryRouter) //Doesn't work
}
返回的对象是类型为SoftLayer_Network_Vlan的vlan数组, https://sldn.softlayer .com/reference/datatypes/softlayer_network_vlan .我能够访问本地属性"列(即名称)中的属性,但无法访问关系和计数属性"列(即PrimaryRouter)中的属性.如何在调用中添加对象掩码以查看这些属性?
The object returned is an array of vlans of type SoftLayer_Network_Vlan, https://sldn.softlayer.com/reference/datatypes/softlayer_network_vlan.I am able to access the properties in column "Local Properties" (ie Name) but am unable to access the properties in column "Relational & Count Properties" (ie PrimaryRouter).How can I add an object mask to my call in order to see these properties?
推荐答案
source: Unable to get itemCategory info from call GetConfiguration when called from golang
F.Ojeda:默认端点是REST,但是在您的环境中,您使用的是xmlrpc,这可能是由于〜/.softlayer文件的存在,并且在此文件中将其配置为XMLRPC枚举.
F.Ojeda:The default endpoint is REST but in your environment you are using xmlrpc, which is probably due to the existence of the ~ / .softlayer file and in this it is configured as an XMLRPC enpoint.
有关更多信息,请参见以下文档: https://github.com/softlayer/softlayer -去
For more information you can see the following documentation: https://github.com/softlayer/softlayer-go
此问题发生在XMLRPC enpoint上,您可以在go GitHub中进行报告. https://github.com/softlayer/softlayer-go/issues/
This issue happens for the XMLRPC enpoint and you can report it in the go GitHub. https://github.com/softlayer/softlayer-go/issues/
使用REST端点尝试您的代码,例如以下示例:
Try in your code with the REST endpoint, like this example:
endpoint := "https://api.softlayer.com/rest/v3"
// Create a session
sess := session.New(username, apikey, endpoint)
这篇关于如何使用golang添加对象掩码以调用GetNetworkVlans的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!