创建

描述

object map.create(object/array **maps**)

这个方法允许创建一个新的拓扑图。

参数

(object/array) Maps to create.

除了standard map properties之外,该方法还接受以下参数。

ParameterTypeDescription
linksarray拓扑图上创建拓扑图链接
selementsarray拓扑图上创建拓扑图元素
urlsarray拓扑图上创建拓扑图URL
usersarray拓扑图共享用户
userGroupsarray拓扑图共享用户组
shapesarray拓扑图上创建拓扑图图形
linesarray拓扑图上创建拓扑图线

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替换该值。

返回值

(对象)返回一个对象,该对象包含在“sysmapid”属性下创建的拓扑图的id。返回id的顺序与传递的拓扑图的顺序相匹配。

例子

创建一个空的拓扑图

创建一个拓扑图没有任何元素。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "map.create",
  4. "params": {
  5. "name": "Map",
  6. "width": 600,
  7. "height": 600
  8. },
  9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "sysmapids": [
  5. "8"
  6. ]
  7. },
  8. "id": 1
  9. }

创建一个主机拓扑图

创建一个关于两个主机的拓扑图,并且关联他们,需要注意的是在地图上临时使用“selementid1”和“selementid2”的值来引用地图元素。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "map.create",
  4. "params": {
  5. "name": "Host map",
  6. "width": 600,
  7. "height": 600,
  8. "selements": [
  9. {
  10. "selementid": "1",
  11. "elements": [
  12. {"hostid": "1033"}
  13. ],
  14. "elementtype": 0,
  15. "iconid_off": "2"
  16. },
  17. {
  18. "selementid": "2",
  19. "elements": [
  20. {"hostid": "1037"}
  21. ],
  22. "elementtype": 0,
  23. "iconid_off": "2"
  24. }
  25. ],
  26. "links": [
  27. {
  28. "selementid1": "1",
  29. "selementid2": "2"
  30. }
  31. ]
  32. },
  33. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  34. "id": 1
  35. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "sysmapids": [
  5. "9"
  6. ]
  7. },
  8. "id": 1
  9. }

创建一个触发器拓扑图

创建一个关于触发器元素的拓扑图,包含两个触发器。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "map.create",
  4. "params": {
  5. "name": "Trigger map",
  6. "width": 600,
  7. "height": 600,
  8. "selements": [
  9. {
  10. "elements": [
  11. {"triggerid": "12345"},
  12. {"triggerid": "67890"}
  13. ],
  14. "elementtype": 2,
  15. "iconid_off": "2"
  16. }
  17. ]
  18. },
  19. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  20. "id": 1
  21. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "sysmapids": [
  5. "10"
  6. ]
  7. },
  8. "id": 1
  9. }

拓扑图共享

创建一个关于两种共享类项(用户和用户组)的拓扑图。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "map.create",
  4. "params": {
  5. "name": "Map sharing",
  6. "width": 600,
  7. "height": 600,
  8. "users": [
  9. {
  10. "userid": "4",
  11. "permission": "3"
  12. }
  13. ],
  14. "userGroups": [
  15. {
  16. "usrgrpid": "7",
  17. "permission": "2"
  18. }
  19. ]
  20. },
  21. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  22. "id": 1
  23. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "sysmapids": [
  5. "9"
  6. ]
  7. },
  8. "id": 1
  9. }

拓扑图形状

创建一个带有主题的拓扑图。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "map.create",
  4. "params": {
  5. "name": "Host map",
  6. "width": 600,
  7. "height": 600,
  8. "shapes": [
  9. {
  10. "type": 0,
  11. "x": 0,
  12. "y": 0,
  13. "width": 600,
  14. "height": 11,
  15. "text": "{MAP.NAME}"
  16. }
  17. ]
  18. },
  19. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  20. "id": 1
  21. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "sysmapids": [
  5. "10"
  6. ]
  7. },
  8. "id": 1
  9. }

Map lines

Create a map line.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "map.create",
  4. "params": {
  5. "name": "Map API lines",
  6. "width": 500,
  7. "height": 500,
  8. "lines": [
  9. {
  10. "x1": 30,
  11. "y1": 10,
  12. "x2": 100,
  13. "y2": 50,
  14. "line_type": 1,
  15. "line_width": 10,
  16. "line_color": "009900"
  17. }
  18. ]
  19. },
  20. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  21. "id": 1
  22. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "sysmapids": [
  5. "11"
  6. ]
  7. },
  8. "id": 1
  9. }

See also

Source

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