[comment]: # translation:outdated

[comment]: # ({8e685c26-8e685c26})
# 获取

[comment]: # ({/8e685c26-8e685c26})

[comment]: # ({e1899382-3833805e})
### 描述

`integer/array valuemap.get(object parameters)`

该方法允许根据给定参数检索值映射。

::: noteclassic
此方法对任何类型的用户都可用。调用该方法的权限可在用户角色设置中撤销。更多信息请参见 [用户角色](/manual/web_interface/frontend_sections/users/user_roles)。
:::

[comment]: # ({/e1899382-3833805e})

[comment]: # ({a3b9345d-84c56f34})
### 参数

`(object)` 定义所需输出的参数。

该方法支持以下参数。

|参数|[类型](/manual/api/reference_commentary#data-types)|描述|
|--|--|------|
|valuemapids|ID/array|仅返回具有给定 ID 的值映射。|
|selectMappings|query|在当前值映射的 [`mappings`](/manual/api/reference/valuemap/object#value-mappings) 属性中返回值映射条目。<br><br>支持 `count`。|
|sortfield|string/array|按给定属性对结果进行排序。<br><br>可能的值：`valuemapid`、`name`。|
|countOutput|boolean|这些参数在[参考注释](/manual/api/reference_commentary#common-get-method-parameters)中进行了说明。|
|editable|boolean|^|
|excludeSearch|boolean|^|
|filter|object|^|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|

[comment]: # ({/a3b9345d-84c56f34})

[comment]: # ({7223bab1-7223bab1})
### 返回值

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

-   一个数组对象；
-   如果使用了参数`countOutput`，则返回检索到的对象的数量。

[comment]: # ({/7223bab1-7223bab1})

[comment]: # ({b41637d2-b41637d2})
### 示例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({7f0a282d-864692f6})
#### 检索值映射

检索所有配置的值映射。

[请求](/manual/api#执行请求):

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

响应：

```json
{
    "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
}
```

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

请求：

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

响应：

```json
{
    "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
}
```

[comment]: # ({/7f0a282d-864692f6})

[comment]: # ({fb99bef1-fb99bef1})
### 源码

*ui/include/classes/api/services/CValueMap.php* 中的 CValueMap::get()。

[comment]: # ({/fb99bef1-fb99bef1})
