【问题标题】:IBM Cloud CLI Softlayer plugin: How to pass filters?IBM Cloud CLI Softlayer 插件:如何通过过滤器?
【发布时间】:2019-06-29 03:01:05
【问题描述】:

我正在使用Softlayer commands in the IBM Cloud CLI 来管理经典基础架构。在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 调用?

【问题讨论】:

    标签: command-line-interface ibm-cloud ibm-cloud-infrastructure


    【解决方案1】:

    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/

    【讨论】:

    • 我使用 ibmcloud 登录并且想要并且必须使用该 CLI 命令。 slcli 未安装。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多