问题描述
当我将billingItemFlag添加到我的蒙版并进行过滤时,结果中缺少它.我正在使用来自 SoftLayer-go api .com/softlayer/softlayer-go"rel =" nofollow noreferrer> SoftLayer GitHub 帐户.我的过滤器或口罩错了吗?
When I add billingItemFlag to my mask and filter it is missing in the results. I am using the SoftLayer-go api from the SoftLayer GitHub account. Is my filter or mask wrong?
请考虑以下代码:
const mask string = "id;hostname;domain;billingItemFlag;billingItem"
var filters = filter.Build(
filter.Path("billingItemFlag").NotNull(),
filter.Path("billingItem").NotNull(),
)
accountService := services.GetAccountService(softlayerSession)
hardware, err := accountService.Filter(filters).Mask(mask).Limit(1).GetHardware()
if err != nil {
panic(err)
}
println(hardware[0].BillingItemFlag)
此代码的结果为"0x0",这是无效的内存地址.
The result of this code is "0x0" which is an invalid memory address.
启用调试后,我可以看到未返回字段,但返回了域,主机名和其他字段.
When I enable debugging I can see the fields are not being returned but domain, hostname, and others are.
2018/02/17 11:08:08 ->>>Request:
2018/02/17 11:08:08 POST /xmlrpc/v3.1/SoftLayer_Account HTTP/1.1
Host: api.softlayer.com
User-Agent: Go-http-client/1.1
Content-Length: 1875
Content-Type: text/xml
Accept-Encoding: gzip
<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>getHardware</methodName><params><param><value><struct><member><name>headers</name><value><struct><member><name>User-Agent</name><value><string>softlayer-go/v0.1.0-alpha (go1.9.2;amd64;darwin)</string></value></member><member><name>authenticate</name><value><struct><member><name>username</name><value><string>REMOVED</string></value></member><member><name>apiKey</name><value><string>REMOVED</string></value></member></struct></value></member><member><name>SoftLayer_AccountObjectMask</name><value><struct><member><name>mask</name><value><struct><member><name>hostname</name><value><array><data></data></array></value></member><member><name>domain</name><value><array><data></data></array></value></member><member><name>billingItemFlag</name><value><array><data></data></array></value></member><member><name>billingItem</name><value><struct><member><name>recurringFee</name><value><array><data></data></array></value></member></struct></value></member><member><name>id</name><value><array><data></data></array></value></member></struct></value></member></struct></value></member><member><name>SoftLayer_AccountObjectFilter</name><value><struct><member><name>billingItem</name><value><struct><member><name>operation</name><value><string>not null</string></value></member></struct></value></member><member><name>billingItemFlag</name><value><struct><member><name>operation</name><value><string>not null</string></value></member></struct></value></member></struct></value></member><member><name>resultLimit</name><value><struct><member><name>limit</name><value><int>1</int></value></member><member><name>offset</name><value><int>0</int></value></member></struct></value></member></struct></value></member></struct></value></param></params></methodCall>
2018/02/17 11:08:09
<<<-Response:
2018/02/17 11:08:09 HTTP/1.1 200 OK
Connection: close
Cache-Control: private
Content-Type: text/xml
Date: Sat, 17 Feb 2018 16:08:08 GMT
Ntcoent-Length: 3031
Server: Apache
Softlayer-Total-Items: 402
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<?xml version="1.0" encoding="utf-8"?>
<params>
<param>
<value>
<struct>
<member>
<name>accountId</name>
<value>
<int>REMOVED</int>
</value>
</member>
<member>
<name>bareMetalInstanceFlag</name>
<value>
<int>0</int>
</value>
</member>
<member>
<name>domain</name>
<value>
<string>REMOVED</string>
</value>
</member>
<member>
<name>fullyQualifiedDomainName</name>
<value>
<string>REMOVED</string>
</value>
</member>
<member>
<name>hardwareStatusId</name>
<value>
<int>5</int>
</value>
</member>
<member>
<name>hostname</name>
<value>
<string>REMOVED</string>
</value>
</member>
<member>
<name>id</name>
<value>
<int>REMOVED</int>
</value>
</member>
<member>
<name>manufacturerSerialNumber</name>
<value>
<string>REMOVED</string>
</value>
</member>
<member>
<name>notes</name>
<value>
<string/>
</value>
</member>
<member>
<name>provisionDate</name>
<value>
<stringREMOVED</string>
</value>
</member>
<member>
<name>serialNumber</name>
<value>
<string> REMOVED</string>
</value>
</member>
<member>
<name>serviceProviderId</name>
<value>
<int>1</int>
</value>
</member>
<member>
<name>serviceProviderResourceId</name>
<value>
<string/>
</value>
</member>
<member>
<name>globalIdentifier</name>
<value>
<string> REMOVED </string>
</value>
</member>
<member>
<name>networkManagementIpAddress</name>
<value>
<string>1 REMOVED 0</string>
</value>
</member>
<member>
<name>primaryBackendIpAddress</name>
<value>
<string> REMOVED 4</string>
</value>
</member>
<member>
<name>primaryIpAddress</name>
<value>
<string> REMOVED </string>
</value>
</member>
<member>
<name>privateIpAddress</name>
<value>
<string> REMOVED</string>
</value>
</member>
<member>
<name>hardwareFunction</name>
<value>
<struct>
<member>
<name>code</name>
<value>
<string>WEBSVR</string>
</value>
</member>
<member>
<name>description</name>
<value>
<string>Web Server</string>
</value>
</member>
<member>
<name>id</name>
<value>
<int>3</int>
</value>
</member>
</struct>
</value>
</member>
<member>
<name>hardwareStatus</name>
<value>
<struct>
<member>
<name>id</name>
<value>
<int>5</int>
</value>
</member>
<member>
<name>status</name>
<value>
<string>ACTIVE</string>
</value>
</member>
</struct>
</value>
</member>
</struct>
</value>
</param>
</params>
推荐答案
您发布的代码在使用默认终结点或任何其他REST终结点时可以工作. API似乎有问题,我建议切换到默认端点或使用:
The code you posted works when using the default endpoint or any other REST endpoint. It seems an issue from API, I recommend to switch to the default endpoint or use:
https://api.softlayer.com/rest/v3.1
这篇关于使用SoftLayer API时,遮罩和滤镜无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!