manual:api:reference:valuemap:create

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

manual:api:reference:valuemap:create [2021/01/27 21:18]
manual:api:reference:valuemap:create [2019/01/28 14:50] (current)
sasha <code js> => <code java>
Line 1: Line 1:
 +===== valuemap.create =====
  
 +==== Description ====
 +''​object valuemap.create(object/​array **valuemaps**)''​
 +
 +This method allows to create new value maps.
 +
 +==== Parameters ====
 +''​(object/​array)''​ Value maps to create.
 +
 +The method accepts value maps with with the [[object#​value_map|standard value map properties]].
 +
 +==== Return values ====
 +''​(object)''​ Returns an object containing the IDs of the created value maps the ''​valuemapids''​ property. The order of the returned IDs matches the order of the passed value maps.
 +
 +==== Examples ====
 +
 +=== Creating a value map ===
 +Create one value map with two mappings.
 +
 +Request:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​method":​ "​valuemap.create",​
 +    "​params":​ {
 +        "​name":​ "​Service state",​
 +        "​mappings":​ [
 +            {
 +                "​value":​ "​0",​
 +                "​newvalue":​ "​Down"​
 +            },
 +            {
 +                "​value":​ "​1",​
 +                "​newvalue":​ "​Up"​
 +            }
 +        ]
 +    },
 +    "​auth":​ "​57562fd409b3b3b9a4d916d45207bbcb",​
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +Response:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ {
 +        "​valuemapids":​ [
 +            "​1"​
 +        ]
 +    },
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +==== Source ====
 +
 +CValueMap::​create() in //​frontends/​php/​include/​classes/​api/​services/​CValueMap.php//​.