Filter
更新时间: 2026/06/29
在Gitcode上查看源码ResourceDefinition
uris
https://device_ip/resourcecollection?$filter=Expression
properties
| 名称 | 类型 | 是否只读 | 取值范围/枚举值 | 说明 |
|---|---|---|---|---|
| @odata.context | string | true | - | 资源模型的OData描述信息 |
| @odata.id | string | true | - | 资源节点的访问路径 |
| @odata.type | string | true | - | 资源类型 |
| Name | string | true | - | 资源名称 |
| Members@odata.count | number | true | - | 筛选后的集合资源成员总数 |
| Members | array | true | - | 与"$filter"表达式匹配的集合成员的子集 |
| Members[].@odata.context | string | true | - | 筛选后资源的元数据描述信息 |
| Members[].@odata.id | string | true | - | 筛选后资源的访问路径 |
| Members[].@odata.type | string | true | - | 筛选后资源的类型 |
| Members[].Id | string | true | - | 筛选后资源的唯一标识 |
supported_methods
- GET
HTTP methods
GET
命令功能
子资源筛选命令($filter)
说明
适用于资源集合。返回与"$filter"表达式匹配的集合成员的子集。"$filter"参数可以与其他参数混合使用,如"$expand"参数与"$select"参数。
BMC300 5.8.0.1及以上版本支持
命令格式
URL: https://device_ip/resourcecollection?$filter=Expression
请求头:
X-Auth-Token: 123456789***********************请求消息体: 无
参数说明
| 参数 | 参数说明 | 取值 |
|---|---|---|
| device_ip | 登录设备的IP地址 | IPv4或IPv6地址 |
| resourcecollection | 预期使用查询参数访问的集合资源 | 集合资源接口对应的uri,如/redfish/v1/Chassis |
| Expression | "$filter"参数表达式 | 表达式中支持的运算符如下: ( ):分组优先运算 not:逻辑非 gt:大于 ge:大于等于 lt:小于 le:小于等于 eq:等于 ne:不等于 and:逻辑与 or:逻辑或 说明:"$filter"参数表达式具体语法规则,请参考使用指南章节 |
| auth_value | 执行该GET请求时,必须在"Headers"中携带"X-Auth-Token"值用于鉴权 | 可通过/redfish/v1/SessionService/Sessions创建会话时获得 |
使用指南
"$filter"参数表达式语法规则: ● 运算符优先级如下,相同层级的优先级相同: – 分组优先运算 – 逻辑非(一般与分组优先运算共同使用) – 关系比较运算(gt、ge、lt、le) – 相等比较运算(eq、ne) – 逻辑与 – 逻辑或 ● 查询参数"$filter"使用运算符定义一组属性和常量。比较运算符包括"gt"、"ge"、"lt"、"le"、"eq"和"ne"。在响应体中,比较运算符的左侧是属性名称,右侧是与左侧属性进行比较的常量。该常量可以是数字、布尔值或用单引号括起来的字符串。"gt"、"ge"、"lt"和"le"比较运算符只能用于比较数字。
说明
LogService的Entries资源不支持"$filter"参数。
使用实例
查询日志服务集合资源中的运行日志。
请求样例:
http
GET https://device_ip/redfish/v1/Managers/1/LogServices?$filter=Id eq 'RunLog'请求头:
X-Auth-Token: 123456789***********************请求消息体:无
响应样例:
json
{
"@odata.context": "/redfish/v1/$metadata#LogServiceCollection.LogServiceCollection",
"@odata.id": "/redfish/v1/Managers/1/LogServices",
"@odata.type": "#LogServiceCollection.LogServiceCollection",
"Name": "LogService Collection",
"Members@odata.count": 1,
"Members": [
{
"@odata.id": "/redfish/v1/Managers/1/LogServices/RunLog"
}
]
}响应码:200
与其他查询参数联合使用:查询日志服务集合资源中的除运行日志外的,数量不超过3000条的日志。
请求样例:
http
GET https://device_ip/redfish/v1/Managers/1/LogServices?$expand=.($levels=1)&$select=Id,MaxNumberOfRecords&$filter=Id ne 'RunLog' and MaxNumberOfRecords le 3000请求头:
X-Auth-Token: 123456789***********************请求消息体:无
响应样例:
json
{
"@odata.context": "/redfish/v1/$metadata#LogServiceCollection.LogServiceCollection",
"@odata.id": "/redfish/v1/Managers/1/LogServices",
"@odata.type": "#LogServiceCollection.LogServiceCollection",
"Name": "LogService Collection",
"Members@odata.count": 2,
"Members": [
{
"@odata.context": "/redfish/v1/$metadata#LogService.LogService",
"@odata.id": "/redfish/v1/Managers/1/LogServices/OperateLog",
"@odata.type": "#LogService.v1_0_3.LogService",
"Id": "OperateLog",
"MaxNumberOfRecords": 2767
},
{
"@odata.context": "/redfish/v1/$metadata#LogService.LogService",
"@odata.id": "/redfish/v1/Managers/1/LogServices/SecurityLog",
"@odata.type": "#LogService.v1_0_3.LogService",
"Id": "SecurityLog",
"MaxNumberOfRecords": 2878
}
]
}响应码:200
说明
对于未展开的子资源,"$filter"参数不会自动将子资源展开,若想获取展开后的结果,可以将"$filter"参数与"$expand"参数联合使用。