diff --git a/.idea/atlassian-ide-plugin.xml b/.idea/atlassian-ide-plugin.xml
new file mode 100644
index 0000000..858eed5
--- /dev/null
+++ b/.idea/atlassian-ide-plugin.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..91f34c3
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..86680ed
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/py-zabbix.iml b/.idea/py-zabbix.iml
new file mode 100644
index 0000000..6711606
--- /dev/null
+++ b/.idea/py-zabbix.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..2c2b0ff
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,335 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1510215142102
+
+
+ 1510215142102
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pyzabbix/hosts-organizer.py b/pyzabbix/hosts-organizer.py
new file mode 100644
index 0000000..e6f748c
--- /dev/null
+++ b/pyzabbix/hosts-organizer.py
@@ -0,0 +1,92 @@
+# -*- encoding: utf-8 -*-
+#
+# Copyright © 2017 Andrey Makarov
+#
+# This file is user for simple manipulations with hosts
+from pprint import pprint
+
+from pyzabbix import ZabbixAPIException
+
+
+class HostsOrganizer:
+
+ """
+ This function gets an object of ZabbixAPI connection to the Zabbix server
+ Gets template id, host id, must be a string value
+ Used for setting template on host
+ """
+ def add_template_on_host(z, template_id, host_id):
+ try:
+ response = z.do_request(method="template.massadd", params={
+ "templates": [
+ {
+ "templateid": template_id
+ }
+ ],
+ "hosts": [
+ {
+ "hostid": host_id
+ },
+ ]
+ })
+ pprint(response)
+ except ZabbixAPIException as e:
+ print(e)
+
+ """
+ This function gets an object of ZabbixAPI connection to the Zabbix server
+ Gets hosts group's id, must be a string value
+ Returns list of duplicates
+ """
+ def search_hosts_duplicates(z, group_id):
+ ids = z.do_request(method="host.get", params={
+ "output": ["hostid"],
+ "filter": {
+ "groupids": group_id
+ }
+ })
+
+ ips = []
+ duplicates = []
+ for i, host in enumerate(ids['result']):
+ try:
+ response = z.do_request(method="hostinterface.get", params={
+ "output": ["ip", "hostid"],
+ "hostids": host['hostid']
+ })
+ except ZabbixAPIException as e:
+ print(e)
+ else:
+ ip = response['result'][0]['ip']
+ if ip in ips:
+ duplicates.append({
+ 'ip': ip,
+ 'id': response['result'][0]['hostid']
+ })
+ else:
+ ips.append(ip)
+ return duplicates
+
+ """
+ This function gets an object of ZabbixAPI connection to the Zabbix server
+ Gets template id, group id, must be a string value
+ Used for setting template on group
+ """
+ def add_template_on_group(z, template_id, group_id):
+ icmp_ping = "10104"
+ try:
+ response = z.do_request(method="template.massadd", params={
+ "templates": [
+ {
+ "templateid": template_id
+ }
+ ],
+ "groups": [
+ {
+ "groupid": group_id
+ }
+ ]
+ })
+ pprint(response)
+ except ZabbixAPIException as e:
+ print(e)
\ No newline at end of file
diff --git a/pyzabbix/maps-organizer.py b/pyzabbix/maps-organizer.py
new file mode 100644
index 0000000..0df4dd5
--- /dev/null
+++ b/pyzabbix/maps-organizer.py
@@ -0,0 +1,151 @@
+# -*- encoding: utf-8 -*-
+#
+# Copyright © 2017 Andrey Makarov
+#
+# This file is user for simple manipulations with hosts's maps
+
+from pprint import pprint
+
+from pyzabbix import ZabbixAPIException
+
+
+class MapsOrganizer:
+ """
+ This function gets an object of ZabbixAPI connection to the Zabbix server
+ Gets user name, must be a string value
+ Returns list with user's maps with map's labels and ids
+ """
+ def get_user_maps(z, user_name):
+ id = z.get_user_id(user_name)
+ try:
+ response = z.do_request(method="map.get", params={
+ "output": ["label"],
+ "userids": id
+ })
+ except ZabbixAPIException as e:
+ print(e)
+ return response
+
+ """
+ This function gets an object of ZabbixAPI connection to the Zabbix server
+ Gets user name, must be a string value
+ Returns user's id
+ """
+ def get_user_id(z, user_name):
+ try:
+ response = z.do_request(method="user.get", params={
+ "search": {"alias": user_name},
+ "output": "extend"
+ })
+ except ZabbixAPIException as e:
+ print(e)
+ return response['result'][0]["userid"]
+
+ """
+ This function gets an object of ZabbixAPI connection to the Zabbix server
+ Gets maps id, must be a string value
+ Get's label's text, must be a string value
+ Used for changing label's value
+ """
+ def change_elements_label(z, sysmapid, label):
+ for id in sysmapid:
+ # pprint(sysmapid)
+ new_request = []
+ try:
+ response = z.do_request(method="map.get", params={
+ "sysmapids": id,
+ "selectSelements": "extend",
+ "output": "extend"
+ })['result'][0]['selements']
+
+ # pprint(response)
+
+ for item in response:
+ item["label"] = label
+ new_request.append(item)
+ # pprint(new_request)
+
+ except ZabbixAPIException as e:
+ print(e)
+ else:
+ try:
+ resp = z.do_request(method="map.update", params={
+ "sysmapid": id,
+ "selements": new_request,
+ })
+ except ZabbixAPIException as e:
+ print(e, id)
+
+ def get_sysmapid():
+ ids = []
+ try:
+ response = z.do_request(method="map.get", params={
+ "output": "extends"
+ })
+ for id in response['result']:
+ i = id['sysmapid']
+ ids.append(i)
+ except ZabbixAPIException as e:
+ print(e)
+ return []
+ else:
+ return ids
+
+ """
+ This function gets an object of ZabbixAPI connection to the Zabbix server
+ Gets map's id, must be a string value
+ Get's returned element such as links
+ Returns map's elements
+ """
+ def get_elements(z, sysmapid, returned_element):
+ try:
+ response = z.do_request(method="map.get", params={
+ "sysmapids": sysmapid,
+ "output": "extend",
+ "selectSelements": "extend",
+ "selectLinks": "extend",
+ "selectUsers": "extend",
+ "selectUserGroups": "extend",
+ "selectShapes": "extend",
+ "selectLines": "extend"
+ })
+
+ # pprint(response['result'][0]['links'])
+
+ except ZabbixAPIException as e:
+ print(e)
+ return response['result'][0][returned_element]
+
+ """
+ This function gets an object of ZabbixAPI connection to the Zabbix server
+ Gets map's id, must be a string value
+ Get's label type, must be a string value
+ Used for changing label type
+ """
+ def change_label_type(z, sysmapid, label_type):
+ for id in sysmapid:
+ # pprint(sysmapid)
+ new_request = []
+ try:
+ response = z.do_request(method="map.get", params={
+ "sysmapids": id,
+ "output": "extend"
+ })['result'][0]['label_type']
+
+ # pprint(response)
+
+ for item in response:
+ item = label_type
+ new_request.append(item)
+ # pprint(new_request)
+
+ except ZabbixAPIException as e:
+ print(e)
+ else:
+ try:
+ resp = z.do_request(method="map.update", params={
+ "sysmapid": id,
+ "selements": new_request,
+ })
+ except ZabbixAPIException as e:
+ print(e)
\ No newline at end of file
diff --git a/pyzabbix/users-organizer.py b/pyzabbix/users-organizer.py
new file mode 100644
index 0000000..1f230dd
--- /dev/null
+++ b/pyzabbix/users-organizer.py
@@ -0,0 +1,82 @@
+# -*- encoding: utf-8 -*-
+#
+# Copyright © 2017 Andrey Makarov
+#
+# This file is user for simple manipulations with users
+
+from pprint import pprint
+
+from pyzabbix import ZabbixAPIException
+
+
+class UserOrganizer:
+ """
+ This function gets an object of ZabbixAPI connection to the Zabbix server
+ Returns user's id and aliases
+ """
+ def get_users(z):
+ try:
+ response = z.do_request(method="user.get", params={
+ "filter": "alias",
+ "output": ["userid", "alias"]
+ })
+ result = response['result']
+ except ZabbixAPIException as e:
+ print(e)
+ return result
+
+ """
+ This function gets an object of ZabbixAPI connection to the Zabbix server
+ Gets user name, must be a string value
+ Prints users alias, ip, name, surname, id
+ """
+ def get_user_info(z, user_name):
+ try:
+ response = z.do_request(method="user.get", params={
+ "search": {"alias": user_name},
+ "output": "extend"
+ })
+ except ZabbixAPIException as e:
+ print(e)
+ nick_name = response['result'][0]['alias']
+ attempt_ip = response['result'][0]['attempt_ip']
+ name = response['result'][0]['name']
+ surname = response['result'][0]['surname']
+ user_id = response['result'][0]['userid']
+
+ pprint("nick name = " + nick_name)
+ pprint("ip = " + attempt_ip)
+ pprint("name = " + name)
+ pprint("surname = " + surname)
+ pprint("user id = " + user_id)
+
+ """
+ This function gets an object of ZabbixAPI connection to the Zabbix server
+ Gets user name, must be a string value
+ Returns user's maps
+ """
+ def get_user_maps(z, user_name):
+ id = z.get_user_id(user_name)
+ try:
+ response = z.do_request(method="map.get", params={
+ "output": ["label"],
+ "userids": id
+ })
+ except ZabbixAPIException as e:
+ print(e)
+ return response
+
+ """
+ This function gets an object of ZabbixAPI connection to the Zabbix server
+ Gets user name, must be a string value
+ Returns user's id
+ """
+ def get_user_id(z, user_name):
+ try:
+ response = z.do_request(method="user.get", params={
+ "search": {"alias": user_name},
+ "output": "extend"
+ })
+ except ZabbixAPIException as e:
+ print(e)
+ return response['result'][0]["userid"]
\ No newline at end of file