如何将对象过滤器与 softlayer rest api 一起使用?

How to use object filter with softlayer rest api?

我读了this article and have some problems trying to follow the examples. The following is one of the examples given in that article. The first parameter in the object filter is virtualGuests. This object filter can be used in api https://api.softlayer.com/rest/v3/SoftLayer_Account/VirtualGuests

object_filter = {
'virtualGuests': {
    'datacenter': {
        'name': {'operation': 'dal05'}
        }
    }
}

我想在其他 api 方法中使用对象过滤器,例如 SoftLayer_Account/getBlockDeviceTemplateGroups。我的问题是如何 get/set 像 virtualGuests 这样的第一个参数?我尝试了几次但都失败了。

尝试遵循这些建议:通过服务数据类型获取第一个参数如何以简单的方式定义第一个参数?


通过服务数据类型获取第一个参数

您正在努力获得

如您所见,您正在使用SoftLayer_Account服务,您需要从该服务中打开其数据类型:

所以,你需要从这里开始,你使用的方法是getBlockDeviceTemplateGroups,如果你想在数据类型中获取这些信息,你应该跳过单词“get”并寻找“BlockDeviceTemplateGroups”属性,因此您将拥有需要首先设置的正确参数。


第一个参数如何简单定义?

如果您注意到,唯一的变化是:从方法中跳过“get”这个词,在本例中是“getBlockDeviceTemplateGroups” ,所以它将是:

"BlockDeviceTemplateGroups"

下一步应该将第一个字符设置为小写,如:

"blockDeviceTemplateGroups"

所以,应该是过滤器:

object_filter = {
'blockDeviceTemplateGroups': {
    'datacenter': {
        'name': {'operation': 'dal05'}
        }
    }
}

参考文献: