python-observabilityclient 1.3.0__py3-none-any.whl → 1.4.0__py3-none-any.whl

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.
@@ -53,15 +53,16 @@ class PrometheusMetric:
53
53
 
54
54
 
55
55
  class PrometheusAPIClient:
56
- def __init__(self, host, session=None, root_path=""):
56
+ def __init__(self, host, session=None, root_path="", scheme=None):
57
+ self._scheme = scheme
57
58
  self._host = host
58
59
  if not self._host.endswith('/'):
59
60
  self._host += '/'
60
61
  if session is None:
61
62
  self._session = requests.Session()
63
+ self._session.verify = False
62
64
  else:
63
65
  self._session = session
64
- self._session.verify = False
65
66
  self._root_path = root_path
66
67
  if root_path != "" and not self._root_path.endswith('/'):
67
68
  self._root_path += '/'
@@ -76,7 +77,10 @@ class PrometheusAPIClient:
76
77
  self._session.auth = (auth_user, auth_password)
77
78
 
78
79
  def _get_url(self, endpoint):
79
- scheme = 'https' if self._session.verify else 'http'
80
+ if self._scheme is None:
81
+ scheme = 'https' if self._session.verify else 'http'
82
+ else:
83
+ scheme = self._scheme
80
84
  return f"{scheme}://{self._host}{self._root_path}api/v1/{endpoint}"
81
85
 
82
86
  def _get(self, endpoint, params=None):
@@ -83,6 +83,34 @@ class PrometheusAPIClientTestBase(testtools.TestCase):
83
83
 
84
84
 
85
85
  class PrometheusAPIClientTest(PrometheusAPIClientTestBase):
86
+ def test_init_scheme_default(self):
87
+ c = client.PrometheusAPIClient("localhost:9090")
88
+ self.assertIsNone(c._scheme)
89
+
90
+ def test_init_scheme_passed(self):
91
+ c = client.PrometheusAPIClient("localhost:9090", scheme="https")
92
+ self.assertEqual("https", c._scheme)
93
+
94
+ def test_get_url_without_scheme_uses_verify(self):
95
+ c = client.PrometheusAPIClient("localhost:9090")
96
+ c._session.verify = False
97
+ self.assertEqual("http://localhost:9090/api/v1/query",
98
+ c._get_url("query"))
99
+ c._session.verify = True
100
+ self.assertEqual("https://localhost:9090/api/v1/query",
101
+ c._get_url("query"))
102
+
103
+ def test_get_url_with_scheme_ignores_verify(self):
104
+ c = client.PrometheusAPIClient("localhost:9090", scheme="https")
105
+ c._session.verify = False
106
+ self.assertEqual("https://localhost:9090/api/v1/query",
107
+ c._get_url("query"))
108
+
109
+ c = client.PrometheusAPIClient("localhost:9090", scheme="http")
110
+ c._session.verify = True
111
+ self.assertEqual("http://localhost:9090/api/v1/query",
112
+ c._get_url("query"))
113
+
86
114
  def test_get(self):
87
115
  url = "test"
88
116
  root_path = "root_path"
@@ -115,7 +115,7 @@ class GetPrometheusClientTest(testtools.TestCase):
115
115
  "set_ca_cert") as ca_m:
116
116
  metric_utils.get_prometheus_client(keystone_session)
117
117
  init_m.assert_called_with(
118
- "localhost:1234", keystone_session, "prometheus"
118
+ "localhost:1234", keystone_session, "prometheus", scheme="http"
119
119
  )
120
120
  ca_m.assert_not_called()
121
121
 
@@ -133,9 +133,11 @@ class GetPrometheusClientTest(testtools.TestCase):
133
133
  "set_ca_cert") as ca_m:
134
134
  metric_utils.get_prometheus_client(keystone_session)
135
135
  init_m.assert_called_with(
136
- "localhost:1234", keystone_session, "prometheus"
136
+ "localhost:1234", keystone_session, "prometheus", scheme="https"
137
137
  )
138
- ca_m.assert_called_with(True)
138
+ # Session transport options (verify/insecure) must be preserved;
139
+ # do not override them based on the endpoint URL scheme.
140
+ ca_m.assert_not_called()
139
141
 
140
142
  def test_get_prometheus_client_from_env_vars_ipv6(self):
141
143
  patched_env = {'PROMETHEUS_HOST': '2607:5300:201:2000::654',
@@ -178,7 +180,8 @@ class GetPrometheusClientTest(testtools.TestCase):
178
180
  "set_ca_cert") as ca_m:
179
181
  metric_utils.get_prometheus_client(keystone_session)
180
182
  init_m.assert_called_with(
181
- "[2607:5300:201:2000::654]:80", keystone_session, "prometheus"
183
+ "[2607:5300:201:2000::654]:80", keystone_session, "prometheus",
184
+ scheme="http"
182
185
  )
