python-observabilityclient 1.4.0__tar.gz → 1.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/.pre-commit-config.yaml +16 -5
  2. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/AUTHORS +1 -0
  3. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/ChangeLog +12 -0
  4. {python_observabilityclient-1.4.0/python_observabilityclient.egg-info → python_observabilityclient-1.5.0}/PKG-INFO +4 -1
  5. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/README.rst +2 -0
  6. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/prometheus_client.py +74 -7
  7. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/unit/test_prometheus_client.py +58 -0
  8. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/unit/test_utils.py +5 -5
  9. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/utils/metric_utils.py +24 -26
  10. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/pyproject.toml +46 -0
  11. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0/python_observabilityclient.egg-info}/PKG-INFO +4 -1
  12. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/python_observabilityclient.egg-info/SOURCES.txt +2 -0
  13. python_observabilityclient-1.5.0/python_observabilityclient.egg-info/pbr.json +1 -0
  14. python_observabilityclient-1.5.0/releasenotes/notes/prometheus-tls-versions.yaml +8 -0
  15. python_observabilityclient-1.5.0/releasenotes/source/2026.2.rst +6 -0
  16. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/source/index.rst +1 -0
  17. python_observabilityclient-1.5.0/requirements.txt +8 -0
  18. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/tox.ini +1 -0
  19. python_observabilityclient-1.4.0/python_observabilityclient.egg-info/pbr.json +0 -1
  20. python_observabilityclient-1.4.0/requirements.txt +0 -4
  21. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/.coveragerc +0 -0
  22. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/.stestr.conf +0 -0
  23. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/.zuul.yaml +0 -0
  24. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/CONTRIBUTING.rst +0 -0
  25. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/LICENSE +0 -0
  26. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/doc/requirements.txt +0 -0
  27. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/doc/source/api.rst +0 -0
  28. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/doc/source/conf.py +0 -0
  29. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/doc/source/contributing.rst +0 -0
  30. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/doc/source/index.rst +0 -0
  31. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/doc/source/installation.rst +0 -0
  32. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/doc/source/shell.rst +0 -0
  33. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/__init__.py +0 -0
  34. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/client.py +0 -0
  35. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/i18n.py +0 -0
  36. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/plugin.py +0 -0
  37. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/rbac.py +0 -0
  38. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/functional/__init__.py +0 -0
  39. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/functional/base.py +0 -0
  40. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/functional/test_cli.py +0 -0
  41. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/functional/test_python_api.py +0 -0
  42. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/unit/__init__.py +0 -0
  43. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/unit/test_cli.py +0 -0
  44. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/unit/test_python_api.py +0 -0
  45. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/unit/test_rbac.py +0 -0
  46. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/utils/__init__.py +0 -0
  47. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/v1/__init__.py +0 -0
  48. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/v1/base.py +0 -0
  49. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/v1/cli.py +0 -0
  50. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/v1/client.py +0 -0
  51. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/observabilityclient/v1/python_api.py +0 -0
  52. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/python_observabilityclient.egg-info/dependency_links.txt +0 -0
  53. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/python_observabilityclient.egg-info/entry_points.txt +0 -0
  54. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/python_observabilityclient.egg-info/not-zip-safe +0 -0
  55. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/python_observabilityclient.egg-info/requires.txt +0 -0
  56. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/python_observabilityclient.egg-info/top_level.txt +0 -0
  57. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/notes/add-root-path-192ac0e6ea99b84f.yaml +0 -0
  58. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/notes/allow-for-providing-metric-names-list-for-rbac-e46a4fd0df3fad73.yaml +0 -0
  59. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/notes/allow-for-specifying-rbac-label-name-f99084757cde5f19.yaml +0 -0
  60. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/notes/change-aetos-service-type-37a53a86f4975803.yaml +0 -0
  61. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/notes/disable-config-overrides-for-keystone-discovered-endpoints-0b36ad382f029fa0.yaml +0 -0
  62. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/notes/fix-ipv6-escaping-faef776565954baa.yaml +0 -0
  63. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/notes/keep-session-transport-options-6ad0880b46c8b1e1.yaml +0 -0
  64. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/notes/refactor-rbac-967ed5edcc1ef2a4.yaml +0 -0
  65. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/notes/remove-py38-acd461c4350f0dca.yaml +0 -0
  66. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/notes/remove-py39-a3f911847e0075b6.yaml +0 -0
  67. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/notes/send-token-only-when-communicating-with-aetos-21299ccc710f6473.yaml +0 -0
  68. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/source/2025.1.rst +0 -0
  69. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/source/2025.2.rst +0 -0
  70. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/source/2026.1.rst +0 -0
  71. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/source/_static/.placeholder +0 -0
  72. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/source/conf.py +0 -0
  73. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/releasenotes/source/unreleased.rst +0 -0
  74. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/setup.cfg +0 -0
  75. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/setup.py +0 -0
  76. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/test-requirements.txt +0 -0
  77. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/tools/fix_ca_bundle.sh +0 -0
  78. {python_observabilityclient-1.4.0 → python_observabilityclient-1.5.0}/tools/install_deps.sh +0 -0
