Sidebar

zh:manual:api:reference:valuemap:update

valuemap.update

说明

object valuemap.update(object/array valuemaps)

该方法允许更新现有的值映射。

P参数

(object/array) 要更新的值映射特性

必须为每个值映射定义valuemapid'属性,所有其他属性都是可选的。 只有通过的属性将被更新,所有其他属性将保持不变。 ==== 返回值 ==== (object)返回一个对象,它包含valuemapids'属性下更新的值映射的ID。

示例

Changing value map name

Change value map name to “Device status”.

Request:

{
    "jsonrpc": "2.0",
    "method": "valuemap.update",
    "params": {
        "valuemapid": "2",
        "name": "Device status"
    },
    "auth": "57562fd409b3b3b9a4d916d45207bbcb",
    "id": 1
}

Response:

{
    "jsonrpc": "2.0",
    "result": {
        "valuemapids": [
            "2"
        ]
    },
    "id": 1
}

Changing mappings for one value map.

Request:

{
    "jsonrpc": "2.0",
    "method": "valuemap.update",
    "params": {
        "valuemapid": "2",
        "mappings": [
            {
                "value": "0",
                "newvalue": "Online"
            },
            {
                "value": "1",
                "newvalue": "Offline"
            }
        ]
    },
    "auth": "57562fd409b3b3b9a4d916d45207bbcb",
    "id": 1
}

Response:

{
    "jsonrpc": "2.0",
    "result": {
        "valuemapids": [
            "2"
        ]
    },
    "id": 1
}

来源

CValueMap::update() in frontends/php/include/classes/api/services/CValueMap.php.