命令#1
slcli call-api Account getUsers --mask=username,secondaryLoginRequiredFlag --filter 'users.secondaryLoginRequiredFlag!=True'
命令#2
slcli call-api Account getUsers --mask=username,successfulLogins.createDate,successfulLogins.ipAddres --filter 'users.successfulLogins.createDate>=2017-01-01T00:00:00-06:00'
答案 0 :(得分:1)
Currenlty使用SCLI的对象过滤器不完全支持它只适用于某些情况,例如:
slcli call-api Account getUsers --mask=username,secondaryLoginRequiredFlag --filter "users.username=sl307608-rcabero"
另一件事是它只适用于相同的情况,你可以在代码中验证:
https://github.com/softlayer/softlayer-python/blob/master/SoftLayer/CLI/call_api.py#L17-L19
因此,如果你真的需要objectFilters,最好的选择是使用python脚本,而不是使用scli:
有关详细信息,请参阅此文章:
https://sldn.softlayer.com/article/object-filters
您也可以在Softlayer Python客户端提交此问题:
https://github.com/softlayer/softlayer-python/issues
但我不确定他们会尽快解决。
这里是一个使用Python脚本的例子
import SoftLayer
# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
accountService = client['SoftLayer_Account']
# Filter the users whose secondaryLoginRequiredFlag = false
filterLoginFalse = {"users":{"secondaryLoginRequiredFlag":{"operation": "!= 1"}}}
# Filter the users whose secondaryLoginRequiredFlag = null
filterLoginNull = {"users":{"secondaryLoginRequiredFlag":{"operation": "is null"}}}
userLoginFalse = accountService.getUsers(filter=filterLoginFalse)
userLoginNull = accountService.getUsers(filter=filterLoginNull)
users = userLoginFalse + userLoginNull
print (users)
# Filter the users created betwern a derteminated date the date must have the following format mm/dd/YY
filterDate = {"users":{"createDate":{"operation":"betweenDate","options":[{"name":"startDate","value":["2/4/2014 00:00:00"]},{"name":"endDate","value":["2/4/2014 10:40:00"]}]}}}
users = accountService.getUsers(filter=filterDate)
print (users)
此致