Skip to content

Commit a591e06

Browse files
authored
Merge pull request #3 from zabbix/release/1.0.2
Release/1.0.2
2 parents e171482 + 18df1e3 commit a591e06

38 files changed

+578
-363
lines changed

.github/scripts/additional_api_tests.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env python
2+
# Copyright (C) 2001-2023 Zabbix SIA
3+
#
4+
# Zabbix SIA licenses this file under the MIT License.
5+
# See the LICENSE file in the project root for more information.
6+
27
import sys
38
import base64
49
import unittest

.github/scripts/check_new_zabbx_release.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env python
2+
# Copyright (C) 2001-2023 Zabbix SIA
3+
#
4+
# Zabbix SIA licenses this file under the MIT License.
5+
# See the LICENSE file in the project root for more information.
6+
27
import os
38
import sys
49
import requests

.github/scripts/compatibility_api_test_5.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env python
2+
# Copyright (C) 2001-2023 Zabbix SIA
3+
#
4+
# Zabbix SIA licenses this file under the MIT License.
5+
# See the LICENSE file in the project root for more information.
6+
27
import sys
38
import time
49
import unittest

.github/scripts/compatibility_api_test_6.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env python
2+
# Copyright (C) 2001-2023 Zabbix SIA
3+
#
4+
# Zabbix SIA licenses this file under the MIT License.
5+
# See the LICENSE file in the project root for more information.
6+
27
import sys
38
import time
49
import unittest

.github/scripts/compatibility_api_test_latest.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env python
2+
# Copyright (C) 2001-2023 Zabbix SIA
3+
#
4+
# Zabbix SIA licenses this file under the MIT License.
5+
# See the LICENSE file in the project root for more information.
6+
27
import sys
38
import time
49
import unittest

.github/scripts/integration_api_test.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env python
2+
# Copyright (C) 2001-2023 Zabbix SIA
3+
#
4+
# Zabbix SIA licenses this file under the MIT License.
5+
# See the LICENSE file in the project root for more information.
6+
27
import sys
38
import unittest
49

@@ -61,7 +66,17 @@ def test_user_get(self):
6166
users = self.zapi.user.get(
6267
output=['userid', 'name']
6368
)
64-
self.assertEqual(type(users), list, "Request user.getter was going wrong")
69+
self.assertEqual(type(users), list, "Request user.get was going wrong")
70+
71+
def test_host_get(self):
72+
"""Tests getting hosts info works properly using suffix"""
73+
74+
hosts = None
75+
if self.zapi:
76+
hosts = self.zapi.host_.get_(
77+
output=['hostid', 'host']
78+
)
79+
self.assertEqual(type(hosts), list, "Request host.get was going wrong")
6580

6681

6782
if __name__ == '__main__':

.github/scripts/integration_get_test.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env python
2+
# Copyright (C) 2001-2023 Zabbix SIA
3+
#
4+
# Zabbix SIA licenses this file under the MIT License.
5+
# See the LICENSE file in the project root for more information.
6+
27
import sys
38
import json
49
import unittest

.github/scripts/integration_sender_test.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env python
2+
# Copyright (C) 2001-2023 Zabbix SIA
3+
#
4+
# Zabbix SIA licenses this file under the MIT License.
5+
# See the LICENSE file in the project root for more information.
6+
27
import sys
38
import unittest
49

.github/scripts/telegram_msg.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env python3
2+
# Copyright (C) 2001-2023 Zabbix SIA
3+
#
4+
# Zabbix SIA licenses this file under the MIT License.
5+
# See the LICENSE file in the project root for more information.
6+
27
import requests
38
import sys
49
import os

