获取

描述

integer/array valuemap.get(object parameters)

此方法允许根据给出的参数检索值映射。

此方法对于任何用户可用。可以在用户角色设置中撤销调用该方法的权限。更多信息请查看 用户角色

参数

(object) 定义期望输出的参数。

此方法支持以下参数。

参数 类型 描述
valuemapids string/array 仅返回给定ID的值映射。
selectMappings query 返回 mappings 属性中当前值映射的值映射关系。

支持count
sortfield string/array 按照给定的属性对结果进行排序。

可用值: valuemapidname
countOutput boolean 这些参数对所有get方法是公共的,详细描述请参见参考说明
editable boolean
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

返回值

(integer/array) 返回以下其中一种结果:

  • 一个数组对象;
  • 如果使用了参数countOutput,则返回检索到的对象的数量。

示例

检索值映射

检索所有配置的值映射。

请求:

{
           "jsonrpc": "2.0",
           "method": "valuemap.get",
           "params": {
               "output": "extend"
           },
           "auth": "57562fd409b3b3b9a4d916d45207bbcb",
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "valuemapid": "4",
                   "name": "APC Battery Replacement Status"
               },
               {
                   "valuemapid": "5",
                   "name": "APC Battery Status"
               },
               {
                   "valuemapid": "7",
                   "name": "Dell Open Manage System Status"
               }
           ],
           "id": 1
       }

根据映射关系,检索一个值映射。

请求:

{
           "jsonrpc": "2.0",
           "method": "valuemap.get",
           "params": {
               "output": "extend",
               "selectMappings": "extend",
               "valuemapids": ["4"]
           },
           "auth": "57562fd409b3b3b9a4d916d45207bbcb",
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "valuemapid": "4",
                   "name": "APC Battery Replacement Status",
                   "mappings": [
                       {
                           "type": "0",
                           "value": "1",
                           "newvalue": "unknown"
                       },
                       {
                           "type": "0",
                           "value": "2",
                           "newvalue": "notInstalled"
                       },
                       {
                           "type": "0",
                           "value": "3",
                           "newvalue": "ok"
                       },
                       {
                           "type": "0",
                           "value": "4",
                           "newvalue": "failed"
                       },
                       {
                           "type": "0",
                           "value": "5",
                           "newvalue": "highTemperature"
                       },
                       {
                           "type": "0",
                           "value": "6",
                           "newvalue": "replaceImmediately"
                       },
                       {
                           "type": "0",
                           "value": "7",
                           "newvalue": "lowCapacity"
                       }
                   ]
               }
           ],
           "id": 1
       }

来源

CValueMap::get() in ui/include/classes/api/services/CValueMap.php.