183
186
  ca_m.assert_not_called()
184
187
 
@@ -59,18 +59,14 @@ def get_prom_client_from_keystone(session, adapter_options=None):
59
59
 
60
60
  escaped_host = netutils.escape_ipv6(parsed_url.hostname)
61
61
  root_path = parsed_url.path.strip('/')
62
- tls = parsed_url.scheme == "https"
63
62
 
64
63
  if parsed_url.port is not None:
65
64
  url = f'{escaped_host}:{parsed_url.port}'
66
65
  else:
67
66
  url = escaped_host
68
67
 
69
- client = PrometheusAPIClient(url, session, root_path)
70
-
71
- if tls:
72
- client.set_ca_cert(True)
73
- return client
68
+ return PrometheusAPIClient(
69
+ url, session, root_path, scheme=parsed_url.scheme)
74
70
 
75
71
 
76
72
  def get_prom_client_from_file_or_env():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-observabilityclient
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: OpenStack Observability Client
5
5
  Author-email: OpenStack <openstack-discuss@lists.openstack.org>
6
6
  License: Apache-2.0
@@ -13,12 +13,12 @@ Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Operating System :: OS Independent
14
14
  Classifier: Programming Language :: Python
15
15
  Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.10
17
16
  Classifier: Programming Language :: Python :: 3.11
18
17
  Classifier: Programming Language :: Python :: 3.12
19
18
  Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
20
  Classifier: Programming Language :: Python :: 3 :: Only
21
- Requires-Python: >=3.10
21
+ Requires-Python: >=3.11
22
22
  Description-Content-Type: text/markdown; charset=UTF-8
23
23
  License-File: LICENSE
24
24
  License-File: AUTHORS
@@ -2,7 +2,7 @@ observabilityclient/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
2
2
  observabilityclient/client.py,sha256=cfRb816p6Ips9t2cdWvmSJ1uGrtTEHXQnctoExrLA5A,828
3
3
  observabilityclient/i18n.py,sha256=PFo6BaOfyGQD5q7L3FunYJ8d4mwbRszG8wOrJIjki_4,790
4
4
  observabilityclient/plugin.py,sha256=fxUDNvo_2UrG_tM-IsgBNWAKCrWwvixhqbWt0QktH4A,2262
5
- observabilityclient/prometheus_client.py,sha256=__TPtWPqrU-DPjEbkoNmmu3VMgwbsj0rxz8sPUXyU4g,7416
5
+ observabilityclient/prometheus_client.py,sha256=bxHGTbdteD7h0JBV7IekTU02bUXFbR_P_R9pXweO-ZE,7548
6
6
  observabilityclient/rbac.py,sha256=b71bi0Ls6lUBL3RE1az5ih98DiPMoqF43SPgQkosSqE,7807
7
7
  observabilityclient/tests/functional/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  observabilityclient/tests/functional/base.py,sha256=FZT3C50z199-7SwgeGEMzxHLnbPqqB4GcHWbdobDLb8,6493
@@ -10,22 +10,22 @@ observabilityclient/tests/functional/test_cli.py,sha256=jwhgt8w0gq1CdDoaDKLV8SB_
10
10
  observabilityclient/tests/functional/test_python_api.py,sha256=5TLFboJ7B__UZ9zfc6bVSxPTzV9KnnrwluTqLwnTZLs,3308
11
11
  observabilityclient/tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  observabilityclient/tests/unit/test_cli.py,sha256=Li3QNEp6mWC758aEVL0yC6JUXv2KKtYgDfWfGLPg4xo,6178
13
- observabilityclient/tests/unit/test_prometheus_client.py,sha256=nMgCNSdoXuAYIhh3FokQMjCWFxXP6FfS5iNG0xQNQPI,18925
13
+ observabilityclient/tests/unit/test_prometheus_client.py,sha256=u2te9c8CE5bR6FCI9pYi7jtPsqBiPa2HVshXUQMeYy0,20105
14
14
  observabilityclient/tests/unit/test_python_api.py,sha256=cgpBwRR9KsCzfKC8OhE8Gm4OCirEobYnXDlK6e_4io4,4719
15
15
  observabilityclient/tests/unit/test_rbac.py,sha256=88mAxgOiTnKDrOGqb3Kt1SiqyeC4voYmDvvkWT1kVhw,8992
16
- observabilityclient/tests/unit/test_utils.py,sha256=IEBG0nfOKS_i_4r5N0Hobw7yr-sxakT5DR6BJMbCWVI,12338
16
+ observabilityclient/tests/unit/test_utils.py,sha256=xyjMjJIK5ofx9Urx-R39y-q1BPof_y-k-ocXcMOKen4,12529
17
17
  observabilityclient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- observabilityclient/utils/metric_utils.py,sha256=JsZSUQ4971cNPkZ0gj3ChUQ3VA8g13RqNJk6jAyOmdI,5779
