创建

Description 描述

object map.create(object/array maps)

This method allows to create new maps. 这个方法允许创建一个新的拓扑图

Parameters 参数

(object/array) Maps to create.

Additionally to the standard map properties, the method accepts the following parameters. 除了standard map properties之外,该方法还接受以下参数。

Parameter Type Description
links array Map links to be created on the map. 拓扑图上创建拓扑图链接
selements array Map elements to be created on the map. 拓扑图上创建拓扑图元素
urls array Map URLs to be created on the map. 拓扑图上创建拓扑图URL
users array Map user shares to be created on the map. 拓扑图共享用户
userGroups array Map user group shares to be created on the map. 拓扑图共享用户组
shapes array Map shapes to be created on the map. 拓扑图上创建拓扑图图形
lines array Map lines to be created on the map. 拓扑图上创建拓扑图线

To create map links you'll need to set a map elements selementid to an arbitrary value and then use this value to reference this element in the links selementid1 or selementid2 properties. When the element is created, this value will be replaced with the correct ID generated by Zabbix. See example. 要创建映射链接,您需要将映射元素设置为任意值,然后使用该值在链接selectd1selemand2属性中引用该元素。在创建元素时,将用Zabbix生成的正确ID替换该值。

Return values 返回值

(object) Returns an object containing the IDs of the created maps under the sysmapids property. The order of the returned IDs matches the order of the passed maps. (对象)返回一个对象,该对象包含在“sysmapid”属性下创建的拓扑图的id。返回id的顺序与传递的拓扑图的顺序相匹配。

Examples 例子

Create an empty map 创建一个空的拓扑图

Create a map with no elements. 创建一个拓扑图没有任何元素

Request:

{
           "jsonrpc": "2.0",
           "method": "map.create",
           "params": {
               "name": "Map",
               "width": 600,
               "height": 600
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "sysmapids": [
                   "8"
               ]
           },
           "id": 1
       }

Create a host map 创建一个主机拓扑图

Create a map with two host elements and a link between them. Note the use of temporary "selementid1" and "selementid2" values in the map link object to refer to map elements. 创建一个关于两个主机的拓扑图,并且关联他们,需要注意的是在地图上临时使用"selementid1"和"selementid2"的值来引用地图元素。

Request:

{
           "jsonrpc": "2.0",
           "method": "map.create",
           "params": {
               "name": "Host map",
               "width": 600,
               "height": 600,
               "selements": [
                   {
                       "selementid": "1",
                       "elements": [
                           {"hostid": "1033"}
                       ],
                       "elementtype": 0,
                       "iconid_off": "2"
                   },
       
                   {
                       "selementid": "2",
                       "elements": [
                           {"hostid": "1037"}
                       ],
                       "elementtype": 0,
                       "iconid_off": "2"
                   }
               ],
               "links": [
                   {
                       "selementid1": "1",
                       "selementid2": "2"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "sysmapids": [
                   "9"
               ]
           },
           "id": 1
       }

Create a trigger map 创建一个触发器拓扑图

Create a map with trigger element, which contains two triggers. 创建一个关于触发器元素的拓扑图,包含两个触发器

Request:

{
           "jsonrpc": "2.0",
           "method": "map.create",
           "params": {
               "name": "Trigger map",
               "width": 600,
               "height": 600,
               "selements": [
                   {
                       "elements": [
                           {"triggerid": "12345"},
                           {"triggerid": "67890"}
                       ],
                       "elementtype": 2,
                       "iconid_off": "2"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "sysmapids": [
                   "10"
               ]
           },
           "id": 1
       }

Map sharing 拓扑图共享

Create a map with two types of sharing (user and user group). 创建一个关于两种共享类项(用户和用户组)的拓扑图。

Request:

{
           "jsonrpc": "2.0",
           "method": "map.create",
           "params": {
               "name": "Map sharing",
               "width": 600,
               "height": 600,
               "users": [
                   {
                       "userid": "4",
                       "permission": "3"
                   }
               ],
               "userGroups": [
                   {
                       "usrgrpid": "7",
                       "permission": "2"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "sysmapids": [
                   "9"
               ]
           },
           "id": 1
       }

Map shapes 拓扑图形状

Create a map with map name title. 创建一个带有主题的拓扑图

Request:

{
           "jsonrpc": "2.0",
           "method": "map.create",
           "params": {
               "name": "Host map",
               "width": 600,
               "height": 600,
               "shapes": [
                   {
                       "type": 0,
                       "x": 0,
                       "y": 0,
                       "width": 600,
                       "height": 11,
                       "text": "{MAP.NAME}"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "sysmapids": [
                   "10"
               ]
           },
           "id": 1
       }

Map lines

Create a map line.

Request:

{
           "jsonrpc": "2.0",
           "method": "map.create",
           "params": {
               "name": "Map API lines",
               "width": 500,
               "height": 500,
               "lines": [
                   {
                       "x1": 30,
                       "y1": 10,
                       "x2": 100,
                       "y2": 50,
                       "line_type": 1,
                       "line_width": 10,
                       "line_color": "009900"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "sysmapids": [
                   "11"
               ]
           },
           "id": 1
       }

See also

Source

CMap::create() in frontends/php/include/classes/api/services/CMap.php.