IBM Cloud CLI Softlayer 插件:如何传递过滤器?

IBM Cloud CLI Softlayer plugin: How to pass filters?

我正在使用 Softlayer commands in the IBM Cloud CLI to manager classic infrastructure. Following the documentation about the Softlayer API 我想针对特定数据中心及其区域进行过滤。

一般情况下,命令允许传入以下参数:

OPTIONS:
   --init value        Init parameter (default: 0)
   --mask value        Object mask: use to limit fields returned
   --parameters value  Append parameters to web call
   --limit value       Result limit (default: 0)
   --offset value      Result offset (default: 0)

所以我正在尝试使用 --parameterspply a filter like shown here

以下是返回所有对象,不过滤。其他变体也不起作用:

ibmcloud sl call-api SoftLayer_Location_Group getAllObjects --parameters 'object_filter={"locationGroupTypeId":1}'

如何使用 IBM Cloud CLI 命令将过滤器应用于 API 调用?

ibmcloud cli 似乎不支持对象过滤器。

我建议您尝试使用 slcli:

使用以下 slcli 命令查看对象过滤器选项:

slcli call-api --help

输出:

Usage: slcli call-api [OPTIONS] SERVICE METHOD [PARAMETERS]...

  Call arbitrary API endpoints with the given SERVICE and METHOD.

  Example::

      slcli call-api Account getObject     slcli call-api Account getVirtualGuests --limit=10 --mask=id,hostname
      slcli call-api Virtual_Guest getObject --id=12345     slcli call-api Metric_Tracking_Object getBandwidthData
      --id=1234 \         "2015-01-01 00:00:00" "2015-01-1 12:00:00" public     slcli call-api Account
      getVirtualGuests \         -f 'virtualGuests.datacenter.name=dal05' \         -f 'virtualGuests.maxCpu=4' \
      --mask=id,hostname,datacenter.name,maxCpu     slcli call-api Account getVirtualGuests \         -f
      'virtualGuests.datacenter.name IN dal05,sng01'

Options:
  --id TEXT                       Init parameter
  -f, --filter TEXT               Object filters. This should be of the form: 'property=value' or
                                  'nested.property=value'. Complex filters like betweenDate are not currently
                                  supported. (multiple occurrence permitted)
  --mask TEXT                     String-based object mask
  --limit INTEGER                 Result limit
  --offset INTEGER                Result offset
  --output-python / --no-output-python
                                  Show python example code instead of executing the call
  -h, --help                      Show this message and exit.

参考:

https://softlayer-api-python-client.readthedocs.io/en/latest/cli/