@@ -18,19 +18,30 @@ repos:
18
18
  - id: debug-statements
19
19
  - id: check-yaml
20
20
  files: .*\.(yaml|yml)$
21
+ - repo: https://github.com/hhatto/autopep8
22
+ rev: v2.3.2
23
+ hooks:
24
+ - id: autopep8
25
+ files: '^.*\.py$'
21
26
  - repo: https://opendev.org/openstack/hacking
22
- rev: 7.0.0
27
+ rev: 8.0.0
23
28
  hooks:
24
29
  - id: hacking
25
30
  additional_dependencies: []
26
- - repo: https://github.com/asottile/pyupgrade
27
- rev: v3.20.0
31
+ - repo: https://github.com/PyCQA/doc8
32
+ rev: v2.0.0
28
33
  hooks:
29
- - id: pyupgrade
30
- args: [--py311-plus]
34
+ - id: doc8
31
35
  - repo: https://github.com/openstack/bashate
32
36
  rev: 2.1.1
33
37
  hooks:
34
38
  - id: bashate
35
39
  args: ['-v', '-iE006']
36
40
  exclude: '.tox/.*'
41
+ - repo: https://github.com/astral-sh/ruff-pre-commit
42
+ rev: v0.15.7
43
+ hooks:
44
+ - id: ruff-check
45
+ args: ['--fix', '--unsafe-fixes', '--show-fixes']
46
+ # TODO(tkajinam): Enable this later
47
+ #- id: ruff-format
@@ -1,6 +1,7 @@
1
1
  Alfredo Moralejo <amoralej@redhat.com>
2
2
  Chris Sibbitt <csibbitt@redhat.com>
3
3
  Cyril Roelandt <cyril@redhat.com>
4
+ Daniel Pawlik <dpawlik@redhat.com>
4
5
  Emma Foley <efoley@redhat.com>
5
6
  Erno Kuvaja <jokke@usr.fi>
6
7
  Ghanshyam Mann <gmann@ghanshyammann.com>
@@ -1,6 +1,18 @@
1
1
  CHANGES
2
2
  =======
3
3
 
4
+ 1.5.0
5
+ -----
6
+
7
+ * Declare Python 3.15 support
8
+ * Add set\_max\_tls\_version to PrometheusAPIClient
9
+ * Add autopep8, doc8 and ruff
10
+ * Refactor get\_prom\_client\_from\_file\_or\_env
11
+ * Refactor url composition
12
+ * Add set\_min\_tls\_version to PrometheusAPIClient
13
+ * Add note about lower bounds of requirements
14
+ * Update master for stable/2026.2
15
+
4
16
  1.4.0
5
17
  -----
6
18
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-observabilityclient
3
- Version: 1.4.0
3
+ Version: 1.5.0
4
4
  Summary: OpenStack Observability Client
5
5
  Author-email: OpenStack <openstack-discuss@lists.openstack.org>
6
6
  License: Apache-2.0
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
20
21
  Classifier: Programming Language :: Python :: 3 :: Only
21
22
  Requires-Python: >=3.11
22
23
  Description-Content-Type: text/markdown; charset=UTF-8
@@ -47,6 +48,7 @@ Install your OpenStack environment and patch your ``openstack`` client
47
48
  application using python.
48
49
 
49
50
  .. code:: console
51
+
50
52
  git clone https://opendev.org/openstack/python-observabilityclient.git
51
53
  cd python-observabilityclient
52
54
  sudo pip install .
@@ -60,6 +62,7 @@ Use ``openstack metric query somequery`` to query for metrics in prometheus.
60
62
  To use the python api do the following:
