Select
更新时间: 2026/06/29
在Gitcode上查看源码

ResourceDefinition

uris

  • https://device_ip/resource?$select=property[/property][,property]

properties

名称类型是否只读取值范围/枚举值说明
@odata.contextstringtrue-资源模型的OData描述信息
@odata.idstringtrue-资源节点的访问路径
@odata.typestringtrue-资源类型
Idstringtrue-资源唯一标识
Namestringtrue-资源名称
Members@odata.countnumbertrue-集合资源成员总数
Membersarraytrue-返回与"$select"表达式匹配的资源属性的子集
Members[].@odata.contextstringtrue-筛选后资源的元数据描述信息
Members[].@odata.idstringtrue-筛选后资源的访问路径
Members[].@odata.typestringtrue-筛选后资源的类型
Members[].Idstringtrue-筛选后资源的唯一标识
Members[].Namestringtrue-筛选后资源的名称

supported_methods

  • GET

HTTP methods

GET

命令功能

属性筛选命令($select)

说明

本命令适用于所有资源的查询操作,使用"$select"参数时返回与"$select"表达式匹配的资源属性的子集。"$select"参数可以与其他参数混合使用。

BMC300 5.8.0.1及以上版本支持

命令格式

URL: https://device_ip/resource?$select=property[/property][,property]

请求头:

X-Auth-Token: 123456789***********************

请求消息体: 无

参数说明

参数参数说明取值
device_ip登录设备的IP地址IPv4或IPv6地址
resource预期使用查询参数访问的接口接口对应的uri,如/redfish/v1/Chassis
property要筛选的属性名由属性名组成的字符串:
● 多级属性以"/"分隔
● 多个属性以","分隔
● 筛选对象数组中对象属性时省略数组索引
auth_value执行该GET请求时,必须在"Headers"中携带"X-Auth-Token"值用于鉴权可通过/redfish/v1/SessionService/Sessions创建会话时获得

使用指南

● "@odata.context"、"@odata.id"、"@odata.type"与"$select"查询参数无关,必定出现在响应体中。 ● 对于数组属性,筛选其子属性时省略数组索引,获取其全部成员下的下一级属性。 ● 对于集合资源,只能筛选"Members"下的属性。在集合资源中使用"$select"查询参数时可以省略"Members"。 ● "$select"查询参数的路径上存在超链接,不会继续进行属性筛选。

使用实例

筛选Managers资源下的Id、名称与详细类型。

请求样例:

http
GET https://device_ip/redfish/v1/Managers/1?$select=Id,Name,ManagerType

请求头:

X-Auth-Token: 123456789***********************

请求消息体:无

响应样例:

json
{
  "@odata.context": "/redfish/v1/$metadata#Manager.Manager",
  "@odata.id": "/redfish/v1/Managers/1",
  "@odata.type": "#Manager.v1_9_0.Manager",
  "Id": "1",
  "Name": "Manager",
  "ManagerType": "BMC"
}

响应码:200

筛选对象数组中对象属性示例:筛选SMTP资源中,接收告警的邮件地址的序号与启用状态。

请求样例:

http
GET https://device_ip/redfish/v1/Managers/1/SmtpService?$select=RecipientAddresses/MemberId,RecipientAddresses/Enabled

请求头:

X-Auth-Token: 123456789***********************

请求消息体:无

响应样例:

json
{
  "@odata.context": "/redfish/v1/$metadata#HwSmtpService.HwSmtpService",
  "@odata.id": "/redfish/v1/Managers/1/SmtpService",
  "@odata.type": "#HwSmtpService.v1_0_0.HwSmtpService",
  "RecipientAddresses": [
    {
      "MemberId": "0",
      "Enabled": false
    },
    {
      "MemberId": "1",
      "Enabled": false
    },
    {
      "MemberId": "2",
      "Enabled": false
    },
    {
      "MemberId": "3",
      "Enabled": false
    }
  ]
}

响应码:200

筛选集合资源中的属性示例:筛选所有Managers资源下的Id、名称与详细类型。

请求样例:

http
GET https://device_ip/redfish/v1/Managers?$select=Id,Name,Members/ManagerType&$expand=.($levels=1)

请求头:

X-Auth-Token: 123456789***********************

请求消息体:无

响应样例:

json
{
  "@odata.context": "/redfish/v1/$metadata#ManagerCollection.ManagerCollection",
  "@odata.id": "/redfish/v1/Managers",
  "@odata.type": "#ManagerCollection.ManagerCollection",
  "Name": "Manager Collection",
  "Members@odata.count": 1,
  "Members": [
    {
      "@odata.context": "/redfish/v1/$metadata#Manager.Manager",
      "@odata.id": "/redfish/v1/Managers/1",
      "@odata.type": "#Manager.v1_9_0.Manager",
      "Id": "1",
      "Name": "Manager",
      "ManagerType": "BMC"
    }
  ]
}

响应码:200