.github/scripts/wait_instance_zabbix.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env python
2+
# Copyright (C) 2001-2023 Zabbix SIA
3+
#
4+
# Zabbix SIA licenses this file under the MIT License.
5+
# See the LICENSE file in the project root for more information.
6+
27
import sys
38
import time
49

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [1.0.2](https://github.com/zabbix/python-zabbix-utils/compare/v1.0.1...v1.0.2) (2023-12-15)
2+
3+
### Bug fixes:
4+
5+
- added trailing underscores as workaround to use Python keywords as names of API object or method
6+
- changed TypeError to ValueError for the exception during version parsing.
7+
- fixed compression support for Sender and Getter.
8+
- made refactoring of some parts of the code.
9+
- fixed small bugs and flaws.
10+
111
## [1.0.1](https://github.com/zabbix/python-zabbix-utils/compare/v1.0.0...v1.0.1) (2023-11-27)
212

313
### Bug fixes:

README.md

+25-4
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Supported versions:
2727

2828
Tested on:
2929

30-
* Zabbix 4.0, 5.0, 6.0, 6.4 and 7.0alpha7
31-
* Python 3.7, 3.8, 3.9, 3.10 and 3.11
30+
* Zabbix 5.0, 6.0, 6.4 and 7.0.0 alpha 7
31+
* Python 3.8, 3.9, 3.10 and 3.11
3232

3333
## Documentation
3434

@@ -76,10 +76,10 @@ users = api.user.get(
7676

7777
for user in users:
7878
print(user['name'])
79-
80-
api.logout()
8179
```
8280

81+
When token is used, calling `api.logout()` is not necessary.
82+
8383
It is possible to specify authentication fields by the following environment variables:
8484
`ZABBIX_URL`, `ZABBIX_TOKEN`, `ZABBIX_USER`, `ZABBIX_PASSWORD`
8585

@@ -115,6 +115,27 @@ print(ver.is_lts()) # True
115115
api.logout()
116116
```
117117

118+
In case the API object or method name matches one of Python keywords, you can use the suffix `_` in their name to execute correctly:
119+
```python
120+
from zabbix_utils import ZabbixAPI
121+
122+
api = ZabbixAPI(url="127.0.0.1")
123+
api.login(token="xxxxxxxx")
124+
125+
template_source = ''
126+
with open('template_example.xml', mode='r', encoding='utf-8') as f:
127+
template_source = f.read()
128+
129+
response = api.configuration.import_(
130+
source=template_source,
131+
format="xml",
132+
rules={...}
133+
)
134+
135+
if response:
136+
print("Template imported successfully")
137+
```
138+
118139
> Please, refer to the [Zabbix API Documentation](https://www.zabbix.com/documentation/current/manual/api/reference) and the [using examples](https://github.com/zabbix/python-zabbix-utils/tree/main/examples/api) for more information.
119140
120141
##### To work via Zabbix sender protocol

examples/api/auth_by_token.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
from zabbix_utils import ZabbixAPI
27

38
# Use an authentication token generated via the web interface or

examples/api/check_auth_state.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
from zabbix_utils import ZabbixAPI
27

38
# Zabbix server details and authentication credentials

examples/api/disabling_validate_certs.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
from zabbix_utils import ZabbixAPI
27

38
# SSL certificate verification will be ignored.

examples/api/export_templates.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
from zabbix_utils import ZabbixAPI
27

38
# Zabbix server details and authentication credentials

examples/api/token_auth_if_supported.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
from zabbix_utils import ZabbixAPI
27

38
# Zabbix server details and authentication credentials

examples/api/use_context_manager.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
from zabbix_utils import ZabbixAPI
27

38
# Zabbix server details and authentication credentials
@@ -7,7 +12,7 @@
712

813
# Use a context manager for automatic logout upon completion of the request.
914
# Each time it's created it performs "login" and "apiinfo.version".
10-
# Highly recommended to use it many times in a single script.
15+
# Highly recommended not to use it many times in a single script.
1116
with ZabbixAPI(url=ZABBIX_SERVER) as api:
1217
# Authenticate with the Zabbix API using the provided user credentials
1318
api.login(user=ZABBIX_USER, password=ZABBIX_PASSWORD)

examples/api/using_http_auth.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
from zabbix_utils import ZabbixAPI
27

38
# Create an instance of the ZabbixAPI class with the Zabbix server URL

examples/get/custom_source_ip.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
from zabbix_utils import Getter
27

38
# Create a Getter instance with specified parameters

examples/get/getting_value.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
import sys
27
import json
38
from zabbix_utils import Getter

examples/get/psk_wrapper.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
import ssl
27
from zabbix_utils import Getter
38

examples/sender/agent_config_using.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
from zabbix_utils import Sender
27

38
# Toy can create an instance of Sender using the default configuration file path

examples/sender/bulk_sending.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
from zabbix_utils import ItemValue, Sender
27

38
# List of ItemValue instances representing items to be sent

examples/sender/custom_source_ip.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
from zabbix_utils import Sender
27

38
# Create an instance of the Sender class with specified parameters

examples/sender/psk_wrapper.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
import ssl
27
from zabbix_utils import Sender
38

examples/sender/psk_wrapper_from_config.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
import ssl
27
from zabbix_utils import Sender
38

examples/sender/single_sending.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
from zabbix_utils import Sender
27

38
# Zabbix server/proxy details for Sender

examples/sender/tls_cert_wrapper.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright (C) 2001-2023 Zabbix SIA
2+
#
3+
# Zabbix SIA licenses this file to you under the MIT License.
4+
# See the LICENSE file in the project root for more information.
5+
16
import ssl
27
from zabbix_utils import Sender
38

setup.py

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
# zabbix_utils
2+
#
3+
# Copyright (C) 2001-2023 Zabbix SIA
4+
#
5+
# Permission is hereby granted, free of charge, to any person
6+
# obtaining a copy of this software and associated documentation
7+
# files (the "Software"), to deal in the Software without restriction,
8+
# including without limitation the rights to use, copy, modify,
9+
# merge, publish, distribute, sublicense, and/or sell copies
10+
# of the Software, and to permit persons to whom the Software
11+
# is furnished to do so, subject to the following conditions:
12+
13+
# The above copyright notice and this permission notice shall be
14+
# included in all copies or substantial portions of the Software.
15+
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
# OTHER DEALINGS IN THE SOFTWARE.
24+
125
import re
226
import setuptools
327
from zabbix_utils.version import __version__

0 commit comments

Comments
 (0)