61
63
 
62
64
  .. code:: python
65
+
63
66
  from observabilityclient import client
64
67
 
65
68
  c = client.Client(
@@ -17,6 +17,7 @@ Install your OpenStack environment and patch your ``openstack`` client
17
17
  application using python.
18
18
 
19
19
  .. code:: console
20
+
20
21
  git clone https://opendev.org/openstack/python-observabilityclient.git
21
22
  cd python-observabilityclient
22
23
  sudo pip install .
@@ -30,6 +31,7 @@ Use ``openstack metric query somequery`` to query for metrics in prometheus.
30
31
  To use the python api do the following:
31
32
 
32
33
  .. code:: python
34
+
33
35
  from observabilityclient import client
34
36
 
35
37
  c = client.Client(
@@ -13,13 +13,51 @@
13
13
  # under the License.
14
14
 
15
15
  import logging
16
+ import ssl
17
+ import urllib.parse
16
18
 
17
19
  import requests
20
+ from requests.adapters import HTTPAdapter
21
+ from urllib3.util.ssl_ import create_urllib3_context
18
22
 
19
23
 
20
24
  LOG = logging.getLogger(__name__)
21
25
 
22
26
 
27
+ _TLS_VERSIONS = {
28
+ '1.2': ssl.TLSVersion.TLSv1_2,
29
+ '1.3': ssl.TLSVersion.TLSv1_3,
30
+ }
31
+
32
+
33
+ class _PrometheusTLSAdapter(HTTPAdapter):
34
+ """HTTP adapter pinning TLS version bounds on new connections."""
35
+
36
+ def __init__(self, min_version, max_version, verify, **kwargs):
37
+ self._min_version = min_version
38
+ self._max_version = max_version
39
+ # requests/urllib3 set verify_mode and load the CA bundle per request,
40
+ # but CERT_NONE on a context with check_hostname enabled raises, so the
41
+ # context has to be built knowing whether we verify.
42
+ self._cert_reqs = None if verify else ssl.CERT_NONE
43
+ super().__init__(**kwargs)
44
+
45
+ def init_poolmanager(self, *args, **kwargs):
46
+ kwargs['ssl_context'] = create_urllib3_context(
47
+ ssl_minimum_version=self._min_version,
48
+ ssl_maximum_version=self._max_version,
49
+ cert_reqs=self._cert_reqs)
50
+ return super().init_poolmanager(*args, **kwargs)
51
+
52
+
53
+ def _resolve_tls_version(version):
54
+ if version not in _TLS_VERSIONS:
55
+ raise ValueError(
56
+ f"Unknown TLS version: {version}. Supported values are "
57
+ f"{', '.join(sorted(_TLS_VERSIONS))}")
58
+ return _TLS_VERSIONS[version]
59
+
60
+
23
61
  class PrometheusAPIClientError(Exception):
24
62
  def __init__(self, response):
25
63
  self.resp = response
@@ -53,22 +91,47 @@ class PrometheusMetric:
53
91
 
54
92
 
55
93
  class PrometheusAPIClient:
56
- def __init__(self, host, session=None, root_path="", scheme=None):
94
+ def __init__(self, host, session=None, root_path=None, scheme=None):
57
95
  self._scheme = scheme
58
96
  self._host = host
59
- if not self._host.endswith('/'):
60
- self._host += '/'
97
+ self._root_path = root_path or ''
98
+
61
99
  if session is None:
62
100
  self._session = requests.Session()
63
101
  self._session.verify = False
64
102
  else:
65
103
  self._session = session
66
- self._root_path = root_path
67
- if root_path != "" and not self._root_path.endswith('/'):
68
- self._root_path += '/'
104
+ self._min_tls_version = None
105
+ self._max_tls_version = None
69
106
 
70
107
  def set_ca_cert(self, ca_cert):
71
108
  self._session.verify = ca_cert
109
+ self._mount_tls_adapter()
110
+
111
+ def set_min_tls_version(self, version):
112
+ """Set the minimum TLS version for HTTPS connections to Prometheus.
113
+
114
+ :param version: TLS version, ``1.2`` or ``1.3``
115
+ :type version: str
116
+ """
117
+ self._min_tls_version = _resolve_tls_version(version)
118
+ self._mount_tls_adapter()
119
+
120
+ def set_max_tls_version(self, version):
121
+ """Set the maximum TLS version for HTTPS connections to Prometheus.
122
+
123
+ :param version: TLS version, ``1.2`` or ``1.3``
124
+ :type version: str
125
+ """
126
+ self._max_tls_version = _resolve_tls_version(version)
127
+ self._mount_tls_adapter()
128
+
129
+ def _mount_tls_adapter(self):
130
+ if self._min_tls_version is None and self._max_tls_version is None:
131
+ return
132
+ self._session.mount('https://', _PrometheusTLSAdapter(
133
+ self._min_tls_version, self._max_tls_version,
134
+ self._session.verify))
72
135
 
73
136
  def set_client_cert(self, client_cert, client_key):
74
137
  self._session.cert = (client_cert, client_key)
@@ -81,7 +144,11 @@ class PrometheusAPIClient:
81
144
  scheme = 'https' if self._session.verify else 'http'
82
145
  else:
83
146
  scheme = self._scheme
84
- return f"{scheme}://{self._host}{self._root_path}api/v1/{endpoint}"
147
+ components = (scheme, self._host, self._root_path, '', '')
148
+ base_url = urllib.parse.urlunsplit(components)
149
+ if not base_url.endswith('/'):
150
+ base_url += '/'
151
+ return urllib.parse.urljoin(base_url, f'api/v1/{endpoint}')
85
152
 
86
153
  def _get(self, endpoint, params=None):
87
154
  url = self._get_url(endpoint)
@@ -14,6 +14,8 @@
14
14
 
15
15
  from unittest import mock
16
16
 
17
+ import ssl
18
+
17
19
  import requests
18
20
 
19
21
  import testtools
@@ -83,6 +85,62 @@ class PrometheusAPIClientTestBase(testtools.TestCase):
83
85
 
84
86
 
85
87
  class PrometheusAPIClientTest(PrometheusAPIClientTestBase):
88
+ def _ssl_context(self, c):
89
+ adapter = c._session.get_adapter("https://localhost:9090/")
90
+ self.assertIsInstance(adapter, client._PrometheusTLSAdapter)
91
+ return adapter.poolmanager.connection_pool_kw['ssl_context']
92
+
93
+ def test_set_min_tls_version(self):
94
+ c = client.PrometheusAPIClient("localhost:9090")
95
+ c.set_min_tls_version("1.2")
96
+ ctx = self._ssl_context(c)
97
+ self.assertEqual(ssl.TLSVersion.TLSv1_2, ctx.minimum_version)
98
+ # verify is False by default, so the context must not demand certs
99
+ self.assertEqual(ssl.CERT_NONE, ctx.verify_mode)
100
+
101
+ def test_set_min_tls_version_with_ca_cert(self):
102
+ c = client.PrometheusAPIClient("localhost:9090")
103
+ c.set_ca_cert(True)
104
+ c.set_min_tls_version("1.3")
105
+ ctx = self._ssl_context(c)
106
+ self.assertEqual(ssl.TLSVersion.TLSv1_3, ctx.minimum_version)
107
+ self.assertEqual(ssl.CERT_REQUIRED, ctx.verify_mode)
108
+ self.assertTrue(ctx.check_hostname)
109
+
110
+ def test_set_min_tls_version_invalid(self):
111
+ c = client.PrometheusAPIClient("localhost:9090")
112
+ self.assertRaises(ValueError, c.set_min_tls_version, "TLSv1_2")
113
+ self.assertRaises(ValueError, c.set_min_tls_version, "1.1")
114
+
115
+ def test_set_max_tls_version(self):
116
+ c = client.PrometheusAPIClient("localhost:9090")
117
+ c.set_max_tls_version("1.2")
118
+ ctx = self._ssl_context(c)
119
+ self.assertEqual(ssl.TLSVersion.TLSv1_2, ctx.maximum_version)
120
+ self.assertEqual(ssl.CERT_NONE, ctx.verify_mode)
121
+
122
+ def test_set_max_tls_version_with_ca_cert(self):
123
+ c = client.PrometheusAPIClient("localhost:9090")
124
+ c.set_ca_cert(True)
125
+ c.set_max_tls_version("1.3")
126
+ ctx = self._ssl_context(c)
127
+ self.assertEqual(ssl.TLSVersion.TLSv1_3, ctx.maximum_version)
128
+ self.assertEqual(ssl.CERT_REQUIRED, ctx.verify_mode)
129
+ self.assertTrue(ctx.check_hostname)
130
+
131
+ def test_set_min_and_max_tls_version(self):
132
+ c = client.PrometheusAPIClient("localhost:9090")
133
+ c.set_min_tls_version("1.2")
134
+ c.set_max_tls_version("1.3")
135
+ ctx = self._ssl_context(c)
136
+ self.assertEqual(ssl.TLSVersion.TLSv1_2, ctx.minimum_version)
137
+ self.assertEqual(ssl.TLSVersion.TLSv1_3, ctx.maximum_version)
138
+
139
+ def test_set_max_tls_version_invalid(self):
140
+ c = client.PrometheusAPIClient("localhost:9090")
141
+ self.assertRaises(ValueError, c.set_max_tls_version, "TLSv1_2")
142
+ self.assertRaises(ValueError, c.set_max_tls_version, "1.1")
143
+
86
144
  def test_init_scheme_default(self):
87
145
  c = client.PrometheusAPIClient("localhost:9090")
88
146
  self.assertIsNone(c._scheme)
@@ -57,7 +57,7 @@ class GetPrometheusClientTest(testtools.TestCase):
57
57
  mock.patch.object(prometheus_client.PrometheusAPIClient,
58
58
  "__init__", return_value=None) as m:
59
59
  metric_utils.get_prometheus_client()
60
- m.assert_called_with("somehost:1234", None, "")
60
+ m.assert_called_with("somehost:1234", None, None)
61
61
 
62
62
  def test_get_prometheus_client_env_override(self):
63
63
  with mock.patch.dict(os.environ,
@@ -67,7 +67,7 @@ class GetPrometheusClientTest(testtools.TestCase):
67
67
  mock.patch.object(prometheus_client.PrometheusAPIClient,
68
68
  "__init__", return_value=None) as m:
69
69
  metric_utils.get_prometheus_client()
70
- m.assert_called_with("env_override:1234", None, "")
70
+ m.assert_called_with("env_override:1234", None, None)
71
71
 
72
72
  def test_get_prometheus_client_no_config_file(self):
73
73
  patched_env = {'PROMETHEUS_HOST': 'env_override',
@@ -78,7 +78,7 @@ class GetPrometheusClientTest(testtools.TestCase):
78
78
  mock.patch.object(prometheus_client.PrometheusAPIClient,
79
79
  "__init__", return_value=None) as m:
80
80
  metric_utils.get_prometheus_client()
81
- m.assert_called_with("env_override:env_port", None, "")
81
+ m.assert_called_with("env_override:env_port", None, None)
82
82
 
83
83
  def test_get_prometheus_client_prefix_in_env_variable(self):
84
84
  patched_env = {'PROMETHEUS_HOST': 'env_override',
@@ -148,7 +148,7 @@ class GetPrometheusClientTest(testtools.TestCase):
148
148
  mock.patch.object(prometheus_client.PrometheusAPIClient,
149
149
  "__init__", return_value=None) as m:
150
150
  metric_utils.get_prometheus_client()
151
- m.assert_called_with("[2607:5300:201:2000::654]:1234", None, "")
151
+ m.assert_called_with("[2607:5300:201:2000::654]:1234", None, None)
152
152
 
153
153
  def test_get_prometheus_client_from_conf_file_ipv6(self):
154
154
  config_data = '''
@@ -163,7 +163,7 @@ class GetPrometheusClientTest(testtools.TestCase):
163
163
  "__init__", return_value=None) as init_m:
164
164
  metric_utils.get_prometheus_client()
165
165
  init_m.assert_called_with(
166
- "[2607:5300:201:2000::654]:80", None, ""
166
+ "[2607:5300:201:2000::654]:80", None, None
167
167
  )
168
168
 
169
169
  def test_get_prometheus_client_from_keystone_ipv6(self):
@@ -70,32 +70,30 @@ def get_prom_client_from_keystone(session, adapter_options=None):
70
70
 
71
71
 
72
72
  def get_prom_client_from_file_or_env():
73
- host = port = ca_cert = None
74
- root_path = ''
75
- conf_file = get_config_file()
76
- if conf_file is not None:
77
- conf = yaml.safe_load(conf_file)
78
- if 'host' in conf:
79
- host = conf['host']
80
- if 'port' in conf:
81
- port = conf['port']
82
- if 'ca_cert' in conf:
83
- ca_cert = conf['ca_cert']
84
- if 'root_path' in conf:
85
- root_path = conf['root_path']
86
- conf_file.close()
87
- if 'PROMETHEUS_HOST' in os.environ:
88
- host = os.environ['PROMETHEUS_HOST']
89
- if 'PROMETHEUS_PORT' in os.environ:
90
- port = os.environ['PROMETHEUS_PORT']
91
- if 'PROMETHEUS_CA_CERT' in os.environ:
92
- ca_cert = os.environ['PROMETHEUS_CA_CERT']
93
- if 'PROMETHEUS_ROOT_PATH' in os.environ:
94
- root_path = os.environ['PROMETHEUS_ROOT_PATH']
95
- if host is None or port is None:
96
- raise ConfigurationError("Can't find prometheus host and "
97
- "port configuration in config file or "
98
- "environment variables.")
73
+ host = ca_cert = root_path = None
74
+ port = 9090
75
+ try:
76
+ conf_file = get_config_file()
77
+ if conf_file is not None:
78
+ conf = yaml.safe_load(conf_file)
79
+ host = conf.get('host', host)
80
+ port = conf.get('port', port)
81
+ ca_cert = conf.get('ca_cert', ca_cert)
82
+ root_path = conf.get('root_path', root_path)
83
+ finally:
84
+ if conf_file is not None:
85
+ conf_file.close()
86
+
87
+ host = os.environ.get('PROMETHEUS_HOST', host)
88
+ port = os.environ.get('PROMETHEUS_PORT', port)
89
+ ca_cert = os.environ.get('PROMETHEUS_CA_CERT', ca_cert)
90
+ root_path = os.environ.get('PROMETHEUS_ROOT_PATH', root_path)
91
+
92
+ if host is None:
93
+ raise ConfigurationError(
94
+ "Can't find prometheus host configuration in config file or "
95
+ "environment variables.")
96
+
99
97
  escaped_host = netutils.escape_ipv6(host)
100
98
  client = PrometheusAPIClient(
101
99
  f"{escaped_host}:{port}", None, root_path
@@ -26,6 +26,7 @@ classifiers = [
26
26
  "Programming Language :: Python :: 3.12",
27
27
  "Programming Language :: Python :: 3.13",
28
28
  "Programming Language :: Python :: 3.14",
29
+ "Programming Language :: Python :: 3.15",
29
30
  "Programming Language :: Python :: 3 :: Only",
30
31
  ]
31
32
 
@@ -44,3 +45,48 @@ metric_query = "observabilityclient.v1.cli:Query"
44
45
  metric_delete = "observabilityclient.v1.cli:Delete"
45
46
  metric_clean-tombstones = "observabilityclient.v1.cli:CleanTombstones"
46
47
  metric_snapshot = "observabilityclient.v1.cli:Snapshot"
48
+
49
+ [tool.autopep8]
50
+ aggressive = 3
51
+ in-place = true
52
+ recursive = true
53
+ ignore = ["E731"]
54
+
55
+ [tool.doc8]
56
+ ignore = ["D001"]
57
+
58
+ [tool.ruff]
59
+ line-length = 79
60
+
61
+ [tool.ruff.lint]
62
+ select = [
63
+ # mcabe complexity checks
64
+ "C90",
65
+ # multiple-imports-on-one-line, module-import-not-at-top-of-file
66
+ "E4",
67
+ # line-too-long, redundant-backslash
68
+ "E5",
69
+ "E7",
70
+ "E9",
71
+ # pyflakes
72
+ "F",
73
+ "G",
74
+ "LOG",
75
+ "S",
76
+ "UP",
77
+ "W",
78
+ ]
79
+ external = ["H"]
80
+ ignore = [
81
+ # UP031 % format — defer f-string migration to a later pass
82
+ "UP031",
83
+ # UP032 f-string — defer migration to a later pass
84
+ "UP032",
85
+ ]
86
+
87
+ [tool.ruff.lint.per-file-ignores]
88
+ "observabilityclient/tests/*" = ["S"]
89
+
90
+ [tool.ruff.lint.mccabe]
91
+ # Flag errors (`C901`) whenever the complexity level exceeds 20.
92
+ max-complexity = 20
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-observabilityclient
3
- Version: 1.4.0
3
+ Version: 1.5.0
4
4
  Summary: OpenStack Observability Client
5
5
  Author-email: OpenStack <openstack-discuss@lists.openstack.org>
6
6
  License: Apache-2.0
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
20
21
  Classifier: Programming Language :: Python :: 3 :: Only
21
22
  Requires-Python: >=3.11
22
23
  Description-Content-Type: text/markdown; charset=UTF-8
@@ -47,6 +48,7 @@ Install your OpenStack environment and patch your ``openstack`` client
47
48
  application using python.
48
49
 
49
50
  .. code:: console
51
+
50
52
  git clone https://opendev.org/openstack/python-observabilityclient.git
51
53
  cd python-observabilityclient
52
54
  sudo pip install .
@@ -60,6 +62,7 @@ Use ``openstack metric query somequery`` to query for metrics in prometheus.
60
62
  To use the python api do the following:
61
63
 
62
64
  .. code:: python
65
+
63
66
  from observabilityclient import client
64
67
 
65
68
  c = client.Client(
@@ -58,6 +58,7 @@ releasenotes/notes/change-aetos-service-type-37a53a86f4975803.yaml
58
58
  releasenotes/notes/disable-config-overrides-for-keystone-discovered-endpoints-0b36ad382f029fa0.yaml
59
59
  releasenotes/notes/fix-ipv6-escaping-faef776565954baa.yaml
60
60
  releasenotes/notes/keep-session-transport-options-6ad0880b46c8b1e1.yaml
61
+ releasenotes/notes/prometheus-tls-versions.yaml
61
62
  releasenotes/notes/refactor-rbac-967ed5edcc1ef2a4.yaml
62
63
  releasenotes/notes/remove-py38-acd461c4350f0dca.yaml
63
64
  releasenotes/notes/remove-py39-a3f911847e0075b6.yaml
@@ -65,6 +66,7 @@ releasenotes/notes/send-token-only-when-communicating-with-aetos-21299ccc710f647
65
66
  releasenotes/source/2025.1.rst
66
67
  releasenotes/source/2025.2.rst
67
68
  releasenotes/source/2026.1.rst
69
+ releasenotes/source/2026.2.rst
68
70
  releasenotes/source/conf.py
69
71
  releasenotes/source/index.rst
70
72
  releasenotes/source/unreleased.rst
@@ -0,0 +1 @@
1
+ {"git_version": "8ba76b1", "is_release": true}
@@ -0,0 +1,8 @@
1
+ ---
2
+ features:
3
+ - |
4
+ ``PrometheusAPIClient`` now supports ``set_min_tls_version`` and
5
+ ``set_max_tls_version`` to configure the TLS protocol version bounds used
6
+ for HTTPS connections to Prometheus. Accepted values are ``1.2`` and
7
+ ``1.3``, matching the spelling used by ``keystoneauth1``'s
8
+ ``tls_min_version``.
@@ -0,0 +1,6 @@
1
+ ===========================
2
+ 2026.2 Series Release Notes
3
+ ===========================
4
+
5
+ .. release-notes::
6
+ :branch: stable/2026.2
@@ -8,6 +8,7 @@ Contents
8
8
  :maxdepth: 2
9
9
 
10
10
  unreleased
11
+ 2026.2
11
12
  2026.1
12
13
  2025.2
13
14
  2025.1
@@ -0,0 +1,8 @@
1
+ # Requirements lower bounds listed here are our best effort to keep them up to
2
+ # date but we do not test them so no guarantee of having them all correct. If
3
+ # you find any incorrect lower bounds, let us know or propose a fix.
4
+
5
+ osc-lib>=1.0.1 # Apache-2.0
6
+ keystoneauth1>=1.0.0 # Apache-2.0
7
+ cliff>=1.14.0 # Apache-2.0
8
+ PyYAML>5.1 # Apache-2.0
@@ -52,6 +52,7 @@ deps =
52
52
  commands = sphinx-build --keep-going -b html doc/source doc/build/html
53
53
 
54
54
  [flake8]
55
+ select = H
55
56
  show-source = True
56
57
  # W504 line break after binary operator
57
58
  ignore = W504
@@ -1 +0,0 @@
1
- {"git_version": "3c745ef", "is_release": true}
@@ -1,4 +0,0 @@
1
- osc-lib>=1.0.1 # Apache-2.0
2
- keystoneauth1>=1.0.0 # Apache-2.0
3
- cliff>=1.14.0 # Apache-2.0
4
- PyYAML>5.1 # Apache-2.0