18
+ observabilityclient/utils/metric_utils.py,sha256=Gp7Ai4WzROEDF0txEEPBmMEmuzTy1njU4HJ7TxZt5Vo,5709
19
19
  observabilityclient/v1/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  observabilityclient/v1/base.py,sha256=UfrHeow54fkJ1tWCNhKieKCPrSg1HiCLxJ_QpUOBb0w,2905
21
21
  observabilityclient/v1/cli.py,sha256=ln7GsnbW95n90oFGw4zLiwHDjY0YHBxkRBzID-j6ZmA,4028
22
22
  observabilityclient/v1/client.py,sha256=AFJkyvBEPvYAKIH-55BGiac8Z73Iasg3Q56NPEk11hc,1747
23
23
  observabilityclient/v1/python_api.py,sha256=GA5R5BezVbdT-Mnl9Nmg3kAlUuFl5sLrENlRQHXz_Vs,3886
24
- python_observabilityclient-1.3.0.dist-info/licenses/AUTHORS,sha256=GkuiTpI2rAHpiqeEGkTOrYuKIIz0MefU7M17EuvPLTQ,597
25
- python_observabilityclient-1.3.0.dist-info/licenses/LICENSE,sha256=qyh9xnj_IPtYWzClm5mZxCWRKTr2eUP_iLcU28DIvCw,11343
26
- python_observabilityclient-1.3.0.dist-info/METADATA,sha256=jBY8b4RD8ggY9XqcU-uBOwPG9wom6pTVZWFMAJXFn_Y,3145
27
- python_observabilityclient-1.3.0.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
28
- python_observabilityclient-1.3.0.dist-info/entry_points.txt,sha256=tY7BbKFvgnS1krnvXKl5D6JYlJf51T8iymb6RtexObk,472
29
- python_observabilityclient-1.3.0.dist-info/pbr.json,sha256=KMaaKrar4A3EoAl1zsXlpYsWSbkKWyzBXnsKCosQbmQ,46
30
- python_observabilityclient-1.3.0.dist-info/top_level.txt,sha256=Lf7Fwm3hfK-X1JNRy19rVlrMUOyQShBBPwsCU3pz6yw,20
31
- python_observabilityclient-1.3.0.dist-info/RECORD,,
24
+ python_observabilityclient-1.4.0.dist-info/licenses/AUTHORS,sha256=TZPAY_mWGQ7oo86HOdjZU566EU_vInwz1QWmymMAFw8,678
25
+ python_observabilityclient-1.4.0.dist-info/licenses/LICENSE,sha256=qyh9xnj_IPtYWzClm5mZxCWRKTr2eUP_iLcU28DIvCw,11343
26
+ python_observabilityclient-1.4.0.dist-info/METADATA,sha256=kkB8dx5in8lhrYxx1nevQRjj7Q1lCz5SuogkfNsVI7E,3145
27
+ python_observabilityclient-1.4.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
28
+ python_observabilityclient-1.4.0.dist-info/entry_points.txt,sha256=15rmai80pMRfBKZrk6yPNrRkAs2h63bwlcbQKq9fax4,424
29
+ python_observabilityclient-1.4.0.dist-info/pbr.json,sha256=SpW49bfnvklqlyuRqz3Lv-iLvqR87m6UZCJ9-Q-Bo9U,46
30
+ python_observabilityclient-1.4.0.dist-info/top_level.txt,sha256=Lf7Fwm3hfK-X1JNRy19rVlrMUOyQShBBPwsCU3pz6yw,20
31
+ python_observabilityclient-1.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (82.0.0)
2
+ Generator: setuptools (84.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,6 +1,3 @@
1
- [console_scripts]
2
- aodh = aodhclient.shell:main
3
-
4
1
  [openstack.cli.extension]
5
2
  observabilityclient = observabilityclient.plugin
6
3
 
@@ -12,5 +12,7 @@ Marihan Girgis mgirgisf@redhat.com
12
12
  Martin Magr <mmagr@redhat.com>
13
13
  Martin Mágr <mmagr@redhat.com>
14
14
  OpenStack Release Bot <infra-root@openstack.org>
15
+ Pavlo Shchelokovskyy <shchelokovskyy@gmail.com>
15
16
  Takashi Kajinami <kajinamit@oss.nttdata.com>
17
+ Thomas Goirand <zigo@debian.org>
16
18
  Victoria Martinez de la Cruz <victoria@redhat.com>
@@ -0,0 +1 @@
1
+ {"git_version": "3c745ef", "is_release": true}
@@ -1 +0,0 @@
1
- {"git_version": "5e7f98b", "is_release": true}