Zabbix Documentation 5.0

3.04.05.0 (current)| In development:5.2 (devel)| Unsupported:1.82.02.22.43.23.44.24.4Guidelines

User Tools

Site Tools


manual:api:reference:map:create

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
manual:api:reference:map:create [2019/01/28 14:51]
sasha <code js> => <code java>
manual:api:reference:map:create [2020/02/18 11:58]
marinagen cross links to improve usability
Line 1: Line 1:
 +===== map.create =====
  
 +==== Description ====
 +
 +''​object map.create(object/​array **maps**)''​
 +
 +This method allows to create new maps.
 +
 +==== Parameters ====
 +
 +''​(object/​array)''​ Maps to create.
 +
 +Additionally to the [[object#​map|standard map properties]],​ the method accepts the following parameters.
 +
 +^ Parameter ^ Type ^ Description ^
 +| links | array | [[:​manual/​api/​reference/​map/​object#​map_link|Map links]] to be created on the map. |
 +| selements | array | [[:​manual/​api/​reference/​map/​object#​map_element|Map elements]] to be created on the map. |
 +| urls | array | [[:​manual/​api/​reference/​map/​object#​map_url|Map URLs]] to be created on the map. |
 +| users | array | [[:​manual/​api/​reference/​map/​object#​map_user|Map user]] shares to be created on the map. |
 +| userGroups | array | [[:​manual/​api/​reference/​map/​object#​map_user_group|Map user group]] shares to be created on the map. |
 +| shapes | array | [[:​manual/​api/​reference/​map/​object#​map_shapes|Map shapes]] to be created on the map. |
 +| lines | array | [[:​manual/​api/​reference/​map/​object#​map_lines|Map lines]] to be created on the map. |
 +
 +<note tip>To create map links you'll need to set a map element ''​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. [[create#​create_a_host_map|See example.]]</​note>​
 +==== 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.
 +
 +==== Examples ====
 +
 +=== Create an empty map ===
 +
 +Create a map with no elements.
 +
 +Request:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​method":​ "​map.create",​
 +    "​params":​ {
 +        "​name":​ "​Map",​
 +        "​width":​ 600,
 +        "​height":​ 600
 +    },
 +    "​auth":​ "​038e1d7b1735c6a5436ee9eae095879e",​
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +Response:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ {
 +        "​sysmapids":​ [
 +            "​8"​
 +        ]
 +    },
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +=== 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.
 +
 +Request:
 +<code java>
 +{
 +    "​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
 +}
 +</​code>​
 +
 +Response:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ {
 +        "​sysmapids":​ [
 +            "​9"​
 +        ]
 +    },
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +=== Create a trigger map ===
 +
 +Create a map with trigger element, which contains two triggers.
 +
 +Request:
 +<code java>
 +{
 +    "​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
 +}
 +</​code>​
 +
 +Response:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ {
 +        "​sysmapids":​ [
 +            "​10"​
 +        ]
 +    },
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +=== Map sharing ===
 +
 +Create a map with two types of sharing (user and user group).
 +
 +Request:
 +<code java>
 +{
 +    "​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
 +}
 +</​code>​
 +
 +Response:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ {
 +        "​sysmapids":​ [
 +            "​9"​
 +        ]
 +    },
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +=== Map shapes ===
 +
 +Create a map with map name title.
 +
 +Request:
 +<code java>
 +{
 +    "​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
 +}
 +</​code>​
 +
 +Response:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ {
 +        "​sysmapids":​ [
 +            "​10"​
 +        ]
 +    },
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +=== Map lines ===
 +
 +Create a map line.
 +
 +Request:
 +<code java>
 +{
 +    "​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
 +}
 +</​code>​
 +
 +Response:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ {
 +        "​sysmapids":​ [
 +            "​11"​
 +        ]
 +    },
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +==== See also ====
 +
 +  * [[object#​map_element|Map element]]
 +  * [[object#​map_link|Map link]]
 +  * [[object#​map_url|Map URL]]
 +  * [[object#​map_user|Map user]]
 +  * [[object#​map_user_group|Map user group]]
 +  * [[object#​map_shapes|Map shape]]
 +  * [[object#​map_lines|Map line]]
 +
 +==== Source ====
 +
 +CMap::​create() in //​frontends/​php/​include/​classes/​api/​services/​CMap